| 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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
| 16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "components/os_crypt/os_crypt_switches.h" | 17 #include "components/os_crypt/os_crypt_switches.h" |
| 18 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
| 19 | 19 |
| 20 #if defined(USE_AURA) | 20 #if defined(USE_AURA) |
| 21 #include "ui/wm/core/wm_core_switches.h" | 21 #include "ui/wm/core/wm_core_switches.h" |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 namespace test_launcher_utils { | 24 namespace test_launcher_utils { |
| 25 | 25 |
| 26 void PrepareBrowserCommandLineForTests(base::CommandLine* command_line) { | 26 void PrepareBrowserCommandLineForTests(base::CommandLine* command_line, |
| 27 bool enable_component_update) { |
| 27 // Turn off preconnects because they break the brittle python webserver; | 28 // Turn off preconnects because they break the brittle python webserver; |
| 28 // see http://crbug.com/60035. | 29 // see http://crbug.com/60035. |
| 29 command_line->AppendSwitch(switches::kDisablePreconnect); | 30 command_line->AppendSwitch(switches::kDisablePreconnect); |
| 30 | 31 |
| 31 // Don't show the first run ui. | 32 // Don't show the first run ui. |
| 32 command_line->AppendSwitch(switches::kNoFirstRun); | 33 command_line->AppendSwitch(switches::kNoFirstRun); |
| 33 | 34 |
| 34 // No default browser check, it would create an info-bar (if we are not the | 35 // No default browser check, it would create an info-bar (if we are not the |
| 35 // default browser) that could conflicts with some tests expectations. | 36 // default browser) that could conflicts with some tests expectations. |
| 36 command_line->AppendSwitch(switches::kNoDefaultBrowserCheck); | 37 command_line->AppendSwitch(switches::kNoDefaultBrowserCheck); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 62 // switch. | 63 // switch. |
| 63 if (!command_line->HasSwitch(switches::kPasswordStore)) | 64 if (!command_line->HasSwitch(switches::kPasswordStore)) |
| 64 command_line->AppendSwitchASCII(switches::kPasswordStore, "basic"); | 65 command_line->AppendSwitchASCII(switches::kPasswordStore, "basic"); |
| 65 #endif | 66 #endif |
| 66 | 67 |
| 67 #if defined(OS_MACOSX) | 68 #if defined(OS_MACOSX) |
| 68 // Use mock keychain on mac to prevent blocking permissions dialogs. | 69 // Use mock keychain on mac to prevent blocking permissions dialogs. |
| 69 command_line->AppendSwitch(os_crypt::switches::kUseMockKeychain); | 70 command_line->AppendSwitch(os_crypt::switches::kUseMockKeychain); |
| 70 #endif | 71 #endif |
| 71 | 72 |
| 72 command_line->AppendSwitch(switches::kDisableComponentUpdate); | 73 if (!enable_component_update) |
| 74 command_line->AppendSwitch(switches::kDisableComponentUpdate); |
| 73 } | 75 } |
| 74 | 76 |
| 75 bool OverrideUserDataDir(const base::FilePath& user_data_dir) { | 77 bool OverrideUserDataDir(const base::FilePath& user_data_dir) { |
| 76 bool success = true; | 78 bool success = true; |
| 77 | 79 |
| 78 // PathService::Override() is the best way to change the user data directory. | 80 // PathService::Override() is the best way to change the user data directory. |
| 79 // This matches what is done in ChromeMain(). | 81 // This matches what is done in ChromeMain(). |
| 80 success = PathService::Override(chrome::DIR_USER_DATA, user_data_dir); | 82 success = PathService::Override(chrome::DIR_USER_DATA, user_data_dir); |
| 81 | 83 |
| 82 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 84 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 83 // Make sure the cache directory is inside our clear profile. Otherwise | 85 // Make sure the cache directory is inside our clear profile. Otherwise |
| 84 // the cache may contain data from earlier tests that could break the | 86 // the cache may contain data from earlier tests that could break the |
| 85 // current test. | 87 // current test. |
| 86 // | 88 // |
| 87 // Note: we use an environment variable here, because we have to pass the | 89 // 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. | 90 // value to the child process. This is the simplest way to do it. |
| 89 std::unique_ptr<base::Environment> env(base::Environment::Create()); | 91 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
| 90 success = success && env->SetVar("XDG_CACHE_HOME", user_data_dir.value()); | 92 success = success && env->SetVar("XDG_CACHE_HOME", user_data_dir.value()); |
| 91 #endif | 93 #endif |
| 92 | 94 |
| 93 return success; | 95 return success; |
| 94 } | 96 } |
| 95 | 97 |
| 96 } // namespace test_launcher_utils | 98 } // namespace test_launcher_utils |
| OLD | NEW |