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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/environment.h" | 8 #include "base/environment.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
15 #include "components/encryptor/encryptor_switches.h" | 15 #include "components/os_crypt/os_crypt_switches.h" |
16 | 16 |
17 #if defined(USE_AURA) | 17 #if defined(USE_AURA) |
18 #include "ui/wm/core/wm_core_switches.h" | 18 #include "ui/wm/core/wm_core_switches.h" |
19 #endif | 19 #endif |
20 | 20 |
21 namespace test_launcher_utils { | 21 namespace test_launcher_utils { |
22 | 22 |
23 void PrepareBrowserCommandLineForTests(CommandLine* command_line) { | 23 void PrepareBrowserCommandLineForTests(CommandLine* command_line) { |
24 // Turn off tip loading for tests; see http://crbug.com/17725. | 24 // Turn off tip loading for tests; see http://crbug.com/17725. |
25 command_line->AppendSwitch(switches::kDisableWebResources); | 25 command_line->AppendSwitch(switches::kDisableWebResources); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // Don't use the native password stores on Linux since they may | 59 // Don't use the native password stores on Linux since they may |
60 // prompt for additional UI during tests and cause test failures or | 60 // prompt for additional UI during tests and cause test failures or |
61 // timeouts. Win, Mac and ChromeOS don't look at the kPasswordStore | 61 // timeouts. Win, Mac and ChromeOS don't look at the kPasswordStore |
62 // switch. | 62 // switch. |
63 if (!command_line->HasSwitch(switches::kPasswordStore)) | 63 if (!command_line->HasSwitch(switches::kPasswordStore)) |
64 command_line->AppendSwitchASCII(switches::kPasswordStore, "basic"); | 64 command_line->AppendSwitchASCII(switches::kPasswordStore, "basic"); |
65 #endif | 65 #endif |
66 | 66 |
67 #if defined(OS_MACOSX) | 67 #if defined(OS_MACOSX) |
68 // Use mock keychain on mac to prevent blocking permissions dialogs. | 68 // Use mock keychain on mac to prevent blocking permissions dialogs. |
69 command_line->AppendSwitch(encryptor::switches::kUseMockKeychain); | 69 command_line->AppendSwitch(os_crypt::switches::kUseMockKeychain); |
70 #endif | 70 #endif |
71 | 71 |
72 command_line->AppendSwitch(switches::kDisableComponentUpdate); | 72 command_line->AppendSwitch(switches::kDisableComponentUpdate); |
73 } | 73 } |
74 | 74 |
75 bool OverrideUserDataDir(const base::FilePath& user_data_dir) { | 75 bool OverrideUserDataDir(const base::FilePath& user_data_dir) { |
76 bool success = true; | 76 bool success = true; |
77 | 77 |
78 // PathService::Override() is the best way to change the user data directory. | 78 // PathService::Override() is the best way to change the user data directory. |
79 // This matches what is done in ChromeMain(). | 79 // This matches what is done in ChromeMain(). |
80 success = PathService::Override(chrome::DIR_USER_DATA, user_data_dir); | 80 success = PathService::Override(chrome::DIR_USER_DATA, user_data_dir); |
81 | 81 |
82 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 82 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
83 // Make sure the cache directory is inside our clear profile. Otherwise | 83 // Make sure the cache directory is inside our clear profile. Otherwise |
84 // the cache may contain data from earlier tests that could break the | 84 // the cache may contain data from earlier tests that could break the |
85 // current test. | 85 // current test. |
86 // | 86 // |
87 // Note: we use an environment variable here, because we have to pass the | 87 // Note: we use an environment variable here, because we have to pass the |
88 // value to the child process. This is the simplest way to do it. | 88 // value to the child process. This is the simplest way to do it. |
89 scoped_ptr<base::Environment> env(base::Environment::Create()); | 89 scoped_ptr<base::Environment> env(base::Environment::Create()); |
90 success = success && env->SetVar("XDG_CACHE_HOME", user_data_dir.value()); | 90 success = success && env->SetVar("XDG_CACHE_HOME", user_data_dir.value()); |
91 #endif | 91 #endif |
92 | 92 |
93 return success; | 93 return success; |
94 } | 94 } |
95 | 95 |
96 } // namespace test_launcher_utils | 96 } // namespace test_launcher_utils |
OLD | NEW |