From 390f78a5dd23bfc4a2e6d3b2b40347fcdf568c1e Mon Sep 17 00:00:00 2001 From: alexey1312 Date: Sat, 18 Mar 2023 09:26:43 +0600 Subject: [PATCH 1/2] Up SnapshotTesting version --- Package.resolved | 6 +++--- Package.swift | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) 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: [ From b53d8ccc147599bc2290d168596f2f40349dbfe3 Mon Sep 17 00:00:00 2001 From: alexey1312 Date: Sat, 18 Mar 2023 09:26:57 +0600 Subject: [PATCH 2/2] Add precision parameter --- .../SnapshotTesting+Accessibility.swift | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) 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