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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/testing/chromevox_unittest_base.js

Issue 595633002: Port event watcher ChromeVox tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@live_regions
Patch Set: Fix async issues Created 6 years, 3 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
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/chromevox_tests.gypi ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 GEN_INCLUDE([ 5 GEN_INCLUDE([
6 'chrome/browser/resources/chromeos/chromevox/testing/assert_additions.js']); 6 'chrome/browser/resources/chromeos/chromevox/testing/assert_additions.js']);
7 7
8 /** 8 /**
9 * Shortcut for document.getElementById. 9 * Shortcut for document.getElementById.
10 * @param {string} id of the element. 10 * @param {string} id of the element.
(...skipping 12 matching lines...) Expand all
23 * 23 *
24 * @constructor 24 * @constructor
25 * @extends {testing.Test} 25 * @extends {testing.Test}
26 */ 26 */
27 function ChromeVoxUnitTestBase() {} 27 function ChromeVoxUnitTestBase() {}
28 28
29 ChromeVoxUnitTestBase.prototype = { 29 ChromeVoxUnitTestBase.prototype = {
30 __proto__: testing.Test.prototype, 30 __proto__: testing.Test.prototype,
31 31
32 /** @override */ 32 /** @override */
33 closureModuleDeps: [
34 'cvox.ChromeVoxTester',
35 'cvox.ChromeVoxUserCommands',
36 'cvox.SpokenListBuilder',
37 ],
38
39 /** @override */
33 browsePreload: DUMMY_URL, 40 browsePreload: DUMMY_URL,
34 41
35 /** 42 /**
36 * @override 43 * @override
37 * It doesn't make sense to run the accessibility audit on these tests, 44 * It doesn't make sense to run the accessibility audit on these tests,
38 * since many of them are deliberately testing inaccessible html. 45 * since many of them are deliberately testing inaccessible html.
39 */ 46 */
40 runAccessibilityChecks: false, 47 runAccessibilityChecks: false,
41 48
42 /** 49 /**
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 var me = this; 141 var me = this;
135 var calmArguments = Array.prototype.slice.call(arguments); 142 var calmArguments = Array.prototype.slice.call(arguments);
136 calmArguments.shift(); 143 calmArguments.shift();
137 cvox.ChromeVoxEventWatcher.addReadyCallback(function() { 144 cvox.ChromeVoxEventWatcher.addReadyCallback(function() {
138 func.apply(me, calmArguments); 145 func.apply(me, calmArguments);
139 }); 146 });
140 return this; // for chaining. 147 return this; // for chaining.
141 }, 148 },
142 149
143 /** 150 /**
151 * Asserts the TTS engine spoke a certain string. Clears the TTS buffer.
152 * @param {string} expectedText The expected text.
153 * @return {ChromeVoxUnitTestBase} this.
154 */
155 assertSpoken: function(expectedText) {
156 assertEquals(expectedText,
157 cvox.ChromeVoxTester.testTts().getUtterancesAsString());
158 cvox.ChromeVoxTester.clearUtterances();
159 return this; // for chaining.
160 },
161
162 /**
144 * Asserts a list of utterances are in the correct queue mode. 163 * Asserts a list of utterances are in the correct queue mode.
145 * @param {cvox.SpokenListBuilder|Array} expectedList A list 164 * @param {cvox.SpokenListBuilder|Array} expectedList A list
146 * of [text, queueMode] tuples OR a SpokenListBuilder with the expected 165 * of [text, queueMode] tuples OR a SpokenListBuilder with the expected
147 * utterances. 166 * utterances.
148 * @return {ChromeVoxUnitTestBase} this. 167 * @return {ChromeVoxUnitTestBase} this.
149 */ 168 */
150 assertSpokenList: function(expectedList) { 169 assertSpokenList: function(expectedList) {
151 if (expectedList instanceof cvox.SpokenListBuilder) { 170 if (expectedList instanceof cvox.SpokenListBuilder) {
152 expectedList = expectedList.build(); 171 expectedList = expectedList.build();
153 } 172 }
154 173
155 var ulist = cvox.ChromeVoxTester.testTts().getUtteranceInfoList(); 174 var ulist = cvox.ChromeVoxTester.testTts().getUtteranceInfoList();
156 for (var i = 0; i < expectedList.length; i++) { 175 for (var i = 0; i < expectedList.length; i++) {
157 var text = expectedList[i][0]; 176 var text = expectedList[i][0];
158 var queueMode = expectedList[i][1]; 177 var queueMode = expectedList[i][1];
159 this.assertSingleUtterance_(text, queueMode, 178 this.assertSingleUtterance_(text, queueMode,
160 ulist[i].text, ulist[i].queueMode); 179 ulist[i].text, ulist[i].queueMode);
161 } 180 }
162 cvox.ChromeVoxTester.clearUtterances(); 181 cvox.ChromeVoxTester.clearUtterances();
163 return this; // for chaining. 182 return this; // for chaining.
164 }, 183 },
165 184
166 assertSingleUtterance_: function( 185 assertSingleUtterance_: function(
167 expectedText, expectedQueueMode, text, queueMode) { 186 expectedText, expectedQueueMode, text, queueMode) {
168 assertEquals(expectedQueueMode, queueMode); 187 assertEquals(expectedQueueMode, queueMode);
169 assertEquals(expectedText, text); 188 assertEquals(expectedText, text);
189 },
190
191 /**
192 * Focuses an element.
193 * @param {string} id The id of the element to focus.
194 * @return {ChromeVoxUnitTestBase} this.
195 */
196 setFocus: function(id) {
197 $(id).focus();
198 return this; // for chaining.
199 },
200
201 /**
202 * Executes a ChromeVox user command.
203 * @param {string} command The name of the command to run.
204 * @return {ChromeVoxUnitTestBase} this.
205 */
206 userCommand: function(command) {
207 cvox.ChromeVoxUserCommands.commands[command]();
208 return this; // for chaining.
209 },
210
211 /**
212 * @return {cvox.SpokenListBuilder} A new builder.
213 */
214 spokenList: function() {
215 return new cvox.SpokenListBuilder();
170 } 216 }
171 }; 217 };
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/chromevox_tests.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698