summaryrefslogtreecommitdiffstats
path: root/chrome/common/pref_service_uitest.cc
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-07 23:21:31 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-07 23:21:31 +0000
commit5cc06369ee53fbde978506263f0b15735560cfd6 (patch)
tree635e0d9c60bb45f633ad220701e0a7513018f7fc /chrome/common/pref_service_uitest.cc
parentc8bdcb753bcbe960bc239419180d085534ef8432 (diff)
downloadchromium_src-5cc06369ee53fbde978506263f0b15735560cfd6.zip
chromium_src-5cc06369ee53fbde978506263f0b15735560cfd6.tar.gz
chromium_src-5cc06369ee53fbde978506263f0b15735560cfd6.tar.bz2
linux: pass a bunch more ui tests.
Mostly random portability fixes: use portable functions, use FilePath, etc. Review URL: http://codereview.chromium.org/62117 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13302 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/pref_service_uitest.cc')
-rw-r--r--chrome/common/pref_service_uitest.cc46
1 files changed, 29 insertions, 17 deletions
diff --git a/chrome/common/pref_service_uitest.cc b/chrome/common/pref_service_uitest.cc
index 61d6506..e5da154 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