diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-07 23:21:31 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-07 23:21:31 +0000 |
commit | 5cc06369ee53fbde978506263f0b15735560cfd6 (patch) | |
tree | 635e0d9c60bb45f633ad220701e0a7513018f7fc /chrome/common | |
parent | c8bdcb753bcbe960bc239419180d085534ef8432 (diff) | |
download | chromium_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')
-rw-r--r-- | chrome/common/json_value_serializer.h | 10 | ||||
-rw-r--r-- | chrome/common/pref_service_uitest.cc | 46 | ||||
-rw-r--r-- | chrome/common/temp_scaffolding_stubs.cc | 6 |
3 files changed, 34 insertions, 28 deletions
diff --git a/chrome/common/json_value_serializer.h b/chrome/common/json_value_serializer.h index 92bd069..2c71e47 100644 --- a/chrome/common/json_value_serializer.h +++ b/chrome/common/json_value_serializer.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_COMMON_JSON_VALUE_SERIALIZER_H__ -#define CHROME_COMMON_JSON_VALUE_SERIALIZER_H__ +#ifndef CHROME_COMMON_JSON_VALUE_SERIALIZER_H_ +#define CHROME_COMMON_JSON_VALUE_SERIALIZER_H_ #include <string> @@ -67,7 +67,7 @@ class JSONFileValueSerializer : public ValueSerializer { // deserialization or the destination of the serialization. // When deserializing, the file should exist, but when serializing, the // serializer will attempt to create the file at the specified location. - JSONFileValueSerializer(const FilePath& json_file_path) + explicit JSONFileValueSerializer(const FilePath& json_file_path) : json_file_path_(json_file_path) {} ~JSONFileValueSerializer() {} @@ -92,7 +92,7 @@ class JSONFileValueSerializer : public ValueSerializer { private: FilePath json_file_path_; - DISALLOW_EVIL_CONSTRUCTORS(JSONFileValueSerializer); + DISALLOW_IMPLICIT_CONSTRUCTORS(JSONFileValueSerializer); }; -#endif // CHROME_COMMON_JSON_VALUE_SERIALIZER_H__ +#endif // CHROME_COMMON_JSON_VALUE_SERIALIZER_H_ 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 diff --git a/chrome/common/temp_scaffolding_stubs.cc b/chrome/common/temp_scaffolding_stubs.cc index 73191cb..1ee64ea 100644 --- a/chrome/common/temp_scaffolding_stubs.cc +++ b/chrome/common/temp_scaffolding_stubs.cc @@ -47,12 +47,6 @@ //-------------------------------------------------------------------------- -WebContents* AutomationProvider::GetWebContentsForHandle( - int handle, NavigationController** tab) { - NOTIMPLEMENTED(); - return NULL; -} - void AutomationProvider::GetActiveWindow(int* handle) { NOTIMPLEMENTED(); } void AutomationProvider::IsWindowActive(int handle, bool* success, |