Remove VoiceTrigger field trial.
[chromium-blink-merge.git] / chrome / browser / extensions / hotword_browsertest.cc
blobb06c814370b9e076500b5d5f50156fa3f3bb2fd5
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
3 // found in the LICENSE file.
5 #include "base/files/file_path.h"
6 #include "base/prefs/pref_service.h"
7 #include "chrome/browser/extensions/component_loader.h"
8 #include "chrome/browser/extensions/error_console/error_console.h"
9 #include "chrome/browser/extensions/extension_browsertest.h"
10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/pref_names.h"
14 #include "content/public/common/content_switches.h"
15 #include "extensions/common/extension.h"
16 #include "extensions/test/extension_test_message_listener.h"
17 #include "testing/gtest/include/gtest/gtest.h"
20 namespace extensions {
22 static const char kHotwordHelperExtensionId[] =
23 "dnhpdliibojhegemfjheidglijccjfmc";
25 class HotwordBrowserTest : public ExtensionBrowserTest {
26 public:
27 HotwordBrowserTest() : error_console_(NULL) { }
28 ~HotwordBrowserTest() override {}
30 protected:
31 void SetUpInProcessBrowserTestFixture() override {
32 ExtensionBrowserTest::SetUpInProcessBrowserTestFixture();
34 // Load the hotword_helper extension.
35 ComponentLoader::EnableBackgroundExtensionsForTesting();
37 // We need to enable the ErrorConsole FeatureSwitch in order to collect
38 // errors. This should be enabled on any channel <= Dev, but let's make
39 // sure (in case a test is running on, e.g., a beta channel).
40 FeatureSwitch::error_console()->SetOverrideValue(
41 FeatureSwitch::OVERRIDE_ENABLED);
44 void SetUpOnMainThread() override {
45 ExtensionBrowserTest::SetUpOnMainThread();
47 // Errors are only kept if we have Developer Mode enabled.
48 profile()->GetPrefs()->SetBoolean(prefs::kExtensionsUIDeveloperMode, true);
50 error_console_ = ErrorConsole::Get(profile());
51 ASSERT_TRUE(error_console_);
54 ErrorConsole* error_console() { return error_console_; }
56 private:
57 // Weak reference to the ErrorConsole.
58 ErrorConsole* error_console_;
60 DISALLOW_COPY_AND_ASSIGN(HotwordBrowserTest);
63 // Test we silently capture an exception from a message handler's response
64 // callback. This happens when the caller to chrome.runtime.sendMessage()
65 // doesn't specify a response callback.
66 // NOTE(amistry): Test is disabled instead of deleted since the functionality
67 // may still be required to implement crbug.com/436681
68 IN_PROC_BROWSER_TEST_F(HotwordBrowserTest, DISABLED_MessageSendResponseError) {
69 // Enable error reporting for the hotword helper extension.
70 error_console()->SetReportingAllForExtension(kHotwordHelperExtensionId, true);
72 ExtensionTestMessageListener doneListener("done", false);
73 const Extension* extension = extension_service()->GetExtensionById(
74 kHotwordHelperExtensionId, false);
75 ASSERT_TRUE(extension);
76 const Extension* test_extension = LoadExtension(
77 test_data_dir_.AppendASCII("hotword"));
78 ASSERT_TRUE(test_extension);
80 ASSERT_TRUE(doneListener.WaitUntilSatisfied());
81 ASSERT_TRUE(error_console()->GetErrorsForExtension(extension->id()).empty());
84 } // namespace extensions