diff --git a/Example/AccessibilitySnapshot.xcodeproj/project.pbxproj b/Example/AccessibilitySnapshot.xcodeproj/project.pbxproj index eed60ddf..57ff7e3e 100644 --- a/Example/AccessibilitySnapshot.xcodeproj/project.pbxproj +++ b/Example/AccessibilitySnapshot.xcodeproj/project.pbxproj @@ -48,6 +48,7 @@ 3F8E5DB92535B25000276B32 /* SwiftUIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F8E5DB82535B25000276B32 /* SwiftUIView.swift */; }; 3FEF854A2538455D0072611F /* SwiftUIView+EmbedInHostingController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FEF85492538455D0072611F /* SwiftUIView+EmbedInHostingController.swift */; }; 3FEF854F253846420072611F /* SwiftUIViewWithScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FEF854E253846420072611F /* SwiftUIViewWithScrollView.swift */; }; + 56EBCA5525B8C42C0049F486 /* IdentifierTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56EBCA5425B8C42C0049F486 /* IdentifierTests.swift */; }; 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; }; 607FACD81AFB9204008FA782 /* RootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* RootViewController.swift */; }; 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; }; @@ -126,6 +127,7 @@ 3FEF85492538455D0072611F /* SwiftUIView+EmbedInHostingController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SwiftUIView+EmbedInHostingController.swift"; sourceTree = ""; }; 3FEF854E253846420072611F /* SwiftUIViewWithScrollView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIViewWithScrollView.swift; sourceTree = ""; }; 4BB19B0B12930973E91DD3A1 /* Pods-AccessibilitySnapshotTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AccessibilitySnapshotTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AccessibilitySnapshotTests/Pods-AccessibilitySnapshotTests.debug.xcconfig"; sourceTree = ""; }; + 56EBCA5425B8C42C0049F486 /* IdentifierTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdentifierTests.swift; sourceTree = ""; }; 607FACD01AFB9204008FA782 /* AccessibilitySnapshotDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AccessibilitySnapshotDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -315,6 +317,7 @@ 3DC8D05A224750F500E8A03C /* TextAccessibilityTests.swift */, 3D220A29252AF70600359C1E /* Utilities */, 607FACE91AFB9204008FA782 /* Supporting Files */, + 56EBCA5425B8C42C0049F486 /* IdentifierTests.swift */, ); path = SnapshotTests; sourceTree = ""; @@ -645,6 +648,7 @@ 3DC8D05B224750F500E8A03C /* TextAccessibilityTests.swift in Sources */, 1635CE4E251EAC6700907101 /* SnapshotTestingTests.swift in Sources */, 3DBEAA5D2223C0CE00FAE61D /* SwitchControlsTests.swift in Sources */, + 56EBCA5525B8C42C0049F486 /* IdentifierTests.swift in Sources */, 3DF46500220D5FB00048D446 /* ElementSelectionTests.swift in Sources */, 3DBAC28722406EBB00EF4D0A /* AccessibilityContainersTests.swift in Sources */, 3DC488392212B40C006D1E15 /* ModalTests.swift in Sources */, diff --git a/Example/Gemfile.lock b/Example/Gemfile.lock index ed176372..8f711a31 100644 --- a/Example/Gemfile.lock +++ b/Example/Gemfile.lock @@ -120,4 +120,4 @@ DEPENDENCIES xcodeproj! BUNDLED WITH - 1.17.3 + 2.1.2 diff --git a/Example/SnapshotTests/IdentifierTests.swift b/Example/SnapshotTests/IdentifierTests.swift new file mode 100644 index 00000000..1d3a3701 --- /dev/null +++ b/Example/SnapshotTests/IdentifierTests.swift @@ -0,0 +1,42 @@ +// +// Copyright 2021 Square Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import AccessibilitySnapshot +import FBSnapshotTestCase + +@testable import AccessibilitySnapshotDemo + +final class IdentifierTests: SnapshotTestCase { + + func testSnapshotIdentifier() { + let label = UILabel(frame: .zero) + label.text = "Hello World" + label.sizeToFit() + + let view = UIView(frame: UIScreen.main.bounds) + view.backgroundColor = .lightGray + view.addSubview(label) + + label.center = view.center + + FBSnapshotVerifyView(view, identifier: "someIdentifier") +// FBSnapshotVerifyView(view.colorInvert(), identifier: "invertedColors") + SnapshotVerifyWithInvertedColors(view, identifier: "invertedColors") + + // Ensures the view has not been modified after calling SnapshotVerifyWithInvertedColors + FBSnapshotVerifyView(view, identifier: "someIdentifier") + } +} diff --git a/Example/SnapshotTests/ReferenceImages/_64/SnapshotTests.IdentifierTests/testSnapshotIdentifier_invertedColors_12_1_375x812@3x.png b/Example/SnapshotTests/ReferenceImages/_64/SnapshotTests.IdentifierTests/testSnapshotIdentifier_invertedColors_12_1_375x812@3x.png new file mode 100644 index 00000000..0c93eda1 Binary files /dev/null and b/Example/SnapshotTests/ReferenceImages/_64/SnapshotTests.IdentifierTests/testSnapshotIdentifier_invertedColors_12_1_375x812@3x.png differ diff --git a/Example/SnapshotTests/ReferenceImages/_64/SnapshotTests.IdentifierTests/testSnapshotIdentifier_invertedColors_13_3_375x812@3x.png b/Example/SnapshotTests/ReferenceImages/_64/SnapshotTests.IdentifierTests/testSnapshotIdentifier_invertedColors_13_3_375x812@3x.png new file mode 100644 index 00000000..e2d75bea Binary files /dev/null and b/Example/SnapshotTests/ReferenceImages/_64/SnapshotTests.IdentifierTests/testSnapshotIdentifier_invertedColors_13_3_375x812@3x.png differ diff --git a/Example/SnapshotTests/ReferenceImages/_64/SnapshotTests.IdentifierTests/testSnapshotIdentifier_invertedColors_14_2_390x844@3x.png b/Example/SnapshotTests/ReferenceImages/_64/SnapshotTests.IdentifierTests/testSnapshotIdentifier_invertedColors_14_2_390x844@3x.png new file mode 100644 index 00000000..942336da Binary files /dev/null and b/Example/SnapshotTests/ReferenceImages/_64/SnapshotTests.IdentifierTests/testSnapshotIdentifier_invertedColors_14_2_390x844@3x.png differ diff --git a/Example/SnapshotTests/ReferenceImages/_64/SnapshotTests.IdentifierTests/testSnapshotIdentifier_someIdentifier_12_1_375x812@3x.png b/Example/SnapshotTests/ReferenceImages/_64/SnapshotTests.IdentifierTests/testSnapshotIdentifier_someIdentifier_12_1_375x812@3x.png new file mode 100644 index 00000000..19000cac Binary files /dev/null and b/Example/SnapshotTests/ReferenceImages/_64/SnapshotTests.IdentifierTests/testSnapshotIdentifier_someIdentifier_12_1_375x812@3x.png differ diff --git a/Example/SnapshotTests/ReferenceImages/_64/SnapshotTests.IdentifierTests/testSnapshotIdentifier_someIdentifier_13_3_375x812@3x.png b/Example/SnapshotTests/ReferenceImages/_64/SnapshotTests.IdentifierTests/testSnapshotIdentifier_someIdentifier_13_3_375x812@3x.png new file mode 100644 index 00000000..200eca91 Binary files /dev/null and b/Example/SnapshotTests/ReferenceImages/_64/SnapshotTests.IdentifierTests/testSnapshotIdentifier_someIdentifier_13_3_375x812@3x.png differ diff --git a/Example/SnapshotTests/ReferenceImages/_64/SnapshotTests.IdentifierTests/testSnapshotIdentifier_someIdentifier_14_2_390x844@3x.png b/Example/SnapshotTests/ReferenceImages/_64/SnapshotTests.IdentifierTests/testSnapshotIdentifier_someIdentifier_14_2_390x844@3x.png new file mode 100644 index 00000000..543e578b Binary files /dev/null and b/Example/SnapshotTests/ReferenceImages/_64/SnapshotTests.IdentifierTests/testSnapshotIdentifier_someIdentifier_14_2_390x844@3x.png differ diff --git a/Sources/AccessibilitySnapshot/iOSSnapshotTestCase/FBSnapshotTestCase+Accessibility.swift b/Sources/AccessibilitySnapshot/iOSSnapshotTestCase/FBSnapshotTestCase+Accessibility.swift index dfb89275..716a3030 100644 --- a/Sources/AccessibilitySnapshot/iOSSnapshotTestCase/FBSnapshotTestCase+Accessibility.swift +++ b/Sources/AccessibilitySnapshot/iOSSnapshotTestCase/FBSnapshotTestCase+Accessibility.swift @@ -167,7 +167,7 @@ extension FBSnapshotTestCase { } let imageView = UIImageView(image: image) - FBSnapshotVerifyView(imageView, file: file, line: line) + FBSnapshotVerifyView(imageView, identifier: identifier, file: file, line: line) statusUtility.unmockStatuses() postNotification()