| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/apps/app_browsertest_util.h" | 5 #include "chrome/browser/apps/app_browsertest_util.h" |
| 6 #include "content/public/common/content_switches.h" | 6 #include "content/public/common/content_switches.h" |
| 7 #include "content/public/test/fake_speech_recognition_manager.h" | 7 #include "content/public/test/fake_speech_recognition_manager.h" |
| 8 #include "media/base/media_switches.h" | 8 #include "media/base/media_switches.h" |
| 9 | 9 |
| 10 class SpeechRecognitionTest : public extensions::PlatformAppBrowserTest { | 10 class SpeechRecognitionTest : public extensions::PlatformAppBrowserTest { |
| 11 public: | 11 public: |
| 12 SpeechRecognitionTest() {} | 12 SpeechRecognitionTest() {} |
| 13 virtual ~SpeechRecognitionTest() {} | 13 virtual ~SpeechRecognitionTest() {} |
| 14 | 14 |
| 15 protected: | 15 protected: |
| 16 virtual void SetUp() OVERRIDE { | 16 virtual void SetUp() override { |
| 17 const testing::TestInfo* const test_info = | 17 const testing::TestInfo* const test_info = |
| 18 testing::UnitTest::GetInstance()->current_test_info(); | 18 testing::UnitTest::GetInstance()->current_test_info(); |
| 19 // For SpeechRecognitionTest.SpeechFromBackgroundPage test, we need to | 19 // For SpeechRecognitionTest.SpeechFromBackgroundPage test, we need to |
| 20 // fake the speech input to make tests run OK in bots. | 20 // fake the speech input to make tests run OK in bots. |
| 21 if (!strcmp(test_info->name(), "SpeechFromBackgroundPage")) { | 21 if (!strcmp(test_info->name(), "SpeechFromBackgroundPage")) { |
| 22 fake_speech_recognition_manager_.reset( | 22 fake_speech_recognition_manager_.reset( |
| 23 new content::FakeSpeechRecognitionManager()); | 23 new content::FakeSpeechRecognitionManager()); |
| 24 fake_speech_recognition_manager_->set_should_send_fake_response(true); | 24 fake_speech_recognition_manager_->set_should_send_fake_response(true); |
| 25 // Inject the fake manager factory so that the test result is returned to | 25 // Inject the fake manager factory so that the test result is returned to |
| 26 // the web page. | 26 // the web page. |
| 27 content::SpeechRecognitionManager::SetManagerForTesting( | 27 content::SpeechRecognitionManager::SetManagerForTesting( |
| 28 fake_speech_recognition_manager_.get()); | 28 fake_speech_recognition_manager_.get()); |
| 29 } | 29 } |
| 30 | 30 |
| 31 extensions::PlatformAppBrowserTest::SetUp(); | 31 extensions::PlatformAppBrowserTest::SetUp(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 34 virtual void SetUpCommandLine(CommandLine* command_line) override { |
| 35 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); | 35 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); |
| 36 command_line->AppendSwitch(switches::kUseFakeUIForMediaStream); | 36 command_line->AppendSwitch(switches::kUseFakeUIForMediaStream); |
| 37 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line); | 37 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line); |
| 38 } | 38 } |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 scoped_ptr<content::FakeSpeechRecognitionManager> | 41 scoped_ptr<content::FakeSpeechRecognitionManager> |
| 42 fake_speech_recognition_manager_; | 42 fake_speech_recognition_manager_; |
| 43 | 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionTest); | 44 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionTest); |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 IN_PROC_BROWSER_TEST_F(SpeechRecognitionTest, SpeechFromBackgroundPage) { | 47 IN_PROC_BROWSER_TEST_F(SpeechRecognitionTest, SpeechFromBackgroundPage) { |
| 48 ASSERT_TRUE(RunPlatformAppTest("platform_apps/speech/background_page")) | 48 ASSERT_TRUE(RunPlatformAppTest("platform_apps/speech/background_page")) |
| 49 << message_; | 49 << message_; |
| 50 } | 50 } |
| 51 | 51 |
| 52 IN_PROC_BROWSER_TEST_F(SpeechRecognitionTest, | 52 IN_PROC_BROWSER_TEST_F(SpeechRecognitionTest, |
| 53 SpeechFromBackgroundPageWithoutPermission) { | 53 SpeechFromBackgroundPageWithoutPermission) { |
| 54 ASSERT_TRUE( | 54 ASSERT_TRUE( |
| 55 RunPlatformAppTest("platform_apps/speech/background_page_no_permission")) | 55 RunPlatformAppTest("platform_apps/speech/background_page_no_permission")) |
| 56 << message_; | 56 << message_; |
| 57 } | 57 } |
| OLD | NEW |