Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/background.extjs |
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.extjs b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.extjs |
index 207d70732f405a2234804763e1e61a6ed1adc7bb..8d21b34b117f9847e077537432233ac7e24898c8 100644 |
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.extjs |
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.extjs |
@@ -67,7 +67,26 @@ MockTts.prototype = { |
return this.utterances.some(function(t) { |
return t.indexOf(textString) != -1; |
}); |
- } |
+ }, |
+ |
+ /** |
+ * Waits for the given strings to be spoken. If satisfied, |opt_callback| is |
+ * called. |
+ * @param {!Array.<string>} textStrings |
+ * @param {function() : void=} opt_callback |
+ */ |
+ waitForSpeech: function(textStrings, opt_callback) { |
+ if (this.checkIfSubstringWasSpoken(textStrings[0])) { |
+ textStrings.splice(0, 1); |
+ if (textStrings.length == 0) { |
+ if (opt_callback) |
+ opt_callback(); |
+ this.utterances.length = 0; |
+ return; |
+ } |
+ } |
+ setTimeout(this.waitForSpeech.bind(this, textStrings, opt_callback), 100); |
dmazzoni
2014/09/26 06:08:52
Rather than a timeout, could you make a way to reg
|
+ }, |
}; |
/** Tests that ChromeVox classic is in this context. */ |
@@ -110,3 +129,18 @@ TEST_F('BackgroundTest', 'DesktopFocus', function() { |
testButton.focus(); |
}); |
}); |
+ |
+TEST_F('BackgroundTest', 'InitialFeedback', function() { |
+ this.runWithDocument(function() {/*! |
+ <p>start |
+ <p>end |
+ */}, |
+ function() { |
+ cvox.ChromeVox.tts.waitForSpeech(['start'], function() { |
+ cvox2.global.backgroundObj.onGotCommand('nextLine'); |
+ cvox.ChromeVox.tts.waitForSpeech(['end'], function() { |
+ testDone(); |
+ }); |
+ }); |
+ }.bind(this)); |
+}); |