diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-16 08:39:54 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-16 08:39:54 +0000 |
commit | 6fd3535a1593f4c73c938c7aa7e35eb976ccf280 (patch) | |
tree | 9a67ff8878ad611c4a35e728a613c451bb25008f /chrome/test/automation/tab_proxy.h | |
parent | b22b5167bd0a7494a78195d04b5a77ff185de5ae (diff) | |
download | chromium_src-6fd3535a1593f4c73c938c7aa7e35eb976ccf280.zip chromium_src-6fd3535a1593f4c73c938c7aa7e35eb976ccf280.tar.gz chromium_src-6fd3535a1593f4c73c938c7aa7e35eb976ccf280.tar.bz2 |
[GTTF] Make automation framework more solid by making sure that
important return values are not ignored.
The macro used here, WARN_UNUSED_RESULT, takes effect only for GCC,
but that's enough since we have bots for all platforms.
Adding these warnings already detected some cases where a return value
was ignored. In some of them the test was trying to get the information
about success "some other way", in some it could sometimes confuse test
failure with test success.
TEST=ui_tests
BUG=none
Review URL: http://codereview.chromium.org/948002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41696 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/automation/tab_proxy.h')
-rw-r--r-- | chrome/test/automation/tab_proxy.h | 115 |
1 files changed, 61 insertions, 54 deletions
diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h index 326f0dc..8fe9318 100644 --- a/chrome/test/automation/tab_proxy.h +++ b/chrome/test/automation/tab_proxy.h @@ -14,6 +14,7 @@ #include <string> #include <vector> +#include "base/compiler_specific.h" #include "base/observer_list.h" #include "chrome/browser/download/save_package.h" #include "chrome/browser/tab_contents/navigation_entry.h" @@ -55,16 +56,16 @@ class TabProxy : public AutomationResourceProxy { : AutomationResourceProxy(tracker, sender, handle) {} // Gets the current url of the tab. - bool GetCurrentURL(GURL* url) const; + bool GetCurrentURL(GURL* url) const WARN_UNUSED_RESULT; // Gets the title of the tab. - bool GetTabTitle(std::wstring* title) const; + bool GetTabTitle(std::wstring* title) const WARN_UNUSED_RESULT; // Gets the tabstrip index of the tab. - bool GetTabIndex(int* index) const; + bool GetTabIndex(int* index) const WARN_UNUSED_RESULT; // Gets the number of constrained window for this tab. - bool GetConstrainedWindowCount(int* count) const; + bool GetConstrainedWindowCount(int* count) const WARN_UNUSED_RESULT; // Executes a javascript in a frame's context whose xpath is provided as the // first parameter and extract the values from the resulting json string. @@ -75,16 +76,16 @@ class TabProxy : public AutomationResourceProxy { // will result in value = 24 bool ExecuteAndExtractString(const std::wstring& frame_xpath, const std::wstring& jscript, - std::wstring* value); + std::wstring* value) WARN_UNUSED_RESULT; bool ExecuteAndExtractBool(const std::wstring& frame_xpath, const std::wstring& jscript, - bool* value); + bool* value) WARN_UNUSED_RESULT; bool ExecuteAndExtractInt(const std::wstring& frame_xpath, const std::wstring& jscript, - int* value); + int* value) WARN_UNUSED_RESULT; bool ExecuteAndExtractValue(const std::wstring& frame_xpath, const std::wstring& jscript, - Value** value); + Value** value) WARN_UNUSED_RESULT; // Configure extension automation mode. When extension automation // mode is turned on, the automation host can overtake extension API calls @@ -108,20 +109,20 @@ class TabProxy : public AutomationResourceProxy { // write tests where some functionality continues to function as normal, // and other functionality is mocked out by the test. bool SetEnableExtensionAutomation( - const std::vector<std::string>& functions_enabled); + const std::vector<std::string>& functions_enabled) WARN_UNUSED_RESULT; // Navigates to a url. 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 // hence blocks until the navigation completes. AutomationMsg_NavigationResponseValues NavigateToURL( - const GURL& url); + const GURL& url) WARN_UNUSED_RESULT; // Navigates to a url. 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 // hence blocks until the |number_of_navigations| navigations complete. AutomationMsg_NavigationResponseValues - NavigateToURLBlockUntilNavigationsComplete(const GURL& url, - int number_of_navigations); + 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 @@ -129,16 +130,17 @@ class TabProxy : public AutomationResourceProxy { // is_timeout is set to true. AutomationMsg_NavigationResponseValues NavigateToURLWithTimeout( const GURL& url, int number_of_navigations, uint32 timeout_ms, - bool* is_timeout); + 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 // hence blocks until the navigation completes. AutomationMsg_NavigationResponseValues NavigateInExternalTab( - const GURL& url, const GURL& referrer); + const GURL& url, const GURL& referrer) WARN_UNUSED_RESULT; - AutomationMsg_NavigationResponseValues NavigateExternalTabAtIndex(int index); + AutomationMsg_NavigationResponseValues NavigateExternalTabAtIndex( + int index) WARN_UNUSED_RESULT; // Navigates to a url. This is an asynchronous version of NavigateToURL. // The function returns immediately after sending the LoadURL notification @@ -146,42 +148,43 @@ class TabProxy : public AutomationResourceProxy { // TODO(vibhor): Add a callback if needed in future. // TODO(mpcomplete): If the navigation results in an auth challenge, the // TabProxy we attach won't know about it. See bug 666730. - bool NavigateToURLAsync(const GURL& url); + bool NavigateToURLAsync(const GURL& url) WARN_UNUSED_RESULT; // Replaces a vector contents with the redirect chain out of the given URL. // Returns true on success. Failure may be due to being unable to send the // message, parse the response, or a failure of the history system in the // browser. - bool GetRedirectsFrom(const GURL& source_url, std::vector<GURL>* redirects); + bool GetRedirectsFrom(const GURL& source_url, + std::vector<GURL>* redirects) WARN_UNUSED_RESULT; // Equivalent to hitting the Back button. This is a synchronous call and // hence blocks until the navigation completes. - AutomationMsg_NavigationResponseValues GoBack(); + AutomationMsg_NavigationResponseValues GoBack() WARN_UNUSED_RESULT; // Equivalent to hitting the Back button. This is a synchronous call and // hence blocks until the |number_of_navigations| navigations complete. AutomationMsg_NavigationResponseValues GoBackBlockUntilNavigationsComplete( - int number_of_navigations); + int number_of_navigations) WARN_UNUSED_RESULT; // Equivalent to hitting the Forward button. This is a synchronous call and // hence blocks until the navigation completes. - AutomationMsg_NavigationResponseValues GoForward(); + AutomationMsg_NavigationResponseValues GoForward() WARN_UNUSED_RESULT; // Equivalent to hitting the Forward button. This is a synchronous call and // hence blocks until the |number_of_navigations| navigations complete. AutomationMsg_NavigationResponseValues GoForwardBlockUntilNavigationsComplete( - int number_of_navigations); + int number_of_navigations) WARN_UNUSED_RESULT; // Equivalent to hitting the Reload button. This is a synchronous call and // hence blocks until the navigation completes. - AutomationMsg_NavigationResponseValues Reload(); + AutomationMsg_NavigationResponseValues Reload() WARN_UNUSED_RESULT; // Closes the tab. This is synchronous, but does NOT block until the tab has // closed, rather it blocks until the browser has initiated the close. Use // Close(true) if you need to block until tab completely closes. // // Note that this proxy is invalid after this call. - bool Close(); + bool Close() WARN_UNUSED_RESULT; // Variant of close that allows you to specify whether you want to block // until the tab has completely closed (wait_until_closed == true) or block @@ -193,27 +196,28 @@ class TabProxy : public AutomationResourceProxy { // when closing the last tab it is possible for the browser to shutdown BEFORE // the tab has completely closed. In other words, this may NOT be sent for // the last tab. - bool Close(bool wait_until_closed); + bool Close(bool wait_until_closed) WARN_UNUSED_RESULT; #if defined(OS_WIN) // TODO(port): Use portable replacement for HWND. // Gets the HWND that corresponds to the content area of this tab. // Returns true if the call was successful. - bool GetHWND(HWND* hwnd) const; + bool GetHWND(HWND* hwnd) const WARN_UNUSED_RESULT; #endif // defined(OS_WIN) // Gets the process ID that corresponds to the content area of this tab. // Returns true if the call was successful. If the specified tab has no // separate process for rendering its content, the return value is true but // the process_id is 0. - bool GetProcessID(int* process_id) const; + bool GetProcessID(int* process_id) const WARN_UNUSED_RESULT; // Supply or cancel authentication to a login prompt. These are synchronous // calls and hence block until the load finishes (or another login prompt // appears, in the case of invalid login info). - bool SetAuth(const std::wstring& username, const std::wstring& password); - bool CancelAuth(); + bool SetAuth(const std::wstring& username, + const std::wstring& password) WARN_UNUSED_RESULT; + bool CancelAuth() WARN_UNUSED_RESULT; // Checks if this tab has a login prompt waiting for auth. This will be // true if a navigation results in a login prompt, and if an attempted login @@ -224,7 +228,7 @@ class TabProxy : public AutomationResourceProxy { // TODO(mpcomplete): we have no way of knowing if auth is needed after either // NavigateToURLAsync, or after appending a tab with an URL that triggers // auth. - bool NeedsAuth() const; + bool NeedsAuth() const WARN_UNUSED_RESULT; // Starts a search within the current tab. The parameter |search_string| // specifies what string to search for, |forward| specifies whether to search @@ -236,11 +240,11 @@ class TabProxy : public AutomationResourceProxy { int FindInPage(const std::wstring& search_string, FindInPageDirection forward, FindInPageCase match_case, bool find_next, int* ordinal); - bool GetCookies(const GURL& url, std::string* cookies); + bool GetCookies(const GURL& url, std::string* cookies) WARN_UNUSED_RESULT; bool GetCookieByName(const GURL& url, const std::string& name, - std::string* cookies); - bool SetCookie(const GURL& url, const std::string& value); + std::string* cookies) WARN_UNUSED_RESULT; + bool SetCookie(const GURL& url, const std::string& value) WARN_UNUSED_RESULT; // Sends a InspectElement message for the current tab. |x| and |y| are the // coordinates that we want to simulate that the user is trying to inspect. @@ -252,24 +256,26 @@ class TabProxy : public AutomationResourceProxy { // The third parameter specifies the timeout length for the wait loop. // Returns false if the count does not change. bool WaitForChildWindowCountToChange(int count, int* new_count, - int wait_timeout); + int wait_timeout) WARN_UNUSED_RESULT; // Gets the number of popups blocked from this tab. - bool GetBlockedPopupCount(int* count) const; + bool GetBlockedPopupCount(int* count) const WARN_UNUSED_RESULT; // Blocks the thread until the number of blocked popup is equal to // |target_count|. - bool WaitForBlockedPopupCountToChangeTo(int target_count, int wait_timeout); + bool WaitForBlockedPopupCountToChangeTo(int target_count, + int wait_timeout) WARN_UNUSED_RESULT; - bool GetDownloadDirectory(FilePath* download_directory); + 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); + bool ShowInterstitialPage(const std::string& html_text, + int timeout_ms) WARN_UNUSED_RESULT; // Hides the currently shown interstitial page. Blocks until the interstitial // page has been hidden. Return false if a failure happens. - bool HideInterstitialPage(); + bool HideInterstitialPage() WARN_UNUSED_RESULT; #if defined(OS_WIN) // TODO(port): Use something portable. @@ -277,41 +283,41 @@ class TabProxy : public AutomationResourceProxy { // The container of an externally hosted tab calls this to reflect any // accelerator keys that it did not process. This gives the tab a chance // to handle the keys - bool ProcessUnhandledAccelerator(const MSG& msg); + bool ProcessUnhandledAccelerator(const MSG& msg) WARN_UNUSED_RESULT; #endif // defined(OS_WIN) // Ask the tab to set focus to either the first or last element on the page. - bool SetInitialFocus(bool reverse); + bool SetInitialFocus(bool reverse) WARN_UNUSED_RESULT; // Waits for the tab to finish being restored. Returns true on success. // timeout_ms gives the max amount of time to wait for restore to complete. - bool WaitForTabToBeRestored(uint32 timeout_ms); + bool WaitForTabToBeRestored(uint32 timeout_ms) WARN_UNUSED_RESULT; // Retrieves the different security states for the current tab. bool GetSecurityState(SecurityStyle* security_style, int* ssl_cert_status, - int* mixed_content_state); + int* mixed_content_state) WARN_UNUSED_RESULT; // Returns the type of the page currently showing (normal, interstitial, // error). - bool GetPageType(NavigationEntry::PageType* page_type); + bool GetPageType(NavigationEntry::PageType* page_type) WARN_UNUSED_RESULT; // Simulates the user action on the SSL blocking page. if |proceed| is true, // this is equivalent to clicking the 'Proceed' button, if false to 'Take me // out of there' button. - bool TakeActionOnSSLBlockingPage(bool proceed); + bool TakeActionOnSSLBlockingPage(bool proceed) WARN_UNUSED_RESULT; // Prints the current page without user intervention. - bool PrintNow(); + bool PrintNow() WARN_UNUSED_RESULT; // Sends off an asynchronous request for printing. - bool PrintAsync(); + bool PrintAsync() WARN_UNUSED_RESULT; // Save the current web page. |file_name| is the HTML file name, and // |dir_path| is the directory for saving resource files. |type| indicates // which type we're saving as: HTML only or the complete web page. bool SavePage(const FilePath& file_name, const FilePath& dir_path, - SavePackage::SavePackageType type); + SavePackage::SavePackageType type) WARN_UNUSED_RESULT; // Posts a message to the external tab. void HandleMessageFromExternalHost(const std::string& message, @@ -319,21 +325,22 @@ class TabProxy : public AutomationResourceProxy { const std::string& target); // Retrieves the number of info-bars currently showing in |count|. - bool GetInfoBarCount(int* count); + bool GetInfoBarCount(int* count) WARN_UNUSED_RESULT; // Waits for up to |wait_timeout| ms until the infobar count is |count|. // Returns false if a timeout occurred before the count matched, or an // error occurred retrieving the count. - bool WaitForInfoBarCount(int count, int wait_timeout); + bool WaitForInfoBarCount(int count, int wait_timeout) WARN_UNUSED_RESULT; // Causes a click on the "accept" button of the info-bar at |info_bar_index|. // If |wait_for_navigation| is true, this call does not return until a // navigation has occured. - bool ClickInfoBarAccept(int info_bar_index, bool wait_for_navigation); + bool ClickInfoBarAccept(int info_bar_index, + bool wait_for_navigation) WARN_UNUSED_RESULT; // Retrieves the time at which the last navigation occured. This is intended // to be used with WaitForNavigation (see below). - bool GetLastNavigationTime(int64* last_navigation_time); + bool GetLastNavigationTime(int64* last_navigation_time) WARN_UNUSED_RESULT; // Waits for a new navigation if none as occurred since |last_navigation_time| // The purpose of this function is for operations that causes asynchronous @@ -343,13 +350,13 @@ class TabProxy : public AutomationResourceProxy { // tab_proxy->GetLastNavigationTime(&last_nav_time); // tab_proxy->SomeOperationThatTriggersAnAsynchronousNavigation(); // tab_proxy->WaitForNavigation(last_nav_time); - bool WaitForNavigation(int64 last_navigation_time); + bool WaitForNavigation(int64 last_navigation_time) WARN_UNUSED_RESULT; // Gets the current used encoding of the page in the tab. - bool GetPageCurrentEncoding(std::string* encoding); + bool GetPageCurrentEncoding(std::string* encoding) WARN_UNUSED_RESULT; // Uses the specified encoding to override encoding of the page in the tab. - bool OverrideEncoding(const std::string& encoding); + bool OverrideEncoding(const std::string& encoding) WARN_UNUSED_RESULT; #if defined(OS_WIN) // Resizes the tab window. |