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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/testing/mock_tts.js

Issue 845693004: Initial implementation of continuous read for ChromeVox Next. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove e2e test. Created 5 years, 11 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/manifest.json.jinja2 ('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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * Mock tts class. 6 * Mock tts class.
7 * @constructor 7 * @constructor
8 * @extends {cvox.TtsInterface} 8 * @extends {cvox.TtsInterface}
9 */ 9 */
10 var MockTts = function() { 10 var MockTts = function() {
11 /**
12 * The event handler for the most recent call to |speak|.
13 * @private
14 */
15 this.onEvent_;
11 }; 16 };
12 17
13 MockTts.prototype = { 18 MockTts.prototype = {
14 /** 19 /**
15 * A list of predicate, start, and end callbacks for a pending expectation. 20 * A list of predicate, start, and end callbacks for a pending expectation.
16 * @type {!Array.<{{predicate: function(string) : boolean, 21 * @type {!Array.<{{predicate: function(string) : boolean,
17 * startCallback: function() : void, 22 * startCallback: function() : void,
18 * endCallback: function() : void}>} 23 * endCallback: function() : void}>}
19 * @private 24 * @private
20 */ 25 */
21 expectations_: [], 26 expectations_: [],
22 27
23 /** 28 /**
24 * A list of strings stored whenever there are no expectations. 29 * A list of strings stored whenever there are no expectations.
25 * @type {!Array.<string} 30 * @type {!Array.<string}
26 * @private 31 * @private
27 */ 32 */
28 idleUtterances_: [], 33 idleUtterances_: [],
29 34
30 /** @override */ 35 /** @override */
31 speak: function(textString, queueMode, properties) { 36 speak: function(textString, queueMode, properties) {
37 if (properties)
38 this.onEvent_ = properties['onEvent'];
39
32 this.process_(textString); 40 this.process_(textString);
33 }, 41 },
34 42
35 /** 43 /**
36 * Adds an expectation for the given string to be spoken. If satisfied, 44 * Adds an expectation for the given string to be spoken. If satisfied,
37 * |opt_callback| is called. 45 * |opt_callback| is called.
38 * @param {string} expectedText 46 * @param {string} expectedText
39 * @param {function() : void=} opt_callback 47 * @param {function() : void=} opt_callback
40 * @param {boolean=} opt_exact Expect an exact match; defaults to false. 48 * @param {boolean=} opt_exact Expect an exact match; defaults to false.
41 */ 49 */
(...skipping 20 matching lines...) Expand all
62 }, 70 },
63 71
64 /** 72 /**
65 * Finishes expectations and calls testDone. 73 * Finishes expectations and calls testDone.
66 */ 74 */
67 finishExpectations: function() { 75 finishExpectations: function() {
68 this.expectSpeechAfter('', testDone); 76 this.expectSpeechAfter('', testDone);
69 }, 77 },
70 78
71 /** 79 /**
80 * Fakes an event to |onEvent|.
81 */
82 sendStartEvent: function() {
83 if (this.onEvent_)
84 this.onEvent_({type: 'start'});
85 },
86
87 /**
88 * Fakes an event to |onEvent|.
89 */
90 sendEndEvent: function() {
91 if (this.onEvent_)
92 this.onEvent_({type: 'end'});
93 },
94
95 /**
72 * @private 96 * @private
73 * @param {string} expectedText Text expected spoken. 97 * @param {string} expectedText Text expected spoken.
74 * @param {{startCallback: function() : void, 98 * @param {{startCallback: function() : void,
75 * endCallback: function() : void}=} opt_expectation 99 * endCallback: function() : void}=} opt_expectation
76 * @param {boolean=} opt_exact Expects an exact match. 100 * @param {boolean=} opt_exact Expects an exact match.
77 */ 101 */
78 addExpectation_: function(expectedText, opt_expectation, opt_exact) { 102 addExpectation_: function(expectedText, opt_expectation, opt_exact) {
79 var expectation = opt_expectation ? opt_expectation : {}; 103 var expectation = opt_expectation ? opt_expectation : {};
80 104
81 expectation.predicate = function(actualText) { 105 expectation.predicate = function(actualText) {
(...skipping 29 matching lines...) Expand all
111 if (targetExpectation.endCallback) 135 if (targetExpectation.endCallback)
112 targetExpectation.endCallback(); 136 targetExpectation.endCallback();
113 var nextExpectation = this.expectations_[0]; 137 var nextExpectation = this.expectations_[0];
114 if (nextExpectation && nextExpectation.startCallback) 138 if (nextExpectation && nextExpectation.startCallback)
115 nextExpectation.startCallback(); 139 nextExpectation.startCallback();
116 } else { 140 } else {
117 this.expectations_.unshift(targetExpectation); 141 this.expectations_.unshift(targetExpectation);
118 } 142 }
119 }, 143 },
120 }; 144 };
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/manifest.json.jinja2 ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698