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

Unified Diff: chrome/browser/resources/chromeos/chromevox/testing/mock_feedback_test.unitjs

Issue 1295773002: Make testDone unavailable for chromevox tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: n Created 5 years, 4 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/testing/mock_feedback.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_feedback_test.unitjs
diff --git a/chrome/browser/resources/chromeos/chromevox/testing/mock_feedback_test.unitjs b/chrome/browser/resources/chromeos/chromevox/testing/mock_feedback_test.unitjs
new file mode 100644
index 0000000000000000000000000000000000000000..0c7bb07e79431b4f3136e7dc556f5e57a8483f6c
--- /dev/null
+++ b/chrome/browser/resources/chromeos/chromevox/testing/mock_feedback_test.unitjs
@@ -0,0 +1,122 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Include test fixture.
+GEN_INCLUDE(['chromevox_unittest_base.js',
+ 'mock_feedback.js']);
+
+function speak(text, opt_endCallback) {
+ cvox.ChromeVox.tts.speak(text, 0, {endCallback: opt_endCallback});
+}
+
+function braille(text) {
+ cvox.ChromeVox.braille.write(cvox.NavBraille.fromText(text));
+}
+
+/**
+ * Test fixture.
+ * @constructor
+ * @extends {ChromeVoxUnitTestBase}
+ */
+function MockFeedbackUnitTest() {
+ ChromeVoxUnitTestBase.call(this);
+}
+
+MockFeedbackUnitTest.prototype = {
+ __proto__: ChromeVoxUnitTestBase.prototype,
+
+ setUp: function() {
+ cvox.ChromeVox = cvox.ChromeVox || {};
+ },
+
+ closureModuleDeps: [
+ 'cvox.BrailleInterface',
+ 'cvox.NavBraille',
+ 'cvox.TtsInterface'
+ ]
+};
+
+TEST_F('MockFeedbackUnitTest', 'speechAndCallbacks', function() {
+ var finishCalled = false;
+ var afterSecondStringCalled = false;
+ var spruiousStringEndCallbackCalled = false;
+ var mock = new MockFeedback(function() {
+ assertTrue(afterSecondStringCalled);
+ assertTrue(spruiousStringEndCallbackCalled);
+ assertFalse(finishCalled);
+ finishCalled = true;
+ });
+ mock.install();
+ speak('First string');
+ mock.expectSpeech('First string')
+ .expectSpeech('Second string')
+ .call(function() {
+ assertFalse(afterSecondStringCalled);
+ afterSecondStringCalled = true;
+ speak('Spurious string', function() {
+ assertFalse(spruiousStringEndCallbackCalled);
+ spruiousStringEndCallbackCalled = true;
+ });
+ speak('Third string');
+ })
+ .expectSpeech('Third string')
+ .go();
+ assertFalse(finishCalled);
+ speak('Second string');
+ assertTrue(finishCalled);
+});
+
+TEST_F('MockFeedbackUnitTest', 'SpeechAndBraille', function() {
+ var finishCalled = false;
+ var mock = new MockFeedback(function() { finishCalled = true; });
+ mock.install();
+ braille('Some braille');
+ speak('Some speech');
+ mock.call(function() {
+ braille('First expected braille');
+ speak('First expected speech');
+ })
+ .expectSpeech('First expected speech')
+ .expectBraille('First expected braille')
+ .go();
+ assertTrue(finishCalled);
+});
+
+TEST_F('MockFeedbackUnitTest', 'expectWithRegex', function() {
+ var done = false;
+ var mock = new MockFeedback();
+ mock.install();
+ mock.call(function() { braille('Item 1 of 14'); })
+ .expectBraille(/Item \d+ of \d+/)
+ .call(function() { done = true;})
+ .go();
+ assertTrue(done);
+});
+
+TEST_F('MockFeedbackUnitTest', 'expectAfterGoThrows', function() {
+ var mock = new MockFeedback();
+ mock.go();
+ assertException('', function() {
+ mock.expectSpeech('hello');
+ }, 'Error');
+});
+
+TEST_F('MockFeedbackUnitTest', 'NoMatchDoesNotFinish', function() {
+ var firstCallbackCalled = false;
+ var mock = new MockFeedback(function() {
+ throw Error('Should not be called');
+ });
+ mock.install();
+ braille('Some string');
+ mock.call(function() {
+ braille('Some other string');
+ firstCallbackCalled = true;
+ })
+ .expectBraille('Unmatched string')
+ .call(function() {
+ throw Error('Should not be called');
+ })
+ .go();
+ assertTrue(firstCallbackCalled);
+});
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/testing/mock_feedback.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698