OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_TEST_UI_UI_TEST_H_ | 5 #ifndef CHROME_TEST_UI_UI_TEST_H_ |
6 #define CHROME_TEST_UI_UI_TEST_H_ | 6 #define CHROME_TEST_UI_UI_TEST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 // This file provides a common base for running UI unit tests, which operate | 9 // This file provides a common base for running UI unit tests, which operate |
10 // the entire browser application in a separate process for holistic | 10 // the entire browser application in a separate process for holistic |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // Polls up to kWaitForActionMaxMsec ms to attain a specific tab count. Will | 139 // Polls up to kWaitForActionMaxMsec ms to attain a specific tab count. Will |
140 // assert that the tab count is valid at the end of the wait. | 140 // assert that the tab count is valid at the end of the wait. |
141 void WaitUntilTabCount(int tab_count); | 141 void WaitUntilTabCount(int tab_count); |
142 | 142 |
143 // Waits until the Bookmark bar has stopped animating and become fully visible | 143 // Waits until the Bookmark bar has stopped animating and become fully visible |
144 // (if |wait_for_open| is true) or fully hidden (if |wait_for_open| is false). | 144 // (if |wait_for_open| is true) or fully hidden (if |wait_for_open| is false). |
145 // This function can time out (in which case it returns false). | 145 // This function can time out (in which case it returns false). |
146 bool WaitForBookmarkBarVisibilityChange(BrowserProxy* browser, | 146 bool WaitForBookmarkBarVisibilityChange(BrowserProxy* browser, |
147 bool wait_for_open); | 147 bool wait_for_open); |
148 | 148 |
149 // Sends the request to close the browser without blocking. | |
150 // This is so we can interact with dialogs opened on browser close, | |
151 // e.g. the beforeunload confirm dialog. | |
152 void CloseBrowserAsync(BrowserProxy* browser) const; | |
153 | |
154 // Closes the specified browser. Returns true if the browser was closed. | 149 // Closes the specified browser. Returns true if the browser was closed. |
155 // This call is blocking. |application_closed| is set to true if this was | 150 // This call is blocking. |application_closed| is set to true if this was |
156 // the last browser window (and therefore as a result of it closing the | 151 // the last browser window (and therefore as a result of it closing the |
157 // browser process terminated). Note that in that case this method returns | 152 // browser process terminated). Note that in that case this method returns |
158 // after the browser process has terminated. | 153 // after the browser process has terminated. |
159 bool CloseBrowser(BrowserProxy* browser, bool* application_closed) const; | 154 bool CloseBrowser(BrowserProxy* browser, bool* application_closed) const; |
160 | 155 |
161 // Gets the executable file path of the Chrome browser process. | 156 // Gets the executable file path of the Chrome browser process. |
162 const FilePath::CharType* GetExecutablePath(); | 157 const FilePath::CharType* GetExecutablePath(); |
163 | 158 |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 // Polls the tab for the cookie_name cookie and returns once one of the | 406 // Polls the tab for the cookie_name cookie and returns once one of the |
412 // following conditions hold true: | 407 // following conditions hold true: |
413 // - The cookie is set to any value. | 408 // - The cookie is set to any value. |
414 // - The browser process died. | 409 // - The browser process died. |
415 // - The timeout value has been exceeded. | 410 // - The timeout value has been exceeded. |
416 std::string WaitUntilCookieNonEmpty(TabProxy* tab, | 411 std::string WaitUntilCookieNonEmpty(TabProxy* tab, |
417 const GURL& url, | 412 const GURL& url, |
418 const char* cookie_name, | 413 const char* cookie_name, |
419 int timeout_ms); | 414 int timeout_ms); |
420 | 415 |
421 // Checks whether the download shelf is visible in the current browser, giving | |
422 // it a chance to appear (we don't know the exact timing) while finishing as | |
423 // soon as possible. | |
424 bool WaitForDownloadShelfVisible(BrowserProxy* browser); | |
425 | |
426 // Checks whether the download shelf is invisible in the current browser, | |
427 // giving it a chance to appear (we don't know the exact timing) while | |
428 // finishing as soon as possible. | |
429 bool WaitForDownloadShelfInvisible(BrowserProxy* browser); | |
430 | |
431 // Waits until the Find window has become fully visible (if |wait_for_open| is | 416 // Waits until the Find window has become fully visible (if |wait_for_open| is |
432 // true) or fully hidden (if |wait_for_open| is false). This function can time | 417 // true) or fully hidden (if |wait_for_open| is false). This function can time |
433 // out (return false) if the window doesn't appear within a specific time. | 418 // out (return false) if the window doesn't appear within a specific time. |
434 bool WaitForFindWindowVisibilityChange(BrowserProxy* browser, | 419 bool WaitForFindWindowVisibilityChange(BrowserProxy* browser, |
435 bool wait_for_open); | 420 bool wait_for_open); |
436 | 421 |
437 // Terminates the browser, simulates end of session. | 422 // Terminates the browser, simulates end of session. |
438 void TerminateBrowser(); | 423 void TerminateBrowser(); |
439 | 424 |
440 // Tells the browser to navigate to the given URL in the active tab | 425 // Tells the browser to navigate to the given URL in the active tab |
441 // of the first app window. | 426 // of the first app window. |
442 // Does not wait for the navigation to complete to return. | 427 // Does not wait for the navigation to complete to return. |
443 // To avoid intermittent test failures, use NavigateToURL instead, if | 428 // To avoid intermittent test failures, use NavigateToURL instead, if |
444 // possible. | 429 // possible. |
445 void NavigateToURLAsync(const GURL& url); | 430 void NavigateToURLAsync(const GURL& url); |
446 | 431 |
447 private: | 432 private: |
448 // Waits for download shelf visibility or invisibility. | |
449 bool WaitForDownloadShelfVisibilityChange(BrowserProxy* browser, | |
450 bool wait_for_open); | |
451 | |
452 MessageLoop message_loop_; // Enables PostTask to main thread. | 433 MessageLoop message_loop_; // Enables PostTask to main thread. |
453 }; | 434 }; |
454 | 435 |
455 // These exist only to support the gTest assertion macros, and | 436 // These exist only to support the gTest assertion macros, and |
456 // shouldn't be used in normal program code. | 437 // shouldn't be used in normal program code. |
457 #ifdef UNIT_TEST | 438 #ifdef UNIT_TEST |
458 std::ostream& operator<<(std::ostream& out, const std::wstring& wstr); | 439 std::ostream& operator<<(std::ostream& out, const std::wstring& wstr); |
459 | 440 |
460 template<typename T> | 441 template<typename T> |
461 std::ostream& operator<<(std::ostream& out, const ::scoped_ptr<T>& ptr) { | 442 std::ostream& operator<<(std::ostream& out, const ::scoped_ptr<T>& ptr) { |
462 return out << ptr.get(); | 443 return out << ptr.get(); |
463 } | 444 } |
464 #endif // UNIT_TEST | 445 #endif // UNIT_TEST |
465 | 446 |
466 #endif // CHROME_TEST_UI_UI_TEST_H_ | 447 #endif // CHROME_TEST_UI_UI_TEST_H_ |
OLD | NEW |