Chromium Code Reviews| 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 ]}, | |
| 40 o.toSpannable()); | |
| 38 }); | 41 }); |
| 39 }); | 42 }); |
| 43 | |
| 44 TEST_F('OutputE2ETest', 'Checkbox', function() { | |
| 45 this.runWithLoadedTree('<input type="checkbox">', | |
| 46 function(root) { | |
| 47 var el = root.firstChild.firstChild; | |
| 48 var range = cursors.Range.fromNode(el); | |
| 49 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); | |
| 50 assertEqualsJSON({string_: 'Check boxnot checked', 'spans_': [ | |
| 51 // Attributes. | |
| 52 {value: 'name', start: 0, end: 0}, | |
| 53 {value: 'role', start: 0, end: 9}, | |
| 54 {value: 'state', start: 9, end: 20}, | |
| 55 | |
| 56 // Link earcon (based on the state). | |
| 57 {value: {}, start: 9, end: 20} | |
| 58 ]}, | |
| 59 o.toSpannable()); | |
|
dmazzoni
2015/04/13 22:56:52
nit: indentation (3x in this file with the same li
David Tseng
2015/04/15 17:58:35
Done.
| |
| 60 }); | |
| 61 }); | |
| 62 | |
| 63 TEST_F('OutputE2ETest', 'InLineTextBoxValueGetsIgnored', function() { | |
| 64 this.runWithLoadedTree('<p>OK', | |
| 65 function(root) { | |
| 66 var el = root.firstChild.firstChild.firstChild; | |
| 67 assertEquals('inlineTextBox', el.role); | |
| 68 var range = cursors.Range.fromNode(el); | |
| 69 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); | |
| 70 assertEqualsJSON({string_: 'OK', 'spans_': [ | |
| 71 // Attributes. | |
| 72 {value: 'name', start: 0, end: 2} | |
| 73 ]}, | |
| 74 o.toSpannable()); | |
| 75 | |
| 76 el = root.firstChild.firstChild; | |
| 77 assertEquals('staticText', el.role); | |
| 78 range = cursors.Range.fromNode(el); | |
| 79 o = new Output().withSpeechAndBraille(range, null, 'navigate'); | |
| 80 assertEqualsJSON({string_: 'OK', 'spans_': [ | |
| 81 // Attributes. | |
| 82 {value: 'value', start: 0, end: 2}, | |
| 83 | |
| 84 // The name is an empty string. | |
| 85 {value: 'name', start: 2, end: 2} | |
| 86 ]}, | |
| 87 o.toSpannable()); | |
| 88 }); | |
| 89 }); | |
| OLD | NEW |