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

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

Issue 674263003: Add remaining text/caret navigation commands to ChromeVox Next. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@integrate_cursor
Patch Set: Add comments. Created 6 years, 1 month 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
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() {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 var expectation = {}; 42 var expectation = {};
43 expectation.endCallback = opt_callback; 43 expectation.endCallback = opt_callback;
44 this.addExpectation_(expectedText, expectation); 44 this.addExpectation_(expectedText, expectation);
45 }, 45 },
46 46
47 /** 47 /**
48 * Adds an expectation for the given string to be spoken after |opt_callback| 48 * Adds an expectation for the given string to be spoken after |opt_callback|
49 * executes. 49 * executes.
50 * @param {string} expectedText 50 * @param {string} expectedText
51 * @param {function() : void=} opt_callback 51 * @param {function() : void=} opt_callback
52 * @param {boolean=} opt_exact Expect an exact match; defaults to false.
52 */ 53 */
53 expectSpeechAfter: function(expectedText, opt_callback) { 54 expectSpeechAfter: function(expectedText, opt_callback, opt_exact) {
54 var expectation = {}; 55 var expectation = {};
55 if (this.expectations_.length == 0 && opt_callback) 56 if (this.expectations_.length == 0 && opt_callback)
56 opt_callback(); 57 opt_callback();
57 else 58 else
58 expectation.startCallback = opt_callback; 59 expectation.startCallback = opt_callback;
59 this.addExpectation_(expectedText, expectation); 60 this.addExpectation_(expectedText, expectation, opt_exact);
60 }, 61 },
61 62
62 /** 63 /**
63 * Finishes expectations and calls testDone. 64 * Finishes expectations and calls testDone.
64 */ 65 */
65 finishExpectations: function() { 66 finishExpectations: function() {
66 this.expectSpeechAfter('', testDone); 67 this.expectSpeechAfter('', testDone);
67 }, 68 },
68 69
69 /** 70 /**
70 * @private 71 * @private
71 * @param {string} expectedText Text expected spoken. 72 * @param {string} expectedText Text expected spoken.
72 * @param {{startCallback: function() : void, 73 * @param {{startCallback: function() : void,
73 * endCallback: function() : void}=} opt_expectation 74 * endCallback: function() : void}=} opt_expectation
75 * @param {boolean=} opt_exact Expects an exact match.
74 */ 76 */
75 addExpectation_: function(expectedText, opt_expectation) { 77 addExpectation_: function(expectedText, opt_expectation, opt_exact) {
76 var expectation = opt_expectation ? opt_expectation : {}; 78 var expectation = opt_expectation ? opt_expectation : {};
77 79
78 expectation.predicate = function(actualText) { 80 expectation.predicate = function(actualText) {
81 if (opt_exact)
82 return actualText === expectedText;
79 return actualText.indexOf(expectedText) != -1; 83 return actualText.indexOf(expectedText) != -1;
80 }; 84 };
81 85
82 this.expectations_.push(expectation); 86 this.expectations_.push(expectation);
83 87
84 // Process any idleUtterances. 88 // Process any idleUtterances.
85 this.idleUtterances_.forEach(function(utterance) { 89 this.idleUtterances_.forEach(function(utterance) {
86 this.process_(utterance, true); 90 this.process_(utterance, true);
87 }); 91 });
88 }, 92 },
(...skipping 17 matching lines...) Expand all
106 if (targetExpectation.endCallback) 110 if (targetExpectation.endCallback)
107 targetExpectation.endCallback(); 111 targetExpectation.endCallback();
108 var nextExpectation = this.expectations_[0]; 112 var nextExpectation = this.expectations_[0];
109 if (nextExpectation && nextExpectation.startCallback) 113 if (nextExpectation && nextExpectation.startCallback)
110 nextExpectation.startCallback(); 114 nextExpectation.startCallback();
111 } else { 115 } else {
112 this.expectations_.unshift(targetExpectation); 116 this.expectations_.unshift(targetExpectation);
113 } 117 }
114 }, 118 },
115 }; 119 };
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/manifest.json.jinja2 ('k') | chrome/common/extensions/command.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698