Skip to content

Commit 58164f3

Browse files
resolving merge conflict
1 parent 1c883c7 commit 58164f3

7 files changed

Lines changed: 38 additions & 26 deletions

File tree

Example/SnapshotTests/ElementOrderTests.swift

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,43 +24,50 @@ final class ElementOrderTests: SnapshotTestCase {
2424
func testScatter() {
2525
let elementOrderViewController = ElementOrderViewController(configurations: .scatter)
2626
elementOrderViewController.view.frame = UIScreen.main.bounds
27-
SnapshotVerifyAccessibility(elementOrderViewController.view, snapshotConfiguration: .init(showElementOrderMarkers: true))
27+
let configuration = AccessibilitySnapshotConfiguration(viewRenderingMode: viewRenderingMode, includesElementOrder: .always)
28+
SnapshotVerifyAccessibility(elementOrderViewController.view, snapshotConfiguration: configuration)
2829
}
2930

3031
func testGrid() {
3132
let elementOrderViewController = ElementOrderViewController(configurations: .grid)
3233
elementOrderViewController.view.frame = UIScreen.main.bounds
33-
SnapshotVerifyAccessibility(elementOrderViewController.view, snapshotConfiguration: .init(showElementOrderMarkers: true))
34+
let configuration = AccessibilitySnapshotConfiguration(viewRenderingMode: viewRenderingMode, includesElementOrder: .always)
35+
SnapshotVerifyAccessibility(elementOrderViewController.view, snapshotConfiguration: configuration)
3436
}
3537

3638
func testContainerInElementStack() {
3739
let elementOrderViewController = ElementOrderViewController(configurations: .containerInElementStack)
3840
elementOrderViewController.view.frame = UIScreen.main.bounds
39-
SnapshotVerifyAccessibility(elementOrderViewController.view, snapshotConfiguration: .init(showElementOrderMarkers: true))
41+
let configuration = AccessibilitySnapshotConfiguration(viewRenderingMode: viewRenderingMode, includesElementOrder: .always)
42+
SnapshotVerifyAccessibility(elementOrderViewController.view, snapshotConfiguration: configuration)
4043
}
4144

4245
func testZeroSizedContainerInElementStack() {
4346
let elementOrderViewController = ElementOrderViewController(configurations: .zeroSizedContainerInElementStack)
4447
elementOrderViewController.view.frame = UIScreen.main.bounds
45-
SnapshotVerifyAccessibility(elementOrderViewController.view, snapshotConfiguration: .init(showElementOrderMarkers: true))
48+
let configuration = AccessibilitySnapshotConfiguration(viewRenderingMode: viewRenderingMode, includesElementOrder: .always)
49+
SnapshotVerifyAccessibility(elementOrderViewController.view, snapshotConfiguration: configuration)
4650
}
4751

4852
func testGroupedViewsInElementStack() {
4953
let elementOrderViewController = ElementOrderViewController(configurations: .groupedViewsInElementStack)
5054
elementOrderViewController.view.frame = UIScreen.main.bounds
51-
SnapshotVerifyAccessibility(elementOrderViewController.view, snapshotConfiguration: .init(showElementOrderMarkers: true))
55+
let configuration = AccessibilitySnapshotConfiguration(viewRenderingMode: viewRenderingMode, includesElementOrder: .always)
56+
SnapshotVerifyAccessibility(elementOrderViewController.view, snapshotConfiguration: configuration)
5257
}
5358

5459
func testUngroupedViewsInElementStack() {
5560
let elementOrderViewController = ElementOrderViewController(configurations: .ungroupedViewsInElementStack)
5661
elementOrderViewController.view.frame = UIScreen.main.bounds
57-
SnapshotVerifyAccessibility(elementOrderViewController.view, snapshotConfiguration: .init(showElementOrderMarkers: true))
62+
let configuration = AccessibilitySnapshotConfiguration(viewRenderingMode: viewRenderingMode, includesElementOrder: .always)
63+
SnapshotVerifyAccessibility(elementOrderViewController.view, snapshotConfiguration: configuration)
5864
}
5965

6066
func testUngroupedViewsInAccessibleParent() {
6167
let elementOrderViewController = ElementOrderViewController(configurations: .ungroupedViewsInAccessibleParent)
6268
elementOrderViewController.view.frame = UIScreen.main.bounds
63-
SnapshotVerifyAccessibility(elementOrderViewController.view, snapshotConfiguration: .init(showElementOrderMarkers: true))
69+
let configuration = AccessibilitySnapshotConfiguration(viewRenderingMode: viewRenderingMode, includesElementOrder: .always)
70+
SnapshotVerifyAccessibility(elementOrderViewController.view, snapshotConfiguration: configuration)
6471
}
6572

6673
}

Sources/AccessibilitySnapshot/Core/AccessibilitySnapshotConfiguration.swift

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,19 @@ public struct AccessibilitySnapshotConfiguration {
3636
/// Defaults to `.whenOverridden`.
3737
public let activationPointDisplay: AccessibilityContentDisplayMode
3838

39+
40+
/// Controls when to show indicators for elements' accessibility order.
41+
/// Defaults to `.never`.
42+
public let elementOrderDisplay: AccessibilityContentDisplayMode
43+
44+
3945
init(colors: [UIColor] = MarkerColors.defaultColors,
40-
activationPointDisplay: AccessibilityContentDisplayMode = .whenOverridden
46+
activationPointDisplay: AccessibilityContentDisplayMode = .whenOverridden,
47+
elementOrderDisplay: AccessibilityContentDisplayMode = .never
4148
) {
4249
self.colors = colors.isEmpty ? MarkerColors.defaultColors : colors
4350
self.activationPointDisplay = activationPointDisplay
51+
self.elementOrderDisplay = elementOrderDisplay
4452
}
4553
}
4654

@@ -71,11 +79,16 @@ public struct AccessibilitySnapshotConfiguration {
7179
colorRenderingMode: ColorRenderingMode = .monochrome,
7280
overlayColors: [UIColor] = MarkerColors.defaultColors,
7381
activationPointDisplay: AccessibilityContentDisplayMode = .whenOverridden,
74-
includesInputLabels: AccessibilityContentDisplayMode = .whenOverridden
82+
includesInputLabels: AccessibilityContentDisplayMode = .whenOverridden,
83+
includesElementOrder: AccessibilityContentDisplayMode = .never
7584
) {
7685

7786
self.snapshot = Snapshot(viewRenderingMode:viewRenderingMode, colorMode: colorRenderingMode)
78-
self.overlay = Overlay(colors: overlayColors.isEmpty ? MarkerColors.defaultColors : overlayColors, activationPointDisplay: activationPointDisplay)
87+
88+
self.overlay = Overlay(colors: overlayColors.isEmpty ? MarkerColors.defaultColors : overlayColors,
89+
activationPointDisplay: activationPointDisplay,
90+
elementOrderDisplay: includesElementOrder)
91+
7992
self.legend = Legend(includesUserInputLabels: includesInputLabels)
8093
}
8194
}

Sources/AccessibilitySnapshot/Core/AccessibilitySnapshotView.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ public final class AccessibilitySnapshotView: SnapshotAndLegendView {
7474
/// - parameter snapshotConfiguration: The configuration for the visual effects and markers applied to the snapshots.
7575
public init(
7676
containedView: UIView,
77-
viewRenderingMode: ViewRenderingMode,
7877
snapshotConfiguration: AccessibilitySnapshotConfiguration
7978
) {
8079
self.containedView = containedView
@@ -97,7 +96,7 @@ public final class AccessibilitySnapshotView: SnapshotAndLegendView {
9796
}
9897

9998
override var minimumLegendWidth: CGFloat {
100-
return LegendView.Metrics.minimumWidth
99+
return ElementLegendView.Metrics.minimumWidth
101100
}
102101

103102
// MARK: - Private Properties
@@ -160,12 +159,14 @@ public final class AccessibilitySnapshotView: SnapshotAndLegendView {
160159

161160
var displayMarkers: [DisplayMarker] = []
162161
for (index, marker) in markers.enumerated() {
162+
let elementIndex: Int? = markers.count > 1 ? index : nil
163+
163164
let color = snapshotConfiguration.overlay.colors[index % snapshotConfiguration.overlay.colors.count]
164165

165-
let legendView = LegendView(marker: marker, color: color, configuration: snapshotConfiguration.legend)
166+
let legendView = ElementLegendView(marker: marker,
166167
elementIndex: elementIndex,
167168
color: color,
168-
showUserInputLabels: snapshotConfiguration.showUserInputLabels)
169+
configuration: snapshotConfiguration.legend)
169170
addSubview(legendView)
170171

171172
let overlayView = OverlayView()
@@ -247,7 +248,7 @@ public final class AccessibilitySnapshotView: SnapshotAndLegendView {
247248

248249
var marker: AccessibilityMarker
249250

250-
var legendView: LegendView
251+
var legendView: ElementLegendView
251252

252253
var overlayView: OverlayView
253254

@@ -264,7 +265,6 @@ internal extension AccessibilitySnapshotView {
264265
guard let markerView else { return }
265266
markerView.sizeToFit()
266267
let origin = markerPosition
267-
// .applying(CGAffineTransform(translationX: -(markerView.bounds.width / 2), y: -(markerView.bounds.height / 2 )))
268268
markerView.frame = CGRect(origin: origin, size: markerView.frame.size)
269269
}
270270
}

Sources/AccessibilitySnapshot/Core/LegendView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ internal extension AccessibilitySnapshotView {
6767
}
6868

6969

70-
final class LegendView: UIView {
70+
final class ElementLegendView: UIView {
7171

7272
// MARK: - Life Cycle
7373

74-
init(marker: AccessibilityMarker, color: UIColor, configuration: AccessibilitySnapshotConfiguration.Legend) {
74+
init(marker: AccessibilityMarker, elementIndex: Int?, color: UIColor, configuration: AccessibilitySnapshotConfiguration.Legend) {
7575
self.hintLabel = marker.hint.map {
7676
let label = UILabel()
7777
label.text = $0

Sources/AccessibilitySnapshot/SnapshotTesting/SnapshotTesting+Accessibility.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ extension Snapshotting where Value == UIView, Format == UIImage {
6868
overlayColors: markerColors,
6969
activationPointDisplay: activationPointDisplayMode,
7070
includesInputLabels: showUserInputLabels ? .whenOverridden : .never
71-
useMonochromeSnapshot: useMonochromeSnapshot)
7271
)
7372

7473
let containerView = AccessibilitySnapshotView(containedView: view, snapshotConfiguration: configuration)

Sources/AccessibilitySnapshot/iOSSnapshotTestCase/Swift/FBSnapshotTestCase+Accessibility.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ extension FBSnapshotTestCase {
7676
SnapshotVerifyAccessibility(view,
7777
identifier: identifier,
7878
snapshotConfiguration: configuration,
79-
colors: markerColors,
80-
activationPointDisplayMode: activationPointDisplayMode,
81-
showUserInputLabels: showUserInputLabels,
82-
useMonochromeSnapshot: useMonochromeSnapshot),
8379
suffixes: suffixes,
8480
file: file,
8581
line: line)

Sources/AccessibilitySnapshot/iOSSnapshotTestCase/Swift/FBSnapshotTestCase+SwiftUI.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ extension FBSnapshotTestCase {
7474
size: size,
7575
identifier: identifier,
7676
snapshotConfiguration: configuration,
77-
activationPointDisplayMode: activationPointDisplayMode,
78-
showUserInputLabels: showUserInputLabels,
79-
useMonochromeSnapshot: useMonochromeSnapshot),
8077
suffixes: suffixes,
8178
file: file,
8279
line: line)

0 commit comments

Comments
 (0)