Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/precision parameter #121

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for SPM, but unfortunately we can't update the dependency past 1.9 for CocoaPods since SnapshotTesting dropped CP support in 1.10. Unfortunately this means our test suite won't compile right now (not sure why the CI job didn't run for this PR), since it uses the demo app as a host app, which uses CP to pull in its dependencies.

),
],
targets: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<UIView, UIImage>
.image(drawHierarchyInKeyWindow: drawHierarchyInKeyWindow)
.image(
drawHierarchyInKeyWindow: drawHierarchyInKeyWindow,
precision: precision,
perceptualPrecision: perceptualPrecision
)
.pullback { view in
let containerView = AccessibilitySnapshotView(
containedView: view,
Expand Down Expand Up @@ -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<UIView, UIImage>
.accessibilityImage(
showActivationPoints: activationPointDisplayMode,
useMonochromeSnapshot: useMonochromeSnapshot,
drawHierarchyInKeyWindow: drawHierarchyInKeyWindow,
markerColors: markerColors
markerColors: markerColors,
precision: precision,
perceptualPrecision: perceptualPrecision
)
.pullback { viewController in
viewController.view
Expand Down