mirror of
https://github.com/stablyai/orca.git
synced 2026-10-06 08:02:28 +00:00
Avoid irrelevant scroll-action searches in Mac snapshots (#24731)
Check the current pure action name before searching for vertical scroll actions in the same immutable array.
This commit is contained in:
@@ -109,8 +109,8 @@ public enum SnapshotRenderHeuristics {
|
||||
return action != "AXCancel" && action != "AXPick"
|
||||
}
|
||||
if role == "AXScrollArea",
|
||||
(rawActions.contains("AXScrollUpByPage") || rawActions.contains("AXScrollDownByPage")),
|
||||
action == "AXScrollLeftByPage" || action == "AXScrollRightByPage" {
|
||||
action == "AXScrollLeftByPage" || action == "AXScrollRightByPage",
|
||||
(rawActions.contains("AXScrollUpByPage") || rawActions.contains("AXScrollDownByPage")) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
||||
+28
@@ -74,6 +74,34 @@ final class SnapshotRenderingTests: XCTestCase {
|
||||
XCTAssertEqual(SnapshotRenderHeuristics.meaningfulActions(node.rawActions, role: node.role), ["AXScrollUpByPage", "AXScrollDownByPage"])
|
||||
}
|
||||
|
||||
func testKeepsHorizontalOnlyActionsInTheirOriginalOrder() {
|
||||
let actions = ["AXScrollRightByPage", "AXPress", "AXScrollLeftByPage", "AXScrollRightByPage"]
|
||||
let node = SnapshotRenderNode(role: "AXScrollArea", rawActions: actions)
|
||||
|
||||
XCTAssertEqual(
|
||||
SnapshotRenderHeuristics.meaningfulActions(actions, role: node.role),
|
||||
["AXScrollRightByPage", "AXScrollLeftByPage", "AXScrollRightByPage"]
|
||||
)
|
||||
XCTAssertEqual(
|
||||
SnapshotRenderHeuristics.line(index: 2, node: node),
|
||||
"2 scroll area, Secondary Actions: scroll right, scroll left, scroll right"
|
||||
)
|
||||
}
|
||||
|
||||
func testKeepsMixedScrollActionsOutsideScrollAreas() {
|
||||
let actions = ["AXScrollLeftByPage", "AXScrollDownByPage", "AXScrollRightByPage", "AXCancel"]
|
||||
let node = SnapshotRenderNode(role: "AXMenu", rawActions: actions)
|
||||
|
||||
XCTAssertEqual(
|
||||
SnapshotRenderHeuristics.meaningfulActions(actions, role: node.role),
|
||||
["AXScrollLeftByPage", "AXScrollDownByPage", "AXScrollRightByPage"]
|
||||
)
|
||||
XCTAssertEqual(
|
||||
SnapshotRenderHeuristics.line(index: 3, node: node),
|
||||
"3 menu, Secondary Actions: scroll left, scroll down, scroll right"
|
||||
)
|
||||
}
|
||||
|
||||
func testTextFieldsKeepDistinctValueAndPlaceholder() {
|
||||
let node = SnapshotRenderNode(
|
||||
role: "AXTextField",
|
||||
|
||||
Reference in New Issue
Block a user