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
3 // found in the LICENSE file.
5 #include "chrome/browser/apps/app_browsertest_util.h"
6 #include "content/public/common/content_switches.h"
7 #include "content/public/test/fake_speech_recognition_manager.h"
8 #include "media/base/media_switches.h"
10 class SpeechRecognitionTest
: public extensions::PlatformAppBrowserTest
{
12 SpeechRecognitionTest() {}
13 ~SpeechRecognitionTest() override
{}
16 void SetUp() override
{
17 const testing::TestInfo
* const test_info
=
18 testing::UnitTest::GetInstance()->current_test_info();
19 // For SpeechRecognitionTest.SpeechFromBackgroundPage test, we need to
20 // fake the speech input to make tests run OK in bots.
21 if (!strcmp(test_info
->name(), "SpeechFromBackgroundPage")) {
22 fake_speech_recognition_manager_
.reset(
23 new content::FakeSpeechRecognitionManager());
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
27 content::SpeechRecognitionManager::SetManagerForTesting(
28 fake_speech_recognition_manager_
.get());
31 extensions::PlatformAppBrowserTest::SetUp();
34 void SetUpCommandLine(CommandLine
* command_line
) override
{
35 command_line
->AppendSwitch(switches::kUseFakeDeviceForMediaStream
);
36 command_line
->AppendSwitch(switches::kUseFakeUIForMediaStream
);
37 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line
);
41 scoped_ptr
<content::FakeSpeechRecognitionManager
>
42 fake_speech_recognition_manager_
;
44 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionTest
);
47 IN_PROC_BROWSER_TEST_F(SpeechRecognitionTest
, SpeechFromBackgroundPage
) {
48 ASSERT_TRUE(RunPlatformAppTest("platform_apps/speech/background_page"))
52 IN_PROC_BROWSER_TEST_F(SpeechRecognitionTest
,
53 SpeechFromBackgroundPageWithoutPermission
) {
55 RunPlatformAppTest("platform_apps/speech/background_page_no_permission"))