Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/output_test.extjs

Issue 2487043002: Refine braille output (Closed)
Patch Set: Simplify Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 ]; 271 ];
272 272
273 var expectedSpeechValues = [ 273 var expectedSpeechValues = [
274 '||Edit text', 274 '||Edit text',
275 '||Edit text, email entry', 275 '||Edit text, email entry',
276 '||Password edit text', 276 '||Password edit text',
277 '||Edit text numeric only', 277 '||Edit text numeric only',
278 ['||Spin button', 278 ['||Spin button',
279 [{value: 'name', start: 0, end: 0}, 279 [{value: 'name', start: 0, end: 0},
280 {value: new Output.EarconAction('LISTBOX'), start: 0, end: 0}, 280 {value: new Output.EarconAction('LISTBOX'), start: 0, end: 0},
281 {value: {startIndex: 0, endIndex: 0, offset: 0}, start: 1, end: 1}, 281 {value: {startIndex: 0, endIndex: 0}, start: 1, end: 1},
282 {value: 'value', start: 1, end: 1}, 282 {value: 'value', start: 1, end: 1},
283 {value: 'role', start: 2, end: 13}] 283 {value: 'role', start: 2, end: 13}]
284 ], 284 ],
285 ['Time control', 285 ['Time control',
286 [{value: 'role', start: 0, end: 12}] 286 [{value: 'role', start: 0, end: 12}]
287 ], 287 ],
288 ['Date control', 288 ['Date control',
289 [{value: 'role', start: 0, end: 12}] 289 [{value: 'role', start: 0, end: 12}]
290 ], 290 ],
291 ['Choose File|No file chosen|Button', 291 ['Choose File|No file chosen|Button',
292 [{value: 'name', start: 0, end: 11}, 292 [{value: 'name', start: 0, end: 11},
293 {value: new Output.EarconAction("BUTTON"), start: 0, end: 11}, 293 {value: new Output.EarconAction("BUTTON"), start: 0, end: 11},
294 {value: 'value', start: 12, end: 26}, 294 {value: 'value', start: 12, end: 26},
295 {value: 'role', start: 27, end: 33}] 295 {value: 'role', start: 27, end: 33}]
296 ], 296 ],
297 '||Edit text, search entry', 297 '||Edit text, search entry',
298 '||Edit text' 298 '||Edit text'
299 ]; 299 ];
300 // TODO(plundblad): Some of these are wrong, there should be an initial 300 // TODO(plundblad): Some of these are wrong, there should be an initial
301 // space for the cursor in edit fields. 301 // space for the cursor in edit fields.
302 var expectedBrailleValues = [ 302 var expectedBrailleValues = [
303 ' ed', 303 ' ed',
304 ' @ed', 304 ' @ed',
305 ' pwded', 305 ' pwded',
306 ' #ed', 306 ' #ed',
307 ' spnbtn', 307 ' spnbtn',
308 {string_: 'time'}, 308 {string_: 'time'},
309 {string_: 'date'}, 309 {string_: 'date'},
310 {string_: 'Choose File No file chosen btn'}, 310 {string_: 'Choose File No file chosen btn'},
311 ' srched', 311 ' srched',
312 ' ed' 312 ' ed'
313 ]; 313 ];
314 assertEquals(expectedSpeechValues.length, expectedBrailleValues.length); 314 assertEquals(expectedSpeechValues.length, expectedBrailleValues.length);
315 315
316 var el = root.firstChild.firstChild; 316 var el = root.firstChild.firstChild;
317 expectedSpeechValues.forEach(function(expectedValue) { 317 expectedSpeechValues.forEach(function(expectedValue) {
318 var range = cursors.Range.fromNode(el); 318 var range = cursors.Range.fromNode(el);
319 var o = new Output().withSpeechAndBraille(range, null, 'navigate'); 319 var o = new Output().withSpeechAndBraille(range, null, 'navigate');
320 if (typeof expectedValue == 'object') { 320 if (typeof expectedValue == 'object') {
321 checkSpeechOutput(expectedValue[0], expectedValue[1], o); 321 checkSpeechOutput(expectedValue[0], expectedValue[1], o);
322 } else { 322 } else {
323 expectedSpans[4].end = expectedValue.length; 323 expectedSpans[4].end = expectedValue.length;
324 checkSpeechOutput(expectedValue, expectedSpans, o); 324 checkSpeechOutput(expectedValue, expectedSpans, o);
325 } 325 }
326 el = el.nextSibling; 326 el = el.nextSibling;
327 }); 327 });
328 328
329 el = root.firstChild.firstChild; 329 el = root.firstChild.firstChild;
330 expectedBrailleValues.forEach(function(expectedValue) { 330 expectedBrailleValues.forEach(function(expectedValue) {
331 var range = cursors.Range.fromNode(el); 331 var range = cursors.Range.fromNode(el);
332 var o = new Output().withBraille(range, null, 'navigate'); 332 var o = new Output().withBraille(range, null, 'navigate');
333 if (typeof expectedValue === 'string') { 333 if (typeof expectedValue === 'string') {
334 checkBrailleOutput( 334 checkBrailleOutput(
335 expectedValue, 335 expectedValue,
336 [{value: {startIndex: 0, endIndex: 0, offset: 0}, 336 [{value: {startIndex: 0, endIndex: 0},
337 start: 0, end: 0}, 337 start: 0, end: 0},
338 {value: new Output.NodeSpan(el), start: 0, 338 {value: new Output.NodeSpan(el), start: 0,
339 end: expectedValue.length}], 339 end: expectedValue.length}],
340 o); 340 o);
341 } else { 341 } else {
342 checkBrailleOutput( 342 checkBrailleOutput(
343 expectedValue.string_, 343 expectedValue.string_,
344 [{value: new Output.NodeSpan(el), start: 0, 344 [{value: new Output.NodeSpan(el), start: 0,
345 end: expectedValue.string_.length}], 345 end: expectedValue.string_.length}],
346 o); 346 o);
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 <div role="row" tabindex=0 aria-label="start"></div> 661 <div role="row" tabindex=0 aria-label="start"></div>
662 <div role="row" tabindex=0 aria-label="end"></div> 662 <div role="row" tabindex=0 aria-label="end"></div>
663 */}, 663 */},
664 function(root) { 664 function(root) {
665 var r1 = cursors.Range.fromNode(root.firstChild); 665 var r1 = cursors.Range.fromNode(root.firstChild);
666 var r2 = cursors.Range.fromNode(root.lastChild); 666 var r2 = cursors.Range.fromNode(root.lastChild);
667 assertEquals('start|Row', 667 assertEquals('start|Row',
668 new Output().withSpeech(r1, r2).speechOutputForTest.string_); 668 new Output().withSpeech(r1, r2).speechOutputForTest.string_);
669 }); 669 });
670 }); 670 });
671
672 TEST_F('OutputE2ETest', 'BraileWhitespace', function() {
dmazzoni 2016/11/10 23:31:29 nit: Braile -> Braille
673 this.runWithLoadedTree(function() {/*!
674 <p>this is a <em>test</em>of emphasized text</p>
675 */},
676 function(root) {
677 var start = root.firstChild.firstChild;
678 var end = root.firstChild.lastChild;
679 var range = new cursors.Range(
680 cursors.Cursor.fromNode(start),
681 cursors.Cursor.fromNode(end)
682 );
683 var o = new Output().withBraille(range, null, 'navigate');
684 checkBrailleOutput(
685 'this is a testof emphasized text',
686 [
687 {value: new Output.NodeSpan(start), start: 0, end: 10},
688 {value: new Output.NodeSpan(start.nextSibling), start: 10, end: 14},
689 {value: new Output.NodeSpan(end), start: 14, end: 32}
690 ],
691 o);
692 });
693 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698