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

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

Issue 582123002: Port live region ChromeVox tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chromevox_keyboard_tests_again
Patch Set: Nits 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
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 * * /}); 112 * * /});
113 * 113 *
114 * @param {Function} commentEncodedHtml The html , embedded as a 114 * @param {Function} commentEncodedHtml The html , embedded as a
115 * comment inside an anonymous function - see example, above. 115 * comment inside an anonymous function - see example, above.
116 @ @return {String} The html text. 116 @ @return {String} The html text.
117 */ 117 */
118 extractHtmlFromCommentEncodedString_: function(commentEncodedHtml) { 118 extractHtmlFromCommentEncodedString_: function(commentEncodedHtml) {
119 return commentEncodedHtml.toString(). 119 return commentEncodedHtml.toString().
120 replace(/^[^\/]+\/\*!?/, ''). 120 replace(/^[^\/]+\/\*!?/, '').
121 replace(/\*\/[^\/]+$/, ''); 121 replace(/\*\/[^\/]+$/, '');
122 },
123
124 /**
125 * Waits for the queued events in ChromeVoxEventWatcher to be
126 * handled. Very useful for asserting the results of events.
127 *
128 * @param {function()} func A function to call when ChromeVox is ready.
Peter Lundblad 2014/09/22 07:30:48 nit: mention varargs
dmazzoni 2014/09/22 17:36:20 Done.
129 * @return {ChromeVoxUnitTestBase} this.
130 */
131 waitForCalm: function(func, var_args) {
132 // For convenience, execute the functions in the test case scope.
Peter Lundblad 2014/09/22 07:30:48 This would be more useful if mentioned in the desc
dmazzoni 2014/09/22 17:36:20 Done.
133 var me = this;
134 var calmArguments = Array.prototype.slice.call(arguments);
135 calmArguments.shift();
136 cvox.ChromeVoxEventWatcher.addReadyCallback(function() {
137 func.apply(me, calmArguments);
138 });
139 return this; // for chaining.
140 },
141
142 /**
143 * Asserts a list of utterances are in the correct queue mode.
144 * @param {cvox.SpokenListBuilder|Array} expectedList A list
145 * of [text, queueMode] tuples OR a SpokenListBuilder with the expected
146 * utterances.
147 * @return {ChromeVoxUnitTestBase} this.
148 */
149 assertSpokenList: function(expectedList) {
150 if (expectedList instanceof cvox.SpokenListBuilder) {
151 expectedList = expectedList.build();
152 }
153
154 var ulist = cvox.ChromeVoxTester.testTts().getUtteranceInfoList();
155 for (var i = 0; i < expectedList.length; i++) {
156 var text = expectedList[i][0];
157 var queueMode = expectedList[i][1];
158 this.assertSingleUtterance_(text, queueMode,
159 ulist[i].text, ulist[i].queueMode);
160 }
161 cvox.ChromeVoxTester.clearUtterances();
162 return this; // for chaining.
163 },
164
165 assertSingleUtterance_: function(
166 expectedText, expectedQueueMode, text, queueMode) {
167 assertEquals(expectedQueueMode, queueMode);
168 assertEquals(expectedText, text);
122 } 169 }
123 }; 170 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698