Skip to content

Commit 3bc761b

Browse files
szdziedzicclaude
andcommitted
test(android): prove the display read rejects a failed result the transport returns
The exit-code tests used a fake that throws whenever allowFailure is unset, so they also passed on code with no exit-code check. withFakeAdb gains returnFailedResults, which hands back a nonzero result regardless, as the managed scoped transport does. Both tests now print the requested index on a failed read; they fail on 6335af1 and pass with the check. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 15a9ec4 commit 3bc761b

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎packages/platform-android/src/__tests__/input-actions.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,9 +458,10 @@ test('a display probe that hangs for the whole budget ends the settle as a failu
458458

459459
test('a display probe that exits non-zero fails the settle instead of passing as no field', async () => {
460460
await withFakeAdb(
461+
// A failed read that still printed the requested index must not confirm the rotation.
461462
(args) =>
462463
args[1] === 'dumpsys'
463-
? { stdout: '', stderr: 'dumpsys: permission denied', exitCode: 1 }
464+
? { stdout: ' mCurrentOrientation=1\n', stderr: 'dumpsys: permission denied', exitCode: 1 }
464465
: undefined,
465466
async ({ calls, device }) => {
466467
await assert.rejects(
@@ -469,6 +470,7 @@ test('a display probe that exits non-zero fails the settle instead of passing as
469470
);
470471
assert.equal(calls.filter((call) => call[1] === 'dumpsys').length, 1);
471472
},
473+
{ returnFailedResults: true },
472474
);
473475
});
474476

@@ -541,5 +543,6 @@ test('probeAndroidDisplayRotation reports none when the display read fails', asy
541543
});
542544
assert.equal(rotation, undefined);
543545
},
546+
{ returnFailedResults: true },
544547
);
545548
});

‎packages/platform-android/src/__tests__/test-utils/fake-adb.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ export async function withFakeAdb<T>(
2727
options: {
2828
device?: DeviceInfo;
2929
provider?: FakeAdbProviderExtras;
30+
/**
31+
* Hand back a nonzero result even when `allowFailure` is unset, as the managed scoped
32+
* transport does, instead of throwing like the local route.
33+
*/
34+
returnFailedResults?: boolean;
3035
} = {},
3136
): Promise<T> {
3237
const device: DeviceInfo = { ...(options.device ?? ANDROID_EMULATOR) };
@@ -43,7 +48,7 @@ export async function withFakeAdb<T>(
4348
typeof response === 'string'
4449
? { stdout: response, stderr: '', exitCode: 0 }
4550
: { stdout: '', stderr: '', exitCode: 0, ...response };
46-
if (result.exitCode !== 0 && !execOptions?.allowFailure) {
51+
if (result.exitCode !== 0 && !execOptions?.allowFailure && !options.returnFailedResults) {
4752
throw androidAdbResultError(
4853
`adb ${args.join(' ')} exited with code ${result.exitCode}`,
4954
result,

0 commit comments

Comments
 (0)