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

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: Created 6 years, 2 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 var me = this; 134 var me = this;
135 var calmArguments = Array.prototype.slice.call(arguments); 135 var calmArguments = Array.prototype.slice.call(arguments);
136 calmArguments.shift(); 136 calmArguments.shift();
137 cvox.ChromeVoxEventWatcher.addReadyCallback(function() { 137 cvox.ChromeVoxEventWatcher.addReadyCallback(function() {
138 func.apply(me, calmArguments); 138 func.apply(me, calmArguments);
139 }); 139 });
140 return this; // for chaining. 140 return this; // for chaining.
141 }, 141 },
142 142
143 /** 143 /**
144 * Asserts the TTS engine spoken a certain string. Clears the TTS buffer.
Peter Lundblad 2014/09/23 09:40:01 nit: grammar seems odd to this non-native speaker.
dmazzoni 2014/09/23 18:02:41 Done.
145 * @param {string} expectedText The expected text.
146 * @return {cvox.TestCaseClass} this.
Peter Lundblad 2014/09/23 09:40:01 nit: Type should be ChromeVoxUnitTestBase.
dmazzoni 2014/09/23 18:02:40 Done.
147 */
148 assertSpoken: function(expectedText) {
149 assertEquals(expectedText,
150 cvox.ChromeVoxTester.testTts().getUtterancesAsString());
151 cvox.ChromeVoxTester.clearUtterances();
152 return this; // for chaining.
153 },
154
155 /**
144 * Asserts a list of utterances are in the correct queue mode. 156 * Asserts a list of utterances are in the correct queue mode.
145 * @param {cvox.SpokenListBuilder|Array} expectedList A list 157 * @param {cvox.SpokenListBuilder|Array} expectedList A list
146 * of [text, queueMode] tuples OR a SpokenListBuilder with the expected 158 * of [text, queueMode] tuples OR a SpokenListBuilder with the expected
147 * utterances. 159 * utterances.
148 * @return {ChromeVoxUnitTestBase} this. 160 * @return {ChromeVoxUnitTestBase} this.
149 */ 161 */
150 assertSpokenList: function(expectedList) { 162 assertSpokenList: function(expectedList) {
151 if (expectedList instanceof cvox.SpokenListBuilder) { 163 if (expectedList instanceof cvox.SpokenListBuilder) {
152 expectedList = expectedList.build(); 164 expectedList = expectedList.build();
153 } 165 }
154 166
155 var ulist = cvox.ChromeVoxTester.testTts().getUtteranceInfoList(); 167 var ulist = cvox.ChromeVoxTester.testTts().getUtteranceInfoList();
156 for (var i = 0; i < expectedList.length; i++) { 168 for (var i = 0; i < expectedList.length; i++) {
157 var text = expectedList[i][0]; 169 var text = expectedList[i][0];
158 var queueMode = expectedList[i][1]; 170 var queueMode = expectedList[i][1];
159 this.assertSingleUtterance_(text, queueMode, 171 this.assertSingleUtterance_(text, queueMode,
160 ulist[i].text, ulist[i].queueMode); 172 ulist[i].text, ulist[i].queueMode);
161 } 173 }
162 cvox.ChromeVoxTester.clearUtterances(); 174 cvox.ChromeVoxTester.clearUtterances();
163 return this; // for chaining. 175 return this; // for chaining.
164 }, 176 },
165 177
166 assertSingleUtterance_: function( 178 assertSingleUtterance_: function(
167 expectedText, expectedQueueMode, text, queueMode) { 179 expectedText, expectedQueueMode, text, queueMode) {
168 assertEquals(expectedQueueMode, queueMode); 180 assertEquals(expectedQueueMode, queueMode);
169 assertEquals(expectedText, text); 181 assertEquals(expectedText, text);
182 },
183
184 /**
185 * Focuses an element.
186 * @param {string} eltName The name of the element to focus.
Peter Lundblad 2014/09/23 09:40:01 Shouldn't this be the id of the element, not the n
dmazzoni 2014/09/23 18:02:40 Done.
187 * @return {ChromeVoxUnitTestBase} this.
188 */
189 setFocus: function(eltName) {
190 $(eltName).focus();
191 return this; // for chaining.
192 },
193
194 /**
195 * Executes a ChromeVox user command.
196 * @param {string} command The name of the command to run.
197 * @return {ChromeVoxUnitTestBase} this.
198 */
199 userCommand: function(command) {
200 cvox.ChromeVoxUserCommands.commands[command]();
Peter Lundblad 2014/09/23 09:40:00 You should add cvox.ChromeVoxUserCommands to the c
dmazzoni 2014/09/23 18:02:41 Done.
201 return this; // for chaining.
202 },
203
204 /**
205 * @return {cvox.SpokenListBuilder} A new builder.
206 */
207 spokenList: function() {
Peter Lundblad 2014/09/23 09:40:00 This also has an undeclared dependency, but I'd ju
dmazzoni 2014/09/23 18:02:41 It's useful for chaining and will make porting oth
208 return new cvox.SpokenListBuilder();
170 } 209 }
171 }; 210 };
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