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/test/base/testing_browser_process.h" | 5 #include "chrome/test/base/testing_browser_process.h" |
6 | 6 |
7 #include "base/path_service.h" | |
7 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
8 #include "base/time/default_clock.h" | 9 #include "base/time/default_clock.h" |
9 #include "base/time/default_tick_clock.h" | 10 #include "base/time/default_tick_clock.h" |
10 #include "build/build_config.h" | 11 #include "build/build_config.h" |
11 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/browser_process_impl.h" | 13 #include "chrome/browser/browser_process_impl.h" |
13 #include "chrome/browser/lifetime/application_lifetime.h" | 14 #include "chrome/browser/lifetime/application_lifetime.h" |
14 #include "chrome/browser/memory/tab_manager.h" | 15 #include "chrome/browser/memory/tab_manager.h" |
15 #include "chrome/browser/notifications/notification_platform_bridge.h" | 16 #include "chrome/browser/notifications/notification_platform_bridge.h" |
16 #include "chrome/browser/notifications/notification_ui_manager.h" | 17 #include "chrome/browser/notifications/notification_ui_manager.h" |
17 #include "chrome/browser/printing/print_job_manager.h" | 18 #include "chrome/browser/printing/print_job_manager.h" |
18 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
19 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 20 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
21 #include "chrome/common/chrome_paths.h" | |
20 #include "chrome/common/features.h" | 22 #include "chrome/common/features.h" |
21 #include "chrome/test/base/testing_browser_process_platform_part.h" | 23 #include "chrome/test/base/testing_browser_process_platform_part.h" |
22 #include "components/network_time/network_time_tracker.h" | 24 #include "components/network_time/network_time_tracker.h" |
23 #include "components/policy/core/browser/browser_policy_connector.h" | 25 #include "components/policy/core/browser/browser_policy_connector.h" |
24 #include "components/prefs/pref_service.h" | 26 #include "components/prefs/pref_service.h" |
25 #include "components/subresource_filter/core/browser/ruleset_service.h" | 27 #include "components/subresource_filter/core/browser/ruleset_service.h" |
26 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
27 #include "extensions/features/features.h" | 29 #include "extensions/features/features.h" |
28 #include "media/media_features.h" | 30 #include "media/media_features.h" |
29 #include "net/url_request/url_request_context_getter.h" | 31 #include "net/url_request/url_request_context_getter.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 | 146 |
145 variations::VariationsService* TestingBrowserProcess::variations_service() { | 147 variations::VariationsService* TestingBrowserProcess::variations_service() { |
146 return nullptr; | 148 return nullptr; |
147 } | 149 } |
148 | 150 |
149 policy::BrowserPolicyConnector* | 151 policy::BrowserPolicyConnector* |
150 TestingBrowserProcess::browser_policy_connector() { | 152 TestingBrowserProcess::browser_policy_connector() { |
151 if (!browser_policy_connector_) { | 153 if (!browser_policy_connector_) { |
152 EXPECT_FALSE(created_browser_policy_connector_); | 154 EXPECT_FALSE(created_browser_policy_connector_); |
153 created_browser_policy_connector_ = true; | 155 created_browser_policy_connector_ = true; |
156 | |
157 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
158 // Make sure that the machine policy directory does not exist so that | |
159 // machine-wide poilcies do not affect tests. | |
Thiemo Nagel
2017/01/10 13:24:37
Nit: typo
pmarko
2017/01/11 09:09:25
Done.
| |
160 // If a test needs to place a file in this directory in the future, we could | |
161 // create a temporary directory and make its path available to tests. | |
162 base::FilePath local_policy_path("/tmp/non/existing/directory"); | |
Paweł Hajdan Jr.
2017/01/05 15:48:02
Why is this in POSIX non-OSX #ifdef?
pmarko
2017/01/05 16:07:53
See Reply on test_launcher_util.cc - if we decide
| |
163 EXPECT_TRUE(PathService::OverrideAndCreateIfNeeded( | |
164 chrome::DIR_POLICY_FILES, local_policy_path, true, false)); | |
165 #endif | |
166 | |
154 browser_policy_connector_ = platform_part_->CreateBrowserPolicyConnector(); | 167 browser_policy_connector_ = platform_part_->CreateBrowserPolicyConnector(); |
155 | 168 |
156 // Note: creating the ChromeBrowserPolicyConnector invokes BrowserThread:: | 169 // Note: creating the ChromeBrowserPolicyConnector invokes BrowserThread:: |
157 // GetTaskRunnerForThread(), which initializes a base::LazyInstance of | 170 // GetTaskRunnerForThread(), which initializes a base::LazyInstance of |
158 // BrowserThreadTaskRunners. However, the threads that these task runners | 171 // BrowserThreadTaskRunners. However, the threads that these task runners |
159 // would run tasks on are *also* created lazily and might not exist yet. | 172 // would run tasks on are *also* created lazily and might not exist yet. |
160 // Creating them requires a MessageLoop, which a test can optionally create | 173 // Creating them requires a MessageLoop, which a test can optionally create |
161 // and manage itself, so don't do it here. | 174 // and manage itself, so don't do it here. |
162 } | 175 } |
163 return browser_policy_connector_.get(); | 176 return browser_policy_connector_.get(); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
456 | 469 |
457 /////////////////////////////////////////////////////////////////////////////// | 470 /////////////////////////////////////////////////////////////////////////////// |
458 | 471 |
459 TestingBrowserProcessInitializer::TestingBrowserProcessInitializer() { | 472 TestingBrowserProcessInitializer::TestingBrowserProcessInitializer() { |
460 TestingBrowserProcess::CreateInstance(); | 473 TestingBrowserProcess::CreateInstance(); |
461 } | 474 } |
462 | 475 |
463 TestingBrowserProcessInitializer::~TestingBrowserProcessInitializer() { | 476 TestingBrowserProcessInitializer::~TestingBrowserProcessInitializer() { |
464 TestingBrowserProcess::DeleteInstance(); | 477 TestingBrowserProcess::DeleteInstance(); |
465 } | 478 } |
OLD | NEW |