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

Allow users to specify SnapshotTesting precision #180

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ extension Snapshotting where Value == UIView, Format == UIImage {
/// read certain views. Defaults to `true`.
/// - 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 precision: The percentage of pixels that must match.
/// - parameter markerColors: The array of colors which will be chosen from when creating the overlays.
/// - parameter showUserInputLabels: Controls when to show elements' accessibility user input labels (used by Voice
/// Control).
public static func accessibilityImage(
showActivationPoints activationPointDisplayMode: ActivationPointDisplayMode = .whenOverridden,
useMonochromeSnapshot: Bool = true,
drawHierarchyInKeyWindow: Bool = false,
precision: Float = 1.0,
Copy link
Author

Choose a reason for hiding this comment

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

Ideally, we'd also move to a version that allows for the use of perceptualPrecision, as made available in 2022 here.

If there's any appetite for that migration, I'm happy to give it a go as well.

markerColors: [UIColor] = [],
showUserInputLabels: Bool = true
) -> Snapshotting {
Expand All @@ -56,7 +58,10 @@ extension Snapshotting where Value == UIView, Format == UIImage {
}

return Snapshotting<UIView, UIImage>
.image(drawHierarchyInKeyWindow: drawHierarchyInKeyWindow)
.image(
drawHierarchyInKeyWindow: drawHierarchyInKeyWindow,
precision: precision
)
.pullback { view in
let containerView = AccessibilitySnapshotView(
containedView: view,
Expand Down