OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/extension_browsertest.h" | 5 #include "chrome/browser/extensions/extension_browsertest.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/extensions/extension_service.h" | 24 #include "chrome/browser/extensions/extension_service.h" |
25 #include "chrome/browser/extensions/extension_util.h" | 25 #include "chrome/browser/extensions/extension_util.h" |
26 #include "chrome/browser/extensions/unpacked_installer.h" | 26 #include "chrome/browser/extensions/unpacked_installer.h" |
27 #include "chrome/browser/extensions/updater/extension_cache_fake.h" | 27 #include "chrome/browser/extensions/updater/extension_cache_fake.h" |
28 #include "chrome/browser/extensions/updater/extension_updater.h" | 28 #include "chrome/browser/extensions/updater/extension_updater.h" |
29 #include "chrome/browser/profiles/profile.h" | 29 #include "chrome/browser/profiles/profile.h" |
30 #include "chrome/browser/profiles/profile_manager.h" | 30 #include "chrome/browser/profiles/profile_manager.h" |
31 #include "chrome/browser/ui/browser.h" | 31 #include "chrome/browser/ui/browser.h" |
32 #include "chrome/browser/ui/browser_window.h" | 32 #include "chrome/browser/ui/browser_window.h" |
33 #include "chrome/browser/ui/extensions/application_launch.h" | 33 #include "chrome/browser/ui/extensions/application_launch.h" |
| 34 #include "chrome/browser/ui/extensions/extension_message_bubble_factory.h" |
34 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 35 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
35 #include "chrome/common/chrome_paths.h" | 36 #include "chrome/common/chrome_paths.h" |
36 #include "chrome/common/chrome_switches.h" | 37 #include "chrome/common/chrome_switches.h" |
37 #include "components/version_info/version_info.h" | 38 #include "components/version_info/version_info.h" |
38 #include "content/public/browser/navigation_controller.h" | 39 #include "content/public/browser/navigation_controller.h" |
39 #include "content/public/browser/navigation_entry.h" | 40 #include "content/public/browser/navigation_entry.h" |
40 #include "content/public/browser/notification_registrar.h" | 41 #include "content/public/browser/notification_registrar.h" |
41 #include "content/public/browser/notification_service.h" | 42 #include "content/public/browser/notification_service.h" |
42 #include "content/public/browser/render_view_host.h" | 43 #include "content/public/browser/render_view_host.h" |
43 #include "content/public/test/browser_test_utils.h" | 44 #include "content/public/test/browser_test_utils.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 void ExtensionBrowserTest::SetUp() { | 116 void ExtensionBrowserTest::SetUp() { |
116 test_extension_cache_.reset(new extensions::ExtensionCacheFake()); | 117 test_extension_cache_.reset(new extensions::ExtensionCacheFake()); |
117 InProcessBrowserTest::SetUp(); | 118 InProcessBrowserTest::SetUp(); |
118 } | 119 } |
119 | 120 |
120 void ExtensionBrowserTest::SetUpCommandLine(base::CommandLine* command_line) { | 121 void ExtensionBrowserTest::SetUpCommandLine(base::CommandLine* command_line) { |
121 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_); | 122 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_); |
122 test_data_dir_ = test_data_dir_.AppendASCII("extensions"); | 123 test_data_dir_ = test_data_dir_.AppendASCII("extensions"); |
123 observer_.reset(new ExtensionTestNotificationObserver(browser())); | 124 observer_.reset(new ExtensionTestNotificationObserver(browser())); |
124 | 125 |
| 126 // We don't want any warning bubbles for, e.g., unpacked extensions. |
| 127 ExtensionMessageBubbleFactory::set_override_for_tests( |
| 128 ExtensionMessageBubbleFactory::OVERRIDE_DISABLED); |
| 129 |
125 #if defined(OS_CHROMEOS) | 130 #if defined(OS_CHROMEOS) |
126 if (set_chromeos_user_) { | 131 if (set_chromeos_user_) { |
127 // This makes sure that we create the Default profile first, with no | 132 // This makes sure that we create the Default profile first, with no |
128 // ExtensionService and then the real profile with one, as we do when | 133 // ExtensionService and then the real profile with one, as we do when |
129 // running on chromeos. | 134 // running on chromeos. |
130 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser, | 135 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser, |
131 "TestUser@gmail.com"); | 136 "TestUser@gmail.com"); |
132 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); | 137 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); |
133 } | 138 } |
134 #endif | 139 #endif |
135 } | 140 } |
136 | 141 |
137 void ExtensionBrowserTest::SetUpOnMainThread() { | 142 void ExtensionBrowserTest::SetUpOnMainThread() { |
138 InProcessBrowserTest::SetUpOnMainThread(); | 143 InProcessBrowserTest::SetUpOnMainThread(); |
139 observer_.reset(new ExtensionTestNotificationObserver(browser())); | 144 observer_.reset(new ExtensionTestNotificationObserver(browser())); |
140 if (extension_service()->updater()) { | 145 if (extension_service()->updater()) { |
141 extension_service()->updater()->SetExtensionCacheForTesting( | 146 extension_service()->updater()->SetExtensionCacheForTesting( |
142 test_extension_cache_.get()); | 147 test_extension_cache_.get()); |
143 } | 148 } |
144 } | 149 } |
145 | 150 |
| 151 void ExtensionBrowserTest::TearDownOnMainThread() { |
| 152 ExtensionMessageBubbleFactory::set_override_for_tests( |
| 153 ExtensionMessageBubbleFactory::NO_OVERRIDE); |
| 154 InProcessBrowserTest::TearDownOnMainThread(); |
| 155 } |
| 156 |
146 const Extension* ExtensionBrowserTest::LoadExtension( | 157 const Extension* ExtensionBrowserTest::LoadExtension( |
147 const base::FilePath& path) { | 158 const base::FilePath& path) { |
148 return LoadExtensionWithFlags(path, kFlagEnableFileAccess); | 159 return LoadExtensionWithFlags(path, kFlagEnableFileAccess); |
149 } | 160 } |
150 | 161 |
151 const Extension* ExtensionBrowserTest::LoadExtensionIncognito( | 162 const Extension* ExtensionBrowserTest::LoadExtensionIncognito( |
152 const base::FilePath& path) { | 163 const base::FilePath& path) { |
153 return LoadExtensionWithFlags(path, | 164 return LoadExtensionWithFlags(path, |
154 kFlagEnableFileAccess | kFlagEnableIncognito); | 165 kFlagEnableFileAccess | kFlagEnableIncognito); |
155 } | 166 } |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 return extensions::browsertest_util::ExecuteScriptInBackgroundPage( | 682 return extensions::browsertest_util::ExecuteScriptInBackgroundPage( |
672 profile(), extension_id, script); | 683 profile(), extension_id, script); |
673 } | 684 } |
674 | 685 |
675 bool ExtensionBrowserTest::ExecuteScriptInBackgroundPageNoWait( | 686 bool ExtensionBrowserTest::ExecuteScriptInBackgroundPageNoWait( |
676 const std::string& extension_id, | 687 const std::string& extension_id, |
677 const std::string& script) { | 688 const std::string& script) { |
678 return extensions::browsertest_util::ExecuteScriptInBackgroundPageNoWait( | 689 return extensions::browsertest_util::ExecuteScriptInBackgroundPageNoWait( |
679 profile(), extension_id, script); | 690 profile(), extension_id, script); |
680 } | 691 } |
OLD | NEW |