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

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

Issue 582123002: Port live region ChromeVox tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chromevox_keyboard_tests_again
Patch Set: Improve comments in chromevox_unittest_base Created 6 years, 3 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
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..0e598a0a57bd8ee0448309584cc091324108e947 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,53 @@ ChromeVoxUnitTestBase.prototype = {
return commentEncodedHtml.toString().
replace(/^[^\/]+\/\*!?/, '').
replace(/\*\/[^\/]+$/, '');
+ },
+
+ /**
+ * Waits for the queued events in ChromeVoxEventWatcher to be
+ * handled, then calls a callback function with provided arguments
+ * in the test case scope. Very useful for asserting the results of events.
+ *
+ * @param {function()} func A function to call when ChromeVox is ready.
+ * @param {*} var_args Additional arguments to pass through to the function.
+ * @return {ChromeVoxUnitTestBase} this.
+ */
+ waitForCalm: function(func, var_args) {
+ 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);
}
};

Powered by Google App Engine
This is Rietveld 408576698