-
Notifications
You must be signed in to change notification settings - Fork 3
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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
|
||
import { RunnerMessage } from './messages.js'; | ||
|
||
/** | ||
|
@@ -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. | ||
* @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()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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({ | ||
|
@@ -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) { | ||
|
There was a problem hiding this comment.
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