diff --git a/Examples/PreviewSnapshotsTestApp.xcodeproj/project.pbxproj b/Examples/PreviewSnapshotsTestApp.xcodeproj/project.pbxproj index 172e359..61b5d1a 100644 --- a/Examples/PreviewSnapshotsTestApp.xcodeproj/project.pbxproj +++ b/Examples/PreviewSnapshotsTestApp.xcodeproj/project.pbxproj @@ -7,13 +7,28 @@ objects = { /* Begin PBXBuildFile section */ - 3A0E5F83292807BA00E3ED94 /* test_previewStateViewSnapshots.Short.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A0E5F79292807BA00E3ED94 /* test_previewStateViewSnapshots.Short.png */; }; - 3A0E5F84292807BA00E3ED94 /* test_observableObjectSnapshots.Too-Short.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A0E5F7A292807BA00E3ED94 /* test_observableObjectSnapshots.Too-Short.png */; }; - 3A0E5F86292807BA00E3ED94 /* test_simpleViewSnapshots.Long-Message.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A0E5F7C292807BA00E3ED94 /* test_simpleViewSnapshots.Long-Message.png */; }; - 3A0E5F87292807BA00E3ED94 /* test_previewStateViewSnapshots.Long.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A0E5F7D292807BA00E3ED94 /* test_previewStateViewSnapshots.Long.png */; }; - 3A0E5F88292807BA00E3ED94 /* test_simpleViewSnapshots.Short-Message.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A0E5F7E292807BA00E3ED94 /* test_simpleViewSnapshots.Short-Message.png */; }; - 3A0E5F8A292807BA00E3ED94 /* test_observableObjectSnapshots.Empty.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A0E5F80292807BA00E3ED94 /* test_observableObjectSnapshots.Empty.png */; }; - 3A0E5F8C292807BA00E3ED94 /* test_observableObjectSnapshots.Valid.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A0E5F82292807BA00E3ED94 /* test_observableObjectSnapshots.Valid.png */; }; + 3A6429A12A8D66EA00D02EBC /* test_previewStateLightAndDark.macOS-Long-Dark.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A6429962A8D66EA00D02EBC /* test_previewStateLightAndDark.macOS-Long-Dark.png */; }; + 3A6429A22A8D66EA00D02EBC /* test_simpleViewSnapshots.macOS-Short-Message.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A6429972A8D66EA00D02EBC /* test_simpleViewSnapshots.macOS-Short-Message.png */; }; + 3A6429A32A8D66EA00D02EBC /* test_previewStateViewSnapshots.macOS-Long.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A6429982A8D66EA00D02EBC /* test_previewStateViewSnapshots.macOS-Long.png */; }; + 3A6429A42A8D66EA00D02EBC /* test_observableObjectSnapshots.macOS-Valid.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A6429992A8D66EA00D02EBC /* test_observableObjectSnapshots.macOS-Valid.png */; }; + 3A6429A52A8D66EA00D02EBC /* test_previewStateLightAndDark.macOS-Short-Dark.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A64299A2A8D66EA00D02EBC /* test_previewStateLightAndDark.macOS-Short-Dark.png */; }; + 3A6429A62A8D66EA00D02EBC /* test_previewStateLightAndDark.macOS-Short-Light.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A64299B2A8D66EA00D02EBC /* test_previewStateLightAndDark.macOS-Short-Light.png */; }; + 3A6429A72A8D66EA00D02EBC /* test_previewStateViewSnapshots.macOS-Short.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A64299C2A8D66EA00D02EBC /* test_previewStateViewSnapshots.macOS-Short.png */; }; + 3A6429A82A8D66EA00D02EBC /* test_observableObjectSnapshots.macOS-Empty.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A64299D2A8D66EA00D02EBC /* test_observableObjectSnapshots.macOS-Empty.png */; }; + 3A6429A92A8D66EA00D02EBC /* test_observableObjectSnapshots.macOS-Too-Short.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A64299E2A8D66EA00D02EBC /* test_observableObjectSnapshots.macOS-Too-Short.png */; }; + 3A6429AA2A8D66EA00D02EBC /* test_previewStateLightAndDark.macOS-Long-Light.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A64299F2A8D66EA00D02EBC /* test_previewStateLightAndDark.macOS-Long-Light.png */; }; + 3A6429AB2A8D66EA00D02EBC /* test_simpleViewSnapshots.macOS-Long-Message.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A6429A02A8D66EA00D02EBC /* test_simpleViewSnapshots.macOS-Long-Message.png */; }; + 3A6429B72A8D679800D02EBC /* test_observableObjectSnapshots.iOS-Valid.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A6429AC2A8D679800D02EBC /* test_observableObjectSnapshots.iOS-Valid.png */; }; + 3A6429B82A8D679800D02EBC /* test_previewStateViewSnapshots.iOS-Short.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A6429AD2A8D679800D02EBC /* test_previewStateViewSnapshots.iOS-Short.png */; }; + 3A6429B92A8D679800D02EBC /* test_previewStateViewSnapshots.iOS-Long.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A6429AE2A8D679800D02EBC /* test_previewStateViewSnapshots.iOS-Long.png */; }; + 3A6429BA2A8D679800D02EBC /* test_simpleViewSnapshots.iOS-Long-Message.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A6429AF2A8D679800D02EBC /* test_simpleViewSnapshots.iOS-Long-Message.png */; }; + 3A6429BB2A8D679800D02EBC /* test_observableObjectSnapshots.iOS-Empty.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A6429B02A8D679800D02EBC /* test_observableObjectSnapshots.iOS-Empty.png */; }; + 3A6429BC2A8D679900D02EBC /* test_previewStateLightAndDark.iOS-Long-Light.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A6429B12A8D679800D02EBC /* test_previewStateLightAndDark.iOS-Long-Light.png */; }; + 3A6429BD2A8D679900D02EBC /* test_previewStateLightAndDark.iOS-Short-Light.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A6429B22A8D679800D02EBC /* test_previewStateLightAndDark.iOS-Short-Light.png */; }; + 3A6429BE2A8D679900D02EBC /* test_simpleViewSnapshots.iOS-Short-Message.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A6429B32A8D679800D02EBC /* test_simpleViewSnapshots.iOS-Short-Message.png */; }; + 3A6429BF2A8D679900D02EBC /* test_previewStateLightAndDark.iOS-Short-Dark.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A6429B42A8D679800D02EBC /* test_previewStateLightAndDark.iOS-Short-Dark.png */; }; + 3A6429C02A8D679900D02EBC /* test_observableObjectSnapshots.iOS-Too-Short.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A6429B52A8D679800D02EBC /* test_observableObjectSnapshots.iOS-Too-Short.png */; }; + 3A6429C12A8D679900D02EBC /* test_previewStateLightAndDark.iOS-Long-Dark.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A6429B62A8D679800D02EBC /* test_previewStateLightAndDark.iOS-Long-Dark.png */; }; 3AA4784D290078DC00ED9DE6 /* PreviewSnapshotsTesting in Frameworks */ = {isa = PBXBuildFile; productRef = 3AA4784C290078DC00ED9DE6 /* PreviewSnapshotsTesting */; }; 3AA47855290079B700ED9DE6 /* PreviewStateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AA47854290079B700ED9DE6 /* PreviewStateView.swift */; }; 3AA4785E29007BF500ED9DE6 /* ObservableObjectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AA4785D29007BF500ED9DE6 /* ObservableObjectView.swift */; }; @@ -22,10 +37,6 @@ 3AD37F2A2900736800184899 /* SimpleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AD37F292900736800184899 /* SimpleView.swift */; }; 3AD37F2C2900736D00184899 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3AD37F2B2900736D00184899 /* Assets.xcassets */; }; 3AD37F392900736E00184899 /* PreviewSnapshotsTestAppTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AD37F382900736E00184899 /* PreviewSnapshotsTestAppTests.swift */; }; - 3AE7CC84292BE12200D0EF74 /* test_previewStateLightAndDark.Long-Light.png in Resources */ = {isa = PBXBuildFile; fileRef = 3AE7CC80292BE12200D0EF74 /* test_previewStateLightAndDark.Long-Light.png */; }; - 3AE7CC85292BE12200D0EF74 /* test_previewStateLightAndDark.Short-Light.png in Resources */ = {isa = PBXBuildFile; fileRef = 3AE7CC81292BE12200D0EF74 /* test_previewStateLightAndDark.Short-Light.png */; }; - 3AE7CC86292BE12200D0EF74 /* test_previewStateLightAndDark.Short-Dark.png in Resources */ = {isa = PBXBuildFile; fileRef = 3AE7CC82292BE12200D0EF74 /* test_previewStateLightAndDark.Short-Dark.png */; }; - 3AE7CC87292BE12200D0EF74 /* test_previewStateLightAndDark.Long-Dark.png in Resources */ = {isa = PBXBuildFile; fileRef = 3AE7CC83292BE12200D0EF74 /* test_previewStateLightAndDark.Long-Dark.png */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -39,13 +50,28 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 3A0E5F79292807BA00E3ED94 /* test_previewStateViewSnapshots.Short.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = test_previewStateViewSnapshots.Short.png; sourceTree = ""; }; - 3A0E5F7A292807BA00E3ED94 /* test_observableObjectSnapshots.Too-Short.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_observableObjectSnapshots.Too-Short.png"; sourceTree = ""; }; - 3A0E5F7C292807BA00E3ED94 /* test_simpleViewSnapshots.Long-Message.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_simpleViewSnapshots.Long-Message.png"; sourceTree = ""; }; - 3A0E5F7D292807BA00E3ED94 /* test_previewStateViewSnapshots.Long.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = test_previewStateViewSnapshots.Long.png; sourceTree = ""; }; - 3A0E5F7E292807BA00E3ED94 /* test_simpleViewSnapshots.Short-Message.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_simpleViewSnapshots.Short-Message.png"; sourceTree = ""; }; - 3A0E5F80292807BA00E3ED94 /* test_observableObjectSnapshots.Empty.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = test_observableObjectSnapshots.Empty.png; sourceTree = ""; }; - 3A0E5F82292807BA00E3ED94 /* test_observableObjectSnapshots.Valid.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = test_observableObjectSnapshots.Valid.png; sourceTree = ""; }; + 3A6429962A8D66EA00D02EBC /* test_previewStateLightAndDark.macOS-Long-Dark.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_previewStateLightAndDark.macOS-Long-Dark.png"; sourceTree = ""; }; + 3A6429972A8D66EA00D02EBC /* test_simpleViewSnapshots.macOS-Short-Message.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_simpleViewSnapshots.macOS-Short-Message.png"; sourceTree = ""; }; + 3A6429982A8D66EA00D02EBC /* test_previewStateViewSnapshots.macOS-Long.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_previewStateViewSnapshots.macOS-Long.png"; sourceTree = ""; }; + 3A6429992A8D66EA00D02EBC /* test_observableObjectSnapshots.macOS-Valid.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_observableObjectSnapshots.macOS-Valid.png"; sourceTree = ""; }; + 3A64299A2A8D66EA00D02EBC /* test_previewStateLightAndDark.macOS-Short-Dark.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_previewStateLightAndDark.macOS-Short-Dark.png"; sourceTree = ""; }; + 3A64299B2A8D66EA00D02EBC /* test_previewStateLightAndDark.macOS-Short-Light.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_previewStateLightAndDark.macOS-Short-Light.png"; sourceTree = ""; }; + 3A64299C2A8D66EA00D02EBC /* test_previewStateViewSnapshots.macOS-Short.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_previewStateViewSnapshots.macOS-Short.png"; sourceTree = ""; }; + 3A64299D2A8D66EA00D02EBC /* test_observableObjectSnapshots.macOS-Empty.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_observableObjectSnapshots.macOS-Empty.png"; sourceTree = ""; }; + 3A64299E2A8D66EA00D02EBC /* test_observableObjectSnapshots.macOS-Too-Short.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_observableObjectSnapshots.macOS-Too-Short.png"; sourceTree = ""; }; + 3A64299F2A8D66EA00D02EBC /* test_previewStateLightAndDark.macOS-Long-Light.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_previewStateLightAndDark.macOS-Long-Light.png"; sourceTree = ""; }; + 3A6429A02A8D66EA00D02EBC /* test_simpleViewSnapshots.macOS-Long-Message.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_simpleViewSnapshots.macOS-Long-Message.png"; sourceTree = ""; }; + 3A6429AC2A8D679800D02EBC /* test_observableObjectSnapshots.iOS-Valid.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_observableObjectSnapshots.iOS-Valid.png"; sourceTree = ""; }; + 3A6429AD2A8D679800D02EBC /* test_previewStateViewSnapshots.iOS-Short.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_previewStateViewSnapshots.iOS-Short.png"; sourceTree = ""; }; + 3A6429AE2A8D679800D02EBC /* test_previewStateViewSnapshots.iOS-Long.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_previewStateViewSnapshots.iOS-Long.png"; sourceTree = ""; }; + 3A6429AF2A8D679800D02EBC /* test_simpleViewSnapshots.iOS-Long-Message.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_simpleViewSnapshots.iOS-Long-Message.png"; sourceTree = ""; }; + 3A6429B02A8D679800D02EBC /* test_observableObjectSnapshots.iOS-Empty.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_observableObjectSnapshots.iOS-Empty.png"; sourceTree = ""; }; + 3A6429B12A8D679800D02EBC /* test_previewStateLightAndDark.iOS-Long-Light.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_previewStateLightAndDark.iOS-Long-Light.png"; sourceTree = ""; }; + 3A6429B22A8D679800D02EBC /* test_previewStateLightAndDark.iOS-Short-Light.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_previewStateLightAndDark.iOS-Short-Light.png"; sourceTree = ""; }; + 3A6429B32A8D679800D02EBC /* test_simpleViewSnapshots.iOS-Short-Message.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_simpleViewSnapshots.iOS-Short-Message.png"; sourceTree = ""; }; + 3A6429B42A8D679800D02EBC /* test_previewStateLightAndDark.iOS-Short-Dark.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_previewStateLightAndDark.iOS-Short-Dark.png"; sourceTree = ""; }; + 3A6429B52A8D679800D02EBC /* test_observableObjectSnapshots.iOS-Too-Short.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_observableObjectSnapshots.iOS-Too-Short.png"; sourceTree = ""; }; + 3A6429B62A8D679800D02EBC /* test_previewStateLightAndDark.iOS-Long-Dark.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_previewStateLightAndDark.iOS-Long-Dark.png"; sourceTree = ""; }; 3AA47854290079B700ED9DE6 /* PreviewStateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewStateView.swift; sourceTree = ""; }; 3AA4785D29007BF500ED9DE6 /* ObservableObjectView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObservableObjectView.swift; sourceTree = ""; }; 3AC960F7292BE4CF0093A901 /* swiftui-preview-snapshots */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "swiftui-preview-snapshots"; path = ..; sourceTree = ""; }; @@ -55,10 +81,6 @@ 3AD37F2B2900736D00184899 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 3AD37F342900736E00184899 /* PreviewSnapshotsTestAppTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PreviewSnapshotsTestAppTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 3AD37F382900736E00184899 /* PreviewSnapshotsTestAppTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewSnapshotsTestAppTests.swift; sourceTree = ""; }; - 3AE7CC80292BE12200D0EF74 /* test_previewStateLightAndDark.Long-Light.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_previewStateLightAndDark.Long-Light.png"; sourceTree = ""; }; - 3AE7CC81292BE12200D0EF74 /* test_previewStateLightAndDark.Short-Light.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_previewStateLightAndDark.Short-Light.png"; sourceTree = ""; }; - 3AE7CC82292BE12200D0EF74 /* test_previewStateLightAndDark.Short-Dark.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_previewStateLightAndDark.Short-Dark.png"; sourceTree = ""; }; - 3AE7CC83292BE12200D0EF74 /* test_previewStateLightAndDark.Long-Dark.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "test_previewStateLightAndDark.Long-Dark.png"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -100,17 +122,28 @@ 3AA4784F2900797500ED9DE6 /* PreviewSnapshotsTestAppTests */ = { isa = PBXGroup; children = ( - 3AE7CC83292BE12200D0EF74 /* test_previewStateLightAndDark.Long-Dark.png */, - 3AE7CC80292BE12200D0EF74 /* test_previewStateLightAndDark.Long-Light.png */, - 3AE7CC82292BE12200D0EF74 /* test_previewStateLightAndDark.Short-Dark.png */, - 3AE7CC81292BE12200D0EF74 /* test_previewStateLightAndDark.Short-Light.png */, - 3A0E5F80292807BA00E3ED94 /* test_observableObjectSnapshots.Empty.png */, - 3A0E5F7A292807BA00E3ED94 /* test_observableObjectSnapshots.Too-Short.png */, - 3A0E5F82292807BA00E3ED94 /* test_observableObjectSnapshots.Valid.png */, - 3A0E5F7D292807BA00E3ED94 /* test_previewStateViewSnapshots.Long.png */, - 3A0E5F79292807BA00E3ED94 /* test_previewStateViewSnapshots.Short.png */, - 3A0E5F7C292807BA00E3ED94 /* test_simpleViewSnapshots.Long-Message.png */, - 3A0E5F7E292807BA00E3ED94 /* test_simpleViewSnapshots.Short-Message.png */, + 3A6429B02A8D679800D02EBC /* test_observableObjectSnapshots.iOS-Empty.png */, + 3A6429B52A8D679800D02EBC /* test_observableObjectSnapshots.iOS-Too-Short.png */, + 3A6429AC2A8D679800D02EBC /* test_observableObjectSnapshots.iOS-Valid.png */, + 3A6429B62A8D679800D02EBC /* test_previewStateLightAndDark.iOS-Long-Dark.png */, + 3A6429B12A8D679800D02EBC /* test_previewStateLightAndDark.iOS-Long-Light.png */, + 3A6429B42A8D679800D02EBC /* test_previewStateLightAndDark.iOS-Short-Dark.png */, + 3A6429B22A8D679800D02EBC /* test_previewStateLightAndDark.iOS-Short-Light.png */, + 3A6429AE2A8D679800D02EBC /* test_previewStateViewSnapshots.iOS-Long.png */, + 3A6429AD2A8D679800D02EBC /* test_previewStateViewSnapshots.iOS-Short.png */, + 3A6429AF2A8D679800D02EBC /* test_simpleViewSnapshots.iOS-Long-Message.png */, + 3A6429B32A8D679800D02EBC /* test_simpleViewSnapshots.iOS-Short-Message.png */, + 3A64299D2A8D66EA00D02EBC /* test_observableObjectSnapshots.macOS-Empty.png */, + 3A64299E2A8D66EA00D02EBC /* test_observableObjectSnapshots.macOS-Too-Short.png */, + 3A6429992A8D66EA00D02EBC /* test_observableObjectSnapshots.macOS-Valid.png */, + 3A6429962A8D66EA00D02EBC /* test_previewStateLightAndDark.macOS-Long-Dark.png */, + 3A64299F2A8D66EA00D02EBC /* test_previewStateLightAndDark.macOS-Long-Light.png */, + 3A64299A2A8D66EA00D02EBC /* test_previewStateLightAndDark.macOS-Short-Dark.png */, + 3A64299B2A8D66EA00D02EBC /* test_previewStateLightAndDark.macOS-Short-Light.png */, + 3A6429982A8D66EA00D02EBC /* test_previewStateViewSnapshots.macOS-Long.png */, + 3A64299C2A8D66EA00D02EBC /* test_previewStateViewSnapshots.macOS-Short.png */, + 3A6429A02A8D66EA00D02EBC /* test_simpleViewSnapshots.macOS-Long-Message.png */, + 3A6429972A8D66EA00D02EBC /* test_simpleViewSnapshots.macOS-Short-Message.png */, ); path = PreviewSnapshotsTestAppTests; sourceTree = ""; @@ -252,17 +285,28 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 3A0E5F84292807BA00E3ED94 /* test_observableObjectSnapshots.Too-Short.png in Resources */, - 3AE7CC84292BE12200D0EF74 /* test_previewStateLightAndDark.Long-Light.png in Resources */, - 3A0E5F87292807BA00E3ED94 /* test_previewStateViewSnapshots.Long.png in Resources */, - 3A0E5F8C292807BA00E3ED94 /* test_observableObjectSnapshots.Valid.png in Resources */, - 3A0E5F88292807BA00E3ED94 /* test_simpleViewSnapshots.Short-Message.png in Resources */, - 3AE7CC87292BE12200D0EF74 /* test_previewStateLightAndDark.Long-Dark.png in Resources */, - 3A0E5F83292807BA00E3ED94 /* test_previewStateViewSnapshots.Short.png in Resources */, - 3AE7CC85292BE12200D0EF74 /* test_previewStateLightAndDark.Short-Light.png in Resources */, - 3A0E5F8A292807BA00E3ED94 /* test_observableObjectSnapshots.Empty.png in Resources */, - 3A0E5F86292807BA00E3ED94 /* test_simpleViewSnapshots.Long-Message.png in Resources */, - 3AE7CC86292BE12200D0EF74 /* test_previewStateLightAndDark.Short-Dark.png in Resources */, + 3A6429BE2A8D679900D02EBC /* test_simpleViewSnapshots.iOS-Short-Message.png in Resources */, + 3A6429A52A8D66EA00D02EBC /* test_previewStateLightAndDark.macOS-Short-Dark.png in Resources */, + 3A6429BA2A8D679800D02EBC /* test_simpleViewSnapshots.iOS-Long-Message.png in Resources */, + 3A6429BB2A8D679800D02EBC /* test_observableObjectSnapshots.iOS-Empty.png in Resources */, + 3A6429C12A8D679900D02EBC /* test_previewStateLightAndDark.iOS-Long-Dark.png in Resources */, + 3A6429AA2A8D66EA00D02EBC /* test_previewStateLightAndDark.macOS-Long-Light.png in Resources */, + 3A6429AB2A8D66EA00D02EBC /* test_simpleViewSnapshots.macOS-Long-Message.png in Resources */, + 3A6429A32A8D66EA00D02EBC /* test_previewStateViewSnapshots.macOS-Long.png in Resources */, + 3A6429A62A8D66EA00D02EBC /* test_previewStateLightAndDark.macOS-Short-Light.png in Resources */, + 3A6429A42A8D66EA00D02EBC /* test_observableObjectSnapshots.macOS-Valid.png in Resources */, + 3A6429A12A8D66EA00D02EBC /* test_previewStateLightAndDark.macOS-Long-Dark.png in Resources */, + 3A6429B72A8D679800D02EBC /* test_observableObjectSnapshots.iOS-Valid.png in Resources */, + 3A6429BF2A8D679900D02EBC /* test_previewStateLightAndDark.iOS-Short-Dark.png in Resources */, + 3A6429BD2A8D679900D02EBC /* test_previewStateLightAndDark.iOS-Short-Light.png in Resources */, + 3A6429A22A8D66EA00D02EBC /* test_simpleViewSnapshots.macOS-Short-Message.png in Resources */, + 3A6429BC2A8D679900D02EBC /* test_previewStateLightAndDark.iOS-Long-Light.png in Resources */, + 3A6429C02A8D679900D02EBC /* test_observableObjectSnapshots.iOS-Too-Short.png in Resources */, + 3A6429A82A8D66EA00D02EBC /* test_observableObjectSnapshots.macOS-Empty.png in Resources */, + 3A6429B92A8D679800D02EBC /* test_previewStateViewSnapshots.iOS-Long.png in Resources */, + 3A6429A92A8D66EA00D02EBC /* test_observableObjectSnapshots.macOS-Too-Short.png in Resources */, + 3A6429A72A8D66EA00D02EBC /* test_previewStateViewSnapshots.macOS-Short.png in Resources */, + 3A6429B82A8D679800D02EBC /* test_previewStateViewSnapshots.iOS-Short.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -435,6 +479,9 @@ MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.doordash.PreviewSnapshotsTestApp; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -463,6 +510,9 @@ MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.doordash.PreviewSnapshotsTestApp; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -482,6 +532,9 @@ MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.doordash.PreviewSnapshotsTestAppTests; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SWIFT_EMIT_LOC_STRINGS = NO; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -502,6 +555,9 @@ MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.doordash.PreviewSnapshotsTestAppTests; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SWIFT_EMIT_LOC_STRINGS = NO; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/Examples/PreviewSnapshotsTestAppTests/PreviewSnapshotsTestAppTests.swift b/Examples/PreviewSnapshotsTestAppTests/PreviewSnapshotsTestAppTests.swift index 899d754..89acb50 100644 --- a/Examples/PreviewSnapshotsTestAppTests/PreviewSnapshotsTestAppTests.swift +++ b/Examples/PreviewSnapshotsTestAppTests/PreviewSnapshotsTestAppTests.swift @@ -20,26 +20,32 @@ import XCTest final class PreviewSnapshotsTestAppTests: XCTestCase { func test_simpleViewSnapshots() { - SimpleView_Previews.snapshots.assertSnapshots(as: .testStrategy()) + SimpleView_Previews.snapshots.assertSnapshots(as: .testStrategy(), named: platformName) } func test_previewStateViewSnapshots() { - PreviewStateView_Previews.snapshots.assertSnapshots(as: .testStrategy()) + PreviewStateView_Previews.snapshots.assertSnapshots(as: .testStrategy(), named: platformName) } func test_observableObjectSnapshots() { - ObservableObjectView_Previews.snapshots.assertSnapshots(as: .testStrategy()) + ObservableObjectView_Previews.snapshots.assertSnapshots(as: .testStrategy(), named: platformName) } func test_previewStateLightAndDark() { PreviewStateView_Previews.snapshots - .assertSnapshots(as: [ - "Light": .testStrategy(userInterfaceStyle: .light), - "Dark": .testStrategy(userInterfaceStyle: .dark), - ]) + .assertSnapshots( + as: [ + "Light": .testStrategy(userInterfaceStyle: .light), + "Dark": .testStrategy(userInterfaceStyle: .dark), + ], + named: platformName + ) } } +#if os(iOS) +let platformName = "iOS" + extension Snapshotting where Value: SwiftUI.View, Format == UIImage { /// Shared image test strategy static func testStrategy(userInterfaceStyle: UIUserInterfaceStyle = .light) -> Self { @@ -54,3 +60,48 @@ extension Snapshotting where Value: SwiftUI.View, Format == UIImage { ) } } +#elseif os(macOS) +let platformName = "macOS" + +extension Snapshotting where Value: SwiftUI.View, Format == NSImage { + /// Shared image test strategy + static func testStrategy(userInterfaceStyle: UserInterfaceStyle = .light) -> Self { + let snapshotting = Snapshotting.image(size: .init(width: 400, height: 400)).pullback { (view: Value) in + let view = NSHostingView(rootView: view.environment(\.colorScheme, userInterfaceStyle.colorScheme)) + view.wantsLayer = true + view.layer?.backgroundColor = NSColor.windowBackgroundColor.cgColor + return view + } + + return Snapshotting( + pathExtension: snapshotting.pathExtension, + diffing: snapshotting.diffing, + asyncSnapshot: { view in + Async { callback in + userInterfaceStyle.appearance.performAsCurrentDrawingAppearance { + snapshotting.snapshot(view).run(callback) + } + } + } + ) + } +} + +enum UserInterfaceStyle { + case light, dark + + var colorScheme: ColorScheme { + switch self { + case .light: return .light + case .dark: return .dark + } + } + + var appearance: NSAppearance { + switch self { + case .light: return NSAppearance(named: .aqua)! + case .dark: return NSAppearance(named: .darkAqua)! + } + } +} +#endif diff --git a/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_observableObjectSnapshots.Empty.png b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_observableObjectSnapshots.iOS-Empty.png similarity index 100% rename from Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_observableObjectSnapshots.Empty.png rename to Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_observableObjectSnapshots.iOS-Empty.png diff --git a/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_observableObjectSnapshots.Too-Short.png b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_observableObjectSnapshots.iOS-Too-Short.png similarity index 100% rename from Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_observableObjectSnapshots.Too-Short.png rename to Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_observableObjectSnapshots.iOS-Too-Short.png diff --git a/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_observableObjectSnapshots.Valid.png b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_observableObjectSnapshots.iOS-Valid.png similarity index 100% rename from Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_observableObjectSnapshots.Valid.png rename to Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_observableObjectSnapshots.iOS-Valid.png diff --git a/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_observableObjectSnapshots.macOS-Empty.png b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_observableObjectSnapshots.macOS-Empty.png new file mode 100644 index 0000000..41921b0 Binary files /dev/null and b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_observableObjectSnapshots.macOS-Empty.png differ diff --git a/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_observableObjectSnapshots.macOS-Too-Short.png b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_observableObjectSnapshots.macOS-Too-Short.png new file mode 100644 index 0000000..38e3b82 Binary files /dev/null and b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_observableObjectSnapshots.macOS-Too-Short.png differ diff --git a/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_observableObjectSnapshots.macOS-Valid.png b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_observableObjectSnapshots.macOS-Valid.png new file mode 100644 index 0000000..845608b Binary files /dev/null and b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_observableObjectSnapshots.macOS-Valid.png differ diff --git a/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.Long-Dark.png b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.iOS-Long-Dark.png similarity index 100% rename from Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.Long-Dark.png rename to Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.iOS-Long-Dark.png diff --git a/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.Long-Light.png b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.iOS-Long-Light.png similarity index 100% rename from Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.Long-Light.png rename to Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.iOS-Long-Light.png diff --git a/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.Short-Dark.png b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.iOS-Short-Dark.png similarity index 100% rename from Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.Short-Dark.png rename to Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.iOS-Short-Dark.png diff --git a/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.Short-Light.png b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.iOS-Short-Light.png similarity index 100% rename from Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.Short-Light.png rename to Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.iOS-Short-Light.png diff --git a/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.macOS-Long-Dark.png b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.macOS-Long-Dark.png new file mode 100644 index 0000000..8b64be7 Binary files /dev/null and b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.macOS-Long-Dark.png differ diff --git a/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.macOS-Long-Light.png b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.macOS-Long-Light.png new file mode 100644 index 0000000..1a3b902 Binary files /dev/null and b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.macOS-Long-Light.png differ diff --git a/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.macOS-Short-Dark.png b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.macOS-Short-Dark.png new file mode 100644 index 0000000..994a881 Binary files /dev/null and b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.macOS-Short-Dark.png differ diff --git a/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.macOS-Short-Light.png b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.macOS-Short-Light.png new file mode 100644 index 0000000..37f0e3b Binary files /dev/null and b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateLightAndDark.macOS-Short-Light.png differ diff --git a/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateViewSnapshots.Long.png b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateViewSnapshots.iOS-Long.png similarity index 100% rename from Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateViewSnapshots.Long.png rename to Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateViewSnapshots.iOS-Long.png diff --git a/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateViewSnapshots.Short.png b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateViewSnapshots.iOS-Short.png similarity index 100% rename from Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateViewSnapshots.Short.png rename to Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateViewSnapshots.iOS-Short.png diff --git a/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateViewSnapshots.macOS-Long.png b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateViewSnapshots.macOS-Long.png new file mode 100644 index 0000000..1a3b902 Binary files /dev/null and b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateViewSnapshots.macOS-Long.png differ diff --git a/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateViewSnapshots.macOS-Short.png b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateViewSnapshots.macOS-Short.png new file mode 100644 index 0000000..37f0e3b Binary files /dev/null and b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_previewStateViewSnapshots.macOS-Short.png differ diff --git a/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_simpleViewSnapshots.Long-Message.png b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_simpleViewSnapshots.iOS-Long-Message.png similarity index 100% rename from Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_simpleViewSnapshots.Long-Message.png rename to Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_simpleViewSnapshots.iOS-Long-Message.png diff --git a/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_simpleViewSnapshots.Short-Message.png b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_simpleViewSnapshots.iOS-Short-Message.png similarity index 100% rename from Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_simpleViewSnapshots.Short-Message.png rename to Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_simpleViewSnapshots.iOS-Short-Message.png diff --git a/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_simpleViewSnapshots.macOS-Long-Message.png b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_simpleViewSnapshots.macOS-Long-Message.png new file mode 100644 index 0000000..f41b8b9 Binary files /dev/null and b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_simpleViewSnapshots.macOS-Long-Message.png differ diff --git a/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_simpleViewSnapshots.macOS-Short-Message.png b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_simpleViewSnapshots.macOS-Short-Message.png new file mode 100644 index 0000000..f1fb76c Binary files /dev/null and b/Examples/PreviewSnapshotsTestAppTests/__Snapshots__/PreviewSnapshotsTestAppTests/test_simpleViewSnapshots.macOS-Short-Message.png differ diff --git a/Package.swift b/Package.swift index 8e99095..9864694 100644 --- a/Package.swift +++ b/Package.swift @@ -7,6 +7,7 @@ let package = Package( platforms: [ .iOS(.v13), .tvOS(.v13), + .macOS(.v10_15), ], products: [ .library( diff --git a/Sources/PreviewSnapshotsTesting/PreviewSnapshots+assertSnapshots.swift b/Sources/PreviewSnapshotsTesting/PreviewSnapshots+assertSnapshots.swift index a0503ff..0adf980 100644 --- a/Sources/PreviewSnapshotsTesting/PreviewSnapshots+assertSnapshots.swift +++ b/Sources/PreviewSnapshotsTesting/PreviewSnapshots+assertSnapshots.swift @@ -20,7 +20,7 @@ extension PreviewSnapshots { /// snapshots recorded on disk. /// /// - Parameters: - /// - snapshotting: Snapshotting instance for `AnyView` into a `UIImage`. + /// - snapshotting: Strategy for serializing, deserializing, and comparing `AnyView`. /// - name: An optional description of the snapshot to include with the configuration name. /// - recording: Whether or not to record a new reference. /// - file: The file in which failure occurred. Defaults to the file name of the test case in @@ -29,8 +29,8 @@ extension PreviewSnapshots { /// of the test case in which this function was called. /// - line: The line number on which failure occurred. Defaults to the line number on which /// this function was called. - public func assertSnapshots( - as snapshotting: Snapshotting = .image, + public func assertSnapshots( + as snapshotting: Snapshotting, named name: String? = nil, record recording: Bool = false, file: StaticString = #file, @@ -62,8 +62,8 @@ extension PreviewSnapshots { /// of the test case in which this function was called. /// - line: The line number on which failure occurred. Defaults to the line number on which /// this function was called. - public func assertSnapshots( - as strategies: [String: Snapshotting], + public func assertSnapshots( + as strategies: [String: Snapshotting], named name: String? = nil, record recording: Bool = false, file: StaticString = #file, @@ -96,8 +96,8 @@ extension PreviewSnapshots { /// of the test case in which this function was called. /// - line: The line number on which failure occurred. Defaults to the line number on which /// this function was called. - public func assertSnapshots( - as strategies: [Snapshotting], + public func assertSnapshots( + as strategies: [Snapshotting], named name: String? = nil, record recording: Bool = false, file: StaticString = #file, @@ -131,14 +131,14 @@ extension PreviewSnapshots { /// /// ```swift /// func test_snapshots() { - /// ContentView_Previews.snapshots.assertSnapshots { + /// ContentView_Previews.snapshots.assertSnapshots(as: .image) { /// $0.border(.red) /// } /// } /// ``` /// /// - Parameters: - /// - snapshotting: Snapshotting instance that converts an `AnyView` into a `UIImage`. + /// - snapshotting: Strategy for serializing, deserializing, and comparing `AnyView`. /// - name: An optional description of the snapshot to include with the configuration name. /// - recording: Whether or not to record a new reference. /// - file: The file in which failure occurred. Defaults to the file name of the test case in @@ -148,8 +148,8 @@ extension PreviewSnapshots { /// - line: The line number on which failure occurred. Defaults to the line number on which /// this function was called. /// - modify: A closure to update the preview content before snapshotting. - public func assertSnapshots( - as snapshotting: Snapshotting = .image, + public func assertSnapshots( + as snapshotting: Snapshotting, named name: String? = nil, record recording: Bool = false, file: StaticString = #file, @@ -178,7 +178,10 @@ extension PreviewSnapshots { /// /// ```swift /// func test_snapshots() { - /// ContentView_Previews.snapshots.assertSnapshots { + /// ContentView_Previews.snapshots.assertSnapshots(as: [ + /// "Light": .image(traits: UITraitCollection(userInterfaceStyle: .light)), + /// "Dark": .image(traits: UITraitCollection(userInterfaceStyle: .dark)), + /// ] { /// $0.border(.red) /// } /// } @@ -196,8 +199,8 @@ extension PreviewSnapshots { /// - line: The line number on which failure occurred. Defaults to the line number on which /// this function was called. /// - modify: A closure to update the preview content before snapshotting. - public func assertSnapshots( - as strategies: [String: Snapshotting], + public func assertSnapshots( + as strategies: [String: Snapshotting], named name: String? = nil, record recording: Bool = false, file: StaticString = #file, @@ -228,7 +231,10 @@ extension PreviewSnapshots { /// /// ```swift /// func test_snapshots() { - /// ContentView_Previews.snapshots.assertSnapshots { + /// ContentView_Previews.snapshots.assertSnapshots(as: [ + /// .image(layout: .fixed(width: 200, height: 200), + /// .image(layout: .fixed(width: 400, height: 400), + /// ]) { /// $0.border(.red) /// } /// } @@ -245,8 +251,8 @@ extension PreviewSnapshots { /// - line: The line number on which failure occurred. Defaults to the line number on which /// this function was called. /// - modify: A closure to update the preview content before snapshotting. - public func assertSnapshots( - as strategies: [Snapshotting], + public func assertSnapshots( + as strategies: [Snapshotting], named name: String? = nil, record recording: Bool = false, file: StaticString = #file, @@ -268,6 +274,76 @@ extension PreviewSnapshots { } } +#if os(iOS) || os(tvOS) +// MARK: - UIImage defaults + +extension PreviewSnapshots { + /// Assert that all of the snapshots defined in a `PreviewSnapshots` collection match their + /// snapshots recorded on disk using the `Snapshotting.image` strategy. + /// + /// - Parameters: + /// - name: An optional description of the snapshot to include with the configuration name. + /// - recording: Whether or not to record a new reference. + /// - file: The file in which failure occurred. Defaults to the file name of the test case in + /// which this function was called. + /// - testName: The name of the test in which failure occurred. Defaults to the function name + /// of the test case in which this function was called. + /// - line: The line number on which failure occurred. Defaults to the line number on which + /// this function was called. + public func assertSnapshots( + named name: String? = nil, + record recording: Bool = false, + file: StaticString = #file, + testName: String = #function, + line: UInt = #line + ) { + assertSnapshots(as: .image, named: name, record: recording, file: file, testName: testName, line: line) + } +} + +// MARK: - PreviewSnapshots.assertSnapshots + modify + +extension PreviewSnapshots { + /// Assert that all of the snapshots defined in a `PreviewSnapshots` collection match their + /// snapshots recorded on disk using the `Snapshotting.image` strategy after + /// applying some modification. + /// + /// `modify` can be used to update the configured view in a way that's useful for snapshotting, + /// but doesn't make sense for previews. + /// + /// For example, adding a border to better visualize the edges of the view in snapshots: + /// + /// ```swift + /// func test_snapshots() { + /// ContentView_Previews.snapshots.assertSnapshots { + /// $0.border(.red) + /// } + /// } + /// ``` + /// + /// - Parameters: + /// - name: An optional description of the snapshot to include with the configuration name. + /// - recording: Whether or not to record a new reference. + /// - file: The file in which failure occurred. Defaults to the file name of the test case in + /// which this function was called. + /// - testName: The name of the test in which failure occurred. Defaults to the function name + /// of the test case in which this function was called. + /// - line: The line number on which failure occurred. Defaults to the line number on which + /// this function was called. + /// - modify: A closure to update the preview content before snapshotting. + public func assertSnapshots( + named name: String? = nil, + record recording: Bool = false, + file: StaticString = #file, + testName: String = #function, + line: UInt = #line, + modify: (AnyView) -> Modified + ) { + assertSnapshots(as: .image, named: name, record: recording, file: file, testName: testName, line: line, modify: modify) + } +} +#endif + // MARK: Configuration name helper private extension PreviewSnapshots.Configuration { diff --git a/Tests/PreviewSnapshotsTests/PreviewSnapshotsTests.swift b/Tests/PreviewSnapshotsTests/PreviewSnapshotsTests.swift index 2029082..3fe1a4c 100644 --- a/Tests/PreviewSnapshotsTests/PreviewSnapshotsTests.swift +++ b/Tests/PreviewSnapshotsTests/PreviewSnapshotsTests.swift @@ -40,33 +40,7 @@ final class PreviewSnapshotsTests: XCTestCase { } ) - snapshots.assertSnapshots(as: .testStrategy) - } - - /// PreviewSnapshots assertion using `named` parameter - func test_namedAssertion() { - struct ContentView: View { - let message: String - - var body: some View { - Text(message) - .font(.largeTitle) - .foregroundColor(.blue) - .padding(8) - } - } - - let snapshots = PreviewSnapshots( - configurations: [ - .init(name: "Short Message", state: "Hello!"), - .init(name: "Long Message", state: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.") - ], - configure: { message in - ContentView(message: message) - } - ) - - snapshots.assertSnapshots(as: .testStrategy, named: "Named Assertion") + snapshots.assertSnapshots(as: .testStrategy, named: frameworkName) } /// PreviewSnapshots with a tuple as the state @@ -105,7 +79,7 @@ final class PreviewSnapshotsTests: XCTestCase { } ) - snapshots.assertSnapshots(as: .testStrategy) + snapshots.assertSnapshots(as: .testStrategy, named: frameworkName) } /// PreviewSnapshots with an ObservableObject as the state @@ -144,7 +118,7 @@ final class PreviewSnapshotsTests: XCTestCase { } ) - snapshots.assertSnapshots(as: .testStrategy) + snapshots.assertSnapshots(as: .testStrategy, named: frameworkName) } /// PreviewSnapshots using a NamedPreviewState as the state @@ -193,7 +167,7 @@ final class PreviewSnapshotsTests: XCTestCase { } ) - snapshots.assertSnapshots(as: .testStrategy) + snapshots.assertSnapshots(as: .testStrategy, named: frameworkName) } /// PreviewSnapshots using assertSnapshots's modify function @@ -218,11 +192,13 @@ final class PreviewSnapshotsTests: XCTestCase { } ) - snapshots.assertSnapshots(as: .testStrategy) { view in + snapshots.assertSnapshots(as: .testStrategy, named: frameworkName) { view in view.border(Color.blue) } } } +#if os(iOS) || os(tvOS) +let frameworkName = "UIKit" extension Snapshotting where Value: SwiftUI.View, Format == UIImage { /// Shared image test strategy @@ -233,3 +209,18 @@ extension Snapshotting where Value: SwiftUI.View, Format == UIImage { ) } } +#elseif os(macOS) +let frameworkName = "AppKit" + +extension Snapshotting where Value: SwiftUI.View, Format == NSImage { + /// Shared image test strategy + static var testStrategy: Self { + Snapshotting.image(size: .init(width: 400, height: 400)).pullback { view in + let view = NSHostingView(rootView: view) + view.wantsLayer = true + view.layer?.backgroundColor = NSColor.windowBackgroundColor.cgColor + return view + } + } +} +#endif diff --git a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_modify.AppKit-Long-Message.png b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_modify.AppKit-Long-Message.png new file mode 100644 index 0000000..f016b2d Binary files /dev/null and b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_modify.AppKit-Long-Message.png differ diff --git a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_modify.AppKit-Short-Message.png b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_modify.AppKit-Short-Message.png new file mode 100644 index 0000000..77b2bbf Binary files /dev/null and b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_modify.AppKit-Short-Message.png differ diff --git a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_modify.Long-Message.png b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_modify.UIKit-Long-Message.png similarity index 100% rename from Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_modify.Long-Message.png rename to Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_modify.UIKit-Long-Message.png diff --git a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_modify.Short-Message.png b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_modify.UIKit-Short-Message.png similarity index 100% rename from Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_modify.Short-Message.png rename to Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_modify.UIKit-Short-Message.png diff --git a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_namedPreviewState.AppKit-Long.png b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_namedPreviewState.AppKit-Long.png new file mode 100644 index 0000000..ed842a0 Binary files /dev/null and b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_namedPreviewState.AppKit-Long.png differ diff --git a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_namedPreviewState.AppKit-Short.png b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_namedPreviewState.AppKit-Short.png new file mode 100644 index 0000000..49c2bf3 Binary files /dev/null and b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_namedPreviewState.AppKit-Short.png differ diff --git a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_namedPreviewState.Long.png b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_namedPreviewState.UIKit-Long.png similarity index 100% rename from Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_namedPreviewState.Long.png rename to Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_namedPreviewState.UIKit-Long.png diff --git a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_namedPreviewState.Short.png b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_namedPreviewState.UIKit-Short.png similarity index 100% rename from Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_namedPreviewState.Short.png rename to Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_namedPreviewState.UIKit-Short.png diff --git a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_simpleState.AppKit-Long-Message.png b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_simpleState.AppKit-Long-Message.png new file mode 100644 index 0000000..f535776 Binary files /dev/null and b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_simpleState.AppKit-Long-Message.png differ diff --git a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_simpleState.AppKit-Short-Message.png b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_simpleState.AppKit-Short-Message.png new file mode 100644 index 0000000..8295819 Binary files /dev/null and b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_simpleState.AppKit-Short-Message.png differ diff --git a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_simpleState.Long-Message.png b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_simpleState.Long-Message.png deleted file mode 100644 index 1d60740..0000000 Binary files a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_simpleState.Long-Message.png and /dev/null differ diff --git a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_simpleState.Short-Message.png b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_simpleState.Short-Message.png deleted file mode 100644 index 69c8e4f..0000000 Binary files a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_simpleState.Short-Message.png and /dev/null differ diff --git a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_namedAssertion.Named-Assertion-Long-Message.png b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_simpleState.UIKit-Long-Message.png similarity index 100% rename from Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_namedAssertion.Named-Assertion-Long-Message.png rename to Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_simpleState.UIKit-Long-Message.png diff --git a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_namedAssertion.Named-Assertion-Short-Message.png b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_simpleState.UIKit-Short-Message.png similarity index 100% rename from Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_namedAssertion.Named-Assertion-Short-Message.png rename to Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_simpleState.UIKit-Short-Message.png diff --git a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_tupleState.AppKit-Large.png b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_tupleState.AppKit-Large.png new file mode 100644 index 0000000..a424c76 Binary files /dev/null and b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_tupleState.AppKit-Large.png differ diff --git a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_tupleState.AppKit-Small.png b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_tupleState.AppKit-Small.png new file mode 100644 index 0000000..996ad2e Binary files /dev/null and b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_tupleState.AppKit-Small.png differ diff --git a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_tupleState.Large.png b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_tupleState.UIKit-Large.png similarity index 100% rename from Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_tupleState.Large.png rename to Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_tupleState.UIKit-Large.png diff --git a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_tupleState.Small.png b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_tupleState.UIKit-Small.png similarity index 100% rename from Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_tupleState.Small.png rename to Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_tupleState.UIKit-Small.png diff --git a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_viewModel.AppKit-Loaded.png b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_viewModel.AppKit-Loaded.png new file mode 100644 index 0000000..5668e0a Binary files /dev/null and b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_viewModel.AppKit-Loaded.png differ diff --git a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_viewModel.AppKit-Loading.png b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_viewModel.AppKit-Loading.png new file mode 100644 index 0000000..60e5c4f Binary files /dev/null and b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_viewModel.AppKit-Loading.png differ diff --git a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_viewModel.Loaded.png b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_viewModel.UIKit-Loaded.png similarity index 100% rename from Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_viewModel.Loaded.png rename to Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_viewModel.UIKit-Loaded.png diff --git a/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_viewModel.Loading.png b/Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_viewModel.UIKit-Loading.png similarity index 100% rename from Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_viewModel.Loading.png rename to Tests/PreviewSnapshotsTests/__Snapshots__/PreviewSnapshotsTests/test_viewModel.UIKit-Loading.png