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 // 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 | 7 |
8 /** | 8 /** |
9 * Test fixture for cvox2.cursors. | 9 * Test fixture for cvox2.cursors. |
10 * @constructor | 10 * @constructor |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 {value: 'same line', index: 5}, {value: 'same line', index: 9}], | 253 {value: 'same line', index: 5}, {value: 'same line', index: 9}], |
254 [WORD, BACKWARD, | 254 [WORD, BACKWARD, |
255 {value: 'same line', index: 0}, {value: 'same line', index: 4}], | 255 {value: 'same line', index: 0}, {value: 'same line', index: 4}], |
256 | 256 |
257 [WORD, BACKWARD, | 257 [WORD, BACKWARD, |
258 {value: 'start ', index: 0}, {value: 'start ', index: 5}], | 258 {value: 'start ', index: 0}, {value: 'start ', index: 5}], |
259 [WORD, BACKWARD, | 259 [WORD, BACKWARD, |
260 {value: undefined, index: 0}, {value: undefined, index: 5}], | 260 {value: undefined, index: 0}, {value: undefined, index: 5}], |
261 ], this.RANGE); | 261 ], this.RANGE); |
262 }); | 262 }); |
263 | 263 |
264 | 264 |
265 TEST_F('CursorsTest', 'LineRange', function() { | 265 TEST_F('CursorsTest', 'LineRange', function() { |
266 this.runCursorMovesOnDocument(this.simpleDoc, [ | 266 this.runCursorMovesOnDocument(this.simpleDoc, [ |
267 [LINE, FORWARD, {value: 'end', index: 0}, {value: 'end', index: 3}], | 267 [LINE, FORWARD, {value: 'end', index: 0}, {value: 'end', index: 3}], |
268 [LINE, FORWARD, {value: 'end', index: 0}, {value: 'end', index: 3}], | 268 [LINE, FORWARD, {value: 'end', index: 0}, {value: 'end', index: 3}], |
269 [LINE, FORWARD, {value: 'end', index: 0}, {value: 'end', index: 3}], | 269 [LINE, FORWARD, {value: 'end', index: 0}, {value: 'end', index: 3}], |
270 [LINE, FORWARD, {value: 'end', index: 0}, {value: 'end', index: 3}], | 270 [LINE, FORWARD, {value: 'end', index: 0}, {value: 'end', index: 3}], |
271 | 271 |
272 [LINE, BACKWARD, | 272 [LINE, BACKWARD, |
273 {value: 'start ', index: 0}, {value: 'same line', index: 9}], | 273 {value: 'start ', index: 0}, {value: 'same line', index: 9}], |
274 | 274 |
275 [LINE, BACKWARD, | 275 [LINE, BACKWARD, |
276 {value: 'start ', index: 0}, {value: 'same line', index: 9}] | 276 {value: 'start ', index: 0}, {value: 'same line', index: 9}] |
277 ], this.RANGE); | 277 ], this.RANGE); |
278 }); | 278 }); |
279 | 279 |
280 TEST_F('CursorsTest', 'DontSplitOnNodeNavigation', function() { | 280 TEST_F('CursorsTest', 'DontSplitOnNodeNavigation', function() { |
281 this.runWithLoadedTree(this.multiInlineDoc, function(root) { | 281 this.runWithLoadedTree(this.multiInlineDoc, function(root) { |
282 var para = root.firstChild; | 282 var para = root.firstChild; |
283 assertEquals('paragraph', para.role); | 283 assertEquals('paragraph', para.role); |
284 var cursor = new cursors.Cursor(para.firstChild, 0); | 284 var cursor = new cursors.Cursor(para.firstChild, 0); |
285 cursor = cursor.move(NODE, DIRECTIONAL, FORWARD); | 285 cursor = cursor.move(NODE, DIRECTIONAL, FORWARD); |
286 assertEquals('staticText', cursor.node.role); | 286 assertEquals('staticText', cursor.node.role); |
287 assertEquals('end', cursor.node.name); | 287 assertEquals('end', cursor.node.name); |
288 | 288 |
289 cursor = cursor.move(NODE, DIRECTIONAL, BACKWARD); | 289 cursor = cursor.move(NODE, DIRECTIONAL, BACKWARD); |
290 assertEquals('staticText', cursor.node.role); | 290 assertEquals('staticText', cursor.node.role); |
291 assertEquals('start diff line', cursor.node.name); | 291 assertEquals('start diff line', cursor.node.name); |
292 | 292 |
293 assertEquals('inlineTextBox', cursor.node.firstChild.role); | 293 assertEquals('inlineTextBox', cursor.node.firstChild.role); |
294 assertEquals('start ', cursor.node.firstChild.name); | 294 assertEquals('start ', cursor.node.firstChild.name); |
295 assertEquals('diff ', cursor.node.firstChild.nextSibling.name); | 295 assertEquals('diff ', cursor.node.firstChild.nextSibling.name); |
296 assertEquals('line', cursor.node.lastChild.name); | 296 assertEquals('line', cursor.node.lastChild.name); |
297 }); | 297 }); |
298 }); | 298 }); |
299 | 299 |
300 TEST_F('CursorsTest', 'WrappingCursors', function() { | 300 TEST_F('CursorsTest', 'WrappingCursors', function() { |
301 this.runWithLoadedTree(this.multiInlineDoc, function(root) { | 301 this.runWithLoadedTree(this.multiInlineDoc, function(root) { |
302 var first = root; | 302 var first = root; |
(...skipping 15 matching lines...) Expand all Loading... |
318 var para = root.firstChild; | 318 var para = root.firstChild; |
319 var webRange = new cursors.Range.fromNode(para); | 319 var webRange = new cursors.Range.fromNode(para); |
320 var auraRange = cursors.Range.fromNode(root.parent); | 320 var auraRange = cursors.Range.fromNode(root.parent); |
321 assertFalse(auraRange.isWebRange()); | 321 assertFalse(auraRange.isWebRange()); |
322 assertTrue(webRange.isWebRange()); | 322 assertTrue(webRange.isWebRange()); |
323 }); | 323 }); |
324 }); | 324 }); |
325 | 325 |
326 TEST_F('CursorsTest', 'SingleDocSelection', function() { | 326 TEST_F('CursorsTest', 'SingleDocSelection', function() { |
327 this.runWithLoadedTree(function() {/*! | 327 this.runWithLoadedTree(function() {/*! |
328 <a href="google.com">google home page</a> | 328 <p><a href="google.com">google home page</a></p> |
329 <p>some more text</p> | 329 <p>some more text</p> |
330 <p>end of text</p> | 330 <p>end of text</p> |
331 */}, | 331 */}, |
332 function(root) { | 332 function(root) { |
333 var link = root.firstChild.firstChild; | 333 var link = root.firstChild.firstChild; |
334 var p1 = root.firstChild.nextSibling; | 334 var p1 = root.firstChild.nextSibling; |
335 var p2 = p1.nextSibling; | 335 var p2 = p1.nextSibling; |
336 | 336 |
337 var singleSel = new cursors.Range( | 337 var singleSel = new cursors.Range( |
338 new cursors.Cursor(link, 0), | 338 new cursors.Cursor(link, 0), |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 | 449 |
450 // Negative cases. | 450 // Negative cases. |
451 assertFalse(rootRange.contentEquals(regionRange)); | 451 assertFalse(rootRange.contentEquals(regionRange)); |
452 assertFalse(rootRange.contentEquals(staticTextRange)); | 452 assertFalse(rootRange.contentEquals(staticTextRange)); |
453 assertFalse(rootRange.contentEquals(inlineTextBoxRange)); | 453 assertFalse(rootRange.contentEquals(inlineTextBoxRange)); |
454 assertFalse(regionRange.contentEquals(rootRange)); | 454 assertFalse(regionRange.contentEquals(rootRange)); |
455 assertFalse(staticTextRange.contentEquals(rootRange)); | 455 assertFalse(staticTextRange.contentEquals(rootRange)); |
456 assertFalse(inlineTextBoxRange.contentEquals(rootRange)); | 456 assertFalse(inlineTextBoxRange.contentEquals(rootRange)); |
457 }); | 457 }); |
458 }); | 458 }); |
OLD | NEW |