This source file includes following definitions.
- PrepareBrowserCommandLineForTests
- OverrideUserDataDir
#include "chrome/test/base/test_launcher_utils.h"
#include "base/command_line.h"
#include "base/environment.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/strings/string_number_conversions.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "components/os_crypt/os_crypt_switches.h"
#if defined(USE_AURA)
#include "ui/wm/core/wm_core_switches.h"
#endif
namespace test_launcher_utils {
void PrepareBrowserCommandLineForTests(CommandLine* command_line) {
command_line->AppendSwitch(switches::kDisableWebResources);
command_line->AppendSwitch(switches::kDisablePreconnect);
command_line->AppendSwitch(switches::kNoFirstRun);
command_line->AppendSwitch(switches::kNoDefaultBrowserCheck);
if (!command_line->HasSwitch(switches::kEnableLogging))
command_line->AppendSwitchASCII(switches::kEnableLogging, "stderr");
if (!command_line->HasSwitch(switches::kLoggingLevel))
command_line->AppendSwitchASCII(switches::kLoggingLevel, "0");
command_line->AppendSwitch(switches::kSbDisableAutoUpdate);
command_line->AppendSwitch(switches::kDisableDefaultApps);
#if defined(USE_AURA)
command_line->AppendSwitch(
wm::switches::kWindowAnimationsDisabled);
#endif
#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_CHROMEOS)
if (!command_line->HasSwitch(switches::kPasswordStore))
command_line->AppendSwitchASCII(switches::kPasswordStore, "basic");
#endif
#if defined(OS_MACOSX)
command_line->AppendSwitch(os_crypt::switches::kUseMockKeychain);
#endif
command_line->AppendSwitch(switches::kDisableComponentUpdate);
}
bool OverrideUserDataDir(const base::FilePath& user_data_dir) {
bool success = true;
success = PathService::Override(chrome::DIR_USER_DATA, user_data_dir);
#if defined(OS_POSIX) && !defined(OS_MACOSX)
scoped_ptr<base::Environment> env(base::Environment::Create());
success = success && env->SetVar("XDG_CACHE_HOME", user_data_dir.value());
#endif
return success;
}
}