diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-08 07:15:16 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-08 07:15:16 +0000 |
commit | 36589350415ced89e716015330fe210a8fcfd180 (patch) | |
tree | 95673c9f4a7aebe659a3500902c7480ecbe10d2b /chrome/browser | |
parent | 93b86a850b7b1b3f46a7c4fc4521fefa8ca56e8d (diff) | |
download | chromium_src-36589350415ced89e716015330fe210a8fcfd180.zip chromium_src-36589350415ced89e716015330fe210a8fcfd180.tar.gz chromium_src-36589350415ced89e716015330fe210a8fcfd180.tar.bz2 |
[GTTF] Tests cleanup:
- use timeouts correctly
- use more automation methods to make test code more clear
- use more reliable ways of waiting
- remove unnecessary automation calls
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/1553016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43932 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/browser_uitest.cc | 6 | ||||
-rw-r--r-- | chrome/browser/dom_ui/bookmarks_ui_uitest.cc | 11 | ||||
-rw-r--r-- | chrome/browser/dom_ui/new_tab_ui_uitest.cc | 17 | ||||
-rw-r--r-- | chrome/browser/download/download_uitest.cc | 38 | ||||
-rw-r--r-- | chrome/browser/extensions/browser_action_apitest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_uitest.cc | 2 |
6 files changed, 22 insertions, 54 deletions
diff --git a/chrome/browser/browser_uitest.cc b/chrome/browser/browser_uitest.cc index 64634a0..08a6a9c4 100644 --- a/chrome/browser/browser_uitest.cc +++ b/chrome/browser/browser_uitest.cc @@ -111,7 +111,7 @@ TEST_F(BrowserTest, NullOpenerRedirectForksProcess) { // Make sure that a new tab has been created and that we have a new renderer // process for it. ASSERT_TRUE(tab->NavigateToURLAsync(fork_url)); - PlatformThread::Sleep(action_timeout_ms()); + PlatformThread::Sleep(sleep_timeout_ms()); ASSERT_EQ(orig_process_count + 1, GetBrowserProcessCount()); int new_tab_count = -1; ASSERT_TRUE(window->GetTabCount(&new_tab_count)); @@ -162,7 +162,7 @@ TEST_F(BrowserTest, MAYBE_OtherRedirectsDontForkProcess) { // Make sure that a new tab but not new process has been created. ASSERT_TRUE(tab->NavigateToURLAsync(dont_fork_url)); - PlatformThread::Sleep(action_timeout_ms()); + PlatformThread::Sleep(sleep_timeout_ms()); ASSERT_EQ(orig_process_count, GetBrowserProcessCount()); int new_tab_count = -1; ASSERT_TRUE(window->GetTabCount(&new_tab_count)); @@ -174,7 +174,7 @@ TEST_F(BrowserTest, MAYBE_OtherRedirectsDontForkProcess) { // Make sure that no new process has been created. ASSERT_TRUE(tab->NavigateToURLAsync(dont_fork_url2)); - PlatformThread::Sleep(action_timeout_ms()); + PlatformThread::Sleep(sleep_timeout_ms()); ASSERT_EQ(orig_process_count, GetBrowserProcessCount()); } diff --git a/chrome/browser/dom_ui/bookmarks_ui_uitest.cc b/chrome/browser/dom_ui/bookmarks_ui_uitest.cc index 77f7f38..3e3ac33 100644 --- a/chrome/browser/dom_ui/bookmarks_ui_uitest.cc +++ b/chrome/browser/dom_ui/bookmarks_ui_uitest.cc @@ -21,7 +21,7 @@ class BookmarksUITest : public UITest { L"domAutomationController.send(" L" location.protocol == 'chrome-extension:' && " L" document.readyState == 'complete')", - UITest::test_timeout_ms()); + test_timeout_ms()); } scoped_refptr<TabProxy> GetBookmarksUITab() { @@ -110,8 +110,7 @@ TEST_F(BookmarksUITest, CommandAgainGoesBackToBookmarksTab) { // Bring up the bookmarks manager tab. ASSERT_TRUE(browser->RunCommand(IDC_SHOW_BOOKMARK_MANAGER)); - ASSERT_TRUE(browser->WaitForTabToBecomeActive(1, - UITest::action_max_timeout_ms())); + ASSERT_TRUE(browser->WaitForTabToBecomeActive(1, action_max_timeout_ms())); ASSERT_TRUE(browser->GetTabCount(&tab_count)); ASSERT_EQ(2, tab_count); @@ -122,13 +121,11 @@ TEST_F(BookmarksUITest, CommandAgainGoesBackToBookmarksTab) { // Switch to first tab and run command again. ASSERT_TRUE(browser->ActivateTab(0)); - ASSERT_TRUE(browser->WaitForTabToBecomeActive(0, - UITest::action_max_timeout_ms())); + ASSERT_TRUE(browser->WaitForTabToBecomeActive(0, action_max_timeout_ms())); ASSERT_TRUE(browser->RunCommand(IDC_SHOW_BOOKMARK_MANAGER)); // Ensure the bookmarks ui tab is active. - ASSERT_TRUE(browser->WaitForTabToBecomeActive(1, - UITest::action_max_timeout_ms())); + ASSERT_TRUE(browser->WaitForTabToBecomeActive(1, action_max_timeout_ms())); ASSERT_TRUE(browser->GetTabCount(&tab_count)); ASSERT_EQ(2, tab_count); } diff --git a/chrome/browser/dom_ui/new_tab_ui_uitest.cc b/chrome/browser/dom_ui/new_tab_ui_uitest.cc index 7d7531e..0b8f380 100644 --- a/chrome/browser/dom_ui/new_tab_ui_uitest.cc +++ b/chrome/browser/dom_ui/new_tab_ui_uitest.cc @@ -43,19 +43,10 @@ TEST_F(NewTabUITest, NTPHasThumbnails) { scoped_refptr<TabProxy> tab = window->GetActiveTab(); ASSERT_TRUE(tab.get()); - int filler_thumbnails_count = -1; - int wait_time = action_max_timeout_ms(); - while (wait_time > 0) { - ASSERT_TRUE(tab->ExecuteAndExtractInt(L"", - L"window.domAutomationController.send(" - L"document.getElementsByClassName('filler').length)", - &filler_thumbnails_count)); - if (filler_thumbnails_count == 0) - break; - PlatformThread::Sleep(sleep_timeout_ms()); - wait_time -= sleep_timeout_ms(); - } - EXPECT_EQ(0, filler_thumbnails_count); + ASSERT_TRUE(WaitUntilJavaScriptCondition(tab, L"", + L"window.domAutomationController.send(" + L"document.getElementsByClassName('filler').length == 0)", + action_max_timeout_ms())); } TEST_F(NewTabUITest, ChromeInternalLoadsNTP) { diff --git a/chrome/browser/download/download_uitest.cc b/chrome/browser/download/download_uitest.cc index 2649364..40a5af27 100644 --- a/chrome/browser/download/download_uitest.cc +++ b/chrome/browser/download/download_uitest.cc @@ -56,11 +56,10 @@ class DownloadTest : public UITest { protected: DownloadTest() : UITest() {} - void CleanUpDownload(const FilePath& client_filename, + void CheckDownload(const FilePath& client_filename, const FilePath& server_filename) { // Find the path on the client. FilePath file_on_client = download_prefix_.Append(client_filename); - EXPECT_TRUE(file_util::PathExists(file_on_client)); // Find the path on the server. FilePath file_on_server; @@ -69,9 +68,8 @@ class DownloadTest : public UITest { file_on_server = file_on_server.Append(server_filename); ASSERT_TRUE(file_util::PathExists(file_on_server)); - // Check that we downloaded the file correctly. - EXPECT_TRUE(file_util::ContentsEqual(file_on_server, - file_on_client)); + WaitForGeneratedFileAndCheck(file_on_client, file_on_server, + true, true, false); #if defined(OS_WIN) // Check if the Zone Identifier is correctly set. @@ -83,8 +81,8 @@ class DownloadTest : public UITest { EXPECT_TRUE(file_util::Delete(file_on_client, false)); } - void CleanUpDownload(const FilePath& file) { - CleanUpDownload(file, file); + void CheckDownload(const FilePath& file) { + CheckDownload(file, file); } virtual void SetUp() { @@ -185,10 +183,7 @@ TEST_F(DownloadTest, FLAKY_DownloadMimeType) { // No new tabs created, downloads appear in the current tab's download shelf. WaitUntilTabCount(1); - // Wait until the file is downloaded. - PlatformThread::Sleep(action_timeout_ms()); - - CleanUpDownload(file); + CheckDownload(file); scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); ASSERT_TRUE(browser.get()); @@ -206,13 +201,11 @@ TEST_F(DownloadTest, FLAKY_NoDownload) { if (file_util::PathExists(file_path)) ASSERT_TRUE(file_util::Delete(file_path, false)); - EXPECT_EQ(1, GetTabCount()); - NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file)); WaitUntilTabCount(1); // Wait to see if the file will be downloaded. - PlatformThread::Sleep(action_timeout_ms()); + PlatformThread::Sleep(sleep_timeout_ms()); EXPECT_FALSE(file_util::PathExists(file_path)); if (file_util::PathExists(file_path)) @@ -232,15 +225,10 @@ TEST_F(DownloadTest, FLAKY_ContentDisposition) { FilePath file(FILE_PATH_LITERAL("download-test3.gif")); FilePath download_file(FILE_PATH_LITERAL("download-test3-attachment.gif")); - EXPECT_EQ(1, GetTabCount()); - NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file)); WaitUntilTabCount(1); - // Wait until the file is downloaded. - PlatformThread::Sleep(action_timeout_ms()); - - CleanUpDownload(download_file, file); + CheckDownload(download_file, file); // Ensure the download shelf is visible on the window. scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); @@ -258,15 +246,10 @@ TEST_F(DownloadTest, FLAKY_PerWindowShelf) { FilePath file(FILE_PATH_LITERAL("download-test3.gif")); FilePath download_file(FILE_PATH_LITERAL("download-test3-attachment.gif")); - EXPECT_EQ(1, GetTabCount()); - NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file)); WaitUntilTabCount(1); - // Wait until the file is downloaded. - PlatformThread::Sleep(action_timeout_ms()); - - CleanUpDownload(download_file, file); + CheckDownload(download_file, file); // Ensure the download shelf is visible on the window. scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); @@ -348,7 +331,6 @@ TEST_F(DownloadTest, FLAKY_IncognitoDownload) { scoped_refptr<TabProxy> tab(incognito->GetTab(0)); ASSERT_TRUE(tab.get()); ASSERT_TRUE(tab->NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file))); - PlatformThread::Sleep(action_timeout_ms()); // Verify that the download shelf is showing for the Incognito window. EXPECT_TRUE(WaitForDownloadShelfVisible(incognito.get())); @@ -362,7 +344,7 @@ TEST_F(DownloadTest, FLAKY_IncognitoDownload) { EXPECT_TRUE(browser->IsShelfVisible(&is_shelf_visible)); EXPECT_FALSE(is_shelf_visible); - CleanUpDownload(file); + CheckDownload(file); } } // namespace diff --git a/chrome/browser/extensions/browser_action_apitest.cc b/chrome/browser/extensions/browser_action_apitest.cc index b46006f..dbdf6c9 100644 --- a/chrome/browser/extensions/browser_action_apitest.cc +++ b/chrome/browser/extensions/browser_action_apitest.cc @@ -34,8 +34,6 @@ #define MAYBE_BrowserActionAddPopup BrowserActionAddPopup #endif -static const int kTimeoutMs = 60 * 1000; // 1 minute - class BrowserActionApiTest : public ExtensionApiTest { public: BrowserActionApiTest() {} diff --git a/chrome/browser/extensions/extension_uitest.cc b/chrome/browser/extensions/extension_uitest.cc index ebfef1f..bec705a 100644 --- a/chrome/browser/extensions/extension_uitest.cc +++ b/chrome/browser/extensions/extension_uitest.cc @@ -145,7 +145,7 @@ TEST_F(ExtensionTestSimpleApiCall, RunTest) { GURL("chrome-extension://pmgpglkggjdpkpghhdmbdhababjpcohk/test.html"), GURL(""))); - loop_.RunFor(2 * action_max_timeout_ms()); + loop_.RunFor(action_max_timeout_ms()); ASSERT_FALSE(message_received.empty()); scoped_ptr<Value> message_value(base::JSONReader::Read(message_received, |