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 * Test fixture for output.js. | 9 * Test fixture for output.js. |
10 * @constructor | 10 * @constructor |
11 * @extends {ChromeVoxNextE2ETestBase} | 11 * @extends {ChromeVoxNextE2ETestBase} |
12 */ | 12 */ |
13 function OutputE2ETest() { | 13 function OutputE2ETest() { |
14 ChromeVoxNextE2ETest.call(this); | 14 ChromeVoxNextE2ETest.call(this); |
15 } | 15 } |
16 | 16 |
17 OutputE2ETest.prototype = { | 17 OutputE2ETest.prototype = { |
18 __proto__: ChromeVoxNextE2ETest.prototype, | 18 __proto__: ChromeVoxNextE2ETest.prototype, |
19 | 19 |
20 /** @override */ | 20 /** @override */ |
21 setUp: function() { | 21 setUp: function() { |
22 window.Dir = AutomationUtil.Dir; | 22 window.Dir = AutomationUtil.Dir; |
23 } | 23 } |
24 }; | 24 }; |
25 | 25 |
26 TEST_F('OutputE2ETest', 'RenderBasic', function() { | 26 TEST_F('OutputE2ETest', 'Links', function() { |
27 this.runWithLoadedTree('<a href="#">Click here</a>', | 27 this.runWithLoadedTree('<a href="#">Click here</a>', |
28 function(root) { | 28 function(root) { |
29 var link = root.firstChild.firstChild; | 29 var el = root.firstChild.firstChild; |
30 var range = cursors.Range.fromNode(link); | 30 var range = cursors.Range.fromNode(el); |
31 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); | 31 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
32 assertEqualsJSON({string_: 'Click here Link', 'spans_': [ | 32 assertEqualsJSON({string_: 'Click hereLink', 'spans_': [ |
33 {value: 'name', start: 0, end: 10}, | 33 // Attributes. |
34 // Link earcon. | 34 {value: 'name', start: 0, end: 10}, |
35 {value: {}, start: 11, end: 15} | 35 {value: 'role', start: 10, end: 14}, |
36 ]}, | 36 |
37 o.getBuffer()); | 37 // Link earcon (based on the role). |
| 38 {value: {}, start: 10, end: 14} |
| 39 ]}, o.toSpannable()); |
38 }); | 40 }); |
39 }); | 41 }); |
| 42 |
| 43 TEST_F('OutputE2ETest', 'Checkbox', function() { |
| 44 this.runWithLoadedTree('<input type="checkbox">', |
| 45 function(root) { |
| 46 var el = root.firstChild.firstChild; |
| 47 var range = cursors.Range.fromNode(el); |
| 48 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
| 49 assertEqualsJSON({string_: 'Check boxnot checked', 'spans_': [ |
| 50 // Attributes. |
| 51 {value: 'name', start: 0, end: 0}, |
| 52 {value: 'role', start: 0, end: 9}, |
| 53 {value: 'state', start: 9, end: 20}, |
| 54 |
| 55 // Link earcon (based on the state). |
| 56 {value: {}, start: 9, end: 20} |
| 57 ]}, o.toSpannable()); |
| 58 }); |
| 59 }); |
| 60 |
| 61 TEST_F('OutputE2ETest', 'InLineTextBoxValueGetsIgnored', function() { |
| 62 this.runWithLoadedTree('<p>OK', |
| 63 function(root) { |
| 64 var el = root.firstChild.firstChild.firstChild; |
| 65 assertEquals('inlineTextBox', el.role); |
| 66 var range = cursors.Range.fromNode(el); |
| 67 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
| 68 assertEqualsJSON({string_: 'OK', 'spans_': [ |
| 69 // Attributes. |
| 70 {value: 'name', start: 0, end: 2} |
| 71 ]}, o.toSpannable()); |
| 72 |
| 73 el = root.firstChild.firstChild; |
| 74 assertEquals('staticText', el.role); |
| 75 range = cursors.Range.fromNode(el); |
| 76 o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
| 77 assertEqualsJSON({string_: 'OK', 'spans_': [ |
| 78 // Attributes. |
| 79 {value: 'value', start: 0, end: 2}, |
| 80 |
| 81 // The name is an empty string. |
| 82 {value: 'name', start: 2, end: 2} |
| 83 ]}, o.toSpannable()); |
| 84 }); |
| 85 }); |
OLD | NEW |