diff options
Diffstat (limited to 'chrome/test/data')
29 files changed, 607 insertions, 227 deletions
diff --git a/chrome/test/data/extensions/api_test/tts/chromeos/test.js b/chrome/test/data/extensions/api_test/tts/chromeos/test.js index ece6f97..6859f21 100644 --- a/chrome/test/data/extensions/api_test/tts/chromeos/test.js +++ b/chrome/test/data/extensions/api_test/tts/chromeos/test.js @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,21 +8,33 @@ chrome.test.runTests([ function testChromeOsSpeech() { var callbacks = 0; - chrome.experimental.tts.speak('text 1', {}, function() { - chrome.test.assertEq('Utterance interrupted.', - chrome.extension.lastError.message); - callbacks++; - }); - chrome.experimental.tts.speak('text 2', {}, function() { - chrome.test.assertNoLastError(); - callbacks++; - if (callbacks == 2) { + chrome.experimental.tts.speak( + 'text 1', + { + 'onevent': function(event) { + callbacks++; + chrome.test.assertEq('interrupted', event.type); + } + }, + function() { chrome.test.assertNoLastError(); - chrome.test.succeed(); - } else { - chrome.test.fail(); - } - }); + }); + chrome.experimental.tts.speak( + 'text 2', + { + 'onevent': function(event) { + chrome.test.assertEq('end', event.type); + callbacks++; + if (callbacks == 2) { + chrome.test.succeed(); + } else { + chrome.test.fail(); + } + } + }, + function() { + chrome.test.assertNoLastError(); + }); } ]); diff --git a/chrome/test/data/extensions/api_test/tts/enqueue/test.js b/chrome/test/data/extensions/api_test/tts/enqueue/test.js index a903ab3..e006ee9 100644 --- a/chrome/test/data/extensions/api_test/tts/enqueue/test.js +++ b/chrome/test/data/extensions/api_test/tts/enqueue/test.js @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,20 +6,38 @@ // browser_tests.exe --gtest_filter="TtsApiTest.*" chrome.test.runTests([ - function testAllSpeakCallbackFunctionsAreCalled() { + function testEnqueue() { var callbacks = 0; - chrome.experimental.tts.speak('text 1', {'enqueue': true}, function() { - chrome.test.assertNoLastError(); - callbacks++; - }); - chrome.experimental.tts.speak('text 2', {'enqueue': true}, function() { - chrome.test.assertNoLastError(); - callbacks++; - if (callbacks == 2) { - chrome.test.succeed(); - } else { - chrome.test.fail(); - } - }); + chrome.experimental.tts.speak( + 'text 1', + { + 'enqueue': true, + 'onevent': function(event) { + chrome.test.assertEq('end', event.type); + callbacks++; + } + }, + function() { + chrome.test.assertNoLastError(); + callbacks++; + }); + chrome.experimental.tts.speak( + 'text 2', + { + 'enqueue': true, + 'onevent': function(event) { + chrome.test.assertEq('end', event.type); + callbacks++; + if (callbacks == 4) { + chrome.test.succeed(); + } else { + chrome.test.fail(); + } + } + }, + function() { + chrome.test.assertNoLastError(); + callbacks++; + }); } ]); diff --git a/chrome/test/data/extensions/api_test/tts/interrupt/test.js b/chrome/test/data/extensions/api_test/tts/interrupt/test.js index 390d68f..65e000c 100644 --- a/chrome/test/data/extensions/api_test/tts/interrupt/test.js +++ b/chrome/test/data/extensions/api_test/tts/interrupt/test.js @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,21 +6,36 @@ // browser_tests.exe --gtest_filter="TtsApiTest.*" chrome.test.runTests([ - function testAllSpeakCallbackFunctionsAreCalled() { + function testInterrupt() { var callbacks = 0; - chrome.experimental.tts.speak('text 1', {'enqueue': false}, function() { - chrome.test.assertEq('Utterance interrupted.', - chrome.extension.lastError.message); - callbacks++; - }); - chrome.experimental.tts.speak('text 2', {'enqueue': false}, function() { - chrome.test.assertNoLastError(); - callbacks++; - if (callbacks == 2) { - chrome.test.succeed(); - } else { - chrome.test.fail(); - } - }); + chrome.experimental.tts.speak( + 'text 1', + { + 'enqueue': false, + 'onevent': function(event) { + chrome.test.assertEq('interrupted', event.type); + callbacks++; + } + }, + function() { + chrome.test.assertNoLastError(); + callbacks++; + }); + chrome.experimental.tts.speak( + 'text 2', + { + 'enqueue': false, + 'onevent': function(event) { + chrome.test.assertEq('end', event.type); + callbacks++; + if (callbacks == 4) { + chrome.test.succeed(); + } + } + }, + function() { + chrome.test.assertNoLastError(); + callbacks++; + }); } ]); diff --git a/chrome/test/data/extensions/api_test/tts/provide/test.js b/chrome/test/data/extensions/api_test/tts/provide/test.js deleted file mode 100644 index bc5e16a..0000000 --- a/chrome/test/data/extensions/api_test/tts/provide/test.js +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// TTS api test for Chrome on ChromeOS. -// browser_tests.exe --gtest_filter="TtsApiTest.*" - -if (!chrome.tts) { - chrome.tts = chrome.experimental.tts; -} - -chrome.test.runTests([ - function testNoListeners() { - // This call should go to native speech because we haven't registered - // any listeners. - chrome.tts.speak('native speech', {}, function() { - chrome.test.assertNoLastError(); - chrome.test.succeed(); - }); - }, - function testTtsProvider() { - // Register listeners for speech functions, enabling this extension - // to be a TTS provider. - var speakListener = function(utterance, options, callback) { - chrome.test.assertNoLastError(); - chrome.test.assertEq('extension speech', utterance); - callback(); - }; - var stopListener = function() {}; - chrome.tts.onSpeak.addListener(speakListener); - chrome.tts.onStop.addListener(stopListener); - - // This call should go to our own speech provider. - chrome.tts.speak('extension speech', {}, function() { - chrome.test.assertNoLastError(); - chrome.tts.onSpeak.removeListener(speakListener); - chrome.tts.onStop.removeListener(stopListener); - chrome.test.succeed(); - }); - }, - function testVoiceMatching() { - // Count the number of times our callback functions have been called. - var callbacks = 0; - // Count the number of times our TTS provider has been called. - var speakListenerCalls = 0; - - // Register listeners for speech functions. - var speakListener = function(utterance, options, callback) { - speakListenerCalls++; - callback(); - }; - var stopListener = function() {}; - chrome.tts.onSpeak.addListener(speakListener); - chrome.tts.onStop.addListener(stopListener); - - // These don't match the voices in the manifest, so they should - // go to native speech. The gmock assertions in TtsApiTest::Provide - // enforce that the native TTS handlers are called. - chrome.tts.speak('native speech 2', - {'voiceName': 'George', 'enqueue': true}, function() { - chrome.test.assertNoLastError(); - callbacks++; - }); - chrome.tts.speak('native speech 3', - {'locale': 'fr-FR', 'enqueue': true}, - function() { - chrome.test.assertNoLastError(); - callbacks++; - }); - - // These do match the voices in the manifest, so they should go to our - // own TTS provider. - chrome.tts.speak('extension speech 2', - {'voiceName': 'Alice', 'enqueue': true}, - function() { - chrome.test.assertNoLastError(); - callbacks++; - chrome.test.succeed(); - }); - chrome.tts.speak('extension speech 3', - {'voiceName': 'Pat', 'gender': 'male', 'enqueue': true}, - function() { - chrome.test.assertNoLastError(); - callbacks++; - chrome.tts.onSpeak.removeListener(speakListener); - chrome.tts.onStop.removeListener(stopListener); - if (callbacks == 4 && speakListenerCalls == 2) { - chrome.test.succeed(); - } - }); - }, - function testTtsProviderError() { - // Register listeners for speech functions, but have speak return an - // error when it's used. - var speakListener = function(utterance, options, callback) { - chrome.test.assertEq('extension speech 4', utterance); - callback('extension tts error'); - }; - var stopListener = function() {}; - chrome.tts.onSpeak.addListener(speakListener); - chrome.tts.onStop.addListener(stopListener); - - // This should go to our own TTS provider, and we can check that we - // get the error message. - chrome.tts.speak('extension speech 4', {}, function() { - chrome.test.assertEq('extension tts error', - chrome.extension.lastError.message); - chrome.tts.onSpeak.removeListener(speakListener); - chrome.tts.onStop.removeListener(stopListener); - chrome.test.succeed(); - }); - } -]); diff --git a/chrome/test/data/extensions/api_test/tts/queue_interrupt/test.js b/chrome/test/data/extensions/api_test/tts/queue_interrupt/test.js index e2317b2..c21f9f7 100644 --- a/chrome/test/data/extensions/api_test/tts/queue_interrupt/test.js +++ b/chrome/test/data/extensions/api_test/tts/queue_interrupt/test.js @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,30 +6,54 @@ // browser_tests.exe --gtest_filter="TtsApiTest.*" chrome.test.runTests([ - function testAllSpeakCallbackFunctionsAreCalled() { + function testQueueInterrupt() { // In this test, two utterances are queued, and then a third // interrupts. The first gets interrupted, the second never gets spoken // at all. The test expectations in extension_tts_apitest.cc ensure that // the first call to tts.speak keeps going until it's interrupted. var callbacks = 0; - chrome.experimental.tts.speak('text 1', {'enqueue': true}, function() { - chrome.test.assertEq('Utterance interrupted.', - chrome.extension.lastError.message); - callbacks++; - }); - chrome.experimental.tts.speak('text 2', {'enqueue': true}, function() { - chrome.test.assertEq('Utterance removed from queue.', - chrome.extension.lastError.message); - callbacks++; - }); - chrome.experimental.tts.speak('text 3', {'enqueue': false}, function() { - chrome.test.assertNoLastError(); - callbacks++; - if (callbacks == 3) { - chrome.test.succeed(); - } else { - chrome.test.fail(); - } - }); + chrome.experimental.tts.speak( + 'text 1', + { + 'enqueue': true, + 'onevent': function(event) { + chrome.test.assertEq('interrupted', event.type); + callbacks++; + } + }, + function() { + chrome.test.assertNoLastError(); + callbacks++; + }); + chrome.experimental.tts.speak( + 'text 2', + { + 'enqueue': true, + 'onevent': function(event) { + chrome.test.assertEq('cancelled', event.type); + callbacks++; + } + }, function() { + chrome.test.assertNoLastError(); + callbacks++; + }); + chrome.experimental.tts.speak( + 'text 3', + { + 'enqueue': false, + 'onevent': function(event) { + chrome.test.assertEq('end', event.type); + callbacks++; + if (callbacks == 6) { + chrome.test.succeed(); + } else { + chrome.test.fail(); + } + } + }, + function() { + chrome.test.assertNoLastError(); + callbacks++; + }); } ]); diff --git a/chrome/test/data/extensions/api_test/tts/speak_error/test.js b/chrome/test/data/extensions/api_test/tts/speak_error/test.js index 637ee46..f592d97 100644 --- a/chrome/test/data/extensions/api_test/tts/speak_error/test.js +++ b/chrome/test/data/extensions/api_test/tts/speak_error/test.js @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,24 +6,37 @@ // browser_tests.exe --gtest_filter="TtsApiTest.*" chrome.test.runTests([ - function testSpeakCallbackFunctionIsCalled() { + function testSpeakError() { var callbacks = 0; - chrome.experimental.tts.speak('first try', {'enqueue': true}, function() { - chrome.test.assertNoLastError(); - callbacks++; - }); - chrome.experimental.tts.speak('second try', {'enqueue': true}, function() { - chrome.test.assertEq('epic fail', chrome.extension.lastError.message); - callbacks++; - }); - chrome.experimental.tts.speak('third try', {'enqueue': true}, function() { - chrome.test.assertNoLastError(); - callbacks++; - if (callbacks == 3) { - chrome.test.succeed(); - } else { - chrome.test.fail(); - } - }); + chrome.experimental.tts.speak( + 'first try', + { + 'enqueue': true, + 'onevent': function(event) { + chrome.test.assertEq('error', event.type); + chrome.test.assertEq('epic fail', event.errorMessage); + callbacks++; + } + }, + function() { + chrome.test.assertNoLastError(); + }); + chrome.experimental.tts.speak( + 'second try', + { + 'enqueue': true, + 'onevent': function(event) { + chrome.test.assertEq('end', event.type); + callbacks++; + if (callbacks == 2) { + chrome.test.succeed(); + } else { + chrome.test.fail(); + } + } + }, + function() { + chrome.test.assertNoLastError(); + }); } ]); diff --git a/chrome/test/data/extensions/api_test/tts/speak_once/test.js b/chrome/test/data/extensions/api_test/tts/speak_once/test.js index 33fc8f5..588f998 100644 --- a/chrome/test/data/extensions/api_test/tts/speak_once/test.js +++ b/chrome/test/data/extensions/api_test/tts/speak_once/test.js @@ -1,15 +1,21 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// TTS api test for Chrome on ChromeOS. // browser_tests.exe --gtest_filter="TtsApiTest.*" chrome.test.runTests([ - function testSpeakCallbackFunctionIsCalled() { - chrome.experimental.tts.speak('hello world', {}, function() { - chrome.test.assertNoLastError(); - chrome.test.succeed(); - }); + function testSpeakOnce() { + function eventListener(event) { + chrome.test.assertEq('end', event.type); + chrome.test.assertEq(11, event.charIndex); + chrome.test.succeed(); + } + chrome.experimental.tts.speak( + 'hello world', + {'onevent': eventListener}, + function() { + chrome.test.assertNoLastError(); + }); } ]); diff --git a/chrome/test/data/extensions/api_test/tts/word_callbacks/manifest.json b/chrome/test/data/extensions/api_test/tts/word_callbacks/manifest.json new file mode 100644 index 0000000..a43bc3d --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts/word_callbacks/manifest.json @@ -0,0 +1,7 @@ +{ + "name": "chrome.experimental.tts", + "version": "0.1", + "description": "browser test for chrome.experimental.tts API", + "background_page": "test.html", + "permissions": ["experimental"] +} diff --git a/chrome/test/data/extensions/api_test/tts/provide/test.html b/chrome/test/data/extensions/api_test/tts/word_callbacks/test.html index 46f4d74..46f4d74 100644 --- a/chrome/test/data/extensions/api_test/tts/provide/test.html +++ b/chrome/test/data/extensions/api_test/tts/word_callbacks/test.html diff --git a/chrome/test/data/extensions/api_test/tts/word_callbacks/test.js b/chrome/test/data/extensions/api_test/tts/word_callbacks/test.js new file mode 100644 index 0000000..232a552 --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts/word_callbacks/test.js @@ -0,0 +1,40 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// TTS api test for Chrome on ChromeOS. +// browser_tests.exe --gtest_filter="TtsApiTest.*" + +chrome.test.runTests([ + function testWordCallbacks() { + var callbacks = 0; + chrome.experimental.tts.speak( + 'one two three', + { + 'onevent': function(event) { + callbacks++; + switch(callbacks) { + case 1: + chrome.test.assertEq('word', event.type); + chrome.test.assertEq(0, event.charIndex); + break; + case 2: + chrome.test.assertEq('word', event.type); + chrome.test.assertEq(4, event.charIndex); + break; + case 3: + chrome.test.assertEq('word', event.type); + chrome.test.assertEq(8, event.charIndex); + break; + case 4: + chrome.test.assertEq('end', event.type); + chrome.test.assertEq(13, event.charIndex); + chrome.test.succeed(); + break; + default: + chrome.test.fail(); + } + } + }); + } +]); diff --git a/chrome/test/data/extensions/api_test/tts/provide/manifest.json b/chrome/test/data/extensions/api_test/tts_engine/engine_error/manifest.json index 93bc98d..39ac616 100644 --- a/chrome/test/data/extensions/api_test/tts/provide/manifest.json +++ b/chrome/test/data/extensions/api_test/tts_engine/engine_error/manifest.json @@ -3,16 +3,12 @@ "version": "0.1", "description": "browser test for chrome.experimental.tts API", "background_page": "test.html", - "tts": { + "tts_engine": { "voices": [ { - "voiceName": "Alice", - "locale": "en-US", - "gender": "female" - }, - { - "voiceName": "Pat", - "locale": "en-US" + "voice_name": "Zach", + "lang": "en-US", + "event_types": [ "end", "error" ] } ] }, diff --git a/chrome/test/data/extensions/api_test/tts_engine/engine_error/test.html b/chrome/test/data/extensions/api_test/tts_engine/engine_error/test.html new file mode 100644 index 0000000..46f4d74 --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts_engine/engine_error/test.html @@ -0,0 +1 @@ +<script src="test.js"></script> diff --git a/chrome/test/data/extensions/api_test/tts_engine/engine_error/test.js b/chrome/test/data/extensions/api_test/tts_engine/engine_error/test.js new file mode 100644 index 0000000..d21156f --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts_engine/engine_error/test.js @@ -0,0 +1,62 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// TTS api test for Chrome on ChromeOS. +// browser_tests.exe --gtest_filter="TtsApiTest.*" + +if (!chrome.tts) { + chrome.tts = chrome.experimental.tts; +} + +if (!chrome.ttsEngine) { + chrome.ttsEngine = chrome.experimental.ttsEngine; +} + +chrome.test.runTests([ + function testTtsEngineError() { + // Register listeners for speech functions, but have speak return an + // error when it's used. + var speakListener = function(utterance, options, sendTtsEvent) { + chrome.test.assertEq('extension speech', utterance); + + try { + // This should fail because 'foo' isn't a valid event type. + sendTtsEvent({'type': 'foo'}); + chrome.test.fail(); + } catch (e) { + } + + // This won't actually send an event, and an error will be logged + // to the console, because we haven't registered the 'word' + // event type in our manifest. + sendTtsEvent({'type': 'word'}); + + // This will succeed. + sendTtsEvent({ + 'type': 'error', + 'charIndex': 0, + 'errorMessage': 'extension tts error'}); + }; + var stopListener = function() {}; + chrome.ttsEngine.onSpeak.addListener(speakListener); + chrome.ttsEngine.onStop.addListener(stopListener); + + // This should go to our own TTS engine, and we can check that we + // get the error message. + chrome.tts.speak( + 'extension speech', + { + 'onevent': function(event) { + chrome.test.assertEq('error', event.type); + chrome.test.assertEq('extension tts error', event.errorMessage); + chrome.ttsEngine.onSpeak.removeListener(speakListener); + chrome.ttsEngine.onStop.removeListener(stopListener); + chrome.test.succeed(); + } + }, + function() { + chrome.test.assertNoLastError(); + }); + } +]); diff --git a/chrome/test/data/extensions/api_test/tts_engine/engine_word_callbacks/manifest.json b/chrome/test/data/extensions/api_test/tts_engine/engine_word_callbacks/manifest.json new file mode 100644 index 0000000..7d28357 --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts_engine/engine_word_callbacks/manifest.json @@ -0,0 +1,16 @@ +{ + "name": "chrome.experimental.tts", + "version": "0.1", + "description": "browser test for chrome.experimental.tts API", + "background_page": "test.html", + "tts_engine": { + "voices": [ + { + "voice_name": "WordCallbackVoice", + "lang": "en-US", + "event_types": [ "end", "word" ] + } + ] + }, + "permissions": ["experimental"] +} diff --git a/chrome/test/data/extensions/api_test/tts_engine/engine_word_callbacks/test.html b/chrome/test/data/extensions/api_test/tts_engine/engine_word_callbacks/test.html new file mode 100644 index 0000000..46f4d74 --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts_engine/engine_word_callbacks/test.html @@ -0,0 +1 @@ +<script src="test.js"></script> diff --git a/chrome/test/data/extensions/api_test/tts_engine/engine_word_callbacks/test.js b/chrome/test/data/extensions/api_test/tts_engine/engine_word_callbacks/test.js new file mode 100644 index 0000000..9a304ba --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts_engine/engine_word_callbacks/test.js @@ -0,0 +1,66 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// TTS api test for Chrome on ChromeOS. +// browser_tests.exe --gtest_filter="TtsApiTest.*" + +if (!chrome.tts) { + chrome.tts = chrome.experimental.tts; +} + +if (!chrome.ttsEngine) { + chrome.ttsEngine = chrome.experimental.ttsEngine; +} + +chrome.test.runTests([ + function testWordCallbacks() { + // Register listeners for speech functions, enabling this extension + // to be a TTS engine. + var speakListener = function(utterance, options, sendTtsEvent) { + chrome.test.assertNoLastError(); + chrome.test.assertEq('alpha beta gamma', utterance); + sendTtsEvent({'type': 'word', 'charIndex': 0}); + sendTtsEvent({'type': 'word', 'charIndex': 6}); + sendTtsEvent({'type': 'word', 'charIndex': 11}); + sendTtsEvent({'type': 'end', 'charIndex': utterance.length}); + }; + var stopListener = function() {}; + chrome.ttsEngine.onSpeak.addListener(speakListener); + chrome.ttsEngine.onStop.addListener(stopListener); + + var callbacks = 0; + chrome.tts.speak( + 'alpha beta gamma', + { + 'onevent': function(event) { + chrome.test.assertNoLastError(); + callbacks++; + switch(callbacks) { + case 1: + chrome.test.assertEq('word', event.type); + chrome.test.assertEq(0, event.charIndex); + break; + case 2: + chrome.test.assertEq('word', event.type); + chrome.test.assertEq(6, event.charIndex); + break; + case 3: + chrome.test.assertEq('word', event.type); + chrome.test.assertEq(11, event.charIndex); + break; + case 4: + chrome.test.assertEq('end', event.type); + chrome.test.assertEq(16, event.charIndex); + chrome.test.succeed(); + break; + default: + chrome.test.fail(); + } + } + }, + function() { + chrome.test.assertNoLastError(); + }); + } +]); diff --git a/chrome/test/data/extensions/api_test/tts_engine/register_engine/manifest.json b/chrome/test/data/extensions/api_test/tts_engine/register_engine/manifest.json new file mode 100644 index 0000000..77b5f03 --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts_engine/register_engine/manifest.json @@ -0,0 +1,22 @@ +{ + "name": "chrome.experimental.tts", + "version": "0.1", + "description": "browser test for chrome.experimental.tts API", + "background_page": "test.html", + "tts_engine": { + "voices": [ + { + "voice_name": "Alice", + "lang": "en-US", + "gender": "female", + "event_types": [ "end" ] + }, + { + "voice_name": "Pat", + "lang": "en-US", + "event_types": [ "end" ] + } + ] + }, + "permissions": ["experimental"] +} diff --git a/chrome/test/data/extensions/api_test/tts_engine/register_engine/test.html b/chrome/test/data/extensions/api_test/tts_engine/register_engine/test.html new file mode 100644 index 0000000..46f4d74 --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts_engine/register_engine/test.html @@ -0,0 +1 @@ +<script src="test.js"></script> diff --git a/chrome/test/data/extensions/api_test/tts_engine/register_engine/test.js b/chrome/test/data/extensions/api_test/tts_engine/register_engine/test.js new file mode 100644 index 0000000..ba9dc14 --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts_engine/register_engine/test.js @@ -0,0 +1,170 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// TTS api test for Chrome on ChromeOS. +// browser_tests.exe --gtest_filter="TtsApiTest.*" + +if (!chrome.tts) { + chrome.tts = chrome.experimental.tts; +} + +if (!chrome.ttsEngine) { + chrome.ttsEngine = chrome.experimental.ttsEngine; +} + +chrome.test.runTests([ + function testNoListeners() { + // This call should go to native speech because we haven't registered + // any listeners. + chrome.tts.speak( + 'native speech', + { + 'onevent': function(event) { + if (event.type == 'end') { + chrome.test.succeed(); + } + } + }, function() { + chrome.test.assertNoLastError(); + }); + }, + function testTtsEngine() { + var calledOurEngine = false; + + // Register listeners for speech functions, enabling this extension + // to be a TTS engine. + var speakListener = function(utterance, options, sendTtsEvent) { + chrome.test.assertNoLastError(); + chrome.test.assertEq('extension speech', utterance); + calledOurEngine = true; + sendTtsEvent({'type': 'end', 'charIndex': utterance.length}); + }; + var stopListener = function() {}; + chrome.ttsEngine.onSpeak.addListener(speakListener); + chrome.ttsEngine.onStop.addListener(stopListener); + + // This call should go to our own speech engine. + chrome.tts.speak( + 'extension speech', + { + 'onevent': function(event) { + if (event.type == 'end') { + chrome.test.assertEq(true, calledOurEngine); + chrome.ttsEngine.onSpeak.removeListener(speakListener); + chrome.ttsEngine.onStop.removeListener(stopListener); + chrome.test.succeed(); + } + } + }, + function() { + chrome.test.assertNoLastError(); + }); + }, + function testVoiceMatching() { + // Count the number of times our callback functions have been called. + var callbacks = 0; + // Count the number of times our TTS engine has been called. + var speakListenerCalls = 0; + + // Register listeners for speech functions. + var speakListener = function(utterance, options, sendTtsEvent) { + speakListenerCalls++; + sendTtsEvent({'type': 'end', 'charIndex': utterance.length}); + }; + var stopListener = function() {}; + chrome.ttsEngine.onSpeak.addListener(speakListener); + chrome.ttsEngine.onStop.addListener(stopListener); + + // These don't match the voices in the manifest, so they should + // go to native speech. The gmock assertions in TtsApiTest::RegisterEngine + // enforce that the native TTS handlers are called. + chrome.tts.speak( + 'native speech 2', + { + 'voiceName': 'George', + 'enqueue': true, + 'onevent': function(event) { + if (event.type == 'end') { + callbacks++; + } + } + }, function() { + chrome.test.assertNoLastError(); + }); + chrome.tts.speak( + 'native speech 3', + { + 'lang': 'fr-FR', + 'enqueue': true, + 'onevent': function(event) { + if (event.type == 'end') { + callbacks++; + } + } + }, function() { + chrome.test.assertNoLastError(); + }); + + // These do match the voices in the manifest, so they should go to our + // own TTS engine. + chrome.tts.speak( + 'extension speech 2', + { + 'voiceName': 'Alice', + 'enqueue': true, + 'onevent': function(event) { + if (event.type == 'end') { + callbacks++; + } + } + }, function() { + chrome.test.assertNoLastError(); + }); + chrome.tts.speak( + 'extension speech 3', + { + 'voiceName': 'Pat', + 'gender': 'male', + 'enqueue': true, + 'onevent': function(event) { + if (event.type == 'end') { + callbacks++; + chrome.ttsEngine.onSpeak.removeListener(speakListener); + chrome.ttsEngine.onStop.removeListener(stopListener); + if (callbacks == 4 && speakListenerCalls == 2) { + chrome.test.succeed(); + } + } + } + }, function() { + chrome.test.assertNoLastError(); + }); + }, + function testGetVoices() { + // We have to register listeners, or the voices provided + // by this extension won't be returned. + var speakListener = function(utterance, options, sendTtsEvent) { + chrome.test.assertNoLastError(); + chrome.test.assertEq('extension speech', utterance); + sendTtsEvent({'type': 'end', 'charIndex': utterance.length}); + }; + var stopListener = function() {}; + chrome.ttsEngine.onSpeak.addListener(speakListener); + chrome.ttsEngine.onStop.addListener(stopListener); + + chrome.tts.getVoices(function(voices) { + chrome.test.assertEq(3, voices.length); + + chrome.test.assertEq('native', voices[0].voiceName); + + chrome.test.assertEq('Alice', voices[1].voiceName); + chrome.test.assertEq('en-US', voices[1].lang); + chrome.test.assertEq('female', voices[1].gender); + + chrome.test.assertEq('Pat', voices[2].voiceName); + chrome.test.assertEq('en-US', voices[2].lang); + chrome.test.succeed(); + }); + } +]); diff --git a/chrome/test/data/extensions/manifest_tests/tts_provider_invalid_1.json b/chrome/test/data/extensions/manifest_tests/tts_engine_invalid_1.json index 90e849e..91f1c28 100644 --- a/chrome/test/data/extensions/manifest_tests/tts_provider_invalid_1.json +++ b/chrome/test/data/extensions/manifest_tests/tts_engine_invalid_1.json @@ -1,5 +1,5 @@ { "name": "test", "version": "1", - "tts": "shouldBeADict" + "tts_engine": "shouldBeADict" } diff --git a/chrome/test/data/extensions/manifest_tests/tts_provider_invalid_2.json b/chrome/test/data/extensions/manifest_tests/tts_engine_invalid_2.json index 261f5d3..5f44e62 100644 --- a/chrome/test/data/extensions/manifest_tests/tts_provider_invalid_2.json +++ b/chrome/test/data/extensions/manifest_tests/tts_engine_invalid_2.json @@ -1,7 +1,7 @@ { "name": "test", "version": "1", - "tts": { + "tts_engine": { "voices": "shouldBeAnArray" } } diff --git a/chrome/test/data/extensions/manifest_tests/tts_provider_invalid_3.json b/chrome/test/data/extensions/manifest_tests/tts_engine_invalid_3.json index b7443df..109804c 100644 --- a/chrome/test/data/extensions/manifest_tests/tts_provider_invalid_3.json +++ b/chrome/test/data/extensions/manifest_tests/tts_engine_invalid_3.json @@ -1,7 +1,7 @@ { "name": "test", "version": "1", - "tts": { + "tts_engine": { "voices": [ "shouldBeADict" ] diff --git a/chrome/test/data/extensions/manifest_tests/tts_engine_invalid_4.json b/chrome/test/data/extensions/manifest_tests/tts_engine_invalid_4.json new file mode 100644 index 0000000..340b676 --- /dev/null +++ b/chrome/test/data/extensions/manifest_tests/tts_engine_invalid_4.json @@ -0,0 +1,11 @@ +{ + "name": "test", + "version": "1", + "tts_engine": { + "voices": [ + { + "voice_name": [ "Shouldn't be in an array" ] + } + ] + } +} diff --git a/chrome/test/data/extensions/manifest_tests/tts_provider_invalid_5.json b/chrome/test/data/extensions/manifest_tests/tts_engine_invalid_5.json index 6297ab1..bb4025b 100644 --- a/chrome/test/data/extensions/manifest_tests/tts_provider_invalid_5.json +++ b/chrome/test/data/extensions/manifest_tests/tts_engine_invalid_5.json @@ -1,10 +1,10 @@ { "name": "test", "version": "1", - "tts": { + "tts_engine": { "voices": [ { - "locale": "" + "lang": "" } ] } diff --git a/chrome/test/data/extensions/manifest_tests/tts_provider_invalid_6.json b/chrome/test/data/extensions/manifest_tests/tts_engine_invalid_6.json index ff45401..8e73a325 100644 --- a/chrome/test/data/extensions/manifest_tests/tts_provider_invalid_6.json +++ b/chrome/test/data/extensions/manifest_tests/tts_engine_invalid_6.json @@ -1,10 +1,10 @@ { "name": "test", "version": "1", - "tts": { + "tts_engine": { "voices": [ { - "locale": "German" + "lang": "German" } ] } diff --git a/chrome/test/data/extensions/manifest_tests/tts_provider_invalid_7.json b/chrome/test/data/extensions/manifest_tests/tts_engine_invalid_7.json index cba13d6..defd0f3 100644 --- a/chrome/test/data/extensions/manifest_tests/tts_provider_invalid_7.json +++ b/chrome/test/data/extensions/manifest_tests/tts_engine_invalid_7.json @@ -1,7 +1,7 @@ { "name": "test", "version": "1", - "tts": { + "tts_engine": { "voices": [ { "gender": "alien" diff --git a/chrome/test/data/extensions/manifest_tests/tts_provider_invalid_4.json b/chrome/test/data/extensions/manifest_tests/tts_engine_invalid_8.json index da41c61..635f484 100644 --- a/chrome/test/data/extensions/manifest_tests/tts_provider_invalid_4.json +++ b/chrome/test/data/extensions/manifest_tests/tts_engine_invalid_8.json @@ -1,10 +1,10 @@ { "name": "test", "version": "1", - "tts": { + "tts_engine": { "voices": [ { - "voiceName": [ "Shouldn't be in an array" ] + "event_types": "shouldBeAnArray" } ] } diff --git a/chrome/test/data/extensions/manifest_tests/tts_engine_invalid_9.json b/chrome/test/data/extensions/manifest_tests/tts_engine_invalid_9.json new file mode 100644 index 0000000..9679e45 --- /dev/null +++ b/chrome/test/data/extensions/manifest_tests/tts_engine_invalid_9.json @@ -0,0 +1,11 @@ +{ + "name": "test", + "version": "1", + "tts_engine": { + "voices": [ + { + "event_types": ["on vacation"] + } + ] + } +} diff --git a/chrome/test/data/extensions/manifest_tests/tts_provider_valid.json b/chrome/test/data/extensions/manifest_tests/tts_engine_valid.json index 8e15ad1..9b9e9ad 100644 --- a/chrome/test/data/extensions/manifest_tests/tts_provider_valid.json +++ b/chrome/test/data/extensions/manifest_tests/tts_engine_valid.json @@ -1,12 +1,13 @@ { "name": "test", "version": "1", - "tts": { + "tts_engine": { "voices": [ { - "voiceName": "name", - "locale": "en-US", + "voice_name": "name", + "lang": "en-US", "gender": "female", + "event_types": ["start", "end", "marker"], "other_key": "other_value" } ] |