Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / apps / app_speech_recognition_browsertest.cc
blob685510c1a3d1ef91e125e53230af62b0102a5396
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 "base/command_line.h"
6 #include "chrome/browser/apps/app_browsertest_util.h"
7 #include "content/public/common/content_switches.h"
8 #include "content/public/test/fake_speech_recognition_manager.h"
9 #include "media/base/media_switches.h"
11 class SpeechRecognitionTest : public extensions::PlatformAppBrowserTest {
12 public:
13 SpeechRecognitionTest() {}
14 ~SpeechRecognitionTest() override {}
16 protected:
17 void SetUp() override {
18 const testing::TestInfo* const test_info =
19 testing::UnitTest::GetInstance()->current_test_info();
20 // For SpeechRecognitionTest.SpeechFromBackgroundPage test, we need to
21 // fake the speech input to make tests run OK in bots.
22 if (!strcmp(test_info->name(), "SpeechFromBackgroundPage")) {
23 fake_speech_recognition_manager_.reset(
24 new content::FakeSpeechRecognitionManager());
25 fake_speech_recognition_manager_->set_should_send_fake_response(true);
26 // Inject the fake manager factory so that the test result is returned to
27 // the web page.
28 content::SpeechRecognitionManager::SetManagerForTesting(
29 fake_speech_recognition_manager_.get());
32 extensions::PlatformAppBrowserTest::SetUp();
35 void SetUpCommandLine(base::CommandLine* command_line) override {
36 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream);
37 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line);
40 private:
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 base::CommandLine::ForCurrentProcess()->AppendSwitch(
49 switches::kUseFakeUIForMediaStream);
50 ASSERT_TRUE(RunPlatformAppTest("platform_apps/speech/background_page"))
51 << message_;
54 IN_PROC_BROWSER_TEST_F(SpeechRecognitionTest,
55 SpeechFromBackgroundPageWithoutPermission) {
56 EXPECT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch(
57 switches::kUseFakeUIForMediaStream));
58 ASSERT_TRUE(
59 RunPlatformAppTest("platform_apps/speech/background_page_no_permission"))
60 << message_;