OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 GEN_INCLUDE(['../../testing/assert_additions.js']); | 5 GEN_INCLUDE(['../../testing/assert_additions.js']); |
6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js']); | 6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js']); |
7 | 7 |
8 /** | 8 /** |
9 * Gets the braille output and asserts that it matches expected values. | 9 * Gets the braille output and asserts that it matches expected values. |
10 * Annotations in the output that are primitive strings are ignored. | 10 * Annotations in the output that are primitive strings are ignored. |
11 */ | 11 */ |
12 function checkBrailleOutput(expectedText, expectedSpans, output) { | 12 function checkBrailleOutput(expectedText, expectedSpans, output) { |
13 var actualOutput = output.brailleOutputForTest; | 13 var actualOutput = output.brailleOutputForTest; |
14 // Remove string annotations. These are tested in the speech output and | 14 // Remove string annotations. These are tested in the speech output and |
15 // there's no need to clutter the tests with the corresponding braille | 15 // there's no need to clutter the tests with the corresponding braille |
16 // annotations. | 16 // annotations. |
17 var actualSpans = actualOutput.spans_.filter(function(span) { | 17 var actualSpans = actualOutput.spans_.filter(function(span) { |
18 return (typeof span.value !== 'string'); | 18 return (typeof span.value !== 'string'); |
19 }); | 19 }); |
20 assertEquals(expectedText, actualOutput.toString()); | 20 checkOutput_( |
| 21 expectedText, expectedSpans, actualOutput.toString(), actualSpans); |
| 22 } |
| 23 |
| 24 function checkSpeechOutput(expectedText, expectedSpans, output) { |
| 25 var actualOutput = output.speechOutputForTest; |
| 26 checkOutput_(expectedText, |
| 27 expectedSpans, |
| 28 actualOutput.toString(), |
| 29 actualOutput.spans_); |
| 30 } |
| 31 |
| 32 /** @private */ |
| 33 function checkOutput_(expectedText, expectedSpans, actualText, actualSpans) { |
| 34 assertEquals(expectedText, actualText); |
| 35 |
| 36 function describeSpanPrettyPrint(span) { |
| 37 return describeSpan(span).replace(':', ': ') |
| 38 .replace('"value":', 'value:') |
| 39 .replace('"start":', 'start:') |
| 40 .replace('"end":', 'end:') |
| 41 .replace('"', '\''); |
| 42 } |
21 | 43 |
22 function describeSpan(span) { | 44 function describeSpan(span) { |
23 var obj = {value: span.value, start: span.start, end: span.end}; | 45 var obj = {value: span.value, start: span.start, end: span.end}; |
24 if (obj.value instanceof Output.NodeSpan) { | 46 if (obj.value instanceof Output.NodeSpan) { |
25 obj.value.node = (obj.value.node.name || '') + ' ' + | 47 obj.value.node = (obj.value.node.name || '') + ' ' + |
26 obj.value.node.toString(); | 48 obj.value.node.toString(); |
27 } | 49 } |
28 return JSON.stringify(obj); | 50 return JSON.stringify(obj); |
29 } | 51 } |
30 | 52 |
31 function describeActualSpans() { | 53 function describeActualSpans() { |
32 return '\nAll actual spans:\n' + actualSpans.map(describeSpan).join('\n'); | 54 return '\nAll actual spans:\n' + |
| 55 actualSpans.map(describeSpanPrettyPrint).join('\n'); |
33 } | 56 } |
34 | 57 |
35 for (var i = 0, max = Math.max(expectedSpans.length, actualSpans.length); | 58 for (var i = 0, max = Math.max(expectedSpans.length, actualSpans.length); |
36 i < max; ++i) { | 59 i < max; ++i) { |
37 var expectedSpan = expectedSpans[i]; | 60 var expectedSpan = expectedSpans[i]; |
38 var actualSpan = actualSpans[i]; | 61 var actualSpan = actualSpans[i]; |
39 if (!expectedSpan) | 62 if (!expectedSpan) |
40 throw Error('Unexpected span in ' + expectedText + ': ' + | 63 throw Error('Unexpected span in ' + expectedText + ': ' + |
41 describeSpan(actualSpan) + describeActualSpans()); | 64 describeSpan(actualSpan) + describeActualSpans()); |
42 if (!actualSpan) | 65 if (!actualSpan) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 o); | 124 o); |
102 }); | 125 }); |
103 }); | 126 }); |
104 | 127 |
105 TEST_F('OutputE2ETest', 'Checkbox', function() { | 128 TEST_F('OutputE2ETest', 'Checkbox', function() { |
106 this.runWithLoadedTree('<input type="checkbox">', | 129 this.runWithLoadedTree('<input type="checkbox">', |
107 function(root) { | 130 function(root) { |
108 var el = root.firstChild.firstChild; | 131 var el = root.firstChild.firstChild; |
109 var range = cursors.Range.fromNode(el); | 132 var range = cursors.Range.fromNode(el); |
110 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); | 133 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
111 assertEqualsJSON({string_: '||Check box|not checked', 'spans_': [ | 134 checkSpeechOutput('|Check box|not checked', |
112 // Checkbox earcon (based on the state). | 135 [ |
113 {value: {earconId: 'CHECK_OFF'}, start: 0, end: 0}, | 136 {value: new Output.EarconAction('CHECK_OFF'), start: 0, end: 0}, |
114 | 137 {value: 'role', start: 1, end: 10}, |
115 // Attributes. | 138 {value: 'state', start: 11, end: 22} |
116 {value: 'name', start: 1, end: 1}, | 139 ], |
117 {value: 'role', start: 2, end: 11}, | 140 o); |
118 {value: 'state', start: 12, end: 23} | |
119 ]}, o.speechOutputForTest); | |
120 checkBrailleOutput( | 141 checkBrailleOutput( |
121 'chk ( )', | 142 'chk ( )', |
122 [{value: new Output.NodeSpan(el), start: 0, end: 7}], | 143 [{value: new Output.NodeSpan(el), start: 0, end: 7}], |
123 o); | 144 o); |
124 }); | 145 }); |
125 }); | 146 }); |
126 | 147 |
127 TEST_F('OutputE2ETest', 'InLineTextBoxValueGetsIgnored', function() { | 148 TEST_F('OutputE2ETest', 'InLineTextBoxValueGetsIgnored', function() { |
128 this.runWithLoadedTree('<p>OK', | 149 this.runWithLoadedTree('<p>OK', |
129 function(root) { | 150 function(root) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 o); | 208 o); |
188 }); | 209 }); |
189 }); | 210 }); |
190 | 211 |
191 TEST_F('OutputE2ETest', 'Audio', function() { | 212 TEST_F('OutputE2ETest', 'Audio', function() { |
192 this.runWithLoadedTree('<audio src="foo.mp3" controls></audio>', | 213 this.runWithLoadedTree('<audio src="foo.mp3" controls></audio>', |
193 function(root) { | 214 function(root) { |
194 var el = root.firstChild.firstChild.firstChild.firstChild; | 215 var el = root.firstChild.firstChild.firstChild.firstChild; |
195 var range = cursors.Range.fromNode(el); | 216 var range = cursors.Range.fromNode(el); |
196 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); | 217 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
197 assertEqualsJSON( | 218 |
198 {string_: 'play||Button|begin playback|audio|Tool bar|audio', | 219 checkSpeechOutput('play|Button|begin playback|audio|Tool bar', |
199 spans_: | 220 [ |
200 [{value: {earconId: 'BUTTON'}, start: 0, end: 4}, | 221 {value: new Output.EarconAction('BUTTON'), start: 0, end: 4}, |
201 {value: 'value', start: 5, end: 5}, | 222 {value: 'description', start: 12, end: 26}, |
202 {value: 'name', start: 28, end: 33}, | 223 {value: 'name', start: 27, end: 32}, |
203 {value: 'role', start: 34, end: 42}, | 224 {value: 'role', start: 33, end: 41} |
204 {value: 'description', start: 43, end: 48}] | 225 ], |
205 }, o.speechOutputForTest); | 226 o); |
| 227 |
206 checkBrailleOutput( | 228 checkBrailleOutput( |
207 'play btn begin playback audio tlbar audio', | 229 'play btn begin playback audio tlbar', |
208 [{value: new Output.NodeSpan(el), start: 0, end: 23}, | 230 [{value: new Output.NodeSpan(el), start: 0, end: 23}, |
209 {value: new Output.NodeSpan(el.parent), start: 24, end: 41}], | 231 {value: new Output.NodeSpan(el.parent), start: 24, end: 35}], |
210 o); | 232 o); |
211 | 233 |
212 el = el.nextSibling.nextSibling; | 234 el = el.nextSibling.nextSibling; |
213 var prevRange = range; | 235 var prevRange = range; |
214 range = cursors.Range.fromNode(el); | 236 range = cursors.Range.fromNode(el); |
215 var o = new Output().withSpeechAndBraille(range, prevRange, 'navigate'); | 237 var o = new Output().withSpeechAndBraille(range, prevRange, 'navigate'); |
216 assertEqualsJSON({string_: '|0, , slider|audio time scrubber', | 238 checkSpeechOutput('|0, , slider|audio time scrubber', |
217 spans_: | 239 [ |
218 [{value: {'earconId': 'SLIDER'}, start: 0, end: 0}, | 240 {value: new Output.EarconAction('SLIDER'), start: 0, end: 0}, |
219 {value: 'description', start: 13, end: 32}] | 241 {value: 'description', start: 13, end: 32} |
220 }, o.speechOutputForTest); | 242 ], |
| 243 o); |
221 // TODO(plundblad): Investigate this. | 244 // TODO(plundblad): Investigate this. |
222 checkBrailleOutput( | 245 checkBrailleOutput( |
223 '0, , slider audio time scrubber', | 246 '0, , slider audio time scrubber', |
224 [{value: new Output.NodeSpan(el), start: 0, end: 31}], | 247 [{value: new Output.NodeSpan(el), start: 0, end: 31}], |
225 o); | 248 o); |
226 }); | 249 }); |
227 }); | 250 }); |
228 | 251 |
229 TEST_F('OutputE2ETest', 'Input', function() { | 252 TEST_F('OutputE2ETest', 'Input', function() { |
230 this.runWithLoadedTree( | 253 this.runWithLoadedTree( |
231 '<input type="text"></input>' + | 254 '<input type="text"></input>' + |
232 '<input type="email"></input>' + | 255 '<input type="email"></input>' + |
233 '<input type="password"></input>' + | 256 '<input type="password"></input>' + |
234 '<input type="tel"></input>' + | 257 '<input type="tel"></input>' + |
235 '<input type="number"></input>' + | 258 '<input type="number"></input>' + |
236 '<input type="time"></input>' + | 259 '<input type="time"></input>' + |
237 '<input type="date"></input>' + | 260 '<input type="date"></input>' + |
238 '<input type="file"</input>' + | 261 '<input type="file"</input>' + |
239 '<input type="search"</input>' + | 262 '<input type="search"</input>' + |
240 '<input type="invalidType"</input>', | 263 '<input type="invalidType"</input>', |
241 function(root) { | 264 function(root) { |
242 var expected = {string_: '', 'spans_': [ | 265 var expectedSpans = [ |
243 {value: 'name', start: 0, end: 0}, | 266 {value: 'name', start: 0, end: 0}, |
244 | 267 {value: new Output.EarconAction('EDITABLE_TEXT'), start: 0, end: 0}, |
245 // Earcon | 268 {value: new Output.SelectionSpan(0, 0, 0), start: 1, end: 1}, |
246 {value: {earconId: 'EDITABLE_TEXT'}, start: 0, end: 0}, | 269 {value: 'value', start: 1, end: 1}, |
247 | 270 {value: 'inputType', start: 2} |
248 // Selection span. | 271 ]; |
249 {value: {startIndex: 0, endIndex: 0, offset: 0}, | |
250 start: 1, end: 1}, | |
251 | |
252 {value: 'value', start: 1, end: 1}, | |
253 {value: 'inputType', start: 2} | |
254 ]}; | |
255 | 272 |
256 var expectedSpeechValues = [ | 273 var expectedSpeechValues = [ |
257 '||Edit text', | 274 '||Edit text', |
258 '||Edit text, email entry', | 275 '||Edit text, email entry', |
259 '||Password edit text', | 276 '||Password edit text', |
260 '||Edit text numeric only', | 277 '||Edit text numeric only', |
261 {string_: '||Spin button', spans_: [{value: 'name', start: 0, end: 0}, | 278 ['||Spin button', |
262 {value: {earconId:'LISTBOX'}, start: 0, end: 0}, | 279 [{value: 'name', start: 0, end: 0}, |
263 {value: {startIndex: 0, endIndex: 0, offset: 0}, start: 1, end: 1}, | 280 {value: new Output.EarconAction('LISTBOX'), start: 0, end: 0}, |
264 {value: 'value', start: 1, end: 1}, | 281 {value: {startIndex: 0, endIndex: 0, offset: 0}, start: 1, end: 1}, |
265 {value: 'role', start: 2, end: 13}]}, | 282 {value: 'value', start: 1, end: 1}, |
266 {string_: '||Time control', spans_: [{value: 'name', start: 0, end: 0}, | 283 {value: 'role', start: 2, end: 13}] |
267 {value: 'value', start: 1, end: 1}, | 284 ], |
268 {value: 'role', start: 2, end: 14}]}, | 285 ['Time control', |
269 {string_: '||Date control', spans_: [{value: 'name', start: 0, end: 0}, | 286 [{value: 'role', start: 0, end: 12}] |
270 {value: 'value', start: 1, end: 1}, | 287 ], |
271 {value: 'role', start: 2, end: 14}]}, | 288 ['Date control', |
272 {string_: 'Choose File|No file chosen|Button', | 289 [{value: 'role', start: 0, end: 12}] |
273 spans_: [{value: 'name', start: 0, end: 11}, | 290 ], |
274 {value: {earconId: "BUTTON"}, start: 0, end: 11}, | 291 ['Choose File|No file chosen|Button', |
275 {value: 'value', start: 12, end: 26}, | 292 [{value: 'name', start: 0, end: 11}, |
276 {value: 'role', start: 27, end: 33}]}, | 293 {value: new Output.EarconAction("BUTTON"), start: 0, end: 11}, |
| 294 {value: 'value', start: 12, end: 26}, |
| 295 {value: 'role', start: 27, end: 33}] |
| 296 ], |
277 '||Edit text, search entry', | 297 '||Edit text, search entry', |
278 '||Edit text' | 298 '||Edit text' |
279 ]; | 299 ]; |
280 // TODO(plundblad): Some of these are wrong, there should be an initial | 300 // TODO(plundblad): Some of these are wrong, there should be an initial |
281 // space for the cursor in edit fields. | 301 // space for the cursor in edit fields. |
282 var expectedBrailleValues = [ | 302 var expectedBrailleValues = [ |
283 ' ed', | 303 ' ed', |
284 ' @ed', | 304 ' @ed', |
285 ' pwded', | 305 ' pwded', |
286 ' #ed', | 306 ' #ed', |
287 ' spnbtn', | 307 ' spnbtn', |
288 {string_: 'time'}, | 308 {string_: 'time'}, |
289 {string_: 'date'}, | 309 {string_: 'date'}, |
290 {string_: 'Choose File No file chosen btn'}, | 310 {string_: 'Choose File No file chosen btn'}, |
291 ' srched', | 311 ' srched', |
292 ' ed' | 312 ' ed' |
293 ]; | 313 ]; |
294 assertEquals(expectedSpeechValues.length, expectedBrailleValues.length); | 314 assertEquals(expectedSpeechValues.length, expectedBrailleValues.length); |
295 | 315 |
296 var el = root.firstChild.firstChild; | 316 var el = root.firstChild.firstChild; |
297 expectedSpeechValues.forEach(function(expectedValue) { | 317 expectedSpeechValues.forEach(function(expectedValue) { |
298 var range = cursors.Range.fromNode(el); | 318 var range = cursors.Range.fromNode(el); |
299 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); | 319 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
300 if (typeof expectedValue == 'object') { | 320 if (typeof expectedValue == 'object') { |
301 assertEqualsJSON(expectedValue, o.speechOutputForTest); | 321 checkSpeechOutput(expectedValue[0], expectedValue[1], o); |
302 } else { | 322 } else { |
303 expected.string_ = expectedValue; | 323 expectedSpans[4].end = expectedValue.length; |
304 expected.spans_[4].end = expectedValue.length; | 324 checkSpeechOutput(expectedValue, expectedSpans, o); |
305 assertEqualsJSON(expected, o.speechOutputForTest); | |
306 } | 325 } |
307 el = el.nextSibling; | 326 el = el.nextSibling; |
308 }); | 327 }); |
309 | 328 |
310 el = root.firstChild.firstChild; | 329 el = root.firstChild.firstChild; |
311 expectedBrailleValues.forEach(function(expectedValue) { | 330 expectedBrailleValues.forEach(function(expectedValue) { |
312 var range = cursors.Range.fromNode(el); | 331 var range = cursors.Range.fromNode(el); |
313 var o = new Output().withBraille(range, null, 'navigate'); | 332 var o = new Output().withBraille(range, null, 'navigate'); |
314 if (typeof expectedValue === 'string') { | 333 if (typeof expectedValue === 'string') { |
315 checkBrailleOutput( | 334 checkBrailleOutput( |
(...skipping 15 matching lines...) Expand all Loading... |
331 }); | 350 }); |
332 }); | 351 }); |
333 | 352 |
334 TEST_F('OutputE2ETest', 'List', function() { | 353 TEST_F('OutputE2ETest', 'List', function() { |
335 this.runWithLoadedTree( | 354 this.runWithLoadedTree( |
336 '<ul><li>a<li>b<li>c</ul>', | 355 '<ul><li>a<li>b<li>c</ul>', |
337 function(root) { | 356 function(root) { |
338 var el = root.firstChild.firstChild; | 357 var el = root.firstChild.firstChild; |
339 var range = cursors.Range.fromNode(el); | 358 var range = cursors.Range.fromNode(el); |
340 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); | 359 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
341 assertEqualsJSON({string_: 'a||List item|list|with 3 items', spans_: | 360 checkSpeechOutput('a|List item|list|with 3 items', |
342 [{value: 'name', start: 0, end: 1}, | 361 [ |
343 {value: {earconId: 'LIST_ITEM'}, start: 0, end: 1}, | 362 {value: 'name', start: 0, end: 1}, |
344 {value: 'value', start: 2, end: 2}, | 363 {value: new Output.EarconAction('LIST_ITEM'), start: 0, end: 1}, |
345 {value: 'role', start: 13, end: 17}]}, o.speechOutputForTest); | 364 {value: 'role', start: 12, end: 16} |
| 365 ], |
| 366 o); |
346 // TODO(plundblad): This output is wrong. Add special handling for | 367 // TODO(plundblad): This output is wrong. Add special handling for |
347 // braille here. | 368 // braille here. |
348 checkBrailleOutput( | 369 checkBrailleOutput( |
349 'a lstitm list +3', | 370 'a lstitm list +3', |
350 [{value: new Output.NodeSpan(el), start: 0, end: 8}, | 371 [{value: new Output.NodeSpan(el), start: 0, end: 8}, |
351 {value: new Output.NodeSpan(el.parent), start: 9, end: 16}], | 372 {value: new Output.NodeSpan(el.parent), start: 9, end: 16}], |
352 o); | 373 o); |
353 }); | 374 }); |
354 }); | 375 }); |
355 | 376 |
356 TEST_F('OutputE2ETest', 'Tree', function() { | 377 TEST_F('OutputE2ETest', 'Tree', function() { |
357 this.runWithLoadedTree(function() {/*! | 378 this.runWithLoadedTree(function() {/*! |
358 <ul role="tree"> | 379 <ul role="tree"> |
359 <li aria-expanded="true" role="treeitem">a | 380 <li aria-expanded="true" role="treeitem">a |
360 <li role="treeitem">b | 381 <li role="treeitem">b |
361 <li aria-expanded="false" role="treeitem">c | 382 <li aria-expanded="false" role="treeitem">c |
362 </ul> | 383 </ul> |
363 */}, | 384 */}, |
364 function(root) { | 385 function(root) { |
365 var el = root.firstChild.children[0].firstChild; | 386 var el = root.firstChild.children[0].firstChild; |
366 var range = cursors.Range.fromNode(el); | 387 var range = cursors.Range.fromNode(el); |
367 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); | 388 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
368 assertEqualsJSON( | 389 checkSpeechOutput( |
369 {string_: 'a|Tree item|Expanded| 1 of 3 | level 1 ||Tree|with 3 items', | 390 'a|Tree item|Expanded| 1 of 3 | level 1 |Tree|with 3 items', |
370 spans_: [ | 391 [ |
371 // TreeItem. | 392 {value: 'name', 'start': 0, end: 1}, |
372 {value: 'state', start: 12, end: 20}, | 393 {value: 'state', start: 12, end: 20}, |
373 {value: 'name', 'start': 40, end: 40}, | 394 {value: 'role','start': 40, end: 44}, |
374 {value: 'role','start': 41, end: 45}, | 395 ], |
375 ]}, o.speechOutputForTest); | 396 o); |
376 // TODO(plundblad): Braille output is wrong. | 397 // TODO(plundblad): Braille output is wrong. |
377 checkBrailleOutput( | 398 checkBrailleOutput( |
378 'a tritm - 1/3 level 1 tree +3', | 399 'a tritm - 1/3 level 1 tree +3', |
379 [{value: new Output.NodeSpan(el), start: 0, end: 1}, | 400 [{value: new Output.NodeSpan(el), start: 0, end: 1}, |
380 {value: new Output.NodeSpan(el.parent), start: 2, end: 23}, | 401 {value: new Output.NodeSpan(el.parent), start: 2, end: 23}, |
381 {value: new Output.NodeSpan(el.parent.parent), start: 24, end: 31}], | 402 {value: new Output.NodeSpan(el.parent.parent), start: 24, end: 31}], |
382 o); | 403 o); |
383 | 404 |
384 el = root.firstChild.children[1].firstChild; | 405 el = root.firstChild.children[1].firstChild; |
385 range = cursors.Range.fromNode(el); | 406 range = cursors.Range.fromNode(el); |
386 o = new Output().withSpeechAndBraille(range, null, 'navigate'); | 407 o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
387 assertEqualsJSON( | 408 checkSpeechOutput( |
388 {string_: 'b|Tree item| 2 of 3 | level 1 ||Tree|with 3 items', | 409 'b|Tree item| 2 of 3 | level 1 |Tree|with 3 items', |
389 spans_: [ | 410 [ |
390 // TreeItem. | 411 {value: 'name', start: 0, end: 1}, |
391 {value: 'name', start: 31, end: 31}, | 412 {value: 'role', 'start': 31, end: 35} |
392 {value: 'role', 'start': 32, end: 36} | 413 ], |
393 ]}, o.speechOutputForTest); | 414 o); |
394 // TODO(plundblad): Braille output is wrong. | 415 // TODO(plundblad): Braille output is wrong. |
395 checkBrailleOutput( | 416 checkBrailleOutput( |
396 'b tritm 2/3 level 1 tree +3', | 417 'b tritm 2/3 level 1 tree +3', |
397 [{value: new Output.NodeSpan(el), start: 0, end: 1}, | 418 [{value: new Output.NodeSpan(el), start: 0, end: 1}, |
398 {value: new Output.NodeSpan(el.parent), start: 2, end: 21}, | 419 {value: new Output.NodeSpan(el.parent), start: 2, end: 21}, |
399 {value: new Output.NodeSpan(el.parent.parent), start: 22, end: 29}], | 420 {value: new Output.NodeSpan(el.parent.parent), start: 22, end: 29}], |
400 o); | 421 o); |
401 | 422 |
402 el = root.firstChild.children[2].firstChild; | 423 el = root.firstChild.children[2].firstChild; |
403 range = cursors.Range.fromNode(el); | 424 range = cursors.Range.fromNode(el); |
404 o = new Output().withSpeechAndBraille(range, null, 'navigate'); | 425 o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
405 assertEqualsJSON( | 426 checkSpeechOutput( |
406 {string_: 'c|Tree item|Collapsed| 3 of 3 | level 1 ||Tree|with 3 items', | 427 'c|Tree item|Collapsed| 3 of 3 | level 1 |Tree|with 3 items', |
407 spans_: [ | 428 [ |
408 // TreeItem. | 429 {value: 'name', 'start': 0, end: 1}, |
409 {value: 'state', start: 12, end: 21}, | 430 {value: 'state', start: 12, end: 21}, |
410 {value: 'name', 'start': 41, end: 41}, | 431 {value: 'role','start': 41, end: 45}, |
411 {value: 'role','start': 42, end: 46}, | 432 ], |
412 ]}, o.speechOutputForTest); | 433 o); |
413 // TODO(plundblad): Braille output is wrong. | 434 // TODO(plundblad): Braille output is wrong. |
414 checkBrailleOutput( | 435 checkBrailleOutput( |
415 'c tritm + 3/3 level 1 tree +3', | 436 'c tritm + 3/3 level 1 tree +3', |
416 [{value: new Output.NodeSpan(el), start: 0, end: 1}, | 437 [{value: new Output.NodeSpan(el), start: 0, end: 1}, |
417 {value: new Output.NodeSpan(el.parent), start: 2, end: 23}, | 438 {value: new Output.NodeSpan(el.parent), start: 2, end: 23}, |
418 {value: new Output.NodeSpan(el.parent.parent), start: 24, end: 31}], | 439 {value: new Output.NodeSpan(el.parent.parent), start: 24, end: 31}], |
419 o); | 440 o); |
420 }); | 441 }); |
421 }); | 442 }); |
422 | 443 |
(...skipping 24 matching lines...) Expand all Loading... |
447 this.runWithLoadedTree(function() {/*! | 468 this.runWithLoadedTree(function() {/*! |
448 <select multiple> | 469 <select multiple> |
449 <option>1</option> | 470 <option>1</option> |
450 <option>2</option> | 471 <option>2</option> |
451 </select> | 472 </select> |
452 */}, | 473 */}, |
453 function(root) { | 474 function(root) { |
454 var el = root.firstChild.firstChild.firstChild; | 475 var el = root.firstChild.firstChild.firstChild; |
455 var range = cursors.Range.fromNode(el); | 476 var range = cursors.Range.fromNode(el); |
456 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); | 477 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
457 assertEqualsJSON({string_: '1|List item| 1 of 2 ||List box|with 2 items', | 478 checkSpeechOutput('1|List item| 1 of 2 |List box|with 2 items', |
458 spans_: | 479 [ |
459 [{value: {earconId: 'LIST_ITEM'}, start: 0,end: 1}, | 480 {value: 'name', start: 0, end: 1}, |
460 {value: 'name', start: 21, end: 21}, | 481 {value: new Output.EarconAction('LIST_ITEM'), start: 0,end: 1}, |
461 {value: 'role', start: 22, end: 30}]}, o.speechOutputForTest); | 482 {value: 'role', start: 21, end: 29} |
| 483 ], |
| 484 o); |
462 checkBrailleOutput( | 485 checkBrailleOutput( |
463 '1 lstitm 1/2 lstbx +2', | 486 '1 lstitm 1/2 lstbx +2', |
464 [{value: new Output.NodeSpan(el), start: 0, end: 12}, | 487 [{value: new Output.NodeSpan(el), start: 0, end: 12}, |
465 {value: new Output.NodeSpan(el.parent), start: 13, end: 21}], | 488 {value: new Output.NodeSpan(el.parent), start: 13, end: 21}], |
466 o); | 489 o); |
467 }); | 490 }); |
468 }); | 491 }); |
469 | 492 |
470 SYNC_TEST_F('OutputE2ETest', 'MessageIdAndEarconValidity', function() { | 493 SYNC_TEST_F('OutputE2ETest', 'MessageIdAndEarconValidity', function() { |
471 for (var key in Output.ROLE_INFO_) { | 494 for (var key in Output.ROLE_INFO_) { |
(...skipping 26 matching lines...) Expand all Loading... |
498 TEST_F('OutputE2ETest', 'DivOmitsRole', function() { | 521 TEST_F('OutputE2ETest', 'DivOmitsRole', function() { |
499 this.runWithLoadedTree(function() {/*! | 522 this.runWithLoadedTree(function() {/*! |
500 <div>that has content</div> | 523 <div>that has content</div> |
501 <div></div> | 524 <div></div> |
502 <div role='group'><div>nested content</div></div> | 525 <div role='group'><div>nested content</div></div> |
503 */}, | 526 */}, |
504 function(root) { | 527 function(root) { |
505 var el = root.firstChild.firstChild; | 528 var el = root.firstChild.firstChild; |
506 var range = cursors.Range.fromNode(el); | 529 var range = cursors.Range.fromNode(el); |
507 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); | 530 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
508 assertEqualsJSON({string_: 'that has content|', | 531 checkSpeechOutput('that has content', |
509 spans_: [ | 532 [{value: 'name', start: 0, end: 16}], o); |
510 {value: 'name', start: 17, end: 17} | |
511 ]}, o.speechOutputForTest); | |
512 checkBrailleOutput( | 533 checkBrailleOutput( |
513 'that has content', | 534 'that has content', |
514 [{value: new Output.NodeSpan(el), start: 0, end: 16}], | 535 [{value: new Output.NodeSpan(el), start: 0, end: 16}], |
515 o); | 536 o); |
516 }); | 537 }); |
517 }); | 538 }); |
518 | 539 |
519 TEST_F('OutputE2ETest', 'LessVerboseAncestry', function() { | 540 TEST_F('OutputE2ETest', 'LessVerboseAncestry', function() { |
520 this.runWithLoadedTree(function() {/*! | 541 this.runWithLoadedTree(function() {/*! |
521 <div role="article"><p>inside</p></div> | 542 <div role="article"><p>inside</p></div> |
522 <div role="article"><p>inside</p></div> | 543 <div role="article"><p>inside</p></div> |
523 <div role="banner"><p>inside</p></div> | 544 <div role="banner"><p>inside</p></div> |
524 */}, | 545 */}, |
525 function(root) { | 546 function(root) { |
526 var first = root.children[0].firstChild; | 547 var first = root.children[0].firstChild; |
527 var second = root.children[1].firstChild; | 548 var second = root.children[1].firstChild; |
528 var third = root.children[2].firstChild; | 549 var third = root.children[2].firstChild; |
529 var firstRange = cursors.Range.fromNode(first); | 550 var firstRange = cursors.Range.fromNode(first); |
530 var secondRange = cursors.Range.fromNode(second); | 551 var secondRange = cursors.Range.fromNode(second); |
531 var thirdRange = cursors.Range.fromNode(third); | 552 var thirdRange = cursors.Range.fromNode(third); |
532 | 553 |
533 var oWithoutPrev = new Output().withSpeech(firstRange, null, 'navigate'); | 554 var oWithoutPrev = new Output().withSpeech(firstRange, null, 'navigate'); |
534 var oWithPrev = | 555 var oWithPrev = |
535 new Output().withSpeech(secondRange, firstRange, 'navigate'); | 556 new Output().withSpeech(secondRange, firstRange, 'navigate'); |
536 var oWithPrevExit = | 557 var oWithPrevExit = |
537 new Output().withSpeech(thirdRange, secondRange, 'navigate'); | 558 new Output().withSpeech(thirdRange, secondRange, 'navigate'); |
538 assertEquals('inside||Article', oWithoutPrev.speechOutputForTest.string_); | 559 assertEquals('inside|Article', oWithoutPrev.speechOutputForTest.string_); |
539 | 560 |
540 // Make sure we don't read the exited article ancestry change. | 561 // Make sure we don't read the exited article ancestry change. |
541 assertEquals('inside||Article', oWithPrev.speechOutputForTest.string_); | 562 assertEquals('inside|Article', oWithPrev.speechOutputForTest.string_); |
542 | 563 |
543 // Different role; do read the exited article ancestry here. | 564 // Different role; do read the exited article ancestry here. |
544 assertEquals('inside|Exited Article.||Banner', | 565 assertEquals('inside|Exited Article.|Banner', |
545 oWithPrevExit.speechOutputForTest.string_); | 566 oWithPrevExit.speechOutputForTest.string_); |
546 }); | 567 }); |
547 }); | 568 }); |
548 | 569 |
549 TEST_F('OutputE2ETest', 'Brief', function() { | 570 TEST_F('OutputE2ETest', 'Brief', function() { |
550 this.runWithLoadedTree(function() {/*! | 571 this.runWithLoadedTree(function() {/*! |
551 <div role="article"><p>inside</p></div> | 572 <div role="article"><p>inside</p></div> |
552 */}, | 573 */}, |
553 function(root) { | 574 function(root) { |
554 var node = root.children[0].firstChild; | 575 var node = root.children[0].firstChild; |
555 var range = cursors.Range.fromNode(node); | 576 var range = cursors.Range.fromNode(node); |
556 | 577 |
557 localStorage['useVerboseMode'] = 'false'; | 578 localStorage['useVerboseMode'] = 'false'; |
558 var oWithoutPrev = new Output().withSpeech(range, null, 'navigate'); | 579 var oWithoutPrev = new Output().withSpeech(range, null, 'navigate'); |
559 assertEquals('inside|', oWithoutPrev.speechOutputForTest.string_); | 580 assertEquals('inside', oWithoutPrev.speechOutputForTest.string_); |
560 }); | 581 }); |
561 }); | 582 }); |
562 | 583 |
563 TEST_F('OutputE2ETest', 'AuralStyledHeadings', function() { | 584 TEST_F('OutputE2ETest', 'AuralStyledHeadings', function() { |
564 | 585 |
565 function toFixed(num) { | 586 function toFixed(num) { |
566 return parseFloat(Number(num).toFixed(1)); | 587 return parseFloat(Number(num).toFixed(1)); |
567 } | 588 } |
568 this.runWithLoadedTree(function() {/*! | 589 this.runWithLoadedTree(function() {/*! |
569 <h1>a</h1><h2>b</h2><h3>c</h3><h4>d</h4><h5>e</h5><h6>f</h6> | 590 <h1>a</h1><h2>b</h2><h3>c</h3><h4>d</h4><h5>e</h5><h6>f</h6> |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 }); | 641 }); |
621 }); | 642 }); |
622 | 643 |
623 TEST_F('OutputE2ETest', 'ComplexDiv', function() { | 644 TEST_F('OutputE2ETest', 'ComplexDiv', function() { |
624 this.runWithLoadedTree(function() {/*! | 645 this.runWithLoadedTree(function() {/*! |
625 <div><button>ok</button></div> | 646 <div><button>ok</button></div> |
626 */}, | 647 */}, |
627 function(root) { | 648 function(root) { |
628 var div = root.find({role: 'div'}); | 649 var div = root.find({role: 'div'}); |
629 var o = new Output().withSpeech(cursors.Range.fromNode(div)); | 650 var o = new Output().withSpeech(cursors.Range.fromNode(div)); |
630 assertEquals('|ok||Button' | 651 assertEquals('ok|Button' |
631 , o.speechOutputForTest.string_); | 652 , o.speechOutputForTest.string_); |
632 }); | 653 }); |
633 }); | 654 }); |
OLD | NEW |