Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: chrome/browser/extensions/extension_startup_browsertest.cc

Issue 11724002: Move ContentScripts out of Extension (Closed) Base URL: http://git.chromium.org/chromium/src.git@dc_unref_browser_action
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <vector> 5 #include <vector>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/extensions/extension_system.h" 13 #include "chrome/browser/extensions/extension_system.h"
14 #include "chrome/browser/extensions/user_script_master.h" 14 #include "chrome/browser/extensions/user_script_master.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" 17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "chrome/common/chrome_notification_types.h" 18 #include "chrome/common/chrome_notification_types.h"
19 #include "chrome/common/chrome_paths.h" 19 #include "chrome/common/chrome_paths.h"
20 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/extensions/api/content_scripts/content_scripts_handler.h "
21 #include "chrome/common/extensions/feature_switch.h" 22 #include "chrome/common/extensions/feature_switch.h"
23 #include "chrome/common/extensions/manifest_handler.h"
22 #include "chrome/test/base/in_process_browser_test.h" 24 #include "chrome/test/base/in_process_browser_test.h"
23 #include "chrome/test/base/testing_profile.h" 25 #include "chrome/test/base/testing_profile.h"
24 #include "chrome/test/base/ui_test_utils.h" 26 #include "chrome/test/base/ui_test_utils.h"
25 #include "content/public/browser/notification_details.h" 27 #include "content/public/browser/notification_details.h"
26 #include "content/public/browser/notification_service.h" 28 #include "content/public/browser/notification_service.h"
27 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
28 #include "content/public/test/browser_test_utils.h" 30 #include "content/public/test/browser_test_utils.h"
29 #include "net/base/net_util.h" 31 #include "net/base/net_util.h"
30 32
31 using extensions::FeatureSwitch; 33 using extensions::FeatureSwitch;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 if (enable_extensions_ && load_extensions_.empty()) { 71 if (enable_extensions_ && load_extensions_.empty()) {
70 base::FilePath src_dir; 72 base::FilePath src_dir;
71 PathService::Get(chrome::DIR_TEST_DATA, &src_dir); 73 PathService::Get(chrome::DIR_TEST_DATA, &src_dir);
72 src_dir = src_dir.AppendASCII("extensions").AppendASCII("good"); 74 src_dir = src_dir.AppendASCII("extensions").AppendASCII("good");
73 75
74 file_util::CopyFile(src_dir.AppendASCII("Preferences"), 76 file_util::CopyFile(src_dir.AppendASCII("Preferences"),
75 preferences_file_); 77 preferences_file_);
76 file_util::CopyDirectory(src_dir.AppendASCII("Extensions"), 78 file_util::CopyDirectory(src_dir.AppendASCII("Extensions"),
77 profile_dir, true); // recursive 79 profile_dir, true); // recursive
78 } 80 }
81
79 return true; 82 return true;
80 } 83 }
81 84
85 virtual void SetUpOnMainThread() OVERRIDE {
86 InProcessBrowserTest::SetUpOnMainThread();
87 (new extensions::ContentScriptsHandler)->Register();
88 }
89
82 virtual void TearDown() { 90 virtual void TearDown() {
83 EXPECT_TRUE(file_util::Delete(preferences_file_, false)); 91 EXPECT_TRUE(file_util::Delete(preferences_file_, false));
84 92
85 // TODO(phajdan.jr): Check return values of the functions below, carefully. 93 // TODO(phajdan.jr): Check return values of the functions below, carefully.
86 file_util::Delete(user_scripts_dir_, true); 94 file_util::Delete(user_scripts_dir_, true);
87 file_util::Delete(extensions_dir_, true); 95 file_util::Delete(extensions_dir_, true);
88 96
97 extensions::ManifestHandler::ClearRegistryForTesting();
98
89 InProcessBrowserTest::TearDown(); 99 InProcessBrowserTest::TearDown();
90 } 100 }
91 101
92 void WaitForServicesToStart(int num_expected_extensions, 102 void WaitForServicesToStart(int num_expected_extensions,
93 bool expect_extensions_enabled) { 103 bool expect_extensions_enabled) {
94 ExtensionService* service = extensions::ExtensionSystem::Get( 104 ExtensionService* service = extensions::ExtensionSystem::Get(
95 browser()->profile())->extension_service(); 105 browser()->profile())->extension_service();
96 106
97 // Count the number of non-component extensions. 107 // Count the number of non-component extensions.
98 int found_extensions = 0; 108 int found_extensions = 0;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 .AppendASCII("extensions") 283 .AppendASCII("extensions")
274 .AppendASCII("app2"); 284 .AppendASCII("app2");
275 load_extensions_.push_back(fourth_extension_path.value()); 285 load_extensions_.push_back(fourth_extension_path.value());
276 } 286 }
277 }; 287 };
278 288
279 IN_PROC_BROWSER_TEST_F(ExtensionsLoadMultipleTest, Test) { 289 IN_PROC_BROWSER_TEST_F(ExtensionsLoadMultipleTest, Test) {
280 WaitForServicesToStart(4, true); 290 WaitForServicesToStart(4, true);
281 TestInjection(true, true); 291 TestInjection(true, true);
282 } 292 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698