| OLD | NEW |
| 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 /** | 5 /** |
| 6 * Mock tts class. | 6 * Mock tts class. |
| 7 * @constructor | 7 * @constructor |
| 8 * @extends {cvox.TtsInterface} | 8 * @extends {cvox.TtsInterface} |
| 9 */ | 9 */ |
| 10 var MockTts = function() { | 10 var MockTts = function() { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 expectSpeechAfter: function(expectedText, opt_callback, opt_exact) { | 55 expectSpeechAfter: function(expectedText, opt_callback, opt_exact) { |
| 56 var expectation = {}; | 56 var expectation = {}; |
| 57 if (this.expectations_.length == 0 && opt_callback) | 57 if (this.expectations_.length == 0 && opt_callback) |
| 58 opt_callback(); | 58 opt_callback(); |
| 59 else | 59 else |
| 60 expectation.startCallback = opt_callback; | 60 expectation.startCallback = opt_callback; |
| 61 this.addExpectation_(expectedText, expectation, opt_exact); | 61 this.addExpectation_(expectedText, expectation, opt_exact); |
| 62 }, | 62 }, |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * Finishes expectations and calls testDone. | 65 * Finishes expectations and calls {@code callback} afterwards. |
| 66 * @param {Function} callback |
| 66 */ | 67 */ |
| 67 finishExpectations: function() { | 68 finishExpectations: function(callback) { |
| 68 this.expectSpeechAfter('', testDone); | 69 this.expectSpeechAfter('', callback); |
| 69 }, | 70 }, |
| 70 | 71 |
| 71 /** | 72 /** |
| 72 * @private | 73 * @private |
| 73 * @param {string} expectedText Text expected spoken. | 74 * @param {string} expectedText Text expected spoken. |
| 74 * @param {{startCallback: function() : void, | 75 * @param {{startCallback: function() : void, |
| 75 * endCallback: function() : void}=} opt_expectation | 76 * endCallback: function() : void}=} opt_expectation |
| 76 * @param {boolean=} opt_exact Expects an exact match. | 77 * @param {boolean=} opt_exact Expects an exact match. |
| 77 */ | 78 */ |
| 78 addExpectation_: function(expectedText, opt_expectation, opt_exact) { | 79 addExpectation_: function(expectedText, opt_expectation, opt_exact) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 matchingProperties.endCallback(); | 122 matchingProperties.endCallback(); |
| 122 } | 123 } |
| 123 var nextExpectation = this.expectations_[0]; | 124 var nextExpectation = this.expectations_[0]; |
| 124 if (nextExpectation && nextExpectation.startCallback) | 125 if (nextExpectation && nextExpectation.startCallback) |
| 125 nextExpectation.startCallback(); | 126 nextExpectation.startCallback(); |
| 126 } else { | 127 } else { |
| 127 this.expectations_.unshift(targetExpectation); | 128 this.expectations_.unshift(targetExpectation); |
| 128 } | 129 } |
| 129 }, | 130 }, |
| 130 }; | 131 }; |
| OLD | NEW |