Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Identifier to inverted snapshot tests
Browse files Browse the repository at this point in the history
Josh Samuels committed Mar 9, 2021
1 parent f2f4c1c commit 45e29f4
Showing 10 changed files with 48 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Example/AccessibilitySnapshot.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -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 = "<group>"; };
3FEF854E253846420072611F /* SwiftUIViewWithScrollView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIViewWithScrollView.swift; sourceTree = "<group>"; };
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 = "<group>"; };
56EBCA5425B8C42C0049F486 /* IdentifierTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdentifierTests.swift; sourceTree = "<group>"; };
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 = "<group>"; };
607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@@ -315,6 +317,7 @@
3DC8D05A224750F500E8A03C /* TextAccessibilityTests.swift */,
3D220A29252AF70600359C1E /* Utilities */,
607FACE91AFB9204008FA782 /* Supporting Files */,
56EBCA5425B8C42C0049F486 /* IdentifierTests.swift */,
);
path = SnapshotTests;
sourceTree = "<group>";
@@ -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 */,
2 changes: 1 addition & 1 deletion Example/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -120,4 +120,4 @@ DEPENDENCIES
xcodeproj!

BUNDLED WITH
1.17.3
2.1.2
42 changes: 42 additions & 0 deletions Example/SnapshotTests/IdentifierTests.swift
Original file line number Diff line number Diff line change
@@ -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")
}
}
Binary file added ...Tests.IdentifierTests/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ...Tests.IdentifierTests/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ...Tests.IdentifierTests/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ...Tests.IdentifierTests/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ...Tests.IdentifierTests/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ...Tests.IdentifierTests/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 45e29f4

Please sign in to comment.