Skip to content

Commit d82bd8d

Browse files
committed
fix(ios): make snapshot presentation construction private
1 parent 766d42e commit d82bd8d

2 files changed

Lines changed: 71 additions & 66 deletions

File tree

‎apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotPresentation.swift‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,73 @@
11
import Foundation
22

33
enum SnapshotPresentation {
4+
/// The only snapshot node shape accepted by response payload assembly.
5+
///
6+
/// The encoded shape intentionally remains byte-for-byte compatible with the former
7+
/// `SnapshotNode` wire model. Construction stays file-private to this presentation module:
8+
/// acquisition backends can return `RawAXNode` values, but cannot recreate a presented node.
9+
struct PresentedNode: Codable {
10+
let index: Int
11+
let type: String
12+
let label: String?
13+
let identifier: String?
14+
let value: String?
15+
let rect: SnapshotRect
16+
let enabled: Bool
17+
let focused: Bool?
18+
let selected: Bool?
19+
let hittable: Bool
20+
let depth: Int
21+
let parentIndex: Int?
22+
let hiddenContentAbove: Bool?
23+
let hiddenContentBelow: Bool?
24+
let actions: [String]?
25+
26+
fileprivate init(presenting raw: RawAXNode) {
27+
self.init(
28+
presenting: raw,
29+
rect: raw.rect,
30+
index: raw.index,
31+
depth: raw.depth,
32+
parentIndex: raw.parentIndex
33+
)
34+
}
35+
36+
fileprivate init(presenting node: SnapshotPresentationNode) {
37+
self.init(
38+
presenting: node.raw,
39+
rect: node.effectiveRect,
40+
index: node.raw.index,
41+
depth: node.raw.depth,
42+
parentIndex: node.raw.parentIndex
43+
)
44+
}
45+
46+
fileprivate init(
47+
presenting raw: RawAXNode,
48+
rect: SnapshotRect,
49+
index: Int,
50+
depth: Int,
51+
parentIndex: Int?
52+
) {
53+
self.index = index
54+
type = raw.type
55+
label = raw.label
56+
identifier = raw.identifier
57+
value = raw.value
58+
self.rect = rect
59+
enabled = raw.enabled
60+
focused = raw.focused
61+
selected = raw.selected
62+
hittable = raw.hittable
63+
self.depth = depth
64+
self.parentIndex = parentIndex
65+
hiddenContentAbove = raw.hiddenContentAbove
66+
hiddenContentBelow = raw.hiddenContentBelow
67+
actions = raw.actions
68+
}
69+
}
70+
471
private static let eligibleInteractiveTypes: Set<String> = [
572
"Button",
673
"Cell",

‎apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotPresentationModels.swift‎

Lines changed: 4 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -70,69 +70,7 @@ struct SnapshotAcquisition {
7070
let viewport: CGRect
7171
}
7272

73-
/// The only snapshot node shape accepted by response payload assembly.
74-
///
75-
/// It has no memberwise initializer, so response assembly has to choose one of the explicit
76-
/// presentation constructors. The encoded shape intentionally remains byte-for-byte compatible
77-
/// with the former `SnapshotNode` wire model.
78-
struct PresentedNode: Codable {
79-
let index: Int
80-
let type: String
81-
let label: String?
82-
let identifier: String?
83-
let value: String?
84-
let rect: SnapshotRect
85-
let enabled: Bool
86-
let focused: Bool?
87-
let selected: Bool?
88-
let hittable: Bool
89-
let depth: Int
90-
let parentIndex: Int?
91-
let hiddenContentAbove: Bool?
92-
let hiddenContentBelow: Bool?
93-
let actions: [String]?
94-
95-
init(presenting raw: RawAXNode) {
96-
self.init(
97-
presenting: raw,
98-
rect: raw.rect,
99-
index: raw.index,
100-
depth: raw.depth,
101-
parentIndex: raw.parentIndex
102-
)
103-
}
104-
105-
init(presenting node: SnapshotPresentationNode) {
106-
self.init(
107-
presenting: node.raw,
108-
rect: node.effectiveRect,
109-
index: node.raw.index,
110-
depth: node.raw.depth,
111-
parentIndex: node.raw.parentIndex
112-
)
113-
}
114-
115-
init(
116-
presenting raw: RawAXNode,
117-
rect: SnapshotRect,
118-
index: Int,
119-
depth: Int,
120-
parentIndex: Int?
121-
) {
122-
self.index = index
123-
type = raw.type
124-
label = raw.label
125-
identifier = raw.identifier
126-
value = raw.value
127-
self.rect = rect
128-
enabled = raw.enabled
129-
focused = raw.focused
130-
selected = raw.selected
131-
hittable = raw.hittable
132-
self.depth = depth
133-
self.parentIndex = parentIndex
134-
hiddenContentAbove = raw.hiddenContentAbove
135-
hiddenContentBelow = raw.hiddenContentBelow
136-
actions = raw.actions
137-
}
138-
}
73+
/// Keep the wire payload's existing spelling while making the presented-node type owned by the
74+
/// presentation module. Its constructors live in `RunnerTests+SnapshotPresentation.swift` and are
75+
/// file-private there, so acquisition backends can carry a `PresentedNode` but cannot construct one.
76+
typealias PresentedNode = SnapshotPresentation.PresentedNode

0 commit comments

Comments
 (0)