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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/background.extjs

Issue 586103004: Implement ChromeVox next/previous line, link, and heading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Added test (and support). Created 6 years, 2 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
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 // Include test fixture. 5 // Include test fixture.
6 GEN_INCLUDE(['../../testing/chromevox_e2e_test_base.js']); 6 GEN_INCLUDE(['../../testing/chromevox_e2e_test_base.js']);
7 7
8 /** 8 /**
9 * Test fixture for cvox2.Background. 9 * Test fixture for cvox2.Background.
10 * @constructor 10 * @constructor
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 /** 60 /**
61 * Checks to see if a string was spoken. 61 * Checks to see if a string was spoken.
62 * @param {string} textString The string to check. 62 * @param {string} textString The string to check.
63 * @return {boolean} True if the string was spoken (possibly as part of a 63 * @return {boolean} True if the string was spoken (possibly as part of a
64 * larger utterance). 64 * larger utterance).
65 */ 65 */
66 checkIfSubstringWasSpoken: function(textString) { 66 checkIfSubstringWasSpoken: function(textString) {
67 return this.utterances.some(function(t) { 67 return this.utterances.some(function(t) {
68 return t.indexOf(textString) != -1; 68 return t.indexOf(textString) != -1;
69 }); 69 });
70 } 70 },
71
72 /**
73 * Waits for the given strings to be spoken. If satisfied, |opt_callback| is
74 * called.
75 * @param {!Array.<string>} textStrings
76 * @param {function() : void=} opt_callback
77 */
78 waitForSpeech: function(textStrings, opt_callback) {
79 if (this.checkIfSubstringWasSpoken(textStrings[0])) {
80 textStrings.splice(0, 1);
81 if (textStrings.length == 0) {
82 if (opt_callback)
83 opt_callback();
84 this.utterances.length = 0;
85 return;
86 }
87 }
88 setTimeout(this.waitForSpeech.bind(this, textStrings, opt_callback), 100);
dmazzoni 2014/09/26 06:08:52 Rather than a timeout, could you make a way to reg
89 },
71 }; 90 };
72 91
73 /** Tests that ChromeVox classic is in this context. */ 92 /** Tests that ChromeVox classic is in this context. */
74 SYNC_TEST_F('BackgroundTest', 'ClassicNamespaces', function() { 93 SYNC_TEST_F('BackgroundTest', 'ClassicNamespaces', function() {
75 assertEquals('object', typeof(cvox)); 94 assertEquals('object', typeof(cvox));
76 assertEquals('function', typeof(cvox.ChromeVoxBackground)); 95 assertEquals('function', typeof(cvox.ChromeVoxBackground));
77 }); 96 });
78 97
79 /** Tests that ChromeVox next is in this context. */ 98 /** Tests that ChromeVox next is in this context. */
80 SYNC_TEST_F('BackgroundTest', 'NextNamespaces', function() { 99 SYNC_TEST_F('BackgroundTest', 'NextNamespaces', function() {
(...skipping 22 matching lines...) Expand all
103 testButton.addEventListener(chrome.automation.EventType.focus, 122 testButton.addEventListener(chrome.automation.EventType.focus,
104 function(e) { 123 function(e) {
105 var result = 124 var result =
106 cvox.ChromeVox.tts.checkIfSubstringWasSpoken('Status tray'); 125 cvox.ChromeVox.tts.checkIfSubstringWasSpoken('Status tray');
107 testDone([result, '']); 126 testDone([result, '']);
108 }, 127 },
109 true); 128 true);
110 testButton.focus(); 129 testButton.focus();
111 }); 130 });
112 }); 131 });
132
133 TEST_F('BackgroundTest', 'InitialFeedback', function() {
134 this.runWithDocument(function() {/*!
135 <p>start
136 <p>end
137 */},
138 function() {
139 cvox.ChromeVox.tts.waitForSpeech(['start'], function() {
140 cvox2.global.backgroundObj.onGotCommand('nextLine');
141 cvox.ChromeVox.tts.waitForSpeech(['end'], function() {
142 testDone();
143 });
144 });
145 }.bind(this));
146 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698