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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 * moves An array of arrays. Each inner array contains 4 items: unit, | 66 * moves An array of arrays. Each inner array contains 4 items: unit, |
67 * direction, start and end assertions objects. See example below. | 67 * direction, start and end assertions objects. See example below. |
68 */ | 68 */ |
69 rangeMoveAndAssert: function(range, moves) { | 69 rangeMoveAndAssert: function(range, moves) { |
70 var move = null; | 70 var move = null; |
71 while (move = moves.shift()) { | 71 while (move = moves.shift()) { |
72 range = range.move(move[0], move[1]); | 72 range = range.move(move[0], move[1]); |
73 var expectedStart = move[2]; | 73 var expectedStart = move[2]; |
74 var expectedEnd = move[3]; | 74 var expectedEnd = move[3]; |
75 | 75 |
76 this.makeCursorAssertion(expectedStart, range.getStart()); | 76 this.makeCursorAssertion(expectedStart, range.start); |
77 this.makeCursorAssertion(expectedEnd, range.getEnd()); | 77 this.makeCursorAssertion(expectedEnd, range.end); |
78 } | 78 } |
79 }, | 79 }, |
80 | 80 |
81 /** | 81 /** |
82 * Makes assertions about the given |cursor|. | 82 * Makes assertions about the given |cursor|. |
83 * @param {Object} expected | 83 * @param {Object} expected |
84 * @param {Cursor} cursor | 84 * @param {Cursor} cursor |
85 */ | 85 */ |
86 makeCursorAssertion: function(expected, cursor) { | 86 makeCursorAssertion: function(expected, cursor) { |
87 if (goog.isDef(expected.index)) | 87 if (goog.isDef(expected.index)) |
88 assertEquals(expected.index, cursor.getIndex()); | 88 assertEquals(expected.index, cursor.getIndex()); |
89 if (goog.isDef(expected.value)) | 89 if (goog.isDef(expected.value)) |
90 assertEquals(expected.value, cursor.getNode().value); | 90 assertEquals(expected.value, cursor.node.value); |
91 }, | 91 }, |
92 | 92 |
93 /** | 93 /** |
94 * Runs the specified moves on the |doc| and asserts expectations. | 94 * Runs the specified moves on the |doc| and asserts expectations. |
95 * @param {function} doc | 95 * @param {function} doc |
96 * @param {string=} opt_testType Either CURSOR or RANGE. | 96 * @param {string=} opt_testType Either CURSOR or RANGE. |
97 */ | 97 */ |
98 runCursorMovesOnDocument: function(doc, moves, opt_testType) { | 98 runCursorMovesOnDocument: function(doc, moves, opt_testType) { |
99 this.runWithLoadedTree(doc, | 99 this.runWithLoadedTree(doc, |
100 function(root) { | 100 function(root) { |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 [LINE, FORWARD, {value: 'end', index: 0}, {value: 'end', index: 3}], | 260 [LINE, FORWARD, {value: 'end', index: 0}, {value: 'end', index: 3}], |
261 | 261 |
262 [LINE, BACKWARD, | 262 [LINE, BACKWARD, |
263 {value: 'start ', index: 0}, {value: 'same line', index: 9}], | 263 {value: 'start ', index: 0}, {value: 'same line', index: 9}], |
264 | 264 |
265 [LINE, BACKWARD, | 265 [LINE, BACKWARD, |
266 {value: 'start ', index: 0}, {value: 'same line', index: 9}], | 266 {value: 'start ', index: 0}, {value: 'same line', index: 9}], |
267 ], this.RANGE); | 267 ], this.RANGE); |
268 }); | 268 }); |
269 | 269 |
OLD | NEW |