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 | |
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
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 2 | ||||
-rw-r--r-- | chrome/browser/errorpage_uitest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc | 16 | ||||
-rw-r--r-- | chrome/browser/tab_contents/view_source_uitest.cc | 2 | ||||
-rw-r--r-- | chrome/chrome.gyp | 9 | ||||
-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 | ||||
-rw-r--r-- | chrome/test/ui/ui_test.cc | 6 | ||||
-rw-r--r-- | chrome/test/ui/ui_test.h | 11 |
10 files changed, 60 insertions, 52 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 471b4bc..c8292ec 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -2509,6 +2509,7 @@ void AutomationProvider::OnMessageFromExternalHost(int handle, view_host->ForwardMessageFromExternalHost(message, origin, target); } } +#endif // defined(OS_WIN) WebContents* AutomationProvider::GetWebContentsForHandle( int handle, NavigationController** tab) { @@ -2525,6 +2526,7 @@ WebContents* AutomationProvider::GetWebContentsForHandle( return web_contents; } +#if defined(OS_WIN) ExternalTabContainer* AutomationProvider::GetExternalTabForHandle(int handle) { if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); diff --git a/chrome/browser/errorpage_uitest.cc b/chrome/browser/errorpage_uitest.cc index c020762..ff604d1 100644 --- a/chrome/browser/errorpage_uitest.cc +++ b/chrome/browser/errorpage_uitest.cc @@ -20,7 +20,7 @@ TEST_F(ErrorPageTest, DNSError) { int i; std::wstring title; for (i = 0; i < 10; ++i) { - Sleep(sleep_timeout_ms()); + PlatformThread::Sleep(sleep_timeout_ms()); title = GetActiveTabTitle(); if (title.find(test_host) != std::wstring::npos) { // Success, bail out. @@ -49,7 +49,7 @@ TEST_F(ErrorPageTest, IFrame404) { int i; std::wstring title; for (i = 0; i < 10; ++i) { - Sleep(sleep_timeout_ms()); + PlatformThread::Sleep(sleep_timeout_ms()); title = GetActiveTabTitle(); if (title == L"SUCCESS") { // Success, bail out. diff --git a/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc b/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc index 682336a..d6946a9 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc @@ -29,7 +29,7 @@ class ResourceDispatcherTest : public UITest { int max_wait_time = 5000; while (max_wait_time > 0) { max_wait_time -= kCheckDelayMs; - Sleep(kCheckDelayMs); + PlatformThread::Sleep(kCheckDelayMs); if (expected_title == GetActiveTabTitle()) break; } @@ -65,7 +65,7 @@ TEST_F(ResourceDispatcherTest, DoNotSniffHTMLFromImageGIF) { TEST_F(ResourceDispatcherTest, SniffNoContentTypeNoData) { CheckTitleTest(L"content-sniffer-test3.html", L"Content Sniffer Test 3"); - Sleep(sleep_timeout_ms() * 2); + PlatformThread::Sleep(sleep_timeout_ms() * 2); EXPECT_EQ(1, GetTabCount()); // Make sure the download shelf is not showing. @@ -210,7 +210,8 @@ TEST_F(ResourceDispatcherTest, CrossSiteAfterCrash) { // Cause the renderer to crash. expected_crashes_ = 1; tab->NavigateToURLAsync(GURL("about:crash")); - Sleep(sleep_timeout_ms()); // Wait for browser to notice the renderer crash. + // Wait for browser to notice the renderer crash. + PlatformThread::Sleep(sleep_timeout_ms()); // Navigate to a new cross-site page. The browser should not wait around for // the old renderer's on{before}unload handlers to run. @@ -268,7 +269,7 @@ TEST_F(ResourceDispatcherTest, CrossSiteNavigationErrorPage) { // reason as ErrorPageTest::DNSError. See bug 1199491. tab->NavigateToURL(GURL(URLRequestFailedDnsJob::kTestUrl)); for (int i = 0; i < 10; ++i) { - Sleep(sleep_timeout_ms()); + PlatformThread::Sleep(sleep_timeout_ms()); if (GetActiveTabTitle() != L"set cookie on unload") { // Success, bail out. break; @@ -289,10 +290,11 @@ TEST_F(ResourceDispatcherTest, CrossSiteNavigationErrorPage) { // the onunload handler, and the navigation would fail. // (Test by redirecting to javascript:window.location='someURL'.) GURL test_url(server->TestServerPageW(L"files/title2.html")); - std::wstring redirect_url = L"javascript:window.location='" + - ASCIIToWide(test_url.possibly_invalid_spec()) + L"'"; + std::string redirect_url = "javascript:window.location='" + + test_url.possibly_invalid_spec() + "'"; tab->NavigateToURLAsync(GURL(redirect_url)); - Sleep(sleep_timeout_ms()); // Wait for JavaScript redirect to happen. + // Wait for JavaScript redirect to happen. + PlatformThread::Sleep(sleep_timeout_ms()); EXPECT_TRUE(tab->GetTabTitle(&tab_title)); EXPECT_EQ(L"Title Of Awesomeness", tab_title); } diff --git a/chrome/browser/tab_contents/view_source_uitest.cc b/chrome/browser/tab_contents/view_source_uitest.cc index fed5ba5..ee16bf4 100644 --- a/chrome/browser/tab_contents/view_source_uitest.cc +++ b/chrome/browser/tab_contents/view_source_uitest.cc @@ -49,7 +49,7 @@ TEST_F(ViewSourceTest, DoesBrowserRenderInViewSource) { url = GURL("view-source:" + url.spec()); scoped_ptr<TabProxy> tab(GetActiveTab()); tab->NavigateToURL(url); - Sleep(sleep_timeout_ms()); + PlatformThread::Sleep(sleep_timeout_ms()); // Try to retrieve the cookie that the page sets // It should not be there (because we are in view-source mode diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 1f3de10..d97982f 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -1976,19 +1976,10 @@ 'browser/crash_recovery_uitest.cc', 'browser/download/download_uitest.cc', 'browser/download/save_page_uitest.cc', - 'browser/errorpage_uitest.cc', - 'browser/history/redirect_uitest.cc', - 'browser/iframe_uitest.cc', - 'browser/interstitial_page_uitest.cc', 'browser/login_prompt_uitest.cc', 'browser/metrics/metrics_service_uitest.cc', - 'browser/renderer_host/resource_dispatcher_host_uitest.cc', 'browser/sessions/session_restore_uitest.cc', - 'browser/tab_contents/view_source_uitest.cc', - 'common/net/cache_uitest.cc', - 'common/pref_service_uitest.cc', 'test/reliability/page_load_test.cc', - 'test/ui/dom_checker_uitest.cc', 'test/ui/layout_plugin_uitest.cc', 'test/ui/omnibox_uitest.cc', ], 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, diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index 804bf04..d273175 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -82,8 +82,7 @@ const wchar_t kEnableErrorDialogs[] = L"enable-errdialogs"; // attach. // #define WAIT_FOR_DEBUGGER_ON_OPEN 1 -// static -bool UITest::DieFileDie(const std::wstring& file, bool recurse) { +bool UITest::DieFileDie(const FilePath& file, bool recurse) { if (!file_util::PathExists(file)) return true; @@ -95,6 +94,9 @@ bool UITest::DieFileDie(const std::wstring& file, bool recurse) { } return false; } +bool UITest::DieFileDie(const std::wstring& file, bool recurse) { + return DieFileDie(FilePath::FromWStringHack(file), recurse); +} UITest::UITest() : testing::Test(), diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h index c059ded..75ecae2 100644 --- a/chrome/test/ui/ui_test.h +++ b/chrome/test/ui/ui_test.h @@ -63,9 +63,14 @@ class UITest : public testing::Test { // ********* Utility functions ********* - // Tries to delete the specified file/directory returning true on success. - // This differs from file_util::Delete in that it repeatedly invokes Delete - // until successful, or a timeout is reached. Returns true on success. + // Tries to delete the specified file/directory returning true on + // success. This differs from file_util::Delete in that it + // repeatedly invokes Delete until successful, or a timeout is + // reached. (This retrying is to work around Windows file locks + // and shouldn't be necessary on POSIX, but it can't hurt.) + // Returns true on success. + bool DieFileDie(const FilePath& file, bool recurse); + // Deprecated backwards-compat version. bool DieFileDie(const std::wstring& file, bool recurse); // Launches the browser and IPC testing server. |