| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
| 6 #include "base/prefs/pref_service.h" | 6 #include "base/prefs/pref_service.h" |
| 7 #include "chrome/browser/extensions/component_loader.h" | 7 #include "chrome/browser/extensions/component_loader.h" |
| 8 #include "chrome/browser/extensions/error_console/error_console.h" | 8 #include "chrome/browser/extensions/error_console/error_console.h" |
| 9 #include "chrome/browser/extensions/extension_browsertest.h" | 9 #include "chrome/browser/extensions/extension_browsertest.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 13 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
| 14 #include "extensions/common/extension.h" | 15 #include "extensions/common/extension.h" |
| 15 #include "extensions/test/extension_test_message_listener.h" | 16 #include "extensions/test/extension_test_message_listener.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 18 |
| 18 | 19 |
| 19 namespace extensions { | 20 namespace extensions { |
| 20 | 21 |
| 21 static const char kHotwordHelperExtensionId[] = | 22 static const char kHotwordHelperExtensionId[] = |
| 22 "dnhpdliibojhegemfjheidglijccjfmc"; | 23 "dnhpdliibojhegemfjheidglijccjfmc"; |
| 23 | 24 |
| 24 class HotwordBrowserTest : public ExtensionBrowserTest { | 25 class HotwordBrowserTest : public ExtensionBrowserTest { |
| 25 public: | 26 public: |
| 26 HotwordBrowserTest() : error_console_(NULL) { } | 27 HotwordBrowserTest() : error_console_(NULL) { } |
| 27 ~HotwordBrowserTest() override {} | 28 ~HotwordBrowserTest() override {} |
| 28 | 29 |
| 29 protected: | 30 protected: |
| 30 void SetUpInProcessBrowserTestFixture() override { | 31 void SetUpInProcessBrowserTestFixture() override { |
| 31 ExtensionBrowserTest::SetUpInProcessBrowserTestFixture(); | 32 ExtensionBrowserTest::SetUpInProcessBrowserTestFixture(); |
| 32 | 33 |
| 33 // Force the VoiceTrigger field trial on to enable the hotword_helper | 34 // Force the VoiceTrigger field trial on to enable the hotword_helper |
| 34 // extension. | 35 // extension. |
| 35 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 36 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 36 switches::kForceFieldTrials, "VoiceTrigger/Install/"); | 37 switches::kForceFieldTrials, "VoiceTrigger/Install/"); |
| 38 // This test is only valid with version 1 of hotwording. |
| 39 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 40 switches::kDisableExperimentalHotwording); |
| 37 // Load the hotword_helper extension. | 41 // Load the hotword_helper extension. |
| 38 ComponentLoader::EnableBackgroundExtensionsForTesting(); | 42 ComponentLoader::EnableBackgroundExtensionsForTesting(); |
| 39 | 43 |
| 40 // We need to enable the ErrorConsole FeatureSwitch in order to collect | 44 // We need to enable the ErrorConsole FeatureSwitch in order to collect |
| 41 // errors. This should be enabled on any channel <= Dev, but let's make | 45 // errors. This should be enabled on any channel <= Dev, but let's make |
| 42 // sure (in case a test is running on, e.g., a beta channel). | 46 // sure (in case a test is running on, e.g., a beta channel). |
| 43 FeatureSwitch::error_console()->SetOverrideValue( | 47 FeatureSwitch::error_console()->SetOverrideValue( |
| 44 FeatureSwitch::OVERRIDE_ENABLED); | 48 FeatureSwitch::OVERRIDE_ENABLED); |
| 45 } | 49 } |
| 46 | 50 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 76 ASSERT_TRUE(extension); | 80 ASSERT_TRUE(extension); |
| 77 const Extension* test_extension = LoadExtension( | 81 const Extension* test_extension = LoadExtension( |
| 78 test_data_dir_.AppendASCII("hotword")); | 82 test_data_dir_.AppendASCII("hotword")); |
| 79 ASSERT_TRUE(test_extension); | 83 ASSERT_TRUE(test_extension); |
| 80 | 84 |
| 81 ASSERT_TRUE(doneListener.WaitUntilSatisfied()); | 85 ASSERT_TRUE(doneListener.WaitUntilSatisfied()); |
| 82 ASSERT_TRUE(error_console()->GetErrorsForExtension(extension->id()).empty()); | 86 ASSERT_TRUE(error_console()->GetErrorsForExtension(extension->id()).empty()); |
| 83 } | 87 } |
| 84 | 88 |
| 85 } // namespace extensions | 89 } // namespace extensions |
| OLD | NEW |