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()); |