| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 if (goog.isDef(expected.value)) | 86 if (goog.isDef(expected.value)) |
| 87 assertEquals(expected.value, cursor.getNode().attributes.value); | 87 assertEquals(expected.value, cursor.getNode().attributes.value); |
| 88 }, | 88 }, |
| 89 | 89 |
| 90 /** | 90 /** |
| 91 * Runs the specified moves on the |doc| and asserts expectations. | 91 * Runs the specified moves on the |doc| and asserts expectations. |
| 92 * @param {function} doc | 92 * @param {function} doc |
| 93 * @param {string=} opt_testType Either CURSOR or RANGE. | 93 * @param {string=} opt_testType Either CURSOR or RANGE. |
| 94 */ | 94 */ |
| 95 runCursorMovesOnDocument: function(doc, moves, opt_testType) { | 95 runCursorMovesOnDocument: function(doc, moves, opt_testType) { |
| 96 this.runWithDocument(doc, | 96 this.runWithAutomation(doc, |
| 97 function() { | 97 function(root) { |
| 98 chrome.automation.getTree(function(root) { | 98 var start = null; |
| 99 var start = null; | |
| 100 | 99 |
| 101 // This occurs as a result of a load complete. | 100 // This occurs as a result of a load complete. |
| 102 var start = AutomationUtil.findNodePost(root, | 101 var start = AutomationUtil.findNodePost(root, |
| 103 FORWARD, | 102 FORWARD, |
| 104 AutomationPredicate.leaf); | 103 AutomationPredicate.leaf); |
| 105 | 104 |
| 105 var cursor = new cursors.Cursor(start, 0); |
| 106 if (!opt_testType || opt_testType == this.CURSOR) { |
| 106 var cursor = new cursors.Cursor(start, 0); | 107 var cursor = new cursors.Cursor(start, 0); |
| 107 if (!opt_testType || opt_testType == this.CURSOR) { | 108 this.cursorMoveAndAssert(cursor, moves); |
| 108 var cursor = new cursors.Cursor(start, 0); | 109 testDone(); |
| 109 this.cursorMoveAndAssert(cursor, moves); | 110 } else if (opt_testType == this.RANGE) { |
| 110 testDone(); | 111 var range = new cursors.Range(cursor, cursor); |
| 111 } else if (opt_testType == this.RANGE) { | 112 this.rangeMoveAndAssert(range, moves); |
| 112 var range = new cursors.Range(cursor, cursor); | 113 testDone(); |
| 113 this.rangeMoveAndAssert(range, moves); | 114 } |
| 114 testDone(); | |
| 115 } | |
| 116 }.bind(this)); | |
| 117 }.bind(this)); | 115 }.bind(this)); |
| 118 }, | 116 }, |
| 119 | 117 |
| 120 simpleDoc: function() {/*! | 118 simpleDoc: function() {/*! |
| 121 <p>start <span>same line</span> | 119 <p>start <span>same line</span> |
| 122 <p>end | 120 <p>end |
| 123 */} | 121 */} |
| 124 }; | 122 }; |
| 125 | 123 |
| 126 TEST_F('CursorsTest', 'CharacterCursor', function() { | 124 TEST_F('CursorsTest', 'CharacterCursor', function() { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 [LINE, FORWARD, {value: 'end', index: 0}, {value: 'end', index: 3}], | 259 [LINE, FORWARD, {value: 'end', index: 0}, {value: 'end', index: 3}], |
| 262 | 260 |
| 263 [LINE, BACKWARD, | 261 [LINE, BACKWARD, |
| 264 {value: 'start ', index: 0}, {value: 'same line', index: 9}], | 262 {value: 'start ', index: 0}, {value: 'same line', index: 9}], |
| 265 | 263 |
| 266 [LINE, BACKWARD, | 264 [LINE, BACKWARD, |
| 267 {value: 'start ', index: 0}, {value: 'same line', index: 9}], | 265 {value: 'start ', index: 0}, {value: 'same line', index: 9}], |
| 268 ], this.RANGE); | 266 ], this.RANGE); |
| 269 }); | 267 }); |
| 270 | 268 |
| OLD | NEW |