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/test_launcher_utils.h" | 5 #include "chrome/test/base/test_launcher_utils.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/environment.h" | 10 #include "base/environment.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 100 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
101 // Make sure the cache directory is inside our clear profile. Otherwise | 101 // Make sure the cache directory is inside our clear profile. Otherwise |
102 // the cache may contain data from earlier tests that could break the | 102 // the cache may contain data from earlier tests that could break the |
103 // current test. | 103 // current test. |
104 // | 104 // |
105 // Note: we use an environment variable here, because we have to pass the | 105 // Note: we use an environment variable here, because we have to pass the |
106 // value to the child process. This is the simplest way to do it. | 106 // value to the child process. This is the simplest way to do it. |
107 std::unique_ptr<base::Environment> env(base::Environment::Create()); | 107 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
108 success = success && env->SetVar("XDG_CACHE_HOME", user_data_dir.value()); | 108 success = success && env->SetVar("XDG_CACHE_HOME", user_data_dir.value()); |
| 109 |
| 110 // Also make sure that the machine policy directory is inside the clear |
| 111 // profile. Otherwise the machine's policies could affect tests. |
| 112 base::FilePath policy_files = user_data_dir.AppendASCII("policies"); |
| 113 success = |
| 114 success && PathService::Override(chrome::DIR_POLICY_FILES, policy_files); |
109 #endif | 115 #endif |
110 | 116 |
111 return success; | 117 return success; |
112 } | 118 } |
113 | 119 |
114 } // namespace test_launcher_utils | 120 } // namespace test_launcher_utils |
OLD | NEW |