Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/cursors_test.extjs

Issue 910013002: Revert of Reland #2: Ensure WebView notifies desktop automation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 * Object>>} 63 * Object>>}
64 * moves An array of arrays. Each inner array contains 4 items: unit, 64 * moves An array of arrays. Each inner array contains 4 items: unit,
65 * direction, start and end assertions objects. See example below. 65 * direction, start and end assertions objects. See example below.
66 */ 66 */
67 rangeMoveAndAssert: function(range, moves) { 67 rangeMoveAndAssert: function(range, moves) {
68 var move = null; 68 var move = null;
69 while (move = moves.shift()) { 69 while (move = moves.shift()) {
70 range = range.move(move[0], move[1]); 70 range = range.move(move[0], move[1]);
71 var expectedStart = move[2]; 71 var expectedStart = move[2];
72 var expectedEnd = move[3]; 72 var expectedEnd = move[3];
73
74 this.makeCursorAssertion(expectedStart, range.getStart()); 73 this.makeCursorAssertion(expectedStart, range.getStart());
75 this.makeCursorAssertion(expectedEnd, range.getEnd()); 74 this.makeCursorAssertion(expectedEnd, range.getEnd());
76 } 75 }
77 }, 76 },
78 77
79 /** 78 /**
80 * Makes assertions about the given |cursor|. 79 * Makes assertions about the given |cursor|.
81 * @param {Object} expected 80 * @param {Object} expected
82 * @param {Cursor} cursor 81 * @param {Cursor} cursor
83 */ 82 */
84 makeCursorAssertion: function(expected, cursor) { 83 makeCursorAssertion: function(expected, cursor) {
85 if (goog.isDef(expected.index)) 84 if (goog.isDef(expected.index))
86 assertEquals(expected.index, cursor.getIndex()); 85 assertEquals(expected.index, cursor.getIndex());
87 if (goog.isDef(expected.value)) 86 if (goog.isDef(expected.value))
88 assertEquals(expected.value, cursor.getNode().attributes.value); 87 assertEquals(expected.value, cursor.getNode().attributes.value);
89 }, 88 },
90 89
91 /** 90 /**
92 * Runs the specified moves on the |doc| and asserts expectations. 91 * Runs the specified moves on the |doc| and asserts expectations.
93 * @param {function} doc 92 * @param {function} doc
94 * @param {string=} opt_testType Either CURSOR or RANGE. 93 * @param {string=} opt_testType Either CURSOR or RANGE.
95 */ 94 */
96 runCursorMovesOnDocument: function(doc, moves, opt_testType) { 95 runCursorMovesOnDocument: function(doc, moves, opt_testType) {
97 this.runWithLoadedTree(doc, 96 this.runWithDocument(doc,
98 function(root) { 97 function() {
99 var start = null; 98 chrome.automation.getTree(function(root) {
99 var start = null;
100 100
101 // This occurs as a result of a load complete. 101 // This occurs as a result of a load complete.
102 var start = AutomationUtil.findNodePost(root, 102 var start = AutomationUtil.findNodePost(root,
103 FORWARD, 103 FORWARD,
104 AutomationPredicate.leaf); 104 AutomationPredicate.leaf);
105 105
106 var cursor = new cursors.Cursor(start, 0);
107 if (!opt_testType || opt_testType == this.CURSOR) {
108 var cursor = new cursors.Cursor(start, 0); 106 var cursor = new cursors.Cursor(start, 0);
109 this.cursorMoveAndAssert(cursor, moves); 107 if (!opt_testType || opt_testType == this.CURSOR) {
110 testDone(); 108 var cursor = new cursors.Cursor(start, 0);
111 } else if (opt_testType == this.RANGE) { 109 this.cursorMoveAndAssert(cursor, moves);
112 var range = new cursors.Range(cursor, cursor); 110 testDone();
113 this.rangeMoveAndAssert(range, moves); 111 } else if (opt_testType == this.RANGE) {
114 testDone(); 112 var range = new cursors.Range(cursor, cursor);
115 } 113 this.rangeMoveAndAssert(range, moves);
114 testDone();
115 }
116 }.bind(this));
116 }.bind(this)); 117 }.bind(this));
117 }, 118 },
118 119
119 simpleDoc: function() {/*! 120 simpleDoc: function() {/*!
120 <p>start <span>same line</span> 121 <p>start <span>same line</span>
121 <p>end 122 <p>end
122 */} 123 */}
123 }; 124 };
124 125
125 TEST_F('CursorsTest', 'CharacterCursor', function() { 126 TEST_F('CursorsTest', 'CharacterCursor', function() {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 [LINE, FORWARD, {value: 'end', index: 0}, {value: 'end', index: 3}], 261 [LINE, FORWARD, {value: 'end', index: 0}, {value: 'end', index: 3}],
261 262
262 [LINE, BACKWARD, 263 [LINE, BACKWARD,
263 {value: 'start ', index: 0}, {value: 'same line', index: 9}], 264 {value: 'start ', index: 0}, {value: 'same line', index: 9}],
264 265
265 [LINE, BACKWARD, 266 [LINE, BACKWARD,
266 {value: 'start ', index: 0}, {value: 'same line', index: 9}], 267 {value: 'start ', index: 0}, {value: 'same line', index: 9}],
267 ], this.RANGE); 268 ], this.RANGE);
268 }); 269 });
269 270
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698