summaryrefslogtreecommitdiffstats
path: root/chrome/browser/speech/extension_api/tts_extension_apitest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/speech/extension_api/tts_extension_apitest.cc')
-rw-r--r--chrome/browser/speech/extension_api/tts_extension_apitest.cc55
1 files changed, 29 insertions, 26 deletions
diff --git a/chrome/browser/speech/extension_api/tts_extension_apitest.cc b/chrome/browser/speech/extension_api/tts_extension_apitest.cc
index d865190..e704f5d 100644
--- a/chrome/browser/speech/extension_api/tts_extension_apitest.cc
+++ b/chrome/browser/speech/extension_api/tts_extension_apitest.cc
@@ -36,21 +36,19 @@ class MockTtsPlatformImpl : public TtsPlatformImpl {
return true;
}
- virtual bool SendsEvent(TtsEventType event_type) {
- return (event_type == TTS_EVENT_END ||
- event_type == TTS_EVENT_WORD);
- }
-
-
- MOCK_METHOD4(Speak,
+ MOCK_METHOD5(Speak,
bool(int utterance_id,
const std::string& utterance,
const std::string& lang,
+ const VoiceData& voice,
const UtteranceContinuousParameters& params));
+
MOCK_METHOD0(StopSpeaking, bool(void));
MOCK_METHOD0(IsSpeaking, bool(void));
+ MOCK_METHOD1(GetVoices, void(std::vector<VoiceData>*));
+
void SetErrorToEpicFail() {
set_error("epic fail");
}
@@ -58,6 +56,7 @@ class MockTtsPlatformImpl : public TtsPlatformImpl {
void SendEndEvent(int utterance_id,
const std::string& utterance,
const std::string& lang,
+ const VoiceData& voice,
const UtteranceContinuousParameters& params) {
MessageLoop::current()->PostDelayedTask(
FROM_HERE, base::Bind(
@@ -72,6 +71,7 @@ class MockTtsPlatformImpl : public TtsPlatformImpl {
int utterance_id,
const std::string& utterance,
const std::string& lang,
+ const VoiceData& voice,
const UtteranceContinuousParameters& params) {
MessageLoop::current()->PostDelayedTask(
FROM_HERE, base::Bind(
@@ -84,6 +84,7 @@ class MockTtsPlatformImpl : public TtsPlatformImpl {
void SendWordEvents(int utterance_id,
const std::string& utterance,
const std::string& lang,
+ const VoiceData& voice,
const UtteranceContinuousParameters& params) {
for (int i = 0; i < static_cast<int>(utterance.size()); i++) {
if (i == 0 || utterance[i - 1] == ' ') {
@@ -126,6 +127,8 @@ class TtsApiTest : public ExtensionApiTest {
virtual void SetUpInProcessBrowserTestFixture() {
ExtensionApiTest::SetUpInProcessBrowserTestFixture();
TtsController::GetInstance()->SetPlatformImpl(&mock_platform_impl_);
+ EXPECT_CALL(mock_platform_impl_, GetVoices(_))
+ .Times(AnyNumber());
}
protected:
@@ -138,23 +141,23 @@ IN_PROC_BROWSER_TEST_F(TtsApiTest, PlatformSpeakOptionalArgs) {
InSequence s;
EXPECT_CALL(mock_platform_impl_, StopSpeaking())
.WillOnce(Return(true));
- EXPECT_CALL(mock_platform_impl_, Speak(_, "", _, _))
+ EXPECT_CALL(mock_platform_impl_, Speak(_, "", _, _, _))
.WillOnce(Return(true));
EXPECT_CALL(mock_platform_impl_, StopSpeaking())
.WillOnce(Return(true));
- EXPECT_CALL(mock_platform_impl_, Speak(_, "Alpha", _, _))
+ EXPECT_CALL(mock_platform_impl_, Speak(_, "Alpha", _, _, _))
.WillOnce(Return(true));
EXPECT_CALL(mock_platform_impl_, StopSpeaking())
.WillOnce(Return(true));
- EXPECT_CALL(mock_platform_impl_, Speak(_, "Bravo", _, _))
+ EXPECT_CALL(mock_platform_impl_, Speak(_, "Bravo", _, _, _))
.WillOnce(Return(true));
EXPECT_CALL(mock_platform_impl_, StopSpeaking())
.WillOnce(Return(true));
- EXPECT_CALL(mock_platform_impl_, Speak(_, "Charlie", _, _))
+ EXPECT_CALL(mock_platform_impl_, Speak(_, "Charlie", _, _, _))
.WillOnce(Return(true));
EXPECT_CALL(mock_platform_impl_, StopSpeaking())
.WillOnce(Return(true));
- EXPECT_CALL(mock_platform_impl_, Speak(_, "Echo", _, _))
+ EXPECT_CALL(mock_platform_impl_, Speak(_, "Echo", _, _, _))
.WillOnce(Return(true));
ASSERT_TRUE(RunExtensionTest("tts/optional_args")) << message_;
}
@@ -164,7 +167,7 @@ IN_PROC_BROWSER_TEST_F(TtsApiTest, PlatformSpeakFinishesImmediately) {
EXPECT_CALL(mock_platform_impl_, IsSpeaking());
EXPECT_CALL(mock_platform_impl_, StopSpeaking())
.WillOnce(Return(true));
- EXPECT_CALL(mock_platform_impl_, Speak(_, _, _, _))
+ EXPECT_CALL(mock_platform_impl_, Speak(_, _, _, _, _))
.WillOnce(DoAll(
Invoke(&mock_platform_impl_,
&MockTtsPlatformImpl::SendEndEvent),
@@ -179,12 +182,12 @@ IN_PROC_BROWSER_TEST_F(TtsApiTest, PlatformSpeakInterrupt) {
InSequence s;
EXPECT_CALL(mock_platform_impl_, StopSpeaking())
.WillOnce(Return(true));
- EXPECT_CALL(mock_platform_impl_, Speak(_, "text 1", _, _))
+ EXPECT_CALL(mock_platform_impl_, Speak(_, "text 1", _, _, _))
.WillOnce(Return(true));
// Expect the second utterance and allow it to finish.
EXPECT_CALL(mock_platform_impl_, StopSpeaking())
.WillOnce(Return(true));
- EXPECT_CALL(mock_platform_impl_, Speak(_, "text 2", _, _))
+ EXPECT_CALL(mock_platform_impl_, Speak(_, "text 2", _, _, _))
.WillOnce(DoAll(
Invoke(&mock_platform_impl_,
&MockTtsPlatformImpl::SendEndEvent),
@@ -196,18 +199,18 @@ IN_PROC_BROWSER_TEST_F(TtsApiTest, PlatformSpeakQueueInterrupt) {
EXPECT_CALL(mock_platform_impl_, IsSpeaking());
// In this test, two utterances are queued, and then a third
- // interrupts. Speak() never gets called on the second utterance.
+ // interrupts. Speak(, _) never gets called on the second utterance.
InSequence s;
EXPECT_CALL(mock_platform_impl_, StopSpeaking())
.WillOnce(Return(true));
- EXPECT_CALL(mock_platform_impl_, Speak(_, "text 1", _, _))
+ EXPECT_CALL(mock_platform_impl_, Speak(_, "text 1", _, _, _))
.WillOnce(Return(true));
// Don't expect the second utterance, because it's queued up and the
// first never finishes.
// Expect the third utterance and allow it to finish successfully.
EXPECT_CALL(mock_platform_impl_, StopSpeaking())
.WillOnce(Return(true));
- EXPECT_CALL(mock_platform_impl_, Speak(_, "text 3", _, _))
+ EXPECT_CALL(mock_platform_impl_, Speak(_, "text 3", _, _, _))
.WillOnce(DoAll(
Invoke(&mock_platform_impl_,
&MockTtsPlatformImpl::SendEndEvent),
@@ -221,12 +224,12 @@ IN_PROC_BROWSER_TEST_F(TtsApiTest, PlatformSpeakEnqueue) {
InSequence s;
EXPECT_CALL(mock_platform_impl_, StopSpeaking())
.WillOnce(Return(true));
- EXPECT_CALL(mock_platform_impl_, Speak(_, "text 1", _, _))
+ EXPECT_CALL(mock_platform_impl_, Speak(_, "text 1", _, _, _))
.WillOnce(DoAll(
Invoke(&mock_platform_impl_,
&MockTtsPlatformImpl::SendEndEventWhenQueueNotEmpty),
Return(true)));
- EXPECT_CALL(mock_platform_impl_, Speak(_, "text 2", _, _))
+ EXPECT_CALL(mock_platform_impl_, Speak(_, "text 2", _, _, _))
.WillOnce(DoAll(
Invoke(&mock_platform_impl_,
&MockTtsPlatformImpl::SendEndEvent),
@@ -241,7 +244,7 @@ IN_PROC_BROWSER_TEST_F(TtsApiTest, PlatformSpeakError) {
InSequence s;
EXPECT_CALL(mock_platform_impl_, StopSpeaking())
.WillOnce(Return(true));
- EXPECT_CALL(mock_platform_impl_, Speak(_, "first try", _, _))
+ EXPECT_CALL(mock_platform_impl_, Speak(_, "first try", _, _, _))
.WillOnce(DoAll(
InvokeWithoutArgs(
CreateFunctor(&mock_platform_impl_,
@@ -249,7 +252,7 @@ IN_PROC_BROWSER_TEST_F(TtsApiTest, PlatformSpeakError) {
Return(false)));
EXPECT_CALL(mock_platform_impl_, StopSpeaking())
.WillOnce(Return(true));
- EXPECT_CALL(mock_platform_impl_, Speak(_, "second try", _, _))
+ EXPECT_CALL(mock_platform_impl_, Speak(_, "second try", _, _, _))
.WillOnce(DoAll(
Invoke(&mock_platform_impl_,
&MockTtsPlatformImpl::SendEndEvent),
@@ -263,7 +266,7 @@ IN_PROC_BROWSER_TEST_F(TtsApiTest, PlatformWordCallbacks) {
InSequence s;
EXPECT_CALL(mock_platform_impl_, StopSpeaking())
.WillOnce(Return(true));
- EXPECT_CALL(mock_platform_impl_, Speak(_, "one two three", _, _))
+ EXPECT_CALL(mock_platform_impl_, Speak(_, "one two three", _, _, _))
.WillOnce(DoAll(
Invoke(&mock_platform_impl_,
&MockTtsPlatformImpl::SendWordEvents),
@@ -281,17 +284,17 @@ IN_PROC_BROWSER_TEST_F(TtsApiTest, RegisterEngine) {
{
InSequence s;
- EXPECT_CALL(mock_platform_impl_, Speak(_, "native speech", _, _))
+ EXPECT_CALL(mock_platform_impl_, Speak(_, "native speech", _, _, _))
.WillOnce(DoAll(
Invoke(&mock_platform_impl_,
&MockTtsPlatformImpl::SendEndEvent),
Return(true)));
- EXPECT_CALL(mock_platform_impl_, Speak(_, "native speech 2", _, _))
+ EXPECT_CALL(mock_platform_impl_, Speak(_, "native speech 2", _, _, _))
.WillOnce(DoAll(
Invoke(&mock_platform_impl_,
&MockTtsPlatformImpl::SendEndEvent),
Return(true)));
- EXPECT_CALL(mock_platform_impl_, Speak(_, "native speech 3", _, _))
+ EXPECT_CALL(mock_platform_impl_, Speak(_, "native speech 3", _, _, _))
.WillOnce(DoAll(
Invoke(&mock_platform_impl_,
&MockTtsPlatformImpl::SendEndEvent),