diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-22 13:26:46 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-22 13:26:46 +0000 |
commit | 1a96b432de916d958dd03404701405c981fbaff3 (patch) | |
tree | 95b1e48eb425c67f139980834e61e848094786e7 /chrome/test/automation | |
parent | 99ad6c9c402c3453044928a6e4414e695feb9200 (diff) | |
download | chromium_src-1a96b432de916d958dd03404701405c981fbaff3.zip chromium_src-1a96b432de916d958dd03404701405c981fbaff3.tar.gz chromium_src-1a96b432de916d958dd03404701405c981fbaff3.tar.bz2 |
[GTTF] Reduce number of automation methods ending with WithTimeout.
They are just too easy to misuse. People started inventing their own
hardcoded timeouts all over the place.
Also, the is_timeout return parameter was not checked consistently.
Additionally, some calls actually had no timeout at all, making
hangs possible.
This change also removes useless DLOG statements. We should get the
required info from the ASSERT/EXPECT macros in test code, which is
quite well checked by WARN_UNUSED_RESULT.
TEST=all ui-based
BUG=none
Review URL: http://codereview.chromium.org/1076005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42213 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/automation')
-rw-r--r-- | chrome/test/automation/automation_proxy.cc | 112 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy.h | 18 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy_uitest.cc | 63 | ||||
-rw-r--r-- | chrome/test/automation/browser_proxy.cc | 105 | ||||
-rw-r--r-- | chrome/test/automation/browser_proxy.h | 42 | ||||
-rw-r--r-- | chrome/test/automation/tab_proxy.cc | 35 | ||||
-rw-r--r-- | chrome/test/automation/tab_proxy.h | 13 | ||||
-rw-r--r-- | chrome/test/automation/window_proxy.cc | 15 | ||||
-rw-r--r-- | chrome/test/automation/window_proxy.h | 6 |
9 files changed, 90 insertions, 319 deletions
diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc index d383443..46fcc3b 100644 --- a/chrome/test/automation/automation_proxy.cc +++ b/chrome/test/automation/automation_proxy.cc @@ -249,16 +249,7 @@ bool AutomationProxy::GetBrowserWindowCount(int* num_windows) { return false; } - bool succeeded = SendWithTimeout( - new AutomationMsg_BrowserWindowCount(0, num_windows), - command_execution_timeout_ms(), NULL); - - if (!succeeded) { - DLOG(ERROR) << "GetWindowCount did not complete in a timely fashion"; - return false; - } - - return succeeded; + return Send(new AutomationMsg_BrowserWindowCount(0, num_windows)); } bool AutomationProxy::GetNormalBrowserWindowCount(int* num_windows) { @@ -267,26 +258,16 @@ bool AutomationProxy::GetNormalBrowserWindowCount(int* num_windows) { return false; } - bool succeeded = SendWithTimeout( - new AutomationMsg_NormalBrowserWindowCount(0, num_windows), - command_execution_timeout_ms(), NULL); - - if (!succeeded) { - DLOG(ERROR) << "GetNormalWindowCount did not complete in a timely fashion"; - return false; - } - - return succeeded; + return Send(new AutomationMsg_NormalBrowserWindowCount(0, num_windows)); } -bool AutomationProxy::WaitForWindowCountToBecome(int count, - int wait_timeout) { +bool AutomationProxy::WaitForWindowCountToBecome(int count) { bool wait_success = false; - bool send_success = SendWithTimeout( - new AutomationMsg_WaitForBrowserWindowCountToBecome(0, count, - &wait_success), - wait_timeout, NULL); - return wait_success && send_success; + if (!Send(new AutomationMsg_WaitForBrowserWindowCountToBecome( + 0, count, &wait_success))) { + return false; + } + return wait_success; } bool AutomationProxy::GetShowingAppModalDialog( @@ -299,11 +280,8 @@ bool AutomationProxy::GetShowingAppModalDialog( int button_int = 0; - if (!SendWithTimeout( - new AutomationMsg_ShowingAppModalDialog( - 0, showing_app_modal_dialog, &button_int), - command_execution_timeout_ms(), NULL)) { - DLOG(ERROR) << "ShowingAppModalDialog did not complete in a timely fashion"; + if (!Send(new AutomationMsg_ShowingAppModalDialog( + 0, showing_app_modal_dialog, &button_int))) { return false; } @@ -315,22 +293,19 @@ bool AutomationProxy::ClickAppModalDialogButton( MessageBoxFlags::DialogButton button) { bool succeeded = false; - if (!SendWithTimeout( - new AutomationMsg_ClickAppModalDialogButton( - 0, button, &succeeded), - command_execution_timeout_ms(), NULL)) { + if (!Send(new AutomationMsg_ClickAppModalDialogButton( + 0, button, &succeeded))) { return false; } return succeeded; } -bool AutomationProxy::WaitForAppModalDialog(int wait_timeout) { +bool AutomationProxy::WaitForAppModalDialog() { bool wait_success = false; - bool send_success = SendWithTimeout( - new AutomationMsg_WaitForAppModalDialogToBeShown(0, &wait_success), - wait_timeout, NULL); - return wait_success && send_success; + if (!Send(new AutomationMsg_WaitForAppModalDialogToBeShown(0, &wait_success))) + return false; + return wait_success; } bool AutomationProxy::IsURLDisplayed(GURL url) { @@ -401,11 +376,8 @@ void AutomationProxy::OnChannelError() { scoped_refptr<WindowProxy> AutomationProxy::GetActiveWindow() { int handle = 0; - - if (!SendWithTimeout(new AutomationMsg_ActiveWindow(0, &handle), - command_execution_timeout_ms(), NULL)) { + if (!Send(new AutomationMsg_ActiveWindow(0, &handle))) return NULL; - } return ProxyObjectFromHandle<WindowProxy>(handle); } @@ -413,51 +385,32 @@ scoped_refptr<WindowProxy> AutomationProxy::GetActiveWindow() { scoped_refptr<BrowserProxy> AutomationProxy::GetBrowserWindow( int window_index) { int handle = 0; - - if (!SendWithTimeout(new AutomationMsg_BrowserWindow(0, window_index, - &handle), - command_execution_timeout_ms(), NULL)) { - DLOG(ERROR) << "GetBrowserWindow did not complete in a timely fashion"; + if (!Send(new AutomationMsg_BrowserWindow(0, window_index, &handle))) return NULL; - } return ProxyObjectFromHandle<BrowserProxy>(handle); } bool AutomationProxy::GetBrowserLocale(string16* locale) { DCHECK(locale != NULL); - if (!SendWithTimeout(new AutomationMsg_GetBrowserLocale(0, locale), - command_execution_timeout_ms(), NULL)) { - DLOG(ERROR) << "GetBrowserLocale did not complete in a timely fashion"; + if (!Send(new AutomationMsg_GetBrowserLocale(0, locale))) return false; - } - // An empty locale means that the browser has no UI language - // which is impossible. - DCHECK(!locale->empty()); return !locale->empty(); } scoped_refptr<BrowserProxy> AutomationProxy::FindNormalBrowserWindow() { int handle = 0; - - if (!SendWithTimeout(new AutomationMsg_FindNormalBrowserWindow(0, &handle), - command_execution_timeout_ms(), NULL)) { + if (!Send(new AutomationMsg_FindNormalBrowserWindow(0, &handle))) return NULL; - } return ProxyObjectFromHandle<BrowserProxy>(handle); } scoped_refptr<BrowserProxy> AutomationProxy::GetLastActiveBrowserWindow() { int handle = 0; - - if (!SendWithTimeout(new AutomationMsg_LastActiveBrowserWindow( - 0, &handle), command_execution_timeout_ms(), NULL)) { - DLOG(ERROR) << - "GetLastActiveBrowserWindow did not complete in a timely fashion"; + if (!Send(new AutomationMsg_LastActiveBrowserWindow(0, &handle))) return NULL; - } return ProxyObjectFromHandle<BrowserProxy>(handle); } @@ -473,26 +426,13 @@ base::file_handle_mapping_vector AutomationProxy::fds_to_map() const { #endif // defined(OS_POSIX) bool AutomationProxy::Send(IPC::Message* message) { - return SendWithTimeout(message, base::kNoTimeout, NULL); -} - -bool AutomationProxy::SendWithTimeout(IPC::Message* message, int timeout, - bool* is_timeout) { - // DCHECK_EQ(listener_thread_id_, PlatformThread::CurrentId()); - - if (is_timeout) - *is_timeout = false; - - if (channel_.get()) { - bool result = channel_->SendWithTimeout(message, timeout); - if (!result && is_timeout) - *is_timeout = true; - return result; + if (!channel_.get()) { + LOG(ERROR) << "Automation channel has been closed; dropping message!"; + delete message; + return false; } - DLOG(WARNING) << "Channel has been closed; dropping message!"; - delete message; - return false; + return channel_->SendWithTimeout(message, command_execution_timeout_ms()); } void AutomationProxy::InvalidateHandle(const IPC::Message& message) { diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h index 9000ec6..7809ec1 100644 --- a/chrome/test/automation/automation_proxy.h +++ b/chrome/test/automation/automation_proxy.h @@ -40,17 +40,14 @@ class AutomationMessageSender : public IPC::Message::Sender { // Sends a message synchronously; it doesn't return until a response has been // received or a timeout has expired. // - // Use base::kNoTimeout for no timeout. - // // The function returns true if a response is received, and returns false if - // there is a failure or timeout (in milliseconds). If return after timeout, - // is_timeout is set to true. + // there is a failure or timeout (in milliseconds). + // // NOTE: When timeout occurs, the connection between proxy provider may be // in transit state. Specifically, there might be pending IPC messages, // and the proxy provider might be still working on the previous // request. - virtual bool SendWithTimeout(IPC::Message* message, int timeout, - bool* is_timeout) = 0; + virtual bool Send(IPC::Message* message) = 0; }; // This is the interface that external processes can use to interact with @@ -99,8 +96,7 @@ class AutomationProxy : public IPC::Channel::Listener, // Block the thread until the window count becomes the provided value. // Returns true on success. - bool WaitForWindowCountToBecome(int target_count, - int wait_timeout) WARN_UNUSED_RESULT; + bool WaitForWindowCountToBecome(int target_count) WARN_UNUSED_RESULT; // Fills the number of open normal browser windows (normal type and // non-incognito mode) into the given variable, returning true on success. @@ -123,7 +119,7 @@ class AutomationProxy : public IPC::Channel::Listener, // Block the thread until a modal dialog is displayed. Returns true on // success. - bool WaitForAppModalDialog(int wait_timeout) WARN_UNUSED_RESULT; + bool WaitForAppModalDialog() WARN_UNUSED_RESULT; // Returns true if one of the tabs in any window displays given url. bool IsURLDisplayed(GURL url) WARN_UNUSED_RESULT; @@ -208,10 +204,8 @@ class AutomationProxy : public IPC::Channel::Listener, base::file_handle_mapping_vector fds_to_map() const; #endif - // AutomationMessageSender implementations. + // AutomationMessageSender implementation. virtual bool Send(IPC::Message* message) WARN_UNUSED_RESULT; - virtual bool SendWithTimeout(IPC::Message* message, int timeout, - bool* is_timeout) WARN_UNUSED_RESULT; // Wrapper over AutomationHandleTracker::InvalidateHandle. Receives the // message from AutomationProxy, unpacks the messages and routes that call to diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc index 9ff86df..004b99b 100644 --- a/chrome/test/automation/automation_proxy_uitest.cc +++ b/chrome/test/automation/automation_proxy_uitest.cc @@ -290,63 +290,6 @@ TEST_F(AutomationProxyTest, NavigateToURL) { // TODO(vibhor) : Add a test using testserver. } -TEST_F(AutomationProxyTest, NavigateToURLWithTimeout1) { - scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); - ASSERT_TRUE(window.get()); - scoped_refptr<TabProxy> tab(window->GetTab(0)); - ASSERT_TRUE(tab.get()); - - FilePath filename(test_data_directory_); - filename = filename.AppendASCII("title2.html"); - - bool is_timeout; - ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, - tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename), - 1, 5000, &is_timeout)); - ASSERT_FALSE(is_timeout); - - std::wstring title; - ASSERT_TRUE(tab->GetTabTitle(&title)); - ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); - - // Use timeout high enough to allow the browser to create a url request job. - const int kLowTimeoutMs = 250; - ASSERT_GE(URLRequestSlowHTTPJob::kDelayMs, kLowTimeoutMs); - ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_ERROR, - tab->NavigateToURLWithTimeout( - URLRequestSlowHTTPJob::GetMockUrl(filename), - 1, kLowTimeoutMs, &is_timeout)); - ASSERT_TRUE(is_timeout); -} - -TEST_F(AutomationProxyTest, NavigateToURLWithTimeout2) { - scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); - ASSERT_TRUE(window.get()); - scoped_refptr<TabProxy> tab(window->GetTab(0)); - ASSERT_TRUE(tab.get()); - - FilePath filename1(test_data_directory_); - filename1 = filename1.AppendASCII("title1.html"); - - bool is_timeout; - - // Use timeout high enough to allow the browser to create a url request job. - const int kLowTimeoutMs = 250; - ASSERT_GE(URLRequestSlowHTTPJob::kDelayMs, kLowTimeoutMs); - ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_ERROR, - tab->NavigateToURLWithTimeout( - URLRequestSlowHTTPJob::GetMockUrl(filename1), - 1, kLowTimeoutMs, &is_timeout)); - ASSERT_TRUE(is_timeout); - - FilePath filename2(test_data_directory_); - filename2 = filename2.AppendASCII("title1.html"); - ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, - tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename2), - 1, 5000, &is_timeout)); - ASSERT_FALSE(is_timeout); -} - TEST_F(AutomationProxyTest, GoBackForward) { scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); ASSERT_TRUE(window.get()); @@ -1439,7 +1382,7 @@ TEST_F(AutomationProxyTest, DISABLED_AppModalDialogTest) { "<body onload='onload()'></body></html>"; ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(GURL(content))); - EXPECT_TRUE(automation()->WaitForAppModalDialog(3000)); + EXPECT_TRUE(automation()->WaitForAppModalDialog()); EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, &button)); EXPECT_TRUE(modal_dialog_showing); @@ -1467,7 +1410,7 @@ TEST_F(AutomationProxyTest, DISABLED_AppModalDialogTest) { "</head><body onload='onload()'></body></html>"; ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(GURL(content))); - EXPECT_TRUE(automation()->WaitForAppModalDialog(3000)); + EXPECT_TRUE(automation()->WaitForAppModalDialog()); EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, &button)); EXPECT_TRUE(modal_dialog_showing); @@ -1488,7 +1431,7 @@ TEST_F(AutomationProxyTest, DISABLED_AppModalDialogTest) { // Try again. ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(GURL(content))); - EXPECT_TRUE(automation()->WaitForAppModalDialog(3000)); + EXPECT_TRUE(automation()->WaitForAppModalDialog()); EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, &button)); EXPECT_TRUE(modal_dialog_showing); diff --git a/chrome/test/automation/browser_proxy.cc b/chrome/test/automation/browser_proxy.cc index 08759a9..6db138e 100644 --- a/chrome/test/automation/browser_proxy.cc +++ b/chrome/test/automation/browser_proxy.cc @@ -22,18 +22,15 @@ using base::TimeTicks; bool BrowserProxy::ActivateTab(int tab_index) { - return ActivateTabWithTimeout(tab_index, base::kNoTimeout, NULL); -} - -bool BrowserProxy::ActivateTabWithTimeout(int tab_index, uint32 timeout_ms, - bool* is_timeout) { if (!is_valid()) return false; int activate_tab_response = -1; - sender_->SendWithTimeout(new AutomationMsg_ActivateTab( - 0, handle_, tab_index, &activate_tab_response), timeout_ms, is_timeout); + if (!sender_->Send(new AutomationMsg_ActivateTab( + 0, handle_, tab_index, &activate_tab_response))) { + return false; + } if (activate_tab_response >= 0) return true; @@ -42,34 +39,25 @@ bool BrowserProxy::ActivateTabWithTimeout(int tab_index, uint32 timeout_ms, } bool BrowserProxy::BringToFront() { - return BringToFrontWithTimeout(base::kNoTimeout, NULL); -} - -bool BrowserProxy::BringToFrontWithTimeout(uint32 timeout_ms, - bool* is_timeout) { if (!is_valid()) return false; bool succeeded = false; - sender_->SendWithTimeout(new AutomationMsg_BringBrowserToFront( - 0, handle_, &succeeded), timeout_ms, is_timeout); + if (!sender_->Send(new AutomationMsg_BringBrowserToFront( + 0, handle_, &succeeded))) { + return false; + } return succeeded; } -bool BrowserProxy::IsPageMenuCommandEnabledWithTimeout(int id, - uint32 timeout_ms, - bool* is_timeout) { +bool BrowserProxy::IsPageMenuCommandEnabled(int id, bool* enabled) { if (!is_valid()) return false; - bool succeeded = false; - - sender_->SendWithTimeout(new AutomationMsg_IsPageMenuCommandEnabled( - 0, handle_, id, &succeeded), timeout_ms, is_timeout); - - return succeeded; + return sender_->Send(new AutomationMsg_IsPageMenuCommandEnabled( + 0, handle_, id, enabled)); } bool BrowserProxy::AppendTab(const GURL& tab_url) { @@ -84,12 +72,6 @@ bool BrowserProxy::AppendTab(const GURL& tab_url) { } bool BrowserProxy::GetActiveTabIndex(int* active_tab_index) const { - return GetActiveTabIndexWithTimeout(active_tab_index, base::kNoTimeout, NULL); -} - -bool BrowserProxy::GetActiveTabIndexWithTimeout(int* active_tab_index, - uint32 timeout_ms, - bool* is_timeout) const { if (!is_valid()) return false; @@ -100,17 +82,17 @@ bool BrowserProxy::GetActiveTabIndexWithTimeout(int* active_tab_index, int active_tab_index_response = -1; - bool succeeded = sender_->SendWithTimeout( - new AutomationMsg_ActiveTabIndex(0, handle_, &active_tab_index_response), - timeout_ms, is_timeout); + if (!sender_->Send(new AutomationMsg_ActiveTabIndex( + 0, handle_, &active_tab_index_response))) { + return false; + } if (active_tab_index_response >= 0) { *active_tab_index = active_tab_index_response; - } else { - succeeded = false; + return true; } - - return succeeded; + + return false; } scoped_refptr<TabProxy> BrowserProxy::GetTab(int tab_index) const { @@ -136,23 +118,13 @@ scoped_refptr<TabProxy> BrowserProxy::GetTab(int tab_index) const { } scoped_refptr<TabProxy> BrowserProxy::GetActiveTab() const { - return GetActiveTabWithTimeout(base::kNoTimeout, NULL); -} - -scoped_refptr<TabProxy> BrowserProxy::GetActiveTabWithTimeout(uint32 timeout_ms, - bool* is_timeout) const { int active_tab_index; - if (!GetActiveTabIndexWithTimeout(&active_tab_index, timeout_ms, is_timeout)) + if (!GetActiveTabIndex(&active_tab_index)) return NULL; return GetTab(active_tab_index); } bool BrowserProxy::GetTabCount(int* num_tabs) const { - return GetTabCountWithTimeout(num_tabs, base::kNoTimeout, NULL); -} - -bool BrowserProxy::GetTabCountWithTimeout(int* num_tabs, uint32 timeout_ms, - bool* is_timeout) const { if (!is_valid()) return false; @@ -163,16 +135,17 @@ bool BrowserProxy::GetTabCountWithTimeout(int* num_tabs, uint32 timeout_ms, int tab_count_response = -1; - bool succeeded = sender_->SendWithTimeout(new AutomationMsg_TabCount( - 0, handle_, &tab_count_response), timeout_ms, is_timeout); + if (!sender_->Send(new AutomationMsg_TabCount( + 0, handle_, &tab_count_response))) { + return false; + } if (tab_count_response >= 0) { *num_tabs = tab_count_response; - } else { - succeeded = false; + return true; } - return succeeded; + return false; } bool BrowserProxy::GetType(Browser::Type* type) const { @@ -185,11 +158,11 @@ bool BrowserProxy::GetType(Browser::Type* type) const { } int type_as_int; - bool succeeded = sender_->SendWithTimeout(new AutomationMsg_Type( - 0, handle_, &type_as_int), base::kNoTimeout, NULL); + if (!sender_->Send(new AutomationMsg_Type(0, handle_, &type_as_int))) + return false; *type = static_cast<Browser::Type>(type_as_int); - return succeeded; + return true; } bool BrowserProxy::ApplyAccelerator(int id) { @@ -200,16 +173,6 @@ bool BrowserProxy::SimulateDrag(const gfx::Point& start, const gfx::Point& end, int flags, bool press_escape_en_route) { - return SimulateDragWithTimeout(start, end, flags, base::kNoTimeout, NULL, - press_escape_en_route); -} - -bool BrowserProxy::SimulateDragWithTimeout(const gfx::Point& start, - const gfx::Point& end, - int flags, - uint32 timeout_ms, - bool* is_timeout, - bool press_escape_en_route) { if (!is_valid()) return false; @@ -219,9 +182,10 @@ bool BrowserProxy::SimulateDragWithTimeout(const gfx::Point& start, bool result = false; - sender_->SendWithTimeout(new AutomationMsg_WindowDrag( - 0, handle_, drag_path, flags, press_escape_en_route, &result), - timeout_ms, is_timeout); + if (!sender_->Send(new AutomationMsg_WindowDrag( + 0, handle_, drag_path, flags, press_escape_en_route, &result))) { + return false; + } return result; } @@ -231,11 +195,8 @@ bool BrowserProxy::WaitForTabCountToBecome(int count, int wait_timeout) { const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout); while (TimeTicks::Now() - start < timeout) { PlatformThread::Sleep(automation::kSleepTime); - bool is_timeout; int new_count; - bool succeeded = GetTabCountWithTimeout(&new_count, wait_timeout, - &is_timeout); - if (!succeeded) + if (!GetTabCount(&new_count)) return false; if (count == new_count) return true; diff --git a/chrome/test/automation/browser_proxy.h b/chrome/test/automation/browser_proxy.h index 674cf83..a21bfe6 100644 --- a/chrome/test/automation/browser_proxy.h +++ b/chrome/test/automation/browser_proxy.h @@ -43,25 +43,13 @@ class BrowserProxy : public AutomationResourceProxy { // successful. bool ActivateTab(int tab_index) WARN_UNUSED_RESULT; - // Like ActivateTab, but returns false if response is not received before - // the specified timeout. - bool ActivateTabWithTimeout(int tab_index, uint32 timeout_ms, - bool* is_timeout) WARN_UNUSED_RESULT; - // Bring the browser window to the front, activating it. Returns true on // success. bool BringToFront() WARN_UNUSED_RESULT; - // Like BringToFront, but returns false if action is not completed before - // the specified timeout. - bool BringToFrontWithTimeout(uint32 timeout_ms, - bool* is_timeout) WARN_UNUSED_RESULT; - - // Checks to see if a navigation command is active or not. Can also - // return false if action is not completed before the specified - // timeout; is_timeout will be set in those cases. - bool IsPageMenuCommandEnabledWithTimeout(int id, uint32 timeout_ms, - bool* is_timeout) WARN_UNUSED_RESULT; + // Checks to see if a navigation command is active or not. If the call was + // successful, puts the result in |enabled| and returns true. + bool IsPageMenuCommandEnabled(int id, bool* enabled) WARN_UNUSED_RESULT; // Append a new tab to the TabStrip. The new tab is selected. // The new tab navigates to the given tab_url. @@ -74,20 +62,10 @@ class BrowserProxy : public AutomationResourceProxy { // successful. bool GetActiveTabIndex(int* active_tab_index) const WARN_UNUSED_RESULT; - // Like GetActiveTabIndex, but returns false if active tab is not received - // before the specified timeout. - bool GetActiveTabIndexWithTimeout(int* active_tab_index, uint32 timeout_ms, - bool* is_timeout) const WARN_UNUSED_RESULT; - // Returns the number of tabs in the given window. Returns true if // the call was successful. bool GetTabCount(int* num_tabs) const WARN_UNUSED_RESULT; - // Like GetTabCount, but returns false if tab count is not received within the - // before timeout. - bool GetTabCountWithTimeout(int* num_tabs, uint32 timeout_ms, - bool* is_timeout) const WARN_UNUSED_RESULT; - // Returns the type of the given window. Returns true if the call was // successful. bool GetType(Browser::Type* type) const WARN_UNUSED_RESULT; @@ -103,11 +81,6 @@ class BrowserProxy : public AutomationResourceProxy { // ownership of the pointer to the caller. On failure, returns NULL. scoped_refptr<TabProxy> GetActiveTab() const; - // Like GetActiveTab, but returns NULL if no response is received before - // the specified timout. - scoped_refptr<TabProxy> GetActiveTabWithTimeout(uint32 timeout_ms, - bool* is_timeout) const; - // Returns the WindowProxy for this browser's window. It can be used to // retreive view bounds, simulate clicks and key press events. The caller // owns the returned WindowProxy. @@ -139,15 +112,6 @@ class BrowserProxy : public AutomationResourceProxy { int flags, bool press_escape_en_route) WARN_UNUSED_RESULT; - // Like SimulateDrag, but returns false if response is not received before - // the specified timeout. - virtual bool SimulateDragWithTimeout(const gfx::Point& start, - const gfx::Point& end, - int flags, uint32 timeout_ms, - bool* is_timeout, - bool press_escape_en_route) - WARN_UNUSED_RESULT; - // Block the thread until the tab count is |count|. // |wait_timeout| is the timeout, in milliseconds, for waiting. // Returns true on success. diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc index dbf4875..0f28409 100644 --- a/chrome/test/automation/tab_proxy.cc +++ b/chrome/test/automation/tab_proxy.cc @@ -77,33 +77,22 @@ AutomationMsg_NavigationResponseValues TabProxy::NavigateToURL( AutomationMsg_NavigationResponseValues TabProxy::NavigateToURLBlockUntilNavigationsComplete( const GURL& url, int number_of_navigations) { - return NavigateToURLWithTimeout(url, number_of_navigations, base::kNoTimeout, - NULL); -} - -AutomationMsg_NavigationResponseValues TabProxy::NavigateToURLWithTimeout( - const GURL& url, int number_of_navigations, uint32 timeout_ms, - bool* is_timeout) { if (!is_valid()) return AUTOMATION_MSG_NAVIGATION_ERROR; - + AutomationMsg_NavigationResponseValues navigate_response = AUTOMATION_MSG_NAVIGATION_ERROR; - + if (number_of_navigations == 1) { // TODO(phajdan.jr): Remove when the reference build gets updated. // This is only for backwards compatibility. - sender_->SendWithTimeout( - new AutomationMsg_NavigateToURL( - 0, handle_, url, &navigate_response), - timeout_ms, is_timeout); + sender_->Send(new AutomationMsg_NavigateToURL(0, handle_, url, + &navigate_response)); } else { - sender_->SendWithTimeout( - new AutomationMsg_NavigateToURLBlockUntilNavigationsComplete( - 0, handle_, url, number_of_navigations, &navigate_response), - timeout_ms, is_timeout); + sender_->Send(new AutomationMsg_NavigateToURLBlockUntilNavigationsComplete( + 0, handle_, url, number_of_navigations, &navigate_response)); } - + return navigate_response; } @@ -470,15 +459,17 @@ bool TabProxy::GetDownloadDirectory(FilePath* directory) { directory)); } -bool TabProxy::ShowInterstitialPage(const std::string& html_text, - int timeout_ms) { +bool TabProxy::ShowInterstitialPage(const std::string& html_text) { if (!is_valid()) return false; AutomationMsg_NavigationResponseValues result = AUTOMATION_MSG_NAVIGATION_ERROR; - sender_->SendWithTimeout(new AutomationMsg_ShowInterstitialPage( - 0, handle_, html_text, &result), timeout_ms, NULL); + if (!sender_->Send(new AutomationMsg_ShowInterstitialPage( + 0, handle_, html_text, &result))) { + return false; + } + return result == AUTOMATION_MSG_NAVIGATION_SUCCESS; } diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h index 8fe9318..15b5ab9 100644 --- a/chrome/test/automation/tab_proxy.h +++ b/chrome/test/automation/tab_proxy.h @@ -124,14 +124,6 @@ class TabProxy : public AutomationResourceProxy { NavigateToURLBlockUntilNavigationsComplete( const GURL& url, int number_of_navigations) WARN_UNUSED_RESULT; - // Navigates to a url. This is same as NavigateToURL with a timeout option. - // The function blocks until the |number_of_navigations| navigations - // completes or timeout (in milliseconds) occurs. If return after timeout, - // is_timeout is set to true. - AutomationMsg_NavigationResponseValues NavigateToURLWithTimeout( - const GURL& url, int number_of_navigations, uint32 timeout_ms, - bool* is_timeout) WARN_UNUSED_RESULT; - // Navigates to a url in an externally hosted tab. // This method accepts the same kinds of URL input that // can be passed to Chrome on the command line. This is a synchronous call and @@ -269,9 +261,8 @@ class TabProxy : public AutomationResourceProxy { bool GetDownloadDirectory(FilePath* download_directory) WARN_UNUSED_RESULT; // Shows an interstitial page. Blocks until the interstitial page - // has been loaded. Return false if a failure happens.3 - bool ShowInterstitialPage(const std::string& html_text, - int timeout_ms) WARN_UNUSED_RESULT; + // has been loaded. Return false if a failure happens. + bool ShowInterstitialPage(const std::string& html_text) WARN_UNUSED_RESULT; // Hides the currently shown interstitial page. Blocks until the interstitial // page has been hidden. Return false if a failure happens. diff --git a/chrome/test/automation/window_proxy.cc b/chrome/test/automation/window_proxy.cc index 65d6cf4..295f05b 100644 --- a/chrome/test/automation/window_proxy.cc +++ b/chrome/test/automation/window_proxy.cc @@ -75,14 +75,6 @@ bool WindowProxy::Activate() { bool WindowProxy::GetViewBounds(int view_id, gfx::Rect* bounds, bool screen_coordinates) { - return GetViewBoundsWithTimeout(view_id, bounds, screen_coordinates, - base::kNoTimeout, NULL); -} - -bool WindowProxy::GetViewBoundsWithTimeout(int view_id, gfx::Rect* bounds, - bool screen_coordinates, - uint32 timeout_ms, - bool* is_timeout) { if (!is_valid()) return false; @@ -93,9 +85,10 @@ bool WindowProxy::GetViewBoundsWithTimeout(int view_id, gfx::Rect* bounds, bool result = false; - sender_->SendWithTimeout(new AutomationMsg_WindowViewBounds( - 0, handle_, view_id, screen_coordinates, &result, bounds), - timeout_ms, is_timeout); + if (!sender_->Send(new AutomationMsg_WindowViewBounds( + 0, handle_, view_id, screen_coordinates, &result, bounds))) { + return false; + } return result; } diff --git a/chrome/test/automation/window_proxy.h b/chrome/test/automation/window_proxy.h index 92f74ae..3c5deca 100644 --- a/chrome/test/automation/window_proxy.h +++ b/chrome/test/automation/window_proxy.h @@ -78,12 +78,6 @@ class WindowProxy : public AutomationResourceProxy { // of the screen, if false in the coordinates of the browser. bool GetViewBounds(int view_id, gfx::Rect* bounds, bool screen_coordinates); - // Like GetViewBounds except returns false if timeout occurs before view - // bounds are obtained, and sets is_timeout accordingly. - bool GetViewBoundsWithTimeout(int view_id, gfx::Rect* bounds, - bool screen_coordinates, uint32 timeout_ms, - bool* is_timeout); - // Gets the position and size of the window. Returns true if setting the // bounds was successful. bool GetBounds(gfx::Rect* bounds); |