diff --git a/Package.resolved b/Package.resolved index 8d531079..56658b90 100644 --- a/Package.resolved +++ b/Package.resolved @@ -11,12 +11,12 @@ } }, { - "package": "SnapshotTesting", + "package": "swift-snapshot-testing", "repositoryURL": "https://github.com/pointfreeco/swift-snapshot-testing.git", "state": { "branch": null, - "revision": "c466812aa2e22898f27557e2e780d3aad7a27203", - "version": "1.8.2" + "revision": "cef5b3f6f11781dd4591bdd1dd0a3d22bd609334", + "version": "1.11.0" } } ] diff --git a/Package.swift b/Package.swift index 8a104e8a..ad169161 100644 --- a/Package.swift +++ b/Package.swift @@ -36,7 +36,7 @@ let package = Package( .package( name: "SnapshotTesting", url: "https://github.com/pointfreeco/swift-snapshot-testing.git", - .upToNextMajor(from: "1.8.0") + .upToNextMajor(from: "1.11.0") ), ], targets: [ diff --git a/Sources/AccessibilitySnapshot/SnapshotTesting/SnapshotTesting+Accessibility.swift b/Sources/AccessibilitySnapshot/SnapshotTesting/SnapshotTesting+Accessibility.swift index 2758e6ef..06ff470c 100644 --- a/Sources/AccessibilitySnapshot/SnapshotTesting/SnapshotTesting+Accessibility.swift +++ b/Sources/AccessibilitySnapshot/SnapshotTesting/SnapshotTesting+Accessibility.swift @@ -42,18 +42,26 @@ extension Snapshotting where Value == UIView, Format == UIImage { /// - parameter drawHierarchyInKeyWindow: Whether or not to draw the view hierachy in the key window, rather than /// rendering the view's layer. This enables the rendering of `UIAppearance` and `UIVisualEffect`s. /// - parameter markerColors: The array of colors which will be chosen from when creating the overlays + /// - parameter precision: The percentage of pixels that must match. + /// - parameter perceptualPrecision: The percentage a pixel must match the source pixel to be considered a match. [98-99% mimics the precision of the human eye.](http://zschuessler.github.io/DeltaE/learn/#toc-defining-delta-e) public static func accessibilityImage( showActivationPoints activationPointDisplayMode: ActivationPointDisplayMode = .whenOverridden, useMonochromeSnapshot: Bool = true, drawHierarchyInKeyWindow: Bool = false, - markerColors: [UIColor] = [] + markerColors: [UIColor] = [], + precision: Float = 1, + perceptualPrecision: Float = 1 ) -> Snapshotting { guard isRunningInHostApplication else { fatalError("Accessibility snapshot tests cannot be run in a test target without a host application") } return Snapshotting - .image(drawHierarchyInKeyWindow: drawHierarchyInKeyWindow) + .image( + drawHierarchyInKeyWindow: drawHierarchyInKeyWindow, + precision: precision, + perceptualPrecision: perceptualPrecision + ) .pullback { view in let containerView = AccessibilitySnapshotView( containedView: view, @@ -180,18 +188,24 @@ extension Snapshotting where Value == UIViewController, Format == UIImage { /// - parameter drawHierarchyInKeyWindow: Whether or not to draw the view hierachy in the key window, rather than /// rendering the view's layer. This enables the rendering of `UIAppearance` and `UIVisualEffect`s. /// - parameter markerColors: The array of colors which will be chosen from when creating the overlays + /// - parameter precision: The percentage of pixels that must match. + /// - parameter perceptualPrecision: The percentage a pixel must match the source pixel to be considered a match. [98-99% mimics the precision of the human eye.](http://zschuessler.github.io/DeltaE/learn/#toc-defining-delta-e) public static func accessibilityImage( showActivationPoints activationPointDisplayMode: ActivationPointDisplayMode = .whenOverridden, useMonochromeSnapshot: Bool = true, drawHierarchyInKeyWindow: Bool = false, - markerColors: [UIColor] = [] + markerColors: [UIColor] = [], + precision: Float = 1, + perceptualPrecision: Float = 1 ) -> Snapshotting { return Snapshotting .accessibilityImage( showActivationPoints: activationPointDisplayMode, useMonochromeSnapshot: useMonochromeSnapshot, drawHierarchyInKeyWindow: drawHierarchyInKeyWindow, - markerColors: markerColors + markerColors: markerColors, + precision: precision, + perceptualPrecision: perceptualPrecision ) .pullback { viewController in viewController.view