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

Unified Diff: chrome/test/base/testing_browser_process.cc

Issue 2612733003: Machine-local policy files should not affect tests (Closed)
Patch Set: Improve comment Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/base/test_launcher_utils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/testing_browser_process.cc
diff --git a/chrome/test/base/testing_browser_process.cc b/chrome/test/base/testing_browser_process.cc
index bed25a5cb9437e27700d6af2bbee38b35cb9889f..758ce502b8520831ea39856201171350e7494582 100644
--- a/chrome/test/base/testing_browser_process.cc
+++ b/chrome/test/base/testing_browser_process.cc
@@ -4,6 +4,7 @@
#include "chrome/test/base/testing_browser_process.h"
+#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/time/default_clock.h"
#include "base/time/default_tick_clock.h"
@@ -17,6 +18,7 @@
#include "chrome/browser/printing/print_job_manager.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
+#include "chrome/common/chrome_paths.h"
#include "chrome/common/features.h"
#include "chrome/test/base/testing_browser_process_platform_part.h"
#include "components/network_time/network_time_tracker.h"
@@ -151,6 +153,19 @@ policy::BrowserPolicyConnector*
if (!browser_policy_connector_) {
EXPECT_FALSE(created_browser_policy_connector_);
created_browser_policy_connector_ = true;
+
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
+ // Make sure that the machine policy directory does not exist so that
+ // machine-wide policies do not affect tests.
+ // Note that passing false as last argument to OverrideAndCreateIfNeeded
+ // means that the directory will not be created.
+ // If a test needs to place a file in this directory in the future, we could
+ // create a temporary directory and make its path available to tests.
+ base::FilePath local_policy_path("/tmp/non/existing/directory");
+ EXPECT_TRUE(PathService::OverrideAndCreateIfNeeded(
+ chrome::DIR_POLICY_FILES, local_policy_path, true, false));
+#endif
+
browser_policy_connector_ = platform_part_->CreateBrowserPolicyConnector();
// Note: creating the ChromeBrowserPolicyConnector invokes BrowserThread::
« no previous file with comments | « chrome/test/base/test_launcher_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698