diff options
author | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-27 17:05:42 +0000 |
---|---|---|
committer | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-27 17:05:42 +0000 |
commit | 63fa4b8ca21410e95af38b919852ecacc6fe5388 (patch) | |
tree | 6894d873fc7be498de9e9cc08ddb286e4d8da44e /chrome/test/data/extensions/api_test/tts | |
parent | 41b5727cb69427bde29d01437be36b8f23163722 (diff) | |
download | chromium_src-63fa4b8ca21410e95af38b919852ecacc6fe5388.zip chromium_src-63fa4b8ca21410e95af38b919852ecacc6fe5388.tar.gz chromium_src-63fa4b8ca21410e95af38b919852ecacc6fe5388.tar.bz2 |
Implement the TTS completion callback in a generic way so that the callback
always gets called. Support queueing utterances. Add new extension api tests
to test this logic with mocks.
BUG=none
TEST=Adds new browser tests.
Review URL: http://codereview.chromium.org/3999004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64089 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/data/extensions/api_test/tts')
16 files changed, 177 insertions, 20 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 0cf73bc0..9db8d96 100644 --- a/chrome/test/data/extensions/api_test/tts/chromeos/test.js +++ b/chrome/test/data/extensions/api_test/tts/chromeos/test.js @@ -3,29 +3,23 @@ // found in the LICENSE file. // TTS api test for Chrome on ChromeOS. -// browser_tests.exe --gtest_filter=ExtensionApiTest.TtsOnChromeOs +// browser_tests.exe --gtest_filter="ExtensionApiTest.TtsChromeOs" chrome.test.runTests([ - function testSpeak() { - chrome.experimental.tts.speak('hello world', {}, function() { + function testChromeOsSpeech() { + var callbacks = 0; + chrome.experimental.tts.speak('text 1', {}, function() { + chrome.test.assertNoLastError(); + callbacks++; + }); + chrome.experimental.tts.speak('text 2', {}, function() { + chrome.test.assertNoLastError(); + callbacks++; + if (callbacks == 2) { chrome.test.succeed(); - }); - }, - - function testStop() { - chrome.experimental.tts.stop(); - chrome.test.succeed(); - }, - - function testIsSpeaking() { - for (var i = 0; i < 3; i++) { - chrome.experimental.tts.isSpeaking(function(speaking) { - chrome.test.assertTrue(speaking); - }); - } - chrome.experimental.tts.isSpeaking(function(speaking) { - chrome.test.assertFalse(speaking); - chrome.test.succeed(); + } else { + chrome.test.fail(); + } }); } diff --git a/chrome/test/data/extensions/api_test/tts/enqueue/manifest.json b/chrome/test/data/extensions/api_test/tts/enqueue/manifest.json new file mode 100644 index 0000000..a43bc3d --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts/enqueue/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/enqueue/test.html b/chrome/test/data/extensions/api_test/tts/enqueue/test.html new file mode 100644 index 0000000..46f4d74 --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts/enqueue/test.html @@ -0,0 +1 @@ +<script src="test.js"></script> diff --git a/chrome/test/data/extensions/api_test/tts/enqueue/test.js b/chrome/test/data/extensions/api_test/tts/enqueue/test.js new file mode 100644 index 0000000..a903ab3 --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts/enqueue/test.js @@ -0,0 +1,25 @@ +// 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.*" + +chrome.test.runTests([ + function testAllSpeakCallbackFunctionsAreCalled() { + 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(); + } + }); + } +]); diff --git a/chrome/test/data/extensions/api_test/tts/interrupt/manifest.json b/chrome/test/data/extensions/api_test/tts/interrupt/manifest.json new file mode 100644 index 0000000..a43bc3d --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts/interrupt/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/interrupt/test.html b/chrome/test/data/extensions/api_test/tts/interrupt/test.html new file mode 100644 index 0000000..46f4d74 --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts/interrupt/test.html @@ -0,0 +1 @@ +<script src="test.js"></script> diff --git a/chrome/test/data/extensions/api_test/tts/interrupt/test.js b/chrome/test/data/extensions/api_test/tts/interrupt/test.js new file mode 100644 index 0000000..51759b2 --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts/interrupt/test.js @@ -0,0 +1,25 @@ +// 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.*" + +chrome.test.runTests([ + function testAllSpeakCallbackFunctionsAreCalled() { + var callbacks = 0; + chrome.experimental.tts.speak('text 1', {'enqueue': false}, function() { + chrome.test.assertNoLastError(); + callbacks++; + }); + chrome.experimental.tts.speak('text 2', {'enqueue': false}, function() { + chrome.test.assertNoLastError(); + callbacks++; + if (callbacks == 2) { + chrome.test.succeed(); + } else { + chrome.test.fail(); + } + }); + } +]); diff --git a/chrome/test/data/extensions/api_test/tts/queue_interrupt/manifest.json b/chrome/test/data/extensions/api_test/tts/queue_interrupt/manifest.json new file mode 100644 index 0000000..a43bc3d --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts/queue_interrupt/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/queue_interrupt/test.html b/chrome/test/data/extensions/api_test/tts/queue_interrupt/test.html new file mode 100644 index 0000000..46f4d74 --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts/queue_interrupt/test.html @@ -0,0 +1 @@ +<script src="test.js"></script> 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 new file mode 100644 index 0000000..c8137cf --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts/queue_interrupt/test.js @@ -0,0 +1,29 @@ +// 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.*" + +chrome.test.runTests([ + function testAllSpeakCallbackFunctionsAreCalled() { + 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++; + }); + chrome.experimental.tts.speak('text 3', {'enqueue': false}, function() { + chrome.test.assertNoLastError(); + callbacks++; + if (callbacks == 3) { + chrome.test.succeed(); + } else { + chrome.test.fail(); + } + }); + } +]); diff --git a/chrome/test/data/extensions/api_test/tts/speak_error/manifest.json b/chrome/test/data/extensions/api_test/tts/speak_error/manifest.json new file mode 100644 index 0000000..a43bc3d --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts/speak_error/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/speak_error/test.html b/chrome/test/data/extensions/api_test/tts/speak_error/test.html new file mode 100644 index 0000000..46f4d74 --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts/speak_error/test.html @@ -0,0 +1 @@ +<script src="test.js"></script> 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 new file mode 100644 index 0000000..637ee46 --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts/speak_error/test.js @@ -0,0 +1,29 @@ +// 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.*" + +chrome.test.runTests([ + function testSpeakCallbackFunctionIsCalled() { + 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(); + } + }); + } +]); diff --git a/chrome/test/data/extensions/api_test/tts/speak_once/manifest.json b/chrome/test/data/extensions/api_test/tts/speak_once/manifest.json new file mode 100644 index 0000000..a43bc3d --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts/speak_once/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/speak_once/test.html b/chrome/test/data/extensions/api_test/tts/speak_once/test.html new file mode 100644 index 0000000..46f4d74 --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts/speak_once/test.html @@ -0,0 +1 @@ +<script src="test.js"></script> 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 new file mode 100644 index 0000000..33fc8f5 --- /dev/null +++ b/chrome/test/data/extensions/api_test/tts/speak_once/test.js @@ -0,0 +1,15 @@ +// 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.*" + +chrome.test.runTests([ + function testSpeakCallbackFunctionIsCalled() { + chrome.experimental.tts.speak('hello world', {}, function() { + chrome.test.assertNoLastError(); + chrome.test.succeed(); + }); + } +]); |