OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // Include test fixture. | 5 // Include test fixture. |
6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js', | 6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js', |
7 '../../testing/assert_additions.js']); | 7 '../../testing/assert_additions.js']); |
8 | 8 |
9 GEN_INCLUDE(['../../testing/mock_feedback.js']); | 9 GEN_INCLUDE(['../../testing/mock_feedback.js']); |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 * @return {!MockFeedback} | 25 * @return {!MockFeedback} |
26 */ | 26 */ |
27 createMockFeedback: function() { | 27 createMockFeedback: function() { |
28 var mockFeedback = new MockFeedback(this.newCallback(), | 28 var mockFeedback = new MockFeedback(this.newCallback(), |
29 this.newCallback.bind(this)); | 29 this.newCallback.bind(this)); |
30 mockFeedback.install(); | 30 mockFeedback.install(); |
31 return mockFeedback; | 31 return mockFeedback; |
32 }, | 32 }, |
33 | 33 |
34 assertLineData: function(doc, data) { | 34 assertLineData: function(doc, data) { |
| 35 editing.useRichText = false; |
35 this.runWithLoadedTree(doc, function(root) { | 36 this.runWithLoadedTree(doc, function(root) { |
36 var input = root.find({role: RoleType.TEXT_FIELD}); | 37 var input = root.find({role: RoleType.TEXT_FIELD}); |
37 input.addEventListener('focus', this.newCallback(function() { | 38 input.addEventListener('focus', this.newCallback(function() { |
38 var textHandler = ChromeVoxState.desktopAutomationHandler | 39 var textHandler = ChromeVoxState.desktopAutomationHandler |
39 .textEditHandler_.editableText_; | 40 .textEditHandler_.editableText_; |
40 | 41 |
41 var offset = 0; | 42 var offset = 0; |
42 for (var i = 0; i < data.length; i++) { | 43 for (var i = 0; i < data.length; i++) { |
43 var line = data[i]; | 44 var line = data[i]; |
44 var actualStart = textHandler.getLineStart(i); | 45 var actualStart = textHandler.getLineStart(i); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 [ | 207 [ |
207 {start: 0, end: 4, text: 'this'}, | 208 {start: 0, end: 4, text: 'this'}, |
208 {start: 5, end: 5, text: ''}, | 209 {start: 5, end: 5, text: ''}, |
209 {start: 6, end: 6, text: ''}, | 210 {start: 6, end: 6, text: ''}, |
210 {start: 7, end: 8, text: 'I'}, | 211 {start: 7, end: 8, text: 'I'}, |
211 {start: 9, end: 17, text: 'can test'}, | 212 {start: 9, end: 17, text: 'can test'}, |
212 ]); | 213 ]); |
213 }); | 214 }); |
214 | 215 |
215 TEST_F('EditingTest', 'RichTextMoveByLine', function() { | 216 TEST_F('EditingTest', 'RichTextMoveByLine', function() { |
216 editing.useRichText = true; | |
217 var mockFeedback = this.createMockFeedback(); | 217 var mockFeedback = this.createMockFeedback(); |
218 this.runWithLoadedTree(function() {/*! | 218 this.runWithLoadedTree(function() {/*! |
219 <div id="go" role="textbox" contenteditable> | 219 <div id="go" role="textbox" contenteditable> |
220 <h2>hello</h2> | 220 <h2>hello</h2> |
221 <div><br></div> | 221 <div><br></div> |
222 <p>This is a <a href="#test">test</a> of rich text</p> | 222 <p>This is a <a href="#test">test</a> of rich text</p> |
223 </div> | 223 </div> |
224 <script> | 224 <script> |
225 var dir = 'forward'; | 225 var dir = 'forward'; |
226 var line = 0; | 226 var line = 0; |
(...skipping 19 matching lines...) Expand all Loading... |
246 .expectSpeech('\n') | 246 .expectSpeech('\n') |
247 .expectBraille('\n') | 247 .expectBraille('\n') |
248 .call(moveByLine) | 248 .call(moveByLine) |
249 .expectSpeech('This is a test of rich text') | 249 .expectSpeech('This is a test of rich text') |
250 .expectBraille('This is a test of rich text') | 250 .expectBraille('This is a test of rich text') |
251 .call(moveByLine) | 251 .call(moveByLine) |
252 .expectSpeech('\n') | 252 .expectSpeech('\n') |
253 .expectBraille('\n') | 253 .expectBraille('\n') |
254 .call(moveByLine) | 254 .call(moveByLine) |
255 .expectSpeech('hello') | 255 .expectSpeech('hello') |
256 .expectBraille('hello') | 256 .expectBraille('hello mled') |
257 .replay(); | 257 .replay(); |
258 }); | 258 }); |
259 input.focus(); | 259 input.focus(); |
260 }); | 260 }); |
261 }); | 261 }); |
262 | 262 |
263 TEST_F('EditingTest', 'RichTextMoveByCharacter', function() { | 263 TEST_F('EditingTest', 'RichTextMoveByCharacter', function() { |
264 editing.useRichText = true; | |
265 var mockFeedback = this.createMockFeedback(); | 264 var mockFeedback = this.createMockFeedback(); |
266 this.runWithLoadedTree(function() {/*! | 265 this.runWithLoadedTree(function() {/*! |
267 <div id="go" role="textbox" contenteditable>This <b>is</b> a test.</div> | 266 <div id="go" role="textbox" contenteditable>This <b>is</b> a test.</div> |
268 | 267 |
269 <script> | 268 <script> |
270 var dir = 'forward'; | 269 var dir = 'forward'; |
271 var char = 0; | 270 var char = 0; |
272 document.getElementById('go').addEventListener('click', function() { | 271 document.getElementById('go').addEventListener('click', function() { |
273 var sel = getSelection(); | 272 var sel = getSelection(); |
274 sel.modify('move', dir, 'character'); | 273 sel.modify('move', dir, 'character'); |
275 if (dir == 'forward') | 274 if (dir == 'forward') |
276 char++; | 275 char++; |
277 else | 276 else |
278 char--; | 277 char--; |
279 | 278 |
280 if (char == 0) | 279 if (char == 0) |
281 dir = 'forward'; | 280 dir = 'forward'; |
282 if (line == 16) | 281 if (line == 16) |
283 dir = 'backward'; | 282 dir = 'backward'; |
284 }, true); | 283 }, true); |
285 </script> | 284 </script> |
286 */}, function(root) { | 285 */}, function(root) { |
287 var input = root.find({role: RoleType.TEXT_FIELD}); | 286 var input = root.find({role: RoleType.TEXT_FIELD}); |
288 var moveByChar = input.doDefault.bind(input); | 287 var moveByChar = input.doDefault.bind(input); |
289 var lineText = 'This is a test.'; | 288 var lineText = 'This is a test. mled'; |
290 | 289 |
291 this.listenOnce(input, 'focus', function() { | 290 this.listenOnce(input, 'focus', function() { |
292 mockFeedback.call(moveByChar) | 291 mockFeedback.call(moveByChar) |
293 .expectSpeech('h') | 292 .expectSpeech('h') |
294 .expectBraille(lineText, { startIndex: 1, endIndex: 1 }) | 293 .expectBraille(lineText, { startIndex: 1, endIndex: 1 }) |
295 .call(moveByChar) | 294 .call(moveByChar) |
296 .expectSpeech('i') | 295 .expectSpeech('i') |
297 .expectBraille(lineText, { startIndex: 2, endIndex: 2 }) | 296 .expectBraille(lineText, { startIndex: 2, endIndex: 2 }) |
298 .call(moveByChar) | 297 .call(moveByChar) |
299 .expectSpeech('s') | 298 .expectSpeech('s') |
(...skipping 25 matching lines...) Expand all Loading... |
325 .expectBraille(lineText, { startIndex: 9, endIndex: 9 }) | 324 .expectBraille(lineText, { startIndex: 9, endIndex: 9 }) |
326 | 325 |
327 .replay(); | 326 .replay(); |
328 }); | 327 }); |
329 input.focus(); | 328 input.focus(); |
330 }); | 329 }); |
331 }); | 330 }); |
332 | 331 |
333 // Tests specifically for cursor workarounds. | 332 // Tests specifically for cursor workarounds. |
334 TEST_F('EditingTest', 'RichTextMoveByCharacterNodeWorkaround', function() { | 333 TEST_F('EditingTest', 'RichTextMoveByCharacterNodeWorkaround', function() { |
335 editing.useRichText = true; | |
336 var mockFeedback = this.createMockFeedback(); | 334 var mockFeedback = this.createMockFeedback(); |
337 this.runWithLoadedTree(function() {/*! | 335 this.runWithLoadedTree(function() {/*! |
338 <div id="go" role="textbox" contenteditable>hello <b>world</b></div> | 336 <div id="go" role="textbox" contenteditable>hello <b>world</b></div> |
339 | 337 |
340 <script> | 338 <script> |
341 document.getElementById('go').addEventListener('click', function() { | 339 document.getElementById('go').addEventListener('click', function() { |
342 var sel = getSelection(); | 340 var sel = getSelection(); |
343 sel.modify('move', 'forward', 'character'); | 341 sel.modify('move', 'forward', 'character'); |
344 }, true); | 342 }, true); |
345 </script> | 343 </script> |
346 */}, function(root) { | 344 */}, function(root) { |
347 var input = root.find({role: RoleType.TEXT_FIELD}); | 345 var input = root.find({role: RoleType.TEXT_FIELD}); |
348 var moveByChar = input.doDefault.bind(input) | 346 var moveByChar = input.doDefault.bind(input) |
349 var lineText = 'hello world'; | 347 var lineText = 'hello world mled'; |
350 | 348 |
351 this.listenOnce(input, 'focus', function() { | 349 this.listenOnce(input, 'focus', function() { |
352 mockFeedback.call(moveByChar) | 350 mockFeedback.call(moveByChar) |
353 .expectSpeech('e') | 351 .expectSpeech('e') |
354 .expectBraille(lineText, { startIndex: 1, endIndex: 1 }) | 352 .expectBraille(lineText, { startIndex: 1, endIndex: 1 }) |
355 .call(moveByChar) | 353 .call(moveByChar) |
356 .expectSpeech('l') | 354 .expectSpeech('l') |
357 .expectBraille(lineText, { startIndex: 2, endIndex: 2 }) | 355 .expectBraille(lineText, { startIndex: 2, endIndex: 2 }) |
358 .call(moveByChar) | 356 .call(moveByChar) |
359 .expectSpeech('l') | 357 .expectSpeech('l') |
360 .expectBraille(lineText, { startIndex: 3, endIndex: 3 }) | 358 .expectBraille(lineText, { startIndex: 3, endIndex: 3 }) |
361 .call(moveByChar) | 359 .call(moveByChar) |
362 .expectSpeech('o') | 360 .expectSpeech('o') |
363 .expectBraille(lineText, { startIndex: 4, endIndex: 4 }) | 361 .expectBraille(lineText, { startIndex: 4, endIndex: 4 }) |
364 .call(moveByChar) | 362 .call(moveByChar) |
365 .expectSpeech(' ') | 363 .expectSpeech(' ') |
366 .expectBraille(lineText, { startIndex: 5, endIndex: 5 }) | 364 .expectBraille(lineText, { startIndex: 5, endIndex: 5 }) |
367 .call(moveByChar) | 365 .call(moveByChar) |
368 .expectSpeech('w') | 366 .expectSpeech('w') |
369 .expectBraille(lineText, { startIndex: 6, endIndex: 6 }) | 367 .expectBraille(lineText, { startIndex: 6, endIndex: 6 }) |
370 .replay(); | 368 .replay(); |
371 }); | 369 }); |
372 input.focus(); | 370 input.focus(); |
373 }); | 371 }); |
374 }); | 372 }); |
375 | 373 |
376 TEST_F('EditingTest', 'RichTextMoveByCharacterEndOfLine', function() { | 374 TEST_F('EditingTest', 'RichTextMoveByCharacterEndOfLine', function() { |
377 editing.useRichText = true; | |
378 var mockFeedback = this.createMockFeedback(); | 375 var mockFeedback = this.createMockFeedback(); |
379 this.runWithLoadedTree(function() {/*! | 376 this.runWithLoadedTree(function() {/*! |
380 <div id="go" role="textbox" contenteditable>Test</div> | 377 <div id="go" role="textbox" contenteditable>Test</div> |
381 | 378 |
382 <script> | 379 <script> |
383 document.getElementById('go').addEventListener('click', function() { | 380 document.getElementById('go').addEventListener('click', function() { |
384 var sel = getSelection(); | 381 var sel = getSelection(); |
385 sel.modify('move', 'forward', 'character'); | 382 sel.modify('move', 'forward', 'character'); |
386 }, true); | 383 }, true); |
387 </script> | 384 </script> |
388 */}, function(root) { | 385 */}, function(root) { |
389 var input = root.find({role: RoleType.TEXT_FIELD}); | 386 var input = root.find({role: RoleType.TEXT_FIELD}); |
390 var moveByChar = input.doDefault.bind(input); | 387 var moveByChar = input.doDefault.bind(input); |
391 var lineText = 'Test'; | 388 var lineText = 'Test mled'; |
392 | 389 |
393 this.listenOnce(input, 'focus', function() { | 390 this.listenOnce(input, 'focus', function() { |
394 mockFeedback.call(moveByChar) | 391 mockFeedback.call(moveByChar) |
395 .expectSpeech('e') | 392 .expectSpeech('e') |
396 .expectBraille(lineText, { startIndex: 1, endIndex: 1 }) | 393 .expectBraille(lineText, { startIndex: 1, endIndex: 1 }) |
397 .call(moveByChar) | 394 .call(moveByChar) |
398 .expectSpeech('s') | 395 .expectSpeech('s') |
399 .expectBraille(lineText, { startIndex: 2, endIndex: 2 }) | 396 .expectBraille(lineText, { startIndex: 2, endIndex: 2 }) |
400 .call(moveByChar) | 397 .call(moveByChar) |
401 .expectSpeech('t') | 398 .expectSpeech('t') |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 assertEquals(0, e1.startOffset); | 680 assertEquals(0, e1.startOffset); |
684 assertEquals(2, e1.endOffset); | 681 assertEquals(2, e1.endOffset); |
685 | 682 |
686 // Across paragraph selection with base line on anchor. | 683 // Across paragraph selection with base line on anchor. |
687 e1 = new editing.EditableLine(thisIsATest, 5, hello, 2, true); | 684 e1 = new editing.EditableLine(thisIsATest, 5, hello, 2, true); |
688 assertEquals('is ', e1.text); | 685 assertEquals('is ', e1.text); |
689 assertEquals(0, e1.startOffset); | 686 assertEquals(0, e1.startOffset); |
690 assertEquals(3, e1.endOffset); | 687 assertEquals(3, e1.endOffset); |
691 }) | 688 }) |
692 }); | 689 }); |
OLD | NEW |