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

Side by Side Diff: chrome/test/data/extensions/api_test/tts_engine/register_engine/test.js

Issue 7282048: Update TTS extension API docs to reflect latest changes. Note that this (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/data/extensions/api_test/tts_engine/engine_word_callbacks/test.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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // TTS api test for Chrome on ChromeOS. 5 // TTS api test for Chrome on ChromeOS.
6 // browser_tests.exe --gtest_filter="TtsApiTest.*" 6 // browser_tests.exe --gtest_filter="TtsApiTest.*"
7 7
8 if (!chrome.tts) { 8 if (!chrome.tts) {
9 chrome.tts = chrome.experimental.tts; 9 chrome.tts = chrome.experimental.tts;
10 } 10 }
11 11
12 if (!chrome.ttsEngine) { 12 if (!chrome.ttsEngine) {
13 chrome.ttsEngine = chrome.experimental.ttsEngine; 13 chrome.ttsEngine = chrome.experimental.ttsEngine;
14 } 14 }
15 15
16 chrome.test.runTests([ 16 chrome.test.runTests([
17 function testNoListeners() { 17 function testNoListeners() {
18 // This call should go to native speech because we haven't registered 18 // This call should go to native speech because we haven't registered
19 // any listeners. 19 // any listeners.
20 chrome.tts.speak( 20 chrome.tts.speak(
21 'native speech', 21 'native speech',
22 { 22 {
23 'onevent': function(event) { 23 'onEvent': function(event) {
24 if (event.type == 'end') { 24 if (event.type == 'end') {
25 chrome.test.succeed(); 25 chrome.test.succeed();
26 } 26 }
27 } 27 }
28 }, function() { 28 }, function() {
29 chrome.test.assertNoLastError(); 29 chrome.test.assertNoLastError();
30 }); 30 });
31 }, 31 },
32 function testTtsEngine() { 32 function testTtsEngine() {
33 var calledOurEngine = false; 33 var calledOurEngine = false;
34 34
35 // Register listeners for speech functions, enabling this extension 35 // Register listeners for speech functions, enabling this extension
36 // to be a TTS engine. 36 // to be a TTS engine.
37 var speakListener = function(utterance, options, sendTtsEvent) { 37 var speakListener = function(utterance, options, sendTtsEvent) {
38 chrome.test.assertNoLastError(); 38 chrome.test.assertNoLastError();
39 chrome.test.assertEq('extension speech', utterance); 39 chrome.test.assertEq('extension speech', utterance);
40 calledOurEngine = true; 40 calledOurEngine = true;
41 sendTtsEvent({'type': 'end', 'charIndex': utterance.length}); 41 sendTtsEvent({'type': 'end', 'charIndex': utterance.length});
42 }; 42 };
43 var stopListener = function() {}; 43 var stopListener = function() {};
44 chrome.ttsEngine.onSpeak.addListener(speakListener); 44 chrome.ttsEngine.onSpeak.addListener(speakListener);
45 chrome.ttsEngine.onStop.addListener(stopListener); 45 chrome.ttsEngine.onStop.addListener(stopListener);
46 46
47 // This call should go to our own speech engine. 47 // This call should go to our own speech engine.
48 chrome.tts.speak( 48 chrome.tts.speak(
49 'extension speech', 49 'extension speech',
50 { 50 {
51 'onevent': function(event) { 51 'onEvent': function(event) {
52 if (event.type == 'end') { 52 if (event.type == 'end') {
53 chrome.test.assertEq(true, calledOurEngine); 53 chrome.test.assertEq(true, calledOurEngine);
54 chrome.ttsEngine.onSpeak.removeListener(speakListener); 54 chrome.ttsEngine.onSpeak.removeListener(speakListener);
55 chrome.ttsEngine.onStop.removeListener(stopListener); 55 chrome.ttsEngine.onStop.removeListener(stopListener);
56 chrome.test.succeed(); 56 chrome.test.succeed();
57 } 57 }
58 } 58 }
59 }, 59 },
60 function() { 60 function() {
61 chrome.test.assertNoLastError(); 61 chrome.test.assertNoLastError();
(...skipping 15 matching lines...) Expand all
77 chrome.ttsEngine.onStop.addListener(stopListener); 77 chrome.ttsEngine.onStop.addListener(stopListener);
78 78
79 // These don't match the voices in the manifest, so they should 79 // These don't match the voices in the manifest, so they should
80 // go to native speech. The gmock assertions in TtsApiTest::RegisterEngine 80 // go to native speech. The gmock assertions in TtsApiTest::RegisterEngine
81 // enforce that the native TTS handlers are called. 81 // enforce that the native TTS handlers are called.
82 chrome.tts.speak( 82 chrome.tts.speak(
83 'native speech 2', 83 'native speech 2',
84 { 84 {
85 'voiceName': 'George', 85 'voiceName': 'George',
86 'enqueue': true, 86 'enqueue': true,
87 'onevent': function(event) { 87 'onEvent': function(event) {
88 if (event.type == 'end') { 88 if (event.type == 'end') {
89 callbacks++; 89 callbacks++;
90 } 90 }
91 } 91 }
92 }, function() { 92 }, function() {
93 chrome.test.assertNoLastError(); 93 chrome.test.assertNoLastError();
94 }); 94 });
95 chrome.tts.speak( 95 chrome.tts.speak(
96 'native speech 3', 96 'native speech 3',
97 { 97 {
98 'lang': 'fr-FR', 98 'lang': 'fr-FR',
99 'enqueue': true, 99 'enqueue': true,
100 'onevent': function(event) { 100 'onEvent': function(event) {
101 if (event.type == 'end') { 101 if (event.type == 'end') {
102 callbacks++; 102 callbacks++;
103 } 103 }
104 } 104 }
105 }, function() { 105 }, function() {
106 chrome.test.assertNoLastError(); 106 chrome.test.assertNoLastError();
107 }); 107 });
108 108
109 // These do match the voices in the manifest, so they should go to our 109 // These do match the voices in the manifest, so they should go to our
110 // own TTS engine. 110 // own TTS engine.
111 chrome.tts.speak( 111 chrome.tts.speak(
112 'extension speech 2', 112 'extension speech 2',
113 { 113 {
114 'voiceName': 'Alice', 114 'voiceName': 'Alice',
115 'enqueue': true, 115 'enqueue': true,
116 'onevent': function(event) { 116 'onEvent': function(event) {
117 if (event.type == 'end') { 117 if (event.type == 'end') {
118 callbacks++; 118 callbacks++;
119 } 119 }
120 } 120 }
121 }, function() { 121 }, function() {
122 chrome.test.assertNoLastError(); 122 chrome.test.assertNoLastError();
123 }); 123 });
124 chrome.tts.speak( 124 chrome.tts.speak(
125 'extension speech 3', 125 'extension speech 3',
126 { 126 {
127 'voiceName': 'Pat', 127 'voiceName': 'Pat',
128 'gender': 'male', 128 'gender': 'male',
129 'enqueue': true, 129 'enqueue': true,
130 'onevent': function(event) { 130 'onEvent': function(event) {
131 if (event.type == 'end') { 131 if (event.type == 'end') {
132 callbacks++; 132 callbacks++;
133 chrome.ttsEngine.onSpeak.removeListener(speakListener); 133 chrome.ttsEngine.onSpeak.removeListener(speakListener);
134 chrome.ttsEngine.onStop.removeListener(stopListener); 134 chrome.ttsEngine.onStop.removeListener(stopListener);
135 if (callbacks == 4 && speakListenerCalls == 2) { 135 if (callbacks == 4 && speakListenerCalls == 2) {
136 chrome.test.succeed(); 136 chrome.test.succeed();
137 } 137 }
138 } 138 }
139 } 139 }
140 }, function() { 140 }, function() {
(...skipping 20 matching lines...) Expand all
161 chrome.test.assertEq('Alice', voices[1].voiceName); 161 chrome.test.assertEq('Alice', voices[1].voiceName);
162 chrome.test.assertEq('en-US', voices[1].lang); 162 chrome.test.assertEq('en-US', voices[1].lang);
163 chrome.test.assertEq('female', voices[1].gender); 163 chrome.test.assertEq('female', voices[1].gender);
164 164
165 chrome.test.assertEq('Pat', voices[2].voiceName); 165 chrome.test.assertEq('Pat', voices[2].voiceName);
166 chrome.test.assertEq('en-US', voices[2].lang); 166 chrome.test.assertEq('en-US', voices[2].lang);
167 chrome.test.succeed(); 167 chrome.test.succeed();
168 }); 168 });
169 } 169 }
170 ]); 170 ]);
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/tts_engine/engine_word_callbacks/test.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698