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 5299451be35246be39bc9230e5cf3b76bc54d62c..7e0fa29b26ce798be4214a918f7683b1086954e1 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 { |
|
Paweł Hajdan Jr.
2011/01/03 09:06:47
nit: Choose a more specific name than BrowserTestF
ahendrickson
2011/01/05 00:32:09
Done.
|
| + 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. |
| + 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,9 @@ 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 to |browser|. |
| void WaitForNewTab(Browser* browser); |
| @@ -96,6 +117,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,6 +132,15 @@ 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 navigation occurs in, and |
| +// |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, |
| @@ -212,6 +248,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. |