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

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

Issue 880063002: Ensure WebView notifies desktop automation on creation, destruction, and change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix leaks? 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
73 this.makeCursorAssertion(expectedStart, range.getStart()); 74 this.makeCursorAssertion(expectedStart, range.getStart());
74 this.makeCursorAssertion(expectedEnd, range.getEnd()); 75 this.makeCursorAssertion(expectedEnd, range.getEnd());
75 } 76 }
76 }, 77 },
77 78
78 /** 79 /**
79 * Makes assertions about the given |cursor|. 80 * Makes assertions about the given |cursor|.
80 * @param {Object} expected 81 * @param {Object} expected
81 * @param {Cursor} cursor 82 * @param {Cursor} cursor
82 */ 83 */
83 makeCursorAssertion: function(expected, cursor) { 84 makeCursorAssertion: function(expected, cursor) {
84 if (goog.isDef(expected.index)) 85 if (goog.isDef(expected.index))
85 assertEquals(expected.index, cursor.getIndex()); 86 assertEquals(expected.index, cursor.getIndex());
86 if (goog.isDef(expected.value)) 87 if (goog.isDef(expected.value))
87 assertEquals(expected.value, cursor.getNode().attributes.value); 88 assertEquals(expected.value, cursor.getNode().attributes.value);
88 }, 89 },
89 90
90 /** 91 /**
91 * Runs the specified moves on the |doc| and asserts expectations. 92 * Runs the specified moves on the |doc| and asserts expectations.
92 * @param {function} doc 93 * @param {function} doc
93 * @param {string=} opt_testType Either CURSOR or RANGE. 94 * @param {string=} opt_testType Either CURSOR or RANGE.
94 */ 95 */
95 runCursorMovesOnDocument: function(doc, moves, opt_testType) { 96 runCursorMovesOnDocument: function(doc, moves, opt_testType) {
96 this.runWithDocument(doc, 97 this.runWithAutomation(doc,
97 function() { 98 function(root) {
98 chrome.automation.getTree(function(root) { 99 var start = null;
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) {
106 var cursor = new cursors.Cursor(start, 0); 108 var cursor = new cursors.Cursor(start, 0);
107 if (!opt_testType || opt_testType == this.CURSOR) { 109 this.cursorMoveAndAssert(cursor, moves);
108 var cursor = new cursors.Cursor(start, 0); 110 testDone();
109 this.cursorMoveAndAssert(cursor, moves); 111 } else if (opt_testType == this.RANGE) {
110 testDone(); 112 var range = new cursors.Range(cursor, cursor);
111 } else if (opt_testType == this.RANGE) { 113 this.rangeMoveAndAssert(range, moves);
112 var range = new cursors.Range(cursor, cursor); 114 testDone();
113 this.rangeMoveAndAssert(range, moves); 115 }
114 testDone();
115 }
116 }.bind(this));
117 }.bind(this)); 116 }.bind(this));
118 }, 117 },
119 118
120 simpleDoc: function() {/*! 119 simpleDoc: function() {/*!
121 <p>start <span>same line</span> 120 <p>start <span>same line</span>
122 <p>end 121 <p>end
123 */} 122 */}
124 }; 123 };
125 124
126 TEST_F('CursorsTest', 'CharacterCursor', function() { 125 TEST_F('CursorsTest', 'CharacterCursor', function() {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 [LINE, FORWARD, {value: 'end', index: 0}, {value: 'end', index: 3}], 260 [LINE, FORWARD, {value: 'end', index: 0}, {value: 'end', index: 3}],
262 261
263 [LINE, BACKWARD, 262 [LINE, BACKWARD,
264 {value: 'start ', index: 0}, {value: 'same line', index: 9}], 263 {value: 'start ', index: 0}, {value: 'same line', index: 9}],
265 264
266 [LINE, BACKWARD, 265 [LINE, BACKWARD,
267 {value: 'start ', index: 0}, {value: 'same line', index: 9}], 266 {value: 'start ', index: 0}, {value: 'same line', index: 9}],
268 ], this.RANGE); 267 ], this.RANGE);
269 }); 268 });
270 269
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698