Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support space-separated list of AT settings #74

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 61 additions & 35 deletions src/runner/driver-test-runner.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { startJob } from '../shared/job.js';

import { ATDriver, ATKey, webDriverCodePoints } from './at-driver.js';

Check warning on line 3 in src/runner/driver-test-runner.js

View workflow job for this annotation

GitHub Actions / test (18.x, ubuntu-latest)

'ATDriver' is defined but never used

Check warning on line 3 in src/runner/driver-test-runner.js

View workflow job for this annotation

GitHub Actions / test (18.x, windows-latest)

'ATDriver' is defined but never used

Check warning on line 3 in src/runner/driver-test-runner.js

View workflow job for this annotation

GitHub Actions / test (20.x, ubuntu-latest)

'ATDriver' is defined but never used

Check warning on line 3 in src/runner/driver-test-runner.js

View workflow job for this annotation

GitHub Actions / test (20.x, windows-latest)

'ATDriver' is defined but never used
import { RunnerMessage } from './messages.js';

/**
Expand Down Expand Up @@ -90,30 +90,40 @@
/**
* Used for v2 tests to ensure proper settings.
*
* @param {string} settings - "browseMode" "focusMode" for NVDA, "pcCursor" "virtualCursor"
* for JAWS., "defaultMode" for others.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remove the reference to JAWS because there is no JAWS functionality in this function

* @param {string} settings - space seperated list of settings. "browseMode", "focusMode" for NVDA,
"quickNavOn", "defaultMode", etc for VoiceOver.
*/
async ensureSettings(settings) {
const { atName } = await this.collectedCapabilities;
if (atName == 'NVDA') {
const desiredResponse = { browsemode: 'Browse mode', focusmode: 'Focus mode' }[
settings.toLowerCase()
];
if (!desiredResponse) {
throw new Error(`Unknown command settings for NVDA "${settings}"`);
}
// break up the space-separated settings into an array so we can iterate over it
const settingsArray = settings.split(' ');

if (atName == 'NVDA') {
// disable the "beeps" when switching focus/browse mode, forces it to speak the mode after switching
await this.atDriver._send({
method: 'nvda:settings.setSettings',
params: { settings: [{ name: 'virtualBuffers.passThroughAudioIndication', value: false }] },
});

try {
await this.pressKeysToToggleSetting(
ATKey.sequence(ATKey.chord(ATKey.key('insert'), ATKey.key('space'))),
desiredResponse
);
for (const setting of settingsArray) {
switch (setting.toLowerCase()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the purposes of this control flow, we could ditch the lower casing and update the case statements but i was wary of doing so in case configuration elsewhere assumes that all lowercase is valid.

case 'browsemode':
await this.pressKeysToToggleSetting(
ATKey.sequence(ATKey.chord(ATKey.key('insert'), ATKey.key('space'))),
'Browse mode'
);
break;
case 'focusmode':
await this.pressKeysToToggleSetting(
ATKey.sequence(ATKey.chord(ATKey.key('insert'), ATKey.key('space'))),
'Focus mode'
);
break;
default:
throw new Error(`Unknown command settings for NVDA "${setting}"`);
}
}
} finally {
// turn the "beeps" back on so mode switches won't be spoken (default setting)
await this.atDriver._send({
Expand All @@ -124,28 +134,44 @@
});
}
} else if (atName == 'VoiceOver') {
if (settings === 'quickNavOn' || settings === 'arrowQuickKeyNavOn') {
await this.pressKeysToToggleSetting(
ATKey.sequence(ATKey.chord(ATKey.key('left'), ATKey.key('right'))),
'quick nav on'
);
} else if (settings === 'quickNavOff' || settings === 'arrowQuickKeyNavOff') {
await this.pressKeysToToggleSetting(
ATKey.sequence(ATKey.chord(ATKey.key('left'), ATKey.key('right'))),
'quick nav off'
);
} else if (settings === 'singleQuickKeyNavOn') {
await this.pressKeysToToggleSetting(
ATKey.sequence(ATKey.chord(ATKey.key('control'), ATKey.key('option'), ATKey.key('q'))),
'single-key quick nav on'
);
} else if (settings === 'singleQuickKeyNavOff') {
await this.pressKeysToToggleSetting(
ATKey.sequence(ATKey.chord(ATKey.key('control'), ATKey.key('option'), ATKey.key('q'))),
'single-key quick nav off'
);
} else if (settings !== 'defaultMode') {
throw new Error(`Unrecognized setting for VoiceOver: ${settings}`);
for (const setting of settingsArray) {
switch (setting) {
case 'quickNavOn':
case 'arrowQuickKeyNavOn':
await this.pressKeysToToggleSetting(
ATKey.sequence(ATKey.chord(ATKey.key('left'), ATKey.key('right'))),
'quick nav on'
);
break;
case 'quickNavOff':
case 'arrowQuickKeyNavOff':
await this.pressKeysToToggleSetting(
ATKey.sequence(ATKey.chord(ATKey.key('left'), ATKey.key('right'))),
'quick nav off'
);
break;
case 'singleQuickKeyNavOn':
await this.pressKeysToToggleSetting(
ATKey.sequence(
ATKey.chord(ATKey.key('control'), ATKey.key('option'), ATKey.key('q'))
),
'single-key quick nav on'
);
break;
case 'singleQuickKeyNavOff':
await this.pressKeysToToggleSetting(
ATKey.sequence(
ATKey.chord(ATKey.key('control'), ATKey.key('option'), ATKey.key('q'))
),
'single-key quick nav off'
);
break;
case 'defaultMode':
// nothing to do here
break;
default:
throw new Error(`Unrecognized setting for VoiceOver: ${setting}`);
}
}
return;
} else if (!atName) {
Expand Down
Loading