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 // Include test fixture. | 5 // Include test fixture. |
6 GEN_INCLUDE(['../testing/chromevox_unittest_base.js']); | 6 GEN_INCLUDE(['../testing/chromevox_unittest_base.js']); |
7 | 7 |
8 /** | 8 /** |
9 * Test fixture. | 9 * Test fixture. |
10 * @constructor | 10 * @constructor |
11 * @extends {ChromeVoxUnitTestBase} | 11 * @extends {ChromeVoxUnitTestBase} |
12 */ | 12 */ |
13 function CvoxBrailleUtilUnitTest() {} | 13 function CvoxBrailleUtilUnitTest() {} |
14 | 14 |
15 CvoxBrailleUtilUnitTest.prototype = { | 15 CvoxBrailleUtilUnitTest.prototype = { |
16 __proto__: ChromeVoxUnitTestBase.prototype, | 16 __proto__: ChromeVoxUnitTestBase.prototype, |
17 | 17 |
18 /** @override */ | 18 /** @override */ |
19 closureModuleDeps: [ | 19 closureModuleDeps: [ |
20 'cvox.BrailleUtil', | 20 'cvox.BrailleUtil', |
21 'cvox.CursorSelection', | 21 'cvox.CursorSelection', |
22 'cvox.NavigationShifter', | 22 'cvox.NavigationShifter', |
23 'cvox.TestMsgs', | 23 'TestMsgs', |
24 ], | 24 ], |
25 | 25 |
26 /** @override */ | 26 /** @override */ |
27 setUp: function() { | 27 setUp: function() { |
28 cvox.ChromeVox.msgs = new cvox.TestMsgs(); | 28 Msgs = TestMsgs; |
29 }, | 29 }, |
30 | 30 |
31 /** | 31 /** |
32 * @param {!Node} expectedParent Expected parent node. | 32 * @param {!Node} expectedParent Expected parent node. |
33 * @param {!Node} node Node to examine. | 33 * @param {!Node} node Node to examine. |
34 * @private | 34 * @private |
35 */ | 35 */ |
36 assertTextNodeChildOf_: function(expectedParent, node) { | 36 assertTextNodeChildOf_: function(expectedParent, node) { |
37 assertEquals(Node.TEXT_NODE, node.nodeType); | 37 assertEquals(Node.TEXT_NODE, node.nodeType); |
38 assertEquals(expectedParent, node.parentNode); | 38 assertEquals(expectedParent, node.parentNode); |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 }); | 352 }); |
353 | 353 |
354 | 354 |
355 /** | 355 /** |
356 * @export | 356 * @export |
357 */ | 357 */ |
358 TEST_F('CvoxBrailleUtilUnitTest', 'GetTemplatedOverride', function() { | 358 TEST_F('CvoxBrailleUtilUnitTest', 'GetTemplatedOverride', function() { |
359 assertEquals('Menu mnu', | 359 assertEquals('Menu mnu', |
360 cvox.BrailleUtil.getTemplated(null, null, | 360 cvox.BrailleUtil.getTemplated(null, null, |
361 { 'name': 'Menu', | 361 { 'name': 'Menu', |
362 'roleMsg': 'aria_role_menu' }). | 362 'roleMsg': 'role_menu' }). |
363 toString()); | 363 toString()); |
364 assertEquals('alrt: Watch out!', | 364 assertEquals('alrt: Watch out!', |
365 cvox.BrailleUtil.getTemplated(null, null, | 365 cvox.BrailleUtil.getTemplated(null, null, |
366 { 'name': 'Watch out!', | 366 { 'name': 'Watch out!', |
367 'roleMsg': 'aria_role_alert' }). | 367 'roleMsg': 'role_alert' }). |
368 toString()); | 368 toString()); |
369 // Test all properties. role, if present, overrides roleMsg. | 369 // Test all properties. role, if present, overrides roleMsg. |
370 assertEquals('Name Value Role State', | 370 assertEquals('Name Value Role State', |
371 cvox.BrailleUtil.getTemplated(null, null, | 371 cvox.BrailleUtil.getTemplated(null, null, |
372 { 'name': 'Name', | 372 { 'name': 'Name', |
373 'role': 'Role', | 373 'role': 'Role', |
374 'roleMsg': 'excluded', | 374 'roleMsg': 'excluded', |
375 'value': 'Value', | 375 'value': 'Value', |
376 'state': 'State' | 376 'state': 'State' |
377 }).toString()); | 377 }).toString()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 selectionSpan = s.getSpanInstanceOf(cvox.ValueSelectionSpan); | 411 selectionSpan = s.getSpanInstanceOf(cvox.ValueSelectionSpan); |
412 assertEquals(5, s.getSpanStart(selectionSpan)); | 412 assertEquals(5, s.getSpanStart(selectionSpan)); |
413 assertEquals(5, s.getSpanEnd(selectionSpan)); | 413 assertEquals(5, s.getSpanEnd(selectionSpan)); |
414 | 414 |
415 // All of the value selected selected with reversed start and end. | 415 // All of the value selected selected with reversed start and end. |
416 s = cvox.BrailleUtil.createValue('value', 5, 0); | 416 s = cvox.BrailleUtil.createValue('value', 5, 0); |
417 selectionSpan = s.getSpanInstanceOf(cvox.ValueSelectionSpan); | 417 selectionSpan = s.getSpanInstanceOf(cvox.ValueSelectionSpan); |
418 assertEquals(0, s.getSpanStart(selectionSpan)); | 418 assertEquals(0, s.getSpanStart(selectionSpan)); |
419 assertEquals(5, s.getSpanEnd(selectionSpan)); | 419 assertEquals(5, s.getSpanEnd(selectionSpan)); |
420 }); | 420 }); |
OLD | NEW |