OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** | 5 /** |
6 * @fileoverview This file contains the |MockFeedback| class which is a | 6 * @fileoverview This file contains the |MockFeedback| class which is a |
7 * combined mock class for speech and braille feedback. A test that uses | 7 * combined mock class for speech and braille feedback. A test that uses |
8 * this class may add expectations for speech utterances and braille display | 8 * this class may add expectations for speech utterances and braille display |
9 * content to be output. The |install| method sets appropriate mock classes | 9 * content to be output. The |install| method sets appropriate mock classes |
10 * as the |cvox.ChromeVox.tts| and |cvox.ChromeVox.braille| objects, | 10 * as the |cvox.ChromeVox.tts| and |cvox.ChromeVox.braille| objects, |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 return !!MockFeedback.matchAndConsume_( | 134 return !!MockFeedback.matchAndConsume_( |
135 text, {}, this.pendingUtterances_); | 135 text, {}, this.pendingUtterances_); |
136 }.bind(this), | 136 }.bind(this), |
137 toString: function() { return 'Speak \'' + text + '\''; } | 137 toString: function() { return 'Speak \'' + text + '\''; } |
138 }); | 138 }); |
139 }.bind(this)); | 139 }.bind(this)); |
140 return this; | 140 return this; |
141 }, | 141 }, |
142 | 142 |
143 /** | 143 /** |
144 * Adds an expectation that the next spoken utterances do *not* match | |
145 * the given arguments. | |
146 * @param {...(string|RegExp)} var_args One or more utterance to add as | |
Peter Lundblad
2015/08/26 18:42:37
One or more utterances.
| |
147 * negative expectations. | |
148 * @return {MockFeedback} |this| for chaining | |
149 */ | |
150 expectNextSpeechUtteranceIsNot: function() { | |
151 assertFalse(this.replaying_); | |
152 Array.prototype.forEach.call(arguments, function(text) { | |
153 this.pendingActions_.push({ | |
154 perform: function() { | |
155 if (this.pendingUtterances_.length == 0) | |
156 return false; | |
157 if (MockFeedback.matchAndConsume_( | |
158 text, {}, this.pendingUtterances_)) { | |
159 throw new Error('Got disallowed utterance "' + text + '".'); | |
160 } | |
161 return true; | |
162 }.bind(this), | |
163 toString: function() { return 'Do not speak \'' + text + '\''; } | |
164 }); | |
165 }.bind(this)); | |
166 return this; | |
167 }, | |
168 | |
169 /** | |
144 * Adds an expectation for braille output. | 170 * Adds an expectation for braille output. |
145 * @param {string|RegExp} text | 171 * @param {string|RegExp} text |
146 * @param {Object=} opt_props Additional properties to match in the | 172 * @param {Object=} opt_props Additional properties to match in the |
147 * |NavBraille| | 173 * |NavBraille| |
148 * @return {MockFeedback} |this| for chaining | 174 * @return {MockFeedback} |this| for chaining |
149 */ | 175 */ |
150 expectBraille: function(text, opt_props) { | 176 expectBraille: function(text, opt_props) { |
151 assertFalse(this.replaying_); | 177 assertFalse(this.replaying_); |
152 var props = opt_props || {}; | 178 var props = opt_props || {}; |
153 this.pendingActions_.push({ | 179 this.pendingActions_.push({ |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 } | 349 } |
324 if (candidate) { | 350 if (candidate) { |
325 var consumed = pending.splice(0, i + 1); | 351 var consumed = pending.splice(0, i + 1); |
326 consumed.forEach(function(item) { | 352 consumed.forEach(function(item) { |
327 if (item.callback) | 353 if (item.callback) |
328 item.callback(); | 354 item.callback(); |
329 }); | 355 }); |
330 } | 356 } |
331 return candidate; | 357 return candidate; |
332 }; | 358 }; |
OLD | NEW |