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

Unified Diff: chrome/browser/speech/extension_api/tts_extension_apitest.cc

Issue 15108002: Add Pause and Resume to Web TTS & Extension TTS APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/speech/extension_api/tts_extension_apitest.cc
diff --git a/chrome/browser/speech/extension_api/tts_extension_apitest.cc b/chrome/browser/speech/extension_api/tts_extension_apitest.cc
index dc4dc90ff15ce7a1e23ca99d6af51c096571bea4..fcf86b1f451de44c03a688228a14ddb97247ae0c 100644
--- a/chrome/browser/speech/extension_api/tts_extension_apitest.cc
+++ b/chrome/browser/speech/extension_api/tts_extension_apitest.cc
@@ -24,9 +24,14 @@ using ::testing::DoAll;
using ::testing::InSequence;
using ::testing::InvokeWithoutArgs;
using ::testing::Return;
+using ::testing::SaveArg;
using ::testing::StrictMock;
using ::testing::_;
+namespace {
+int g_saved_utterance_id;
+}
+
class MockTtsPlatformImpl : public TtsPlatformImpl {
public:
MockTtsPlatformImpl()
@@ -45,6 +50,10 @@ class MockTtsPlatformImpl : public TtsPlatformImpl {
MOCK_METHOD0(StopSpeaking, bool(void));
+ MOCK_METHOD0(Pause, void(void));
+
+ MOCK_METHOD0(Resume, void(void));
+
MOCK_METHOD0(IsSpeaking, bool(void));
MOCK_METHOD1(GetVoices, void(std::vector<VoiceData>*));
@@ -53,6 +62,15 @@ class MockTtsPlatformImpl : public TtsPlatformImpl {
set_error("epic fail");
}
+ void SendEndEventOnSavedUtteranceId() {
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE, base::Bind(
+ &MockTtsPlatformImpl::SendEvent,
+ ptr_factory_.GetWeakPtr(),
+ false, g_saved_utterance_id, TTS_EVENT_END, 0, std::string()),
+ base::TimeDelta());
+ }
+
void SendEndEvent(int utterance_id,
const std::string& utterance,
const std::string& lang,
@@ -276,6 +294,35 @@ IN_PROC_BROWSER_TEST_F(TtsApiTest, PlatformWordCallbacks) {
ASSERT_TRUE(RunExtensionTest("tts/word_callbacks")) << message_;
}
+IN_PROC_BROWSER_TEST_F(TtsApiTest, PlatformPauseResume) {
+ EXPECT_CALL(mock_platform_impl_, IsSpeaking())
+ .Times(AnyNumber());
+
+ InSequence s;
+ EXPECT_CALL(mock_platform_impl_, Speak(_, "test 1", _, _, _))
+ .WillOnce(DoAll(
+ Invoke(&mock_platform_impl_,
+ &MockTtsPlatformImpl::SendEndEvent),
+ Return(true)));
+ EXPECT_CALL(mock_platform_impl_, StopSpeaking())
+ .WillOnce(Return(true));
+ EXPECT_CALL(mock_platform_impl_, Speak(_, "test 2", _, _, _))
+ .WillOnce(DoAll(
+ SaveArg<0>(&g_saved_utterance_id),
+ Return(true)));
+ EXPECT_CALL(mock_platform_impl_, Pause());
+ EXPECT_CALL(mock_platform_impl_, Resume())
+ .WillOnce(
+ InvokeWithoutArgs(
+ &mock_platform_impl_,
+ &MockTtsPlatformImpl::SendEndEventOnSavedUtteranceId));
+ ASSERT_TRUE(RunExtensionTest("tts/pause_resume")) << message_;
+}
+
+//
+// TTS Engine tests.
+//
+
IN_PROC_BROWSER_TEST_F(TtsApiTest, RegisterEngine) {
EXPECT_CALL(mock_platform_impl_, IsSpeaking())
.Times(AnyNumber());
« no previous file with comments | « chrome/browser/speech/extension_api/tts_extension_api_constants.cc ('k') | chrome/browser/speech/tts_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698