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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 }); | 236 }); |
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="invalidType"</input>', |
247 function(root) { | 248 function(root) { |
248 var expected = {string_: '', 'spans_': [ | 249 var expected = {string_: '', 'spans_': [ |
249 {value: 'name', start: 0, end: 0}, | 250 {value: 'name', start: 0, end: 0}, |
250 | 251 |
251 // Earcon | 252 // Earcon |
252 {value: {earconId: 'EDITABLE_TEXT'}, start: 0, end: 0}, | 253 {value: {earconId: 'EDITABLE_TEXT'}, start: 0, end: 0}, |
253 | 254 |
254 // Selection span. | 255 // Selection span. |
255 {value: {startIndex: 0, endIndex: 0}, start: 1, end: 1}, | 256 {value: {startIndex: 0, endIndex: 0}, start: 1, end: 1}, |
256 | 257 |
257 {value: 'value', start: 1, end: 1} | 258 {value: 'value', start: 1, end: 1}, |
| 259 {value: 'inputType', start: 2} |
258 ]}; | 260 ]}; |
259 | 261 |
260 var expectedSpeechValues = [ | 262 var expectedSpeechValues = [ |
261 '||Edit text', | 263 '||Edit text', |
262 '||Edit text, email entry', | 264 '||Edit text, email entry', |
263 '||Password edit text', | 265 '||Password edit text', |
264 '||Edit text, number entry', | 266 '||Edit text, number entry', |
265 {string_: '||Spin button', spans_: [{value: 'name', start: 0, end: 0}, | 267 {string_: '||Spin button', spans_: [{value: 'name', start: 0, end: 0}, |
266 {value: {earconId:'LISTBOX'}, start: 0, end: 0}, | 268 {value: {earconId:'LISTBOX'}, start: 0, end: 0}, |
267 {value: {startIndex: 0, endIndex: 0}, start: 1, end: 1}, | 269 {value: {startIndex: 0, endIndex: 0}, start: 1, end: 1}, |
268 {value: 'value', start: 1, end: 1}, | 270 {value: 'value', start: 1, end: 1}, |
269 {value: 'role', start: 2, end: 13}]}, | 271 {value: 'role', start: 2, end: 13}]}, |
270 {string_: '||Time control', spans_: [{value: 'name', start: 0, end: 0}, | 272 {string_: '||Time control', spans_: [{value: 'name', start: 0, end: 0}, |
271 {value: 'value', start: 1, end: 1}, | 273 {value: 'value', start: 1, end: 1}, |
272 {value: 'role', start: 2, end: 14}]}, | 274 {value: 'role', start: 2, end: 14}]}, |
273 {string_: '||Date control', spans_: [{value: 'name', start: 0, end: 0}, | 275 {string_: '||Date control', spans_: [{value: 'name', start: 0, end: 0}, |
274 {value: 'value', start: 1, end: 1}, | 276 {value: 'value', start: 1, end: 1}, |
275 {value: 'role', start: 2, end: 14}]} | 277 {value: 'role', start: 2, end: 14}]}, |
| 278 "||Edit text" |
276 ]; | 279 ]; |
277 // TODO(plundblad): Some of these are wrong, there should be an initial | 280 // TODO(plundblad): Some of these are wrong, there should be an initial |
278 // space for the cursor in edit fields. | 281 // space for the cursor in edit fields. |
279 var expectedBrailleValues = [ | 282 var expectedBrailleValues = [ |
280 ' ed', | 283 ' ed', |
281 ' @ed', | 284 ' @ed', |
282 ' pwded', | 285 ' pwded', |
283 ' #ed', | 286 ' #ed', |
284 ' spnbtn', | 287 ' spnbtn', |
285 {string_: 'time'}, | 288 {string_: 'time'}, |
286 {string_: 'date'} | 289 {string_: 'date'}, |
| 290 ' ed' |
287 ]; | 291 ]; |
288 assertEquals(expectedSpeechValues.length, expectedBrailleValues.length); | 292 assertEquals(expectedSpeechValues.length, expectedBrailleValues.length); |
289 | 293 |
290 var el = root.firstChild.firstChild; | 294 var el = root.firstChild.firstChild; |
291 expectedSpeechValues.forEach(function(expectedValue) { | 295 expectedSpeechValues.forEach(function(expectedValue) { |
292 var range = cursors.Range.fromNode(el); | 296 var range = cursors.Range.fromNode(el); |
293 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); | 297 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); |
294 if (typeof expectedValue == 'object') { | 298 if (typeof expectedValue == 'object') { |
295 assertEqualsJSON(expectedValue, o.speechOutputForTest); | 299 assertEqualsJSON(expectedValue, o.speechOutputForTest); |
296 } else { | 300 } else { |
297 expected.string_ = expectedValue; | 301 expected.string_ = expectedValue; |
| 302 expected.spans_[4].end = expectedValue.length; |
298 assertEqualsJSON(expected, o.speechOutputForTest); | 303 assertEqualsJSON(expected, o.speechOutputForTest); |
299 } | 304 } |
300 el = el.nextSibling; | 305 el = el.nextSibling; |
301 }); | 306 }); |
302 | 307 |
303 el = root.firstChild.firstChild; | 308 el = root.firstChild.firstChild; |
304 expectedBrailleValues.forEach(function(expectedValue) { | 309 expectedBrailleValues.forEach(function(expectedValue) { |
305 var range = cursors.Range.fromNode(el); | 310 var range = cursors.Range.fromNode(el); |
306 var o = new Output().withBraille(range, null, 'navigate'); | 311 var o = new Output().withBraille(range, null, 'navigate'); |
307 if (typeof expectedValue === 'string') { | 312 if (typeof expectedValue === 'string') { |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 assertEqualsJSON({string_: '|that has content', | 520 assertEqualsJSON({string_: '|that has content', |
516 spans_: [ | 521 spans_: [ |
517 {value: 'name', start: 1, end: 17} | 522 {value: 'name', start: 1, end: 17} |
518 ]}, o.speechOutputForTest); | 523 ]}, o.speechOutputForTest); |
519 checkBrailleOutput( | 524 checkBrailleOutput( |
520 'that has content', | 525 'that has content', |
521 [{value: new Output.NodeSpan(el), start: 0, end: 16}], | 526 [{value: new Output.NodeSpan(el), start: 0, end: 16}], |
522 o); | 527 o); |
523 }); | 528 }); |
524 }); | 529 }); |
OLD | NEW |