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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Include test fixture.
6 GEN_INCLUDE(['chromevox_unittest_base.js',
7 'mock_feedback.js']);
8
9 function speak(text, opt_endCallback) {
10 cvox.ChromeVox.tts.speak(text, 0, {endCallback: opt_endCallback});
11 }
12
13 function braille(text) {
14 cvox.ChromeVox.braille.write(cvox.NavBraille.fromText(text));
15 }
16
17 /**
18 * Test fixture.
19 * @constructor
20 * @extends {ChromeVoxUnitTestBase}
21 */
22 function MockFeedbackUnitTest() {
23 ChromeVoxUnitTestBase.call(this);
24 }
25
26 MockFeedbackUnitTest.prototype = {
27 __proto__: ChromeVoxUnitTestBase.prototype,
28
29 setUp: function() {
30 cvox.ChromeVox = cvox.ChromeVox || {};
31 },
32
33 closureModuleDeps: [
34 'cvox.BrailleInterface',
35 'cvox.NavBraille',
36 'cvox.TtsInterface'
37 ]
38 };
39
40 TEST_F('MockFeedbackUnitTest', 'speechAndCallbacks', function() {
41 var finishCalled = false;
42 var afterSecondStringCalled = false;
43 var spruiousStringEndCallbackCalled = false;
44 var mock = new MockFeedback(function() {
45 assertTrue(afterSecondStringCalled);
46 assertTrue(spruiousStringEndCallbackCalled);
47 assertFalse(finishCalled);
48 finishCalled = true;
49 });
50 mock.install();
51 speak('First string');
52 mock.expectSpeech('First string')
53 .expectSpeech('Second string')
54 .call(function() {
55 assertFalse(afterSecondStringCalled);
56 afterSecondStringCalled = true;
57 speak('Spurious string', function() {
58 assertFalse(spruiousStringEndCallbackCalled);
59 spruiousStringEndCallbackCalled = true;
60 });
61 speak('Third string');
62 })
63 .expectSpeech('Third string')
64 .go();
65 assertFalse(finishCalled);
66 speak('Second string');
67 assertTrue(finishCalled);
68 });
69
70 TEST_F('MockFeedbackUnitTest', 'SpeechAndBraille', function() {
71 var finishCalled = false;
72 var mock = new MockFeedback(function() { finishCalled = true; });
73 mock.install();
74 braille('Some braille');
75 speak('Some speech');
76 mock.call(function() {
77 braille('First expected braille');
78 speak('First expected speech');
79 })
80 .expectSpeech('First expected speech')
81 .expectBraille('First expected braille')
82 .go();
83 assertTrue(finishCalled);
84 });
85
86 TEST_F('MockFeedbackUnitTest', 'expectWithRegex', function() {
87 var done = false;
88 var mock = new MockFeedback();
89 mock.install();
90 mock.call(function() { braille('Item 1 of 14'); })
91 .expectBraille(/Item \d+ of \d+/)
92 .call(function() { done = true;})
93 .go();
94 assertTrue(done);
95 });
96
97 TEST_F('MockFeedbackUnitTest', 'expectAfterGoThrows', function() {
98 var mock = new MockFeedback();
99 mock.go();
100 assertException('', function() {
101 mock.expectSpeech('hello');
102 }, 'Error');
103 });
104
105 TEST_F('MockFeedbackUnitTest', 'NoMatchDoesNotFinish', function() {
106 var firstCallbackCalled = false;
107 var mock = new MockFeedback(function() {
108 throw Error('Should not be called');
109 });
110 mock.install();
111 braille('Some string');
112 mock.call(function() {
113 braille('Some other string');
114 firstCallbackCalled = true;
115 })
116 .expectBraille('Unmatched string')
117 .call(function() {
118 throw Error('Should not be called');
119 })
120 .go();
121 assertTrue(firstCallbackCalled);
122 });
OLDNEW
« 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