OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
14 #include "chrome/browser/extensions/component_loader.h" | 14 #include "chrome/browser/extensions/component_loader.h" |
15 #include "chrome/browser/extensions/extension_apitest.h" | 15 #include "chrome/browser/extensions/extension_apitest.h" |
16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
17 #include "chrome/browser/speech/extension_api/tts_extension_api.h" | 17 #include "chrome/browser/speech/extension_api/tts_extension_api.h" |
18 #include "chrome/browser/speech/tts_controller.h" | 18 #include "chrome/browser/speech/tts_controller.h" |
19 #include "chrome/browser/speech/tts_platform.h" | 19 #include "chrome/browser/speech/tts_platform.h" |
20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
21 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
22 #include "content/public/test/test_utils.h" | 22 #include "content/public/test/test_utils.h" |
23 #include "extensions/browser/extension_system.h" | 23 #include "extensions/browser/extension_system.h" |
24 #include "net/base/network_change_notifier.h" | 24 #include "net/base/network_change_notifier.h" |
25 #include "testing/gmock/include/gmock/gmock.h" | 25 #include "testing/gmock/include/gmock/gmock.h" |
| 26 #include "testing/gmock_mutant.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
27 | 28 |
28 // Needed for CreateFunctor. | |
29 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING | |
30 #include "testing/gmock_mutant.h" | |
31 | |
32 using ::testing::AnyNumber; | 29 using ::testing::AnyNumber; |
33 using ::testing::CreateFunctor; | 30 using ::testing::CreateFunctor; |
34 using ::testing::DoAll; | 31 using ::testing::DoAll; |
35 using ::testing::Invoke; | 32 using ::testing::Invoke; |
36 using ::testing::InSequence; | 33 using ::testing::InSequence; |
37 using ::testing::InvokeWithoutArgs; | 34 using ::testing::InvokeWithoutArgs; |
38 using ::testing::Return; | 35 using ::testing::Return; |
39 using ::testing::SaveArg; | 36 using ::testing::SaveArg; |
40 using ::testing::SetArgPointee; | 37 using ::testing::SetArgPointee; |
41 using ::testing::StrictMock; | 38 using ::testing::StrictMock; |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 IN_PROC_BROWSER_TEST_F(TtsApiTest, PlatformSpeakError) { | 307 IN_PROC_BROWSER_TEST_F(TtsApiTest, PlatformSpeakError) { |
311 EXPECT_CALL(mock_platform_impl_, IsSpeaking()) | 308 EXPECT_CALL(mock_platform_impl_, IsSpeaking()) |
312 .Times(AnyNumber()); | 309 .Times(AnyNumber()); |
313 | 310 |
314 InSequence s; | 311 InSequence s; |
315 EXPECT_CALL(mock_platform_impl_, StopSpeaking()) | 312 EXPECT_CALL(mock_platform_impl_, StopSpeaking()) |
316 .WillOnce(Return(true)); | 313 .WillOnce(Return(true)); |
317 EXPECT_CALL(mock_platform_impl_, Speak(_, "first try", _, _, _)) | 314 EXPECT_CALL(mock_platform_impl_, Speak(_, "first try", _, _, _)) |
318 .WillOnce(DoAll( | 315 .WillOnce(DoAll( |
319 InvokeWithoutArgs( | 316 InvokeWithoutArgs( |
320 CreateFunctor(&mock_platform_impl_, | 317 CreateFunctor(&MockTtsPlatformImpl::SetErrorToEpicFail, |
321 &MockTtsPlatformImpl::SetErrorToEpicFail)), | 318 base::Unretained(&mock_platform_impl_))), |
322 Return(false))); | 319 Return(false))); |
323 EXPECT_CALL(mock_platform_impl_, StopSpeaking()) | 320 EXPECT_CALL(mock_platform_impl_, StopSpeaking()) |
324 .WillOnce(Return(true)); | 321 .WillOnce(Return(true)); |
325 EXPECT_CALL(mock_platform_impl_, Speak(_, "second try", _, _, _)) | 322 EXPECT_CALL(mock_platform_impl_, Speak(_, "second try", _, _, _)) |
326 .WillOnce(DoAll( | 323 .WillOnce(DoAll( |
327 Invoke(&mock_platform_impl_, | 324 Invoke(&mock_platform_impl_, |
328 &MockTtsPlatformImpl::SendEndEvent), | 325 &MockTtsPlatformImpl::SendEndEvent), |
329 Return(true))); | 326 Return(true))); |
330 ASSERT_TRUE(RunExtensionTest("tts/speak_error")) << message_; | 327 ASSERT_TRUE(RunExtensionTest("tts/speak_error")) << message_; |
331 } | 328 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 // Test should fail when offline. | 452 // Test should fail when offline. |
456 ASSERT_FALSE(RunExtensionTest("tts_engine/network_speech_engine")); | 453 ASSERT_FALSE(RunExtensionTest("tts_engine/network_speech_engine")); |
457 } | 454 } |
458 | 455 |
459 // http://crbug.com/122474 | 456 // http://crbug.com/122474 |
460 IN_PROC_BROWSER_TEST_F(TtsApiTest, EngineApi) { | 457 IN_PROC_BROWSER_TEST_F(TtsApiTest, EngineApi) { |
461 ASSERT_TRUE(RunExtensionTest("tts_engine/engine_api")) << message_; | 458 ASSERT_TRUE(RunExtensionTest("tts_engine/engine_api")) << message_; |
462 } | 459 } |
463 | 460 |
464 } // namespace extensions | 461 } // namespace extensions |
OLD | NEW |