Chromium Code Reviews| Index: chrome/test/ui_test_utils.h |
| diff --git a/chrome/test/ui_test_utils.h b/chrome/test/ui_test_utils.h |
| index f6e383f441f4ceed5c6d2841b27d0bd495c0f4ad..a463a3cddebb69c8c8e345d26373800c68ad5edd 100644 |
| --- a/chrome/test/ui_test_utils.h |
| +++ b/chrome/test/ui_test_utils.h |
| @@ -24,6 +24,7 @@ |
| #include "chrome/test/automation/dom_element_proxy.h" |
| #include "gfx/native_widget_types.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| +#include "webkit/glue/window_open_disposition.h" |
| class AppModalDialog; |
| class BookmarkModel; |
| @@ -52,6 +53,23 @@ class Size; |
| // A collections of functions designed for use with InProcessBrowserTest. |
| namespace ui_test_utils { |
| +// Flags to indicate what to wait for in a navigation test. |
| +// They can be ORed together. |
| +// The order in which the waits happen when more than one is selected, is: |
| +// Browser |
| +// Tab |
| +// Navigation |
| +enum BrowserTestFlags { |
| + BROWSER_TEST_NONE = 0, // Don't wait for anything. |
| + BROWSER_TEST_WAIT_FOR_BROWSER = 1 << 0, // Wait for a new browser. |
| + BROWSER_TEST_WAIT_FOR_TAB = 1 << 1, // Wait for a new tab. |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
So just confirming: If I WAIT_FOR_TAB but don't WA
ahendrickson
2010/12/16 19:26:41
Correct.
|
| + BROWSER_TEST_WAIT_FOR_NAVIGATION = 1 << 2, // Wait for navigation to finish. |
| + |
| + BROWSER_TEST_MASK = BROWSER_TEST_WAIT_FOR_BROWSER | |
| + BROWSER_TEST_WAIT_FOR_TAB | |
| + BROWSER_TEST_WAIT_FOR_NAVIGATION |
| +}; |
| + |
| // Turns on nestable tasks, runs the message loop, then resets nestable tasks |
| // to what they were originally. Prefer this over MessageLoop::Run for in |
| // process browser tests that need to block until a condition is met. |
| @@ -84,6 +102,12 @@ void WaitForNavigation(NavigationController* controller); |
| void WaitForNavigations(NavigationController* controller, |
| int number_of_navigations); |
| +// Waits for the |browser| to close its window. |
| +void WaitForWindowClosed(Browser* browser); |
| + |
| +// Waits for a new tab to be added anywhere. |
| +Browser* WaitForAnyNewTab(); |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
This is only used in one place, which is inside ui
ahendrickson
2010/12/16 19:26:41
Moved. I do think it could be used by other files
|
| + |
| // Waits for a new tab to be added to |browser|. |
| void WaitForNewTab(Browser* browser); |
| @@ -96,6 +120,12 @@ void WaitForLoadStop(NavigationController* controller); |
| // Waits for a new browser to be created, returning the browser. |
| Browser* WaitForNewBrowser(); |
| +// Waits for a new browser to be created, returning the browser. |
| +// Pass in the number of browsers that exist before the navigation starts in |
| +// |start_count|, and it will exit even if the notification occurs before it's |
| +// called. |
| +Browser* WaitForNewBrowserWithCount(size_t start_count); |
| + |
| // Opens |url| in an incognito browser window with the off the record profile of |
| // |profile|, blocking until the navigation finishes. This will create a new |
| // browser if a browser with the off the record profile does not exist. |
| @@ -105,12 +135,32 @@ void OpenURLOffTheRecord(Profile* profile, const GURL& url); |
| // navigation finishes. |
| void NavigateToURL(Browser* browser, const GURL& url); |
| +// Navigates the specified tab of |browser| to |url|, blocking until the |
| +// navigation finishes. |
| +// |disposition| indicates what tab the download occurs in, and |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
nit: This call isn't about downloads specifically.
ahendrickson
2010/12/16 19:26:41
Done.
|
| +// |browser_test_flags| controls what to wait for before continuing. |
| +void NavigateToURLWithDisposition(Browser* browser, |
| + const GURL& url, |
| + WindowOpenDisposition disposition, |
| + int browser_test_flags); |
| + |
| // Navigates the selected tab of |browser| to |url|, blocking until the |
| // number of navigations specified complete. |
| void NavigateToURLBlockUntilNavigationsComplete(Browser* browser, |
| const GURL& url, |
| int number_of_navigations); |
| +// Navigates the specified tab (via |disposition|) of |browser| to |url|, |
| +// blocking until the |number_of_navigations| specified complete. |
|
Randy Smith (Not in Mondays)
2010/12/13 21:44:58
This is a bit confusing, at least to an untutored
ahendrickson
2010/12/16 19:26:41
Yeah, I found it a bit odd too -- I copied the com
|
| +// |disposition| indicates what tab the download occurs in, and |
| +// |browser_test_flags| controls what to wait for before continuing. |
| +void NavigateToURLWithDispositionBlockUntilNavigationsComplete( |
| + Browser* browser, |
| + const GURL& url, |
| + int number_of_navigations, |
| + WindowOpenDisposition disposition, |
| + int browser_test_flags); |
| + |
| // Gets the DOMDocument for the active tab in |browser|. |
| // Returns a NULL reference on failure. |
| DOMElementProxyRef GetActiveDOMDocument(Browser* browser); |
| @@ -212,6 +262,9 @@ bool GetNativeWindow(const Browser* browser, gfx::NativeWindow* native_window) |
| // success. |
| bool BringBrowserWindowToFront(const Browser* browser) WARN_UNUSED_RESULT; |
| +// Gets the browser at the specified |index|. |
| +Browser* GetBrowser(int index); |
| + |
| // Sends a key press, blocking until the key press is received or the test times |
| // out. This uses ui_controls::SendKeyPress, see it for details. Returns true |
| // if the event was successfully sent and received. |