Chromium Code Reviews| Index: chrome/browser/resources/chromeos/chromevox/testing/chromevox_unittest_base.js |
| diff --git a/chrome/browser/resources/chromeos/chromevox/testing/chromevox_unittest_base.js b/chrome/browser/resources/chromeos/chromevox/testing/chromevox_unittest_base.js |
| index f09aa2788dac732a6757f1155ff6fb7cc2ba6ef7..e438c23ded224b14c8d51c6ae02950d02cf65461 100644 |
| --- a/chrome/browser/resources/chromeos/chromevox/testing/chromevox_unittest_base.js |
| +++ b/chrome/browser/resources/chromeos/chromevox/testing/chromevox_unittest_base.js |
| @@ -119,5 +119,52 @@ ChromeVoxUnitTestBase.prototype = { |
| return commentEncodedHtml.toString(). |
| replace(/^[^\/]+\/\*!?/, ''). |
| replace(/\*\/[^\/]+$/, ''); |
| + }, |
| + |
| + /** |
| + * Waits for the queued events in ChromeVoxEventWatcher to be |
| + * handled. Very useful for asserting the results of events. |
| + * |
| + * @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.
|
| + * @return {ChromeVoxUnitTestBase} this. |
| + */ |
| + waitForCalm: function(func, var_args) { |
| + // 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.
|
| + var me = this; |
| + var calmArguments = Array.prototype.slice.call(arguments); |
| + calmArguments.shift(); |
| + cvox.ChromeVoxEventWatcher.addReadyCallback(function() { |
| + func.apply(me, calmArguments); |
| + }); |
| + return this; // for chaining. |
| + }, |
| + |
| + /** |
| + * Asserts a list of utterances are in the correct queue mode. |
| + * @param {cvox.SpokenListBuilder|Array} expectedList A list |
| + * of [text, queueMode] tuples OR a SpokenListBuilder with the expected |
| + * utterances. |
| + * @return {ChromeVoxUnitTestBase} this. |
| + */ |
| + assertSpokenList: function(expectedList) { |
| + if (expectedList instanceof cvox.SpokenListBuilder) { |
| + expectedList = expectedList.build(); |
| + } |
| + |
| + var ulist = cvox.ChromeVoxTester.testTts().getUtteranceInfoList(); |
| + for (var i = 0; i < expectedList.length; i++) { |
| + var text = expectedList[i][0]; |
| + var queueMode = expectedList[i][1]; |
| + this.assertSingleUtterance_(text, queueMode, |
| + ulist[i].text, ulist[i].queueMode); |
| + } |
| + cvox.ChromeVoxTester.clearUtterances(); |
| + return this; // for chaining. |
| + }, |
| + |
| + assertSingleUtterance_: function( |
| + expectedText, expectedQueueMode, text, queueMode) { |
| + assertEquals(expectedQueueMode, queueMode); |
| + assertEquals(expectedText, text); |
| } |
| }; |