Skip to content

Commit 62714f5

Browse files
committed
fix(android): cover Appium bar membership snapshot route
1 parent 1d6925b commit 62714f5

6 files changed

Lines changed: 29 additions & 21 deletions

File tree

‎packages/contracts/src/android-system-chrome.test.ts‎

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,20 @@ test('bar inheritance requires SystemUI ownership at each edge', () => {
4848
).toBeUndefined();
4949
});
5050

51-
test('shade settle provenance is private and does not imply public bar membership', () => {
52-
const identifier = 'com.android.systemui:id/split_shade_status_bar';
53-
expect(isAndroidSystemChromeWindowResourceId(identifier)).toBe(true);
54-
expect(androidSystemBarMembership('com.android.systemui', identifier)).toBeUndefined();
55-
expect(
56-
isAndroidSystemChromeWindowResourceId('com.android.systemui:id/status_bar_notification_row'),
57-
).toBe(false);
58-
expect(
59-
isAndroidSystemChromeWindowResourceId('com.android.systemui:id/navigation_bar_dialog'),
60-
).toBe(false);
61-
});
51+
test.each(['split_shade_status_bar', 'keyguard_status_bar'])(
52+
'%s settle provenance is private and does not imply public bar membership',
53+
(leaf) => {
54+
const identifier = `com.android.systemui:id/${leaf}`;
55+
expect(isAndroidSystemChromeWindowResourceId(identifier)).toBe(true);
56+
expect(androidSystemBarMembership('com.android.systemui', identifier)).toBeUndefined();
57+
expect(
58+
isAndroidSystemChromeWindowResourceId('com.android.systemui:id/status_bar_notification_row'),
59+
).toBe(false);
60+
expect(
61+
isAndroidSystemChromeWindowResourceId('com.android.systemui:id/navigation_bar_dialog'),
62+
).toBe(false);
63+
},
64+
);
6265

6366
test.each(['com.android.launcher3', 'com.google.android.apps.nexuslauncher'])(
6467
'launcher navigation is the navbuttons subtree only: %s',

‎packages/contracts/src/android-system-chrome.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ import type { RawSnapshotNode, SnapshotNode } from '@agent-device/kernel/snapsho
99
*/
1010
export const ANDROID_SYSTEM_CHROME_PACKAGE = 'com.android.systemui';
1111

12-
/** Persistent bar roots and the shade header whose icon churn settle ignores. */
12+
/** Persistent bar roots and shade/keyguard headers whose icon churn settle ignores. */
1313
export function isAndroidSystemChromeWindowResourceId(
1414
resourceId: string | null | undefined,
1515
): boolean {
1616
return (
1717
androidSystemBarMembership(ANDROID_SYSTEM_CHROME_PACKAGE, resourceId) !== undefined ||
18-
resourceId === 'com.android.systemui:id/split_shade_status_bar'
18+
resourceId === 'com.android.systemui:id/split_shade_status_bar' ||
19+
resourceId === 'com.android.systemui:id/keyguard_status_bar'
1920
);
2021
}
2122

‎packages/provider-webdriver/src/webdriver-android-source.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ test('Android native wrappers retain unknown ownership barriers for membership a
6161
const nodes = parseWebDriverAndroidSnapshotNodes(
6262
`<hierarchy>
6363
<android.widget.FrameLayout package="com.android.systemui" resource-id="com.android.systemui:id/status_bar">
64-
<android.widget.FrameLayout>
64+
<android.widget.FrameLayout index="0" class="android.widget.FrameLayout" bounds="[0,0][100,40]">
6565
<android.widget.Button package="com.android.systemui" text="Unknown subtree action" bounds="[0,0][100,40]" />
6666
</android.widget.FrameLayout>
6767
</android.widget.FrameLayout>

‎packages/provider-webdriver/src/webdriver-interactor.test.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ test('iOS WebDriver interactor routes snapshots through the acquisition adapter'
271271
assert.equal(result.acquisition.nodes[0]?.type, 'XCUIElementTypeApplication');
272272
});
273273

274-
test('Android WebDriver interactor keeps legacy-derived source facts at its call site', async () => {
274+
test('Android WebDriver interactor returns source facts with system-bar membership', async () => {
275275
const source = vi.fn(
276276
async () =>
277-
'<hierarchy rotation="0"><android.widget.Button bounds="[0,0][100,40]" displayed="true" enabled="true" /></hierarchy>',
277+
'<hierarchy rotation="0"><android.widget.FrameLayout index="0" class="android.widget.FrameLayout" package="com.android.systemui" resource-id="com.android.systemui:id/status_bar" bounds="[0,0][100,40]"><android.widget.Button index="0" class="android.widget.Button" package="com.android.systemui" bounds="[0,0][100,40]" displayed="true" enabled="true" /></android.widget.FrameLayout></hierarchy>',
278278
);
279279
const interactor = createWebDriverInteractor({
280280
client: { source } as unknown as WebDriverClient,
@@ -287,8 +287,13 @@ test('Android WebDriver interactor keeps legacy-derived source facts at its call
287287
if ('stage' in result) throw new Error('Android snapshot must be presented by the interactor');
288288
assert.equal(result.backend, 'android');
289289
assert.equal(result.nodes?.[0]?.type, 'hierarchy');
290-
assert.equal(result.nodes?.[1]?.type, 'android.widget.Button');
291-
assert.equal(result.nodes?.[1]?.hittable, true);
290+
assert.equal(result.nodes?.[1]?.type, 'android.widget.FrameLayout');
291+
assert.equal(result.nodes?.[2]?.type, 'android.widget.Button');
292+
assert.equal(result.nodes?.[2]?.hittable, true);
293+
for (const node of result.nodes!.slice(1)) {
294+
assert.equal(node.bundleId, 'com.android.systemui');
295+
assert.equal(node.systemBar, 'status');
296+
}
292297
assert.equal(source.mock.calls.length, 1);
293298
});
294299

‎packages/provider-webdriver/src/webdriver-source.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,8 @@ function appendSourceNodes(
117117
}
118118

119119
function isSourceContainer(xmlNode: XmlNode, platform: WebDriverSourcePlatform): boolean {
120+
if (Object.keys(xmlNode.attributes).length === 0) return true;
120121
const name = xmlNode.name.toLowerCase();
121-
if (Object.keys(xmlNode.attributes).length === 0) {
122-
return platform === 'ios' || name === 'hierarchy';
123-
}
124122
return platform === 'ios' && (name === 'hierarchy' || name === 'appiumaut');
125123
}
126124

‎website/docs/docs/commands.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ agent-device wait 'id="field-phone" value="00 062 91 77"'
465465
- `scroll <direction> [amount]` takes the finger path as a fraction of the viewport (`0.5` is half), or `--pixels <n>` for a fixed distance. Large distances are clamped. The app's scroll physics decide the final offset, so a scroll does not land on an exact position.
466466
- `scroll <direction> --until <selector>` repeats passes until the selector is on screen and fails if the content runs out first. Add an amount (`scroll down 0.8 --until <selector>`) to widen each pass. Use it in `.ad` scripts too, instead of fixed amounts that depend on screen size; see [Replay & E2E](/docs/replay-e2e).
467467
- Default snapshot text summarizes off-screen interactive content instead of listing refs. `scroll <direction> --settle` (and `back --settle`) waits for the UI to go quiet and returns the diff with fresh refs, so you don't need another `snapshot -i`. Settle is best-effort and never fails the action.
468+
- On Android, settle ignores an allowlist of system-bar containers and shade/keyguard status headers; other SystemUI overlays remain content. Appium settle also applies package rules for keyboard and system chrome.
468469
- With a keyboard up on iOS or Android, the swipe stays above the keyboard (reported as `keyboardAvoided` and `keyboardMinY`) and the keyboard stays open. If too little room is left, the command refuses with `scroll_keyboard_occludes_surface`; run `keyboard dismiss` first.
469470
- A directional scroll reports what it observed as `movement`: `moved`, `at-edge` (no change and no more content that way), `unchanged` (no change, no edge signal), or `unobserved` (no reliable comparison). If nothing changed, the swipe ran inside a container, and that container still has hidden content in that direction, it refuses with `scroll_no_progress`; the hint names the usual causes: a focused keyboard, a nested scroller, or a list that needs a raw `swipe`. See `agent-device help scroll`.
470471

0 commit comments

Comments
 (0)