Commit c4901feb authored by gab@chromium.org's avatar gab@chromium.org

Have chromedriver use chrome/common/chrome_constants.cc directly rather than...

Have chromedriver use chrome/common/chrome_constants.cc directly rather than having to hardcode a copy or depend on the full target itself.

akin to https://codereview.chromium.org/163763004/

BUG=343692

Review URL: https://codereview.chromium.org/165053002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251804 0039d316-1c4b-4281-b951-d872f2087c98
parent acb3f667
...@@ -736,6 +736,8 @@ ...@@ -736,6 +736,8 @@
'<(SHARED_INTERMEDIATE_DIR)/chrome/test/chromedriver/version.h', '<(SHARED_INTERMEDIATE_DIR)/chrome/test/chromedriver/version.h',
'../third_party/webdriver/atoms.cc', '../third_party/webdriver/atoms.cc',
'../third_party/webdriver/atoms.h', '../third_party/webdriver/atoms.h',
'common/chrome_constants.cc',
'common/chrome_constants.h',
'test/chromedriver/alert_commands.cc', 'test/chromedriver/alert_commands.cc',
'test/chromedriver/alert_commands.h', 'test/chromedriver/alert_commands.h',
'test/chromedriver/basic_types.cc', 'test/chromedriver/basic_types.cc',
......
...@@ -3,6 +3,9 @@ include_rules = [ ...@@ -3,6 +3,9 @@ include_rules = [
"-chrome", "-chrome",
"-content", "-content",
# Except for constants which it links in directly.
"+chrome/common/chrome_constants.h",
"+chrome/test/chromedriver", "+chrome/test/chromedriver",
"+third_party/webdriver", "+third_party/webdriver",
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "base/threading/platform_thread.h" #include "base/threading/platform_thread.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/test/chromedriver/chrome/chrome_android_impl.h" #include "chrome/test/chromedriver/chrome/chrome_android_impl.h"
#include "chrome/test/chromedriver/chrome/chrome_desktop_impl.h" #include "chrome/test/chromedriver/chrome/chrome_desktop_impl.h"
#include "chrome/test/chromedriver/chrome/chrome_existing_impl.h" #include "chrome/test/chromedriver/chrome/chrome_existing_impl.h"
...@@ -661,28 +662,28 @@ Status PrepareUserDataDir( ...@@ -661,28 +662,28 @@ Status PrepareUserDataDir(
const base::FilePath& user_data_dir, const base::FilePath& user_data_dir,
const base::DictionaryValue* custom_prefs, const base::DictionaryValue* custom_prefs,
const base::DictionaryValue* custom_local_state) { const base::DictionaryValue* custom_local_state) {
base::FilePath default_dir = user_data_dir.AppendASCII("Default"); base::FilePath default_dir =
user_data_dir.AppendASCII(chrome::kInitialProfile);
if (!base::CreateDirectory(default_dir)) if (!base::CreateDirectory(default_dir))
return Status(kUnknownError, "cannot create default profile directory"); return Status(kUnknownError, "cannot create default profile directory");
Status status = WritePrefsFile( Status status =
kPreferences, WritePrefsFile(kPreferences,
custom_prefs, custom_prefs,
default_dir.AppendASCII("Preferences")); default_dir.Append(chrome::kPreferencesFilename));
if (status.IsError()) if (status.IsError())
return status; return status;
status = WritePrefsFile( status = WritePrefsFile(kLocalState,
kLocalState, custom_local_state,
custom_local_state, user_data_dir.Append(chrome::kLocalStateFilename));
user_data_dir.AppendASCII("Local State"));
if (status.IsError()) if (status.IsError())
return status; return status;
// Write empty "First Run" file, otherwise Chrome will wipe the default // Write empty "First Run" file, otherwise Chrome will wipe the default
// profile that was written. // profile that was written.
if (file_util::WriteFile( if (file_util::WriteFile(
user_data_dir.AppendASCII("First Run"), "", 0) != 0) { user_data_dir.Append(chrome::kFirstRunSentinel), "", 0) != 0) {
return Status(kUnknownError, "failed to write first run file"); return Status(kUnknownError, "failed to write first run file");
} }
return Status(kOk); return Status(kOk);
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/path_service.h" #include "base/path_service.h"
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/test/chromedriver/chrome/status.h" #include "chrome/test/chromedriver/chrome/status.h"
#include "chrome/test/chromedriver/chrome_launcher.h" #include "chrome/test/chromedriver/chrome_launcher.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -175,7 +176,8 @@ TEST(PrepareUserDataDir, CustomPrefs) { ...@@ -175,7 +176,8 @@ TEST(PrepareUserDataDir, CustomPrefs) {
ASSERT_EQ(kOk, status.code()); ASSERT_EQ(kOk, status.code());
base::FilePath prefs_file = base::FilePath prefs_file =
temp_dir.path().AppendASCII("Default").AppendASCII("Preferences"); temp_dir.path().AppendASCII(chrome::kInitialProfile).Append(
chrome::kPreferencesFilename);
std::string prefs_str; std::string prefs_str;
ASSERT_TRUE(base::ReadFileToString(prefs_file, &prefs_str)); ASSERT_TRUE(base::ReadFileToString(prefs_file, &prefs_str));
scoped_ptr<base::Value> prefs_value(base::JSONReader::Read(prefs_str)); scoped_ptr<base::Value> prefs_value(base::JSONReader::Read(prefs_str));
...@@ -184,7 +186,8 @@ TEST(PrepareUserDataDir, CustomPrefs) { ...@@ -184,7 +186,8 @@ TEST(PrepareUserDataDir, CustomPrefs) {
AssertEQ(*prefs_dict, "myPrefsKey", "ok"); AssertEQ(*prefs_dict, "myPrefsKey", "ok");
AssertEQ(*prefs_dict, "pref.sub", "1"); AssertEQ(*prefs_dict, "pref.sub", "1");
base::FilePath local_state_file = temp_dir.path().AppendASCII("Local State"); base::FilePath local_state_file =
temp_dir.path().Append(chrome::kLocalStateFilename);
std::string local_state_str; std::string local_state_str;
ASSERT_TRUE(base::ReadFileToString(local_state_file, &local_state_str)); ASSERT_TRUE(base::ReadFileToString(local_state_file, &local_state_str));
scoped_ptr<base::Value> local_state_value( scoped_ptr<base::Value> local_state_value(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment