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

Unified Diff: chrome/browser/resources/chromeos/chromevox/testing/mock_tts.js

Issue 955643006: Allows endCallbacks in tts to queue up speech in the speech queue and simplify speech output logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/host/chrome/tts_background.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/chromeos/chromevox/testing/mock_tts.js
diff --git a/chrome/browser/resources/chromeos/chromevox/testing/mock_tts.js b/chrome/browser/resources/chromeos/chromevox/testing/mock_tts.js
index 04fdb7d39b83dcc9fe45289da30faf2af30d00a1..3308992120cd8b9da4a5ad9930711d707f739dd7 100644
--- a/chrome/browser/resources/chromeos/chromevox/testing/mock_tts.js
+++ b/chrome/browser/resources/chromeos/chromevox/testing/mock_tts.js
@@ -8,11 +8,6 @@
* @extends {cvox.TtsInterface}
*/
var MockTts = function() {
- /**
- * The event handler for the most recent call to |speak|.
- * @private
- */
- this.onEvent_;
};
MockTts.prototype = {
@@ -34,10 +29,7 @@ MockTts.prototype = {
/** @override */
speak: function(textString, queueMode, properties) {
- if (properties)
- this.onEvent_ = properties['onEvent'];
-
- this.process_(textString);
+ this.process_(textString, false, properties);
},
/**
@@ -77,22 +69,6 @@ MockTts.prototype = {
},
/**
- * Fakes an event to |onEvent|.
- */
- sendStartEvent: function() {
- if (this.onEvent_)
- this.onEvent_({type: 'start'});
- },
-
- /**
- * Fakes an event to |onEvent|.
- */
- sendEndEvent: function() {
- if (this.onEvent_)
- this.onEvent_({type: 'end'});
- },
-
- /**
* @private
* @param {string} expectedText Text expected spoken.
* @param {{startCallback: function() : void,
@@ -112,28 +88,38 @@ MockTts.prototype = {
// Process any idleUtterances.
this.idleUtterances_.forEach(function(utterance) {
- this.process_(utterance, true);
+ this.process_(utterance.text, true, utterance.properties);
}.bind(this));
},
/**
* @param {string} textString Utterance to match against callbacks.
* @param {boolean=} opt_manual True if called outside of tts.speak.
+ * @param {!Object=} opt_properties
* @private
*/
- process_: function(textString, opt_manual) {
+ process_: function(textString, opt_manual, opt_properties) {
+ var utterance = {text: textString, properties: opt_properties};
if (this.expectations_.length == 0) {
- if (!opt_manual)
- this.idleUtterances_.push(textString);
+ if (!opt_manual) {
+ this.idleUtterances_.push(utterance);
+ }
return;
}
- var allUtterances = this.idleUtterances_.concat([textString]);
+ var allUtterances = this.idleUtterances_.concat([utterance]);
var targetExpectation = this.expectations_.shift();
- if (allUtterances.some(targetExpectation.predicate)) {
+ allUtterances = allUtterances.filter(function(u) {
+ return targetExpectation.predicate(u.text);
+ });
+ if (allUtterances.length > 0) {
+ var matchingProperties = allUtterances[0].properties;
this.idleUtterances_.length = 0;
if (targetExpectation.endCallback)
targetExpectation.endCallback();
+ if (matchingProperties && matchingProperties.endCallback) {
+ matchingProperties.endCallback();
+ }
var nextExpectation = this.expectations_[0];
if (nextExpectation && nextExpectation.startCallback)
nextExpectation.startCallback();
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/host/chrome/tts_background.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698