| 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 | 7 |
| 8 // This file provides a common base for running UI unit tests, which operate | 8 // This file provides a common base for running UI unit tests, which operate |
| 9 // the entire browser application in a separate process for holistic | 9 // the entire browser application in a separate process for holistic |
| 10 // functional testing. | 10 // functional testing. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 void LaunchBrowser(); | 60 void LaunchBrowser(); |
| 61 | 61 |
| 62 // Launches the browser and IPC testing connection in server mode. | 62 // Launches the browser and IPC testing connection in server mode. |
| 63 void LaunchBrowserAndServer(); | 63 void LaunchBrowserAndServer(); |
| 64 | 64 |
| 65 // Launches the IPC testing connection in client mode, | 65 // Launches the IPC testing connection in client mode, |
| 66 // which then attempts to connect to a browser. | 66 // which then attempts to connect to a browser. |
| 67 void ConnectToRunningBrowser(); | 67 void ConnectToRunningBrowser(); |
| 68 | 68 |
| 69 // Only for pyauto. | 69 // Only for pyauto. |
| 70 base::TimeDelta action_timeout(); |
| 70 int action_timeout_ms(); | 71 int action_timeout_ms(); |
| 72 void set_action_timeout(base::TimeDelta timeout); |
| 71 void set_action_timeout_ms(int timeout); | 73 void set_action_timeout_ms(int timeout); |
| 72 | 74 |
| 73 // Overridable so that derived classes can provide their own ProxyLauncher. | 75 // Overridable so that derived classes can provide their own ProxyLauncher. |
| 74 virtual ProxyLauncher* CreateProxyLauncher(); | 76 virtual ProxyLauncher* CreateProxyLauncher(); |
| 75 | 77 |
| 76 // Closes the browser and IPC testing server. | 78 // Closes the browser and IPC testing server. |
| 77 void CloseBrowserAndServer(); | 79 void CloseBrowserAndServer(); |
| 78 | 80 |
| 79 // Launches the browser with the given command line. | 81 // Launches the browser with the given command line. |
| 80 // TODO(phajdan.jr): Make LaunchBrowser private. | 82 // TODO(phajdan.jr): Make LaunchBrowser private. |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 // responsible for deleting the returned object. Returns NULL if there is an | 372 // responsible for deleting the returned object. Returns NULL if there is an |
| 371 // error. | 373 // error. |
| 372 base::DictionaryValue* GetDefaultProfilePreferences(); | 374 base::DictionaryValue* GetDefaultProfilePreferences(); |
| 373 | 375 |
| 374 // Waits for the test case to finish. | 376 // Waits for the test case to finish. |
| 375 // ASSERTS if there are test failures. | 377 // ASSERTS if there are test failures. |
| 376 void WaitForFinish(const std::string &name, | 378 void WaitForFinish(const std::string &name, |
| 377 const std::string &id, const GURL &url, | 379 const std::string &id, const GURL &url, |
| 378 const std::string& test_complete_cookie, | 380 const std::string& test_complete_cookie, |
| 379 const std::string& expected_cookie_value, | 381 const std::string& expected_cookie_value, |
| 380 const int wait_time); | 382 const base::TimeDelta wait_time); |
| 381 | 383 |
| 382 // Wrapper around EvictFileFromSystemCache to retry 10 times in case of | 384 // Wrapper around EvictFileFromSystemCache to retry 10 times in case of |
| 383 // error. | 385 // error. |
| 384 // Apparently needed for Windows buildbots (to workaround an error when | 386 // Apparently needed for Windows buildbots (to workaround an error when |
| 385 // file is in use). | 387 // file is in use). |
| 386 // TODO(phajdan.jr): Move to test_file_util if we need it in more places. | 388 // TODO(phajdan.jr): Move to test_file_util if we need it in more places. |
| 387 bool EvictFileFromSystemCacheWrapper(const FilePath& path); | 389 bool EvictFileFromSystemCacheWrapper(const FilePath& path); |
| 388 | 390 |
| 389 // Polls the tab for a JavaScript condition and returns once one of the | 391 // Polls the tab for a JavaScript condition and returns once one of the |
| 390 // following conditions hold true: | 392 // following conditions hold true: |
| 391 // - The JavaScript condition evaluates to true (return true). | 393 // - The JavaScript condition evaluates to true (return true). |
| 392 // - The browser process died (return false). | 394 // - The browser process died (return false). |
| 393 // - The timeout value has been exceeded (return false). | 395 // - The timeout value has been exceeded (return false). |
| 394 // | 396 // |
| 395 // The JavaScript expression is executed in the context of the frame that | 397 // The JavaScript expression is executed in the context of the frame that |
| 396 // matches the provided xpath. | 398 // matches the provided xpath. |
| 397 bool WaitUntilJavaScriptCondition(TabProxy* tab, | 399 bool WaitUntilJavaScriptCondition(TabProxy* tab, |
| 398 const std::wstring& frame_xpath, | 400 const std::wstring& frame_xpath, |
| 399 const std::wstring& jscript, | 401 const std::wstring& jscript, |
| 400 int timeout_ms); | 402 base::TimeDelta timeout); |
| 401 | 403 |
| 402 // Polls the tab for the cookie_name cookie and returns once one of the | 404 // Polls the tab for the cookie_name cookie and returns once one of the |
| 403 // following conditions hold true: | 405 // following conditions hold true: |
| 404 // - The cookie is of expected_value. | 406 // - The cookie is of expected_value. |
| 405 // - The browser process died. | 407 // - The browser process died. |
| 406 // - The timeout value has been exceeded. | 408 // - The timeout value has been exceeded. |
| 407 bool WaitUntilCookieValue(TabProxy* tab, const GURL& url, | 409 bool WaitUntilCookieValue(TabProxy* tab, const GURL& url, |
| 408 const char* cookie_name, | 410 const char* cookie_name, |
| 409 int timeout_ms, | 411 base::TimeDelta timeout, |
| 410 const char* expected_value); | 412 const char* expected_value); |
| 411 | 413 |
| 412 // Polls the tab for the cookie_name cookie and returns once one of the | 414 // Polls the tab for the cookie_name cookie and returns once one of the |
| 413 // following conditions hold true: | 415 // following conditions hold true: |
| 414 // - The cookie is set to any value. | 416 // - The cookie is set to any value. |
| 415 // - The browser process died. | 417 // - The browser process died. |
| 416 // - The timeout value has been exceeded. | 418 // - The timeout value has been exceeded. |
| 417 std::string WaitUntilCookieNonEmpty(TabProxy* tab, | 419 std::string WaitUntilCookieNonEmpty(TabProxy* tab, |
| 418 const GURL& url, | 420 const GURL& url, |
| 419 const char* cookie_name, | 421 const char* cookie_name, |
| 420 int timeout_ms); | 422 base::TimeDelta timeout); |
| 421 | 423 |
| 422 // Waits until the Find window has become fully visible (if |wait_for_open| is | 424 // Waits until the Find window has become fully visible (if |wait_for_open| is |
| 423 // true) or fully hidden (if |wait_for_open| is false). This function can time | 425 // true) or fully hidden (if |wait_for_open| is false). This function can time |
| 424 // out (return false) if the window doesn't appear within a specific time. | 426 // out (return false) if the window doesn't appear within a specific time. |
| 425 bool WaitForFindWindowVisibilityChange(BrowserProxy* browser, | 427 bool WaitForFindWindowVisibilityChange(BrowserProxy* browser, |
| 426 bool wait_for_open); | 428 bool wait_for_open); |
| 427 | 429 |
| 428 // Terminates the browser, simulates end of session. | 430 // Terminates the browser, simulates end of session. |
| 429 void TerminateBrowser(); | 431 void TerminateBrowser(); |
| 430 | 432 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 444 #ifdef UNIT_TEST | 446 #ifdef UNIT_TEST |
| 445 std::ostream& operator<<(std::ostream& out, const std::wstring& wstr); | 447 std::ostream& operator<<(std::ostream& out, const std::wstring& wstr); |
| 446 | 448 |
| 447 template<typename T> | 449 template<typename T> |
| 448 std::ostream& operator<<(std::ostream& out, const ::scoped_ptr<T>& ptr) { | 450 std::ostream& operator<<(std::ostream& out, const ::scoped_ptr<T>& ptr) { |
| 449 return out << ptr.get(); | 451 return out << ptr.get(); |
| 450 } | 452 } |
| 451 #endif // UNIT_TEST | 453 #endif // UNIT_TEST |
| 452 | 454 |
| 453 #endif // CHROME_TEST_UI_UI_TEST_H_ | 455 #endif // CHROME_TEST_UI_UI_TEST_H_ |
| OLD | NEW |