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 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 ]}, o.toSpannable()); | 137 ]}, o.toSpannable()); |
138 }); | 138 }); |
139 }); | 139 }); |
140 | 140 |
141 TEST_F('OutputE2ETest', 'Audio', function() { | 141 TEST_F('OutputE2ETest', 'Audio', function() { |
142 this.runWithLoadedTree('<audio src="foo.mp3" controls></audio>', | 142 this.runWithLoadedTree('<audio src="foo.mp3" controls></audio>', |
143 function(root) { | 143 function(root) { |
144 var el = root.firstChild.firstChild.firstChild.firstChild; | 144 var el = root.firstChild.firstChild.firstChild.firstChild; |
145 var range = cursors.Range.fromNode(el); | 145 var range = cursors.Range.fromNode(el); |
146 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); | 146 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
147 assertEqualsJSON({string_: 'media control|Tool bar|||play|Button', | 147 assertEqualsJSON( |
148 spans_: | 148 {string_: 'media control|Tool bar|||play|begin playback|Button', |
| 149 spans_: |
149 // Entered container toolbar. | 150 // Entered container toolbar. |
150 | 151 |
151 // Button. | 152 // Button. |
152 [{value: 'name', start: 23, end: 23}, | 153 [{value: 'name', start: 23, end: 23}, |
153 {value: 'value', start: 24, end: 24}, | 154 {value: 'value', start: 24, end: 24}, |
154 {value: 'description', start: 25, end: 29}, | 155 {value: 'description', start: 25, end: 29}, |
155 {value: 'role', start: 30, end: 36}, | 156 {value: 'help', start: 30, end: 44}, |
| 157 {value: 'role', start: 45, end: 51}, |
156 | 158 |
157 // Button earcon. | 159 // Button earcon. |
158 {value: {}, start: 30, end: 36}] | 160 {value: {}, start: 45, end: 51}] |
159 }, o.toSpannableForTest()); | 161 }, o.toSpannableForTest()); |
160 | 162 |
161 el = el.nextSibling; | 163 el = el.nextSibling; |
162 var prevRange = range; | 164 var prevRange = range; |
163 range = cursors.Range.fromNode(el); | 165 range = cursors.Range.fromNode(el); |
164 var o = new Output().withSpeechAndBraille(range, prevRange, 'navigate'); | 166 var o = new Output().withSpeechAndBraille(range, prevRange, 'navigate'); |
165 assertEqualsJSON({string_: '0, , slider|audio time scrubber', | 167 assertEqualsJSON({string_: '0, , slider|audio time scrubber', |
166 spans_: | 168 spans_: |
167 [{value: 'help', start: 12, end: 31}] | 169 [{value: 'help', start: 12, end: 31}] |
168 }, o.toSpannableForTest()); | 170 }, o.toSpannableForTest()); |
169 }); | 171 }); |
170 }); | 172 }); |
| 173 |
| 174 TEST_F('OutputE2ETest', 'Input', function() { |
| 175 this.runWithLoadedTree( |
| 176 '<input type="text"></input>' + |
| 177 '<input type="email"></input>' + |
| 178 '<input type="password"></input>' + |
| 179 '<input type="tel"></input>' + |
| 180 '<input type="number"></input>' + |
| 181 '<input type="time"></input>' + |
| 182 '<input type="date"></input>', |
| 183 function(root) { |
| 184 var expected = {string_: '', 'spans_': [ |
| 185 {value: 'name', start: 0, end: 0}, |
| 186 |
| 187 // Selection span. |
| 188 {value: {startIndex: 0, endIndex: 0}, start: 1, end: 1}, |
| 189 |
| 190 {value: 'value', start: 1, end: 1}, |
| 191 |
| 192 // Earcon |
| 193 {value: {}, start: 2, end: 2} |
| 194 ]}; |
| 195 |
| 196 var expectedValues = [ |
| 197 '||Edit text', |
| 198 '||Edit text, email entry', |
| 199 '||Password edit text', |
| 200 '||Edit text, number entry', |
| 201 {string_: '||Combo box', spans_: [{value: 'name', start: 0, end: 0}, |
| 202 {value: {startIndex: 0, endIndex: 0}, start: 1, end: 1}, |
| 203 {value: 'value', start: 1, end: 1}, |
| 204 {value: 'role', start: 2, end: 11}, |
| 205 {value: {}, start: 2, end: 11}]}, |
| 206 {string_: '||Time', spans_: [{value: 'name', start: 0, end: 0}, |
| 207 {value: 'value', start: 1, end: 1}, |
| 208 {value: 'role', start: 2, end: 6}]}, |
| 209 {string_: '||Date control', spans_: [{value: 'name', start: 0, end: 0}, |
| 210 {value: 'value', start: 1, end: 1}, |
| 211 {value: 'role', start: 2, end: 14}]} |
| 212 ]; |
| 213 |
| 214 var el = root.firstChild.firstChild; |
| 215 expectedValues.forEach(function(expectedValue) { |
| 216 var range = cursors.Range.fromNode(el); |
| 217 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
| 218 if (typeof expectedValue == 'object') { |
| 219 assertEqualsJSON(expectedValue, o.toSpannableForTest()); |
| 220 } else { |
| 221 expected.string_ = expectedValue; |
| 222 assertEqualsJSON(expected, o.toSpannableForTest()); |
| 223 } |
| 224 el = el.nextSibling; |
| 225 }); |
| 226 }); |
| 227 }); |
OLD | NEW |