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. |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 237 |
238 TEST_F('OutputE2ETest', 'Input', function() { | 238 TEST_F('OutputE2ETest', 'Input', function() { |
239 this.runWithLoadedTree( | 239 this.runWithLoadedTree( |
240 '<input type="text"></input>' + | 240 '<input type="text"></input>' + |
241 '<input type="email"></input>' + | 241 '<input type="email"></input>' + |
242 '<input type="password"></input>' + | 242 '<input type="password"></input>' + |
243 '<input type="tel"></input>' + | 243 '<input type="tel"></input>' + |
244 '<input type="number"></input>' + | 244 '<input type="number"></input>' + |
245 '<input type="time"></input>' + | 245 '<input type="time"></input>' + |
246 '<input type="date"></input>' + | 246 '<input type="date"></input>' + |
| 247 '<input type="file"</input>' + |
| 248 '<input type="search"</input>' + |
247 '<input type="invalidType"</input>', | 249 '<input type="invalidType"</input>', |
248 function(root) { | 250 function(root) { |
249 var expected = {string_: '', 'spans_': [ | 251 var expected = {string_: '', 'spans_': [ |
250 {value: 'name', start: 0, end: 0}, | 252 {value: 'name', start: 0, end: 0}, |
251 | 253 |
252 // Earcon | 254 // Earcon |
253 {value: {earconId: 'EDITABLE_TEXT'}, start: 0, end: 0}, | 255 {value: {earconId: 'EDITABLE_TEXT'}, start: 0, end: 0}, |
254 | 256 |
255 // Selection span. | 257 // Selection span. |
256 {value: {startIndex: 0, endIndex: 0}, start: 1, end: 1}, | 258 {value: {startIndex: 0, endIndex: 0}, start: 1, end: 1}, |
257 | 259 |
258 {value: 'value', start: 1, end: 1}, | 260 {value: 'value', start: 1, end: 1}, |
259 {value: 'inputType', start: 2} | 261 {value: 'inputType', start: 2} |
260 ]}; | 262 ]}; |
261 | 263 |
262 var expectedSpeechValues = [ | 264 var expectedSpeechValues = [ |
263 '||Edit text', | 265 '||Edit text', |
264 '||Edit text, email entry', | 266 '||Edit text, email entry', |
265 '||Password edit text', | 267 '||Password edit text', |
266 '||Edit text, number entry', | 268 '||Edit text numeric only', |
267 {string_: '||Spin button', spans_: [{value: 'name', start: 0, end: 0}, | 269 {string_: '||Spin button', spans_: [{value: 'name', start: 0, end: 0}, |
268 {value: {earconId:'LISTBOX'}, start: 0, end: 0}, | 270 {value: {earconId:'LISTBOX'}, start: 0, end: 0}, |
269 {value: {startIndex: 0, endIndex: 0}, start: 1, end: 1}, | 271 {value: {startIndex: 0, endIndex: 0}, start: 1, end: 1}, |
270 {value: 'value', start: 1, end: 1}, | 272 {value: 'value', start: 1, end: 1}, |
271 {value: 'role', start: 2, end: 13}]}, | 273 {value: 'role', start: 2, end: 13}]}, |
272 {string_: '||Time control', spans_: [{value: 'name', start: 0, end: 0}, | 274 {string_: '||Time control', spans_: [{value: 'name', start: 0, end: 0}, |
273 {value: 'value', start: 1, end: 1}, | 275 {value: 'value', start: 1, end: 1}, |
274 {value: 'role', start: 2, end: 14}]}, | 276 {value: 'role', start: 2, end: 14}]}, |
275 {string_: '||Date control', spans_: [{value: 'name', start: 0, end: 0}, | 277 {string_: '||Date control', spans_: [{value: 'name', start: 0, end: 0}, |
276 {value: 'value', start: 1, end: 1}, | 278 {value: 'value', start: 1, end: 1}, |
277 {value: 'role', start: 2, end: 14}]}, | 279 {value: 'role', start: 2, end: 14}]}, |
278 "||Edit text" | 280 {string_: 'Choose File|No file chosen|Button', |
| 281 spans_: [{value: 'name', start: 0, end: 11}, |
| 282 {value: {earconId: "BUTTON"}, start: 0, end: 11}, |
| 283 {value: 'value', start: 12, end: 26}, |
| 284 {value: 'role', start: 27, end: 33}]}, |
| 285 '||Edit text, search entry', |
| 286 '||Edit text' |
279 ]; | 287 ]; |
280 // TODO(plundblad): Some of these are wrong, there should be an initial | 288 // TODO(plundblad): Some of these are wrong, there should be an initial |
281 // space for the cursor in edit fields. | 289 // space for the cursor in edit fields. |
282 var expectedBrailleValues = [ | 290 var expectedBrailleValues = [ |
283 ' ed', | 291 ' ed', |
284 ' @ed', | 292 ' @ed', |
285 ' pwded', | 293 ' pwded', |
286 ' #ed', | 294 ' #ed', |
287 ' spnbtn', | 295 ' spnbtn', |
288 {string_: 'time'}, | 296 {string_: 'time'}, |
289 {string_: 'date'}, | 297 {string_: 'date'}, |
| 298 {string_: 'Choose File No file chosen btn'}, |
| 299 ' srched', |
290 ' ed' | 300 ' ed' |
291 ]; | 301 ]; |
292 assertEquals(expectedSpeechValues.length, expectedBrailleValues.length); | 302 assertEquals(expectedSpeechValues.length, expectedBrailleValues.length); |
293 | 303 |
294 var el = root.firstChild.firstChild; | 304 var el = root.firstChild.firstChild; |
295 expectedSpeechValues.forEach(function(expectedValue) { | 305 expectedSpeechValues.forEach(function(expectedValue) { |
296 var range = cursors.Range.fromNode(el); | 306 var range = cursors.Range.fromNode(el); |
297 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); | 307 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
298 if (typeof expectedValue == 'object') { | 308 if (typeof expectedValue == 'object') { |
299 assertEqualsJSON(expectedValue, o.speechOutputForTest); | 309 assertEqualsJSON(expectedValue, o.speechOutputForTest); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 'lstbx +2 lstitm 1/2', | 491 'lstbx +2 lstitm 1/2', |
482 [{value: new Output.NodeSpan(el.parent), start: 0, end: 8}, | 492 [{value: new Output.NodeSpan(el.parent), start: 0, end: 8}, |
483 {value: new Output.NodeSpan(el), start: 9, end: 19}], | 493 {value: new Output.NodeSpan(el), start: 9, end: 19}], |
484 o); | 494 o); |
485 }); | 495 }); |
486 }); | 496 }); |
487 | 497 |
488 SYNC_TEST_F('OutputE2ETest', 'MessageIdAndEarconValidity', function() { | 498 SYNC_TEST_F('OutputE2ETest', 'MessageIdAndEarconValidity', function() { |
489 for (var key in Output.ROLE_INFO_) { | 499 for (var key in Output.ROLE_INFO_) { |
490 var value = Output.ROLE_INFO_[key]; | 500 var value = Output.ROLE_INFO_[key]; |
491 cvox.ChromeVox.msgs.getMsg(value.msgId); | 501 Msgs.getMsg(value.msgId); |
492 cvox.ChromeVox.msgs.getMsg(value.msgId + '_brl'); | 502 Msgs.getMsg(value.msgId + '_brl'); |
493 assertFalse(/[A-Z]+/.test(value.msgId)); | 503 assertFalse(/[A-Z]+/.test(value.msgId)); |
494 if (value.earconId) | 504 if (value.earconId) |
495 assertNotNullNorUndefined(cvox.Earcon[value.earconId]); | 505 assertNotNullNorUndefined(cvox.Earcon[value.earconId]); |
496 } | 506 } |
497 for (var key in Output.STATE_INFO_) { | 507 for (var key in Output.STATE_INFO_) { |
498 var value = Output.STATE_INFO_[key]; | 508 var value = Output.STATE_INFO_[key]; |
499 for (innerKey in value) { | 509 for (innerKey in value) { |
500 var innerValue = value[innerKey]; | 510 var innerValue = value[innerKey]; |
501 cvox.ChromeVox.msgs.getMsg(innerValue.msgId); | 511 Msgs.getMsg(innerValue.msgId); |
502 cvox.ChromeVox.msgs.getMsg(innerValue.msgId + '_brl'); | 512 Msgs.getMsg(innerValue.msgId + '_brl'); |
503 assertFalse(/[A-Z]+/.test(innerValue.msgId)); | 513 assertFalse(/[A-Z]+/.test(innerValue.msgId)); |
504 if (innerValue.earconId) | 514 if (innerValue.earconId) |
505 assertNotNullNorUndefined(cvox.Earcon[innerValue.earconId]); | 515 assertNotNullNorUndefined(cvox.Earcon[innerValue.earconId]); |
506 } | 516 } |
507 } | 517 } |
| 518 for (var key in Output.INPUT_TYPE_MESSAGE_IDS_) { |
| 519 var msgId = Output.INPUT_TYPE_MESSAGE_IDS_[key]; |
| 520 assertFalse(/[A-Z]+/.test(msgId)); |
| 521 Msgs.getMsg(msgId); |
| 522 Msgs.getMsg(msgId + '_brl'); |
| 523 } |
508 }); | 524 }); |
509 | 525 |
510 TEST_F('OutputE2ETest', 'DivOmitsRole', function() { | 526 TEST_F('OutputE2ETest', 'DivOmitsRole', function() { |
511 this.runWithLoadedTree(function() {/*! | 527 this.runWithLoadedTree(function() {/*! |
512 <div>that has content</div> | 528 <div>that has content</div> |
513 <div></div> | 529 <div></div> |
514 <div role='group'><div>nested content</div></div> | 530 <div role='group'><div>nested content</div></div> |
515 */}, | 531 */}, |
516 function(root) { | 532 function(root) { |
517 var el = root.firstChild.firstChild; | 533 var el = root.firstChild.firstChild; |
518 var range = cursors.Range.fromNode(el); | 534 var range = cursors.Range.fromNode(el); |
519 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); | 535 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
520 assertEqualsJSON({string_: '|that has content', | 536 assertEqualsJSON({string_: '|that has content', |
521 spans_: [ | 537 spans_: [ |
522 {value: 'name', start: 1, end: 17} | 538 {value: 'name', start: 1, end: 17} |
523 ]}, o.speechOutputForTest); | 539 ]}, o.speechOutputForTest); |
524 checkBrailleOutput( | 540 checkBrailleOutput( |
525 'that has content', | 541 'that has content', |
526 [{value: new Output.NodeSpan(el), start: 0, end: 16}], | 542 [{value: new Output.NodeSpan(el), start: 0, end: 16}], |
527 o); | 543 o); |
528 }); | 544 }); |
529 }); | 545 }); |
OLD | NEW |