diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-27 23:01:34 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-27 23:01:34 +0000 |
commit | 4575021b2000963304a99b8cf6a4f0ba7afb88d3 (patch) | |
tree | 806a3445fdd4fe0876eb438ef1835252c955c496 | |
parent | 07dc5ffd9a5d10d55e2299651fe7a826d7fd7aba (diff) | |
download | chromium_src-4575021b2000963304a99b8cf6a4f0ba7afb88d3.zip chromium_src-4575021b2000963304a99b8cf6a4f0ba7afb88d3.tar.gz chromium_src-4575021b2000963304a99b8cf6a4f0ba7afb88d3.tar.bz2 |
Revert r14620 which was a rollback of r14549 and r14508. This
change re-enables the ui tests. Since jam re-enabled some tests,
I had to #ifdef around 4 tests that are not shutting down cleanly
on linux. It looks like we have renderers that aren't shutting
down properly (pegged at 100% cpu).
Review URL: http://codereview.chromium.org/100061
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14680 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/process_util_posix.cc | 9 | ||||
-rw-r--r-- | chrome/browser/app_modal_dialog_gtk.cc | 21 | ||||
-rw-r--r-- | chrome/browser/unload_uitest.cc | 28 | ||||
-rw-r--r-- | chrome/chrome.gyp | 2 |
4 files changed, 46 insertions, 14 deletions
diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc index 562b8e9..2e3fd55 100644 --- a/base/process_util_posix.cc +++ b/base/process_util_posix.cc @@ -22,6 +22,7 @@ #include "base/scoped_ptr.h" #include "base/sys_info.h" #include "base/time.h" +#include "base/waitable_event.h" const int kMicrosecondsPerSecond = 1000000; @@ -207,7 +208,7 @@ int WaitpidWithTimeout(ProcessHandle handle, int wait_milliseconds, // has been installed. This means that when a SIGCHLD is sent, it will exit // depending on behavior external to this function. // - // This function is used primarilly for unit tests, if we want to use it in + // This function is used primarily for unit tests, if we want to use it in // the application itself it would probably be best to examine other routes. int status = -1; pid_t ret_pid = waitpid(handle, &status, WNOHANG); @@ -243,7 +244,11 @@ int WaitpidWithTimeout(ProcessHandle handle, int wait_milliseconds, bool WaitForSingleProcess(ProcessHandle handle, int wait_milliseconds) { bool waitpid_success; - int status = WaitpidWithTimeout(handle, wait_milliseconds, &waitpid_success); + int status; + if (wait_milliseconds == base::kNoTimeout) + waitpid_success = (waitpid(handle, &status, 0) != -1); + else + status = WaitpidWithTimeout(handle, wait_milliseconds, &waitpid_success); if (status != -1) { DCHECK(waitpid_success); return WIFEXITED(status); diff --git a/chrome/browser/app_modal_dialog_gtk.cc b/chrome/browser/app_modal_dialog_gtk.cc index b44d865..2f9337d 100644 --- a/chrome/browser/app_modal_dialog_gtk.cc +++ b/chrome/browser/app_modal_dialog_gtk.cc @@ -107,14 +107,27 @@ void AppModalDialog::CloseModalDialog() { } int AppModalDialog::GetDialogButtons() { - NOTIMPLEMENTED(); - return 0; + switch (dialog_flags_) { + case MessageBoxFlags::kIsJavascriptAlert: + return MessageBoxFlags::DIALOGBUTTON_OK; + + case MessageBoxFlags::kIsJavascriptConfirm: + return MessageBoxFlags::DIALOGBUTTON_OK | + MessageBoxFlags::DIALOGBUTTON_CANCEL; + + case MessageBoxFlags::kIsJavascriptPrompt: + return MessageBoxFlags::DIALOGBUTTON_OK; + + default: + NOTREACHED(); + return 0; + } } void AppModalDialog::AcceptWindow() { - NOTIMPLEMENTED(); + OnDialogResponse(GTK_DIALOG(dialog_), GTK_RESPONSE_OK, this); } void AppModalDialog::CancelWindow() { - NOTIMPLEMENTED(); + OnDialogResponse(GTK_DIALOG(dialog_), GTK_RESPONSE_CANCEL, this); } diff --git a/chrome/browser/unload_uitest.cc b/chrome/browser/unload_uitest.cc index a2e3369..d499411 100644 --- a/chrome/browser/unload_uitest.cc +++ b/chrome/browser/unload_uitest.cc @@ -3,13 +3,13 @@ // found in the LICENSE file. #include "base/file_util.h" - +#include "base/platform_thread.h" #include "chrome/browser/automation/url_request_mock_http_job.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/message_box_flags.h" #include "chrome/test/automation/browser_proxy.h" #include "chrome/test/automation/tab_proxy.h" #include "chrome/test/ui/ui_test.h" -#include "chrome/views/window/dialog_delegate.h" #include "net/url_request/url_request_unittest.h" const std::string NOLISTENERS_HTML = @@ -96,7 +96,7 @@ class UnloadTest : public UITest { int max_wait_time = 5000; while (max_wait_time > 0) { max_wait_time -= kCheckDelayMs; - Sleep(kCheckDelayMs); + PlatformThread::Sleep(kCheckDelayMs); if (!IsBrowserRunning()) break; } @@ -107,7 +107,7 @@ class UnloadTest : 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; } @@ -136,10 +136,10 @@ class UnloadTest : public UITest { void NavigateToNolistenersFileTwiceAsync() { // TODO(ojan): We hit a DCHECK in RenderViewHost::OnMsgShouldCloseACK // if we don't sleep here. - Sleep(400); + PlatformThread::Sleep(400); NavigateToURLAsync( URLRequestMockHTTPJob::GetMockUrl(L"title2.html")); - Sleep(400); + PlatformThread::Sleep(400); NavigateToURL( URLRequestMockHTTPJob::GetMockUrl(L"title2.html")); @@ -155,17 +155,26 @@ class UnloadTest : public UITest { } void ClickModalDialogButton(MessageBoxFlags::DialogButton button) { +#if defined(OS_WIN) || defined(OS_LINUX) bool modal_dialog_showing = false; MessageBoxFlags::DialogButton available_buttons; EXPECT_TRUE(automation()->WaitForAppModalDialog(3000)); EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, &available_buttons)); ASSERT_TRUE(modal_dialog_showing); - EXPECT_TRUE((button & available_buttons) != NULL); + EXPECT_TRUE((button & available_buttons) != 0); EXPECT_TRUE(automation()->ClickAppModalDialogButton(button)); +#else + // TODO(port): port this function if and when the tests that use it are + // enabled (currently they are not being run even on windows). + NOTIMPLEMENTED(); +#endif } }; +// TODO(port): these tests fail on linux because they leave a renderer process +// lying around which holds onto the user data directory. +#if defined(OS_WIN) // Navigate to a page with an infinite unload handler. // Then two two async crosssite requests to ensure // we don't get confused and think we're closing the tab. @@ -221,6 +230,7 @@ TEST_F(UnloadTest, CrossSiteInfiniteBeforeUnloadSync) { NavigateToNolistenersFileTwice(); ASSERT_TRUE(IsBrowserRunning()); } +#endif // Tests closing the browser on a page with no unload listeners registered. TEST_F(UnloadTest, BrowserCloseNoUnloadListeners) { @@ -268,6 +278,9 @@ TEST_F(UnloadTest, BrowserCloseTwoSecondBeforeUnload) { L"twosecondbeforeunload"); } +// TODO(estade): On linux, the renderer process doesn't seem to quit and pegs +// CPU. +#if defined(OS_WIN) // Tests closing the browser on a page with an unload listener registered where // the unload handler has an infinite loop. TEST_F(UnloadTest, BrowserCloseInfiniteUnload) { @@ -307,6 +320,7 @@ TEST_F(UnloadTest, BrowserCloseInfiniteBeforeUnloadAlert) { LoadUrlAndQuitBrowser(INFINITE_BEFORE_UNLOAD_ALERT_HTML, L"infinitebeforeunloadalert"); } +#endif // defined(OS_WIN) // Tests closing the browser on a page with an unload listener registered where // the unload handler has an 2 second long loop followed by an alert. diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 5d2f6ed..67c4db3 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -2149,6 +2149,7 @@ 'browser/metrics/metrics_service_uitest.cc', 'browser/sessions/session_restore_uitest.cc', 'browser/tab_restore_uitest.cc', + 'browser/unload_uitest.cc', 'test/reliability/page_load_test.cc', 'test/ui/layout_plugin_uitest.cc', 'test/ui/omnibox_uitest.cc', @@ -2174,7 +2175,6 @@ # TODO(port)? (Most of these include windows.h or similar.) 'browser/printing/printing_layout_uitest.cc', 'browser/ssl/ssl_uitest.cc', - 'browser/unload_uitest.cc', 'browser/views/find_bar_win_uitest.cc', 'common/logging_chrome_uitest.cc', 'test/accessibility/accessibility_tests.cc', |