| Index: chrome/common/pref_service_uitest.cc
|
| diff --git a/chrome/common/pref_service_uitest.cc b/chrome/common/pref_service_uitest.cc
|
| index 61d65065142f93e911fc88f222ffa415955d43b5..e5da154622abe809727a263bed99e34d836accb4 100644
|
| --- a/chrome/common/pref_service_uitest.cc
|
| +++ b/chrome/common/pref_service_uitest.cc
|
| @@ -8,6 +8,7 @@
|
| #include "base/file_path.h"
|
| #include "base/file_util.h"
|
| #include "base/values.h"
|
| +#include "build/build_config.h"
|
| #include "chrome/common/chrome_constants.h"
|
| #include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/json_value_serializer.h"
|
| @@ -20,32 +21,34 @@ class PreferenceServiceTest : public UITest {
|
| public:
|
| void SetUp() {
|
| PathService::Get(base::DIR_TEMP, &tmp_profile_);
|
| - file_util::AppendToPath(&tmp_profile_, L"tmp_profile");
|
| + tmp_profile_ = tmp_profile_.AppendASCII("tmp_profile");
|
|
|
| // Create a fresh, empty copy of this directory.
|
| file_util::Delete(tmp_profile_, true);
|
| - ::CreateDirectory(tmp_profile_.c_str(), NULL);
|
| + file_util::CreateDirectory(tmp_profile_);
|
|
|
| - std::wstring reference_pref_file(test_data_directory_);
|
| - file_util::AppendToPath(&reference_pref_file, L"profiles");
|
| - file_util::AppendToPath(&reference_pref_file, L"window_placement");
|
| - file_util::AppendToPath(&reference_pref_file, chrome::kLocalStateFilename);
|
| + FilePath reference_pref_file =
|
| + FilePath::FromWStringHack(test_data_directory_)
|
| + .AppendASCII("profiles")
|
| + .AppendASCII("window_placement")
|
| + .Append(chrome::kLocalStateFilename);
|
|
|
| - tmp_pref_file_ = tmp_profile_;
|
| - file_util::AppendToPath(&tmp_pref_file_, chrome::kLocalStateFilename);
|
| + tmp_pref_file_ = tmp_profile_.Append(chrome::kLocalStateFilename);
|
|
|
| ASSERT_TRUE(file_util::PathExists(reference_pref_file));
|
|
|
| // Copy only the Local State file, the rest will be automatically created
|
| - ASSERT_TRUE(::CopyFileW(reference_pref_file.c_str(), tmp_pref_file_.c_str(),
|
| - TRUE));
|
| + ASSERT_TRUE(file_util::CopyFile(reference_pref_file, tmp_pref_file_));
|
|
|
| - // Make the copy writable
|
| - ASSERT_TRUE(::SetFileAttributesW(tmp_pref_file_.c_str(),
|
| +#if defined(OS_WIN)
|
| + // Make the copy writable. On POSIX we assume the umask allows files
|
| + // we create to be writable.
|
| + ASSERT_TRUE(::SetFileAttributesW(tmp_pref_file_.value().c_str(),
|
| FILE_ATTRIBUTE_NORMAL));
|
| +#endif
|
|
|
| launch_arguments_.AppendSwitchWithValue(switches::kUserDataDir,
|
| - tmp_profile_);
|
| + tmp_profile_.ToWStringHack());
|
| }
|
|
|
| bool LaunchAppWithProfile() {
|
| @@ -62,18 +65,25 @@ public:
|
| }
|
|
|
| public:
|
| - std::wstring tmp_pref_file_;
|
| - std::wstring tmp_profile_;
|
| + FilePath tmp_pref_file_;
|
| + FilePath tmp_profile_;
|
| };
|
|
|
| +#if defined(OS_WIN)
|
| +// This test verifies that the window position from the prefs file is restored
|
| +// when the app restores. This doesn't really make sense on Linux, where
|
| +// the window manager might fight with you over positioning. However, we
|
| +// might be able to make this work on buildbots.
|
| +// Also, not sure what should happen on the mac. In any case, the code below
|
| +// (minus the Windows bits) compiles fine on my Linux box now.
|
| +// TODO(port): revisit this.
|
| TEST_F(PreferenceServiceTest, PreservedWindowPlacementIsLoaded) {
|
| // The window should open with the reference profile
|
| ASSERT_TRUE(LaunchAppWithProfile());
|
|
|
| ASSERT_TRUE(file_util::PathExists(tmp_pref_file_));
|
|
|
| - JSONFileValueSerializer deserializer =
|
| - FilePath::FromWStringHack(tmp_pref_file_);
|
| + JSONFileValueSerializer deserializer(tmp_pref_file_);
|
| scoped_ptr<Value> root(deserializer.Deserialize(NULL));
|
|
|
| ASSERT_TRUE(root.get());
|
| @@ -85,6 +95,7 @@ TEST_F(PreferenceServiceTest, PreservedWindowPlacementIsLoaded) {
|
| scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
|
| ASSERT_TRUE(browser.get());
|
| scoped_ptr<WindowProxy> window(browser->GetWindow());
|
| +
|
| HWND hWnd;
|
| ASSERT_TRUE(window->GetHWND(&hWnd));
|
|
|
| @@ -121,3 +132,4 @@ TEST_F(PreferenceServiceTest, PreservedWindowPlacementIsLoaded) {
|
| &is_maximized));
|
| ASSERT_EQ(is_maximized, is_window_maximized);
|
| }
|
| +#endif
|
|
|