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 27 matching lines...) Expand all Loading... |
254 .call(moveByLine) | 254 .call(moveByLine) |
255 .expectSpeech('hello') | 255 .expectSpeech('hello') |
256 .expectBraille('hello') | 256 .expectBraille('hello') |
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'); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after 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> |
(...skipping 21 matching lines...) Expand all Loading... |
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> |
(...skipping 295 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 |