Skip to content

Commit a5b642a

Browse files
committed
Mark method as available for iOS 13 and above
1 parent 569a2fd commit a5b642a

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/iOSSnapshotTestCase/SwiftSupport.swift

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,38 +31,38 @@ public extension FBSnapshotTestCase {
3131
FBSnapshotVerifyViewOrLayer(layer, identifier: identifier, suffixes: suffixes, perPixelTolerance: perPixelTolerance, overallTolerance: overallTolerance, file: file, line: line)
3232
}
3333

34+
@available(iOS 13, *)
3435
func FBSnapshotVerifyViewForLightDarkMode(_ view: UIView, identifier: String? = nil, delay: TimeInterval = 0, perPixelTolerance: CGFloat = 0, overallTolerance: CGFloat = 0, file: StaticString = #file, line: UInt = #line) {
3536
let viewController = UIViewController()
3637
viewController.view.addSubview(view)
3738

3839
FBSnapshotVerifyViewControllerForLightDarkMode(viewController, identifier: identifier, delay: delay, perPixelTolerance: perPixelTolerance, overallTolerance: overallTolerance, file: file, line: line)
3940
}
4041

42+
@available(iOS 13, *)
4143
func FBSnapshotVerifyViewControllerForLightDarkMode(_ viewController: UIViewController, identifier: String? = nil, delay: TimeInterval = 0, perPixelTolerance: CGFloat = 0, overallTolerance: CGFloat = 0, file: StaticString = #file, line: UInt = #line) {
42-
if #available(iOS 13.0, *) {
43-
let navigationController = UINavigationController(rootViewController: viewController)
44-
let window = UIWindow()
45-
window.rootViewController = navigationController
46-
window.makeKeyAndVisible()
44+
let navigationController = UINavigationController(rootViewController: viewController)
45+
let window = UIWindow()
46+
window.rootViewController = navigationController
47+
window.makeKeyAndVisible()
4748

48-
// Take snapshot in light mode
49-
navigationController.overrideUserInterfaceStyle = .light
50-
RunLoop.main.run(until: Date(timeIntervalSinceNow: delay))
49+
// Take snapshot in light mode
50+
navigationController.overrideUserInterfaceStyle = .light
51+
RunLoop.main.run(until: Date(timeIntervalSinceNow: delay))
5152

52-
let lightId = [identifier, "light"].compactMap { $0 }.joined(separator: "_")
53-
FBSnapshotVerifyView(navigationController.view, identifier: lightId, suffixes: ["Light"], perPixelTolerance: 0, overallTolerance: 0, file: file, line: line)
53+
let lightId = [identifier, "light"].compactMap { $0 }.joined(separator: "_")
54+
FBSnapshotVerifyView(navigationController.view, identifier: lightId, suffixes: ["Light"], perPixelTolerance: 0, overallTolerance: 0, file: file, line: line)
5455

55-
// Take snapshot in dark mode
56-
window.rootViewController = nil
57-
window.rootViewController = navigationController
58-
navigationController.overrideUserInterfaceStyle = .dark
59-
RunLoop.main.run(until: Date(timeIntervalSinceNow: delay))
56+
// Take snapshot in dark mode
57+
window.rootViewController = nil
58+
window.rootViewController = navigationController
59+
navigationController.overrideUserInterfaceStyle = .dark
60+
RunLoop.main.run(until: Date(timeIntervalSinceNow: delay))
6061

61-
let darkId = [identifier, "dark"].compactMap { $0 }.joined(separator: "_")
62-
FBSnapshotVerifyView(navigationController.view, identifier: darkId, suffixes: ["Dark"], perPixelTolerance: 0, overallTolerance: 0, file: file, line: line)
62+
let darkId = [identifier, "dark"].compactMap { $0 }.joined(separator: "_")
63+
FBSnapshotVerifyView(navigationController.view, identifier: darkId, suffixes: ["Dark"], perPixelTolerance: 0, overallTolerance: 0, file: file, line: line)
6364

64-
window.rootViewController = nil
65-
}
65+
window.rootViewController = nil
6666
}
6767

6868
private func FBSnapshotVerifyViewOrLayer(_ viewOrLayer: AnyObject, identifier: String? = nil, suffixes: NSOrderedSet = FBSnapshotTestCaseDefaultSuffixes(), perPixelTolerance: CGFloat = 0, overallTolerance: CGFloat = 0, file: StaticString = #file, line: UInt = #line) {

0 commit comments

Comments
 (0)