Skip to content

Commit 042fd5e

Browse files
test(orientation): drive the unlock refusal through the conformance matrix
The orientation auto argument is its own admission cell on the orientation descriptor, so it owes its own conformance row plus a refusal assertion on each owner that never declares the cell.
1 parent fd0f146 commit 042fd5e

6 files changed

Lines changed: 50 additions & 4 deletions

File tree

‎packages/daemon/src/__tests__/support/runtime-binding-conformance.ts‎

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,14 @@ type ConformedRuntimeBinding = Readonly<{
5555
/**
5656
* A plan route admits several declared cells in order; name the one this table refuses on and
5757
* the ones the plan admits before reaching it. A single-use route derives its one cell from the
58-
* command registry instead.
58+
* command registry instead. A route variant that shares another command's descriptor (its own
59+
* key is not a registry name) names that command here.
5960
*/
60-
plan?: Readonly<{ refused: RuntimeOperation; admitted: readonly RuntimeOperation[] }>;
61+
plan?: Readonly<{
62+
refused: RuntimeOperation;
63+
admitted: readonly RuntimeOperation[];
64+
command?: string;
65+
}>;
6166
}>;
6267

6368
const available = Object.freeze({ available: true } as const);
@@ -139,6 +144,19 @@ export const conformedRuntimeBindings = {
139144
}),
140145
),
141146
},
147+
// The `auto` argument is its own admission cell (`unlockOrientation`) on the `orientation`
148+
// descriptor, so it owes its own refusal row across every conformance device.
149+
'orientation auto': {
150+
plan: { refused: 'unlockOrientation', admitted: [], command: 'orientation' },
151+
resolve: async (device, bindings) =>
152+
refusable(
153+
await resolveBoundOrientationRuntime({
154+
device,
155+
positionals: ['auto'],
156+
...bindings,
157+
}),
158+
),
159+
},
142160
'tv-remote': {
143161
resolve: async (device, bindings) =>
144162
refusable(await resolveBoundTvRemoteRuntime({ device, positionals: ['down'], ...bindings })),
@@ -188,7 +206,7 @@ export type ConformedRuntimeCommand = keyof typeof conformedRuntimeBindings;
188206
export function refusedRuntimeOperation(command: ConformedRuntimeCommand): RuntimeOperation {
189207
const binding: ConformedRuntimeBinding = conformedRuntimeBindings[command];
190208
if (binding.plan) return binding.plan.refused;
191-
const uses = commandRuntimeUseRequirements(command);
209+
const uses = commandRuntimeUseRequirements(registryCommandOf(command));
192210
const required = uses?.length === 1 ? uses[0] : undefined;
193211
if (required?.length !== 1) {
194212
throw new Error(
@@ -198,6 +216,12 @@ export function refusedRuntimeOperation(command: ConformedRuntimeCommand): Runti
198216
return required[0] as RuntimeOperation;
199217
}
200218

219+
/** The registry command one conformance key resolves to; a route variant names its own. */
220+
export function registryCommandOf(command: ConformedRuntimeCommand): string {
221+
const binding: ConformedRuntimeBinding = conformedRuntimeBindings[command];
222+
return binding.plan?.command ?? command;
223+
}
224+
201225
export type UnavailableExactOwnerFactCase = Readonly<{
202226
command: ConformedRuntimeCommand;
203227
device: DeviceInfo;

‎packages/daemon/src/sessions/__tests__/runtime-binding-conformance-completeness.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
import {
77
conformedRuntimeBindings,
88
refusedRuntimeOperation,
9+
registryCommandOf,
910
refuseUnavailableExactOwnerFact,
1011
type ConformedRuntimeCommand,
1112
} from '../../__tests__/support/runtime-binding-conformance.ts';
@@ -43,7 +44,7 @@ test('every single-use generic or interaction route descriptor has a conformance
4344

4445
test('every conformance entry refuses on a cell its registry descriptor declares', () => {
4546
const undeclared = conformedCommands.filter((command) => {
46-
const declared = commandRuntimeUseRequirements(command)?.flat() ?? [];
47+
const declared = commandRuntimeUseRequirements(registryCommandOf(command))?.flat() ?? [];
4748
return !declared.includes(refusedRuntimeOperation(command));
4849
});
4950

‎packages/platform-harmonyos/src/runtime.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,16 @@ test.each([
109109
available: false,
110110
reason: 'unsupported-platform-leaf',
111111
});
112+
expect(facts.operations.unlockOrientation).toMatchObject({
113+
available: false,
114+
reason: 'unsupported-platform-leaf',
115+
});
112116
expect(facts.operations.tvRemote).toEqual({
113117
available: false,
114118
reason: 'unsupported-platform-leaf',
115119
});
116120
expect(binding.operations.setOrientation).toBeUndefined();
121+
expect(binding.operations.unlockOrientation).toBeUndefined();
117122
expect(binding.operations.tvRemote).toBeUndefined();
118123
// Android's live IME status read has no HarmonyOS counterpart.
119124
expect(facts.operations.keyboardStatus).toEqual({

‎packages/platform-vega/src/runtime.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ test.each([
171171
hint: 'orientation is not supported on Vega OS.',
172172
});
173173
expect(binding.operations.setOrientation).toBeUndefined();
174+
expect(binding.facts.operations.unlockOrientation).toMatchObject({
175+
available: false,
176+
reason: 'unsupported-platform-leaf',
177+
hint: 'orientation is not supported on Vega OS.',
178+
});
179+
expect(binding.operations.unlockOrientation).toBeUndefined();
174180
for (const operation of ['keyboardStatus', 'keyboardDismiss', 'keyboardEnter'] as const) {
175181
expect(binding.facts.operations[operation]).toMatchObject({
176182
available: false,

‎packages/platform-web/src/runtime.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,13 @@ test('back/home/orientation/tv-remote/keyboard never carried a web capability bu
256256
});
257257
expect(binding.operations[operation]).toBeUndefined();
258258
}
259+
// `orientation auto`'s cell comes from the orientation facts' default refusal, not the web
260+
// transport, so it refuses with the ADB-only hint instead of the web leaf's bare reason.
261+
expect(binding.facts.operations.unlockOrientation).toMatchObject({
262+
available: false,
263+
reason: 'unsupported-platform-leaf',
264+
});
265+
expect(binding.operations.unlockOrientation).toBeUndefined();
259266
});
260267

261268
test('binds viewport resizing through the local web interactor and honors cancellation', async () => {

‎packages/provider-webdriver/src/platform-runtime.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,9 @@ test.each([
354354
}
355355
expect(facts.operations.home.available).toBe(state.isSessionActive());
356356
expect(facts.operations.setOrientation.available).toBe(state.isSessionActive());
357+
// `orientation auto` is ADB-only: even a fully reachable WebDriver session keeps the default
358+
// unlock refusal the orientation facts state for an owner that declares no unlock cell.
359+
expect(facts.operations.unlockOrientation.available).toBe(false);
357360
expect(facts.operations.readClipboard.available).toBe(state.isSessionActive());
358361
expect(facts.operations.writeClipboard.available).toBe(state.isSessionActive());
359362
expect(facts.operations.appSwitcher.available).toBe(state.isSessionActive());

0 commit comments

Comments
 (0)