@@ -11,24 +11,22 @@ import { AgentMessage } from './messages.js';
11
11
* @module agent
12
12
*/
13
13
14
- const AFTER_NAVIGATION_DELAY = 1000 ;
15
- const AFTER_KEYS_DELAY = 5000 ;
16
- const RUN_TEST_SETUP_BUTTON_TIMEOUT = 1000 ;
17
-
18
14
export class DriverTestRunner {
19
15
/**
20
16
* @param {object } options
21
17
* @param {AriaATCIShared.BaseURL } options.baseUrl
22
18
* @param {AriaATCIAgent.Log } options.log
23
19
* @param {BrowserDriver } options.browserDriver
24
20
* @param {ATDriver } options.atDriver
21
+ * @param {AriaATCIShared.timesOption } options.timesOption
25
22
*/
26
- constructor ( { baseUrl, log, browserDriver, atDriver } ) {
23
+ constructor ( { baseUrl, log, browserDriver, atDriver, timesOption } ) {
27
24
this . baseUrl = baseUrl ;
28
25
this . log = log ;
29
26
this . browserDriver = browserDriver ;
30
27
this . atDriver = atDriver ;
31
28
this . collectedCapabilities = this . getCapabilities ( ) ;
29
+ this . timesOption = timesOption ;
32
30
}
33
31
34
32
async getCapabilities ( ) {
@@ -51,7 +49,7 @@ export class DriverTestRunner {
51
49
try {
52
50
await this . browserDriver . clickWhenPresent (
53
51
'.button-run-test-setup' ,
54
- RUN_TEST_SETUP_BUTTON_TIMEOUT
52
+ this . timesOption . testSetup
55
53
) ;
56
54
} catch ( { } ) {
57
55
await this . log ( AgentMessage . NO_RUN_TEST_SETUP , { referencePage } ) ;
@@ -71,15 +69,10 @@ export class DriverTestRunner {
71
69
* @param {string } desiredResponse
72
70
*/
73
71
async pressKeysToToggleSetting ( sequence , desiredResponse ) {
74
- // This timeout may be reached as many as two times for every test.
75
- // Delays of over 500ms have been observed during local testing in a
76
- // Windows virtual machine.
77
- const MODE_SWITCH_SPEECH_TIMEOUT = 750 ;
78
-
79
72
let unknownCollected = '' ;
80
73
// there are 2 modes, so we will try pressing mode switch up to twice
81
74
for ( let triesRemain = 2 ; triesRemain > 0 ; triesRemain -- ) {
82
- const speechResponse = await this . _collectSpeech ( MODE_SWITCH_SPEECH_TIMEOUT , ( ) =>
75
+ const speechResponse = await this . _collectSpeech ( this . timesOption . modeSwitch , ( ) =>
83
76
this . sendKeys ( sequence )
84
77
) ;
85
78
while ( speechResponse . length ) {
@@ -202,7 +195,7 @@ export class DriverTestRunner {
202
195
const { value : validCommand , errors } = validateKeysFromCommand ( command ) ;
203
196
204
197
if ( validCommand ) {
205
- await this . _collectSpeech ( AFTER_NAVIGATION_DELAY , ( ) =>
198
+ await this . _collectSpeech ( this . timesOption . afterNav , ( ) =>
206
199
this . openPage ( {
207
200
url : this . _appendBaseUrl ( test . target . referencePage ) ,
208
201
referencePage : test . target . referencePage ,
@@ -217,11 +210,11 @@ export class DriverTestRunner {
217
210
await this . ensureMode ( test . target . mode ) ;
218
211
}
219
212
220
- const spokenOutput = await this . _collectSpeech ( AFTER_KEYS_DELAY , ( ) =>
213
+ const spokenOutput = await this . _collectSpeech ( this . timesOption . afterKeys , ( ) =>
221
214
this . sendKeys ( atKeysFromCommand ( validCommand ) )
222
215
) ;
223
216
224
- await this . _collectSpeech ( AFTER_NAVIGATION_DELAY , async ( ) => {
217
+ await this . _collectSpeech ( this . timesOption . afterNav , async ( ) => {
225
218
await this . log ( AgentMessage . OPEN_PAGE , { url : 'about:blank' } ) ;
226
219
await this . browserDriver . navigate ( 'about:blank' ) ;
227
220
} ) ;
0 commit comments