diff options
author | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-07 22:31:47 +0000 |
---|---|---|
committer | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-07 22:31:47 +0000 |
commit | 5c943180e410b2a4e76f93e1612985cdab407e8c (patch) | |
tree | 6aef67f089f4ecbd73fbdac524f7627ecfb6b6a2 /chrome | |
parent | 23512f4ba83ab011aac513972290aa30b26785cd (diff) | |
download | chromium_src-5c943180e410b2a4e76f93e1612985cdab407e8c.zip chromium_src-5c943180e410b2a4e76f93e1612985cdab407e8c.tar.gz chromium_src-5c943180e410b2a4e76f93e1612985cdab407e8c.tar.bz2 |
Sprinkle some defensiveness into the UI tests so that they don't explode if the proxy doesn't respond (e.g., due to a timeout).
BUG=none
TEST=Hopefully the Mac valgrind bots will more reliably run all their tests (although there are likely more issues like this lurking).
Review URL: http://codereview.chromium.org/149281
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20096 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser_uitest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/crash_recovery_uitest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/download/download_uitest.cc | 6 | ||||
-rw-r--r-- | chrome/browser/download/save_page_uitest.cc | 5 | ||||
-rw-r--r-- | chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc | 7 | ||||
-rw-r--r-- | chrome/browser/sessions/session_restore_uitest.cc | 13 | ||||
-rw-r--r-- | chrome/browser/tab_contents/view_source_uitest.cc | 1 | ||||
-rw-r--r-- | chrome/browser/tab_restore_uitest.cc | 20 | ||||
-rw-r--r-- | chrome/browser/unload_uitest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/views/find_bar_win_uitest.cc | 3 | ||||
-rw-r--r-- | chrome/test/automated_ui_tests/automated_ui_test_base.cc | 5 | ||||
-rw-r--r-- | chrome/test/automated_ui_tests/automated_ui_test_test.cc | 34 | ||||
-rw-r--r-- | chrome/test/page_cycler/page_cycler_test.cc | 1 | ||||
-rw-r--r-- | chrome/test/ui/dom_checker_uitest.cc | 1 | ||||
-rw-r--r-- | chrome/test/ui/sunspider_uitest.cc | 1 | ||||
-rw-r--r-- | chrome/test/ui/ui_test.cc | 21 | ||||
-rw-r--r-- | chrome/worker/worker_uitest.cc | 4 |
17 files changed, 98 insertions, 34 deletions
diff --git a/chrome/browser/browser_uitest.cc b/chrome/browser/browser_uitest.cc index 108273e..3b14290 100644 --- a/chrome/browser/browser_uitest.cc +++ b/chrome/browser/browser_uitest.cc @@ -198,6 +198,7 @@ TEST_F(BrowserTest, DISABLED_JavascriptAlertActivatesTab) { int javascript_tab_index; ASSERT_TRUE(window->GetActiveTabIndex(&javascript_tab_index)); scoped_refptr<TabProxy> javascript_tab = window->GetActiveTab(); + ASSERT_TRUE(javascript_tab.get()); // Switch back to the starting tab, then send the second tab a javascript // alert, which should force it to become active. ASSERT_TRUE(window->ActivateTab(start_index)); @@ -226,6 +227,7 @@ TEST_F(BrowserTest, NullOpenerRedirectForksProcess) { FilePath test_file(test_data_directory_); scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); scoped_refptr<TabProxy> tab(window->GetActiveTab()); + ASSERT_TRUE(tab.get()); // Start with a file:// url test_file = test_file.AppendASCII("title2.html"); @@ -268,6 +270,7 @@ TEST_F(BrowserTest, OtherRedirectsDontForkProcess) { FilePath test_file(test_data_directory_); scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); scoped_refptr<TabProxy> tab(window->GetActiveTab()); + ASSERT_TRUE(tab.get()); // Start with a file:// url test_file = test_file.AppendASCII("title2.html"); @@ -342,6 +345,7 @@ TEST_F(ShowModalDialogTest, BasicTest) { scoped_refptr<BrowserProxy> browser = automation()->GetBrowserWindow(1); scoped_refptr<TabProxy> tab = browser->GetActiveTab(); + ASSERT_TRUE(tab.get()); std::wstring title; ASSERT_TRUE(tab->GetTabTitle(&title)); diff --git a/chrome/browser/crash_recovery_uitest.cc b/chrome/browser/crash_recovery_uitest.cc index 42b2b1a..e016156 100644 --- a/chrome/browser/crash_recovery_uitest.cc +++ b/chrome/browser/crash_recovery_uitest.cc @@ -28,6 +28,7 @@ TEST_F(CrashRecoveryUITest, Reload) { std::wstring title1 = GetActiveTabTitle(); scoped_refptr<TabProxy> tab(GetActiveTab()); + ASSERT_TRUE(tab.get()); // Cause the renderer to crash. // TODO: Need to port crash_service.exe. @@ -65,6 +66,7 @@ TEST_F(CrashRecoveryUITest, LoadInNewTab) { EXPECT_EQ(title, GetActiveTabTitle()); scoped_refptr<TabProxy> tab(GetActiveTab()); + ASSERT_TRUE(tab.get()); // Cause the renderer to crash. // TODO: Need to port crash_service.exe. diff --git a/chrome/browser/download/download_uitest.cc b/chrome/browser/download/download_uitest.cc index c35bafc..8f588fc 100644 --- a/chrome/browser/download/download_uitest.cc +++ b/chrome/browser/download/download_uitest.cc @@ -313,7 +313,7 @@ TEST_F(DownloadTest, MAYBE_IncognitoDownload) { // count and shelf visibility. scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); int window_count = 0; - automation()->GetBrowserWindowCount(&window_count); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); ASSERT_EQ(1, window_count); EXPECT_EQ(1, GetTabCount()); bool is_shelf_visible; @@ -324,7 +324,7 @@ TEST_F(DownloadTest, MAYBE_IncognitoDownload) { ASSERT_TRUE(browser->RunCommand(IDC_NEW_INCOGNITO_WINDOW)); scoped_refptr<BrowserProxy> incognito(automation()->GetBrowserWindow(1)); scoped_refptr<TabProxy> tab(incognito->GetTab(0)); - automation()->GetBrowserWindowCount(&window_count); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); ASSERT_EQ(2, window_count); // Download something. @@ -339,7 +339,7 @@ TEST_F(DownloadTest, MAYBE_IncognitoDownload) { // Close the Incognito window and don't crash. ASSERT_TRUE(incognito->RunCommand(IDC_CLOSE_WINDOW)); - automation()->GetBrowserWindowCount(&window_count); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); ASSERT_EQ(1, window_count); // Verify that the regular window does not have a download shelf. diff --git a/chrome/browser/download/save_page_uitest.cc b/chrome/browser/download/save_page_uitest.cc index cbd10c1..fbef625 100644 --- a/chrome/browser/download/save_page_uitest.cc +++ b/chrome/browser/download/save_page_uitest.cc @@ -103,6 +103,7 @@ TEST_F(SavePageTest, MAYBE_SaveHTMLOnly) { GURL url = URLRequestMockHTTPJob::GetMockUrl( UTF8ToWide(std::string(kTestDir) + "/" + file_name)); scoped_refptr<TabProxy> tab(GetActiveTab()); + ASSERT_TRUE(tab.get()); ASSERT_TRUE(tab->NavigateToURL(url)); WaitUntilTabCount(1); @@ -125,6 +126,7 @@ TEST_F(SavePageTest, MAYBE_SaveCompleteHTML) { GURL url = URLRequestMockHTTPJob::GetMockUrl( UTF8ToWide(std::string(kTestDir) + "/" + file_name)); scoped_refptr<TabProxy> tab(GetActiveTab()); + ASSERT_TRUE(tab.get()); ASSERT_TRUE(tab->NavigateToURL(url)); WaitUntilTabCount(1); @@ -148,6 +150,7 @@ TEST_F(SavePageTest, NoSave) { FilePath dir = save_dir_.AppendASCII("c_files"); scoped_refptr<TabProxy> tab(GetActiveTab()); + ASSERT_TRUE(tab.get()); ASSERT_TRUE(tab->NavigateToURL(GURL("about:blank"))); WaitUntilTabCount(1); @@ -169,6 +172,7 @@ TEST_F(SavePageTest, MAYBE_FilenameFromPageTitle) { GURL url = URLRequestMockHTTPJob::GetMockUrl( UTF8ToWide(std::string(kTestDir) + "/" + file_name)); scoped_refptr<TabProxy> tab(GetActiveTab()); + ASSERT_TRUE(tab.get()); ASSERT_TRUE(tab->NavigateToURL(url)); WaitUntilTabCount(1); @@ -201,6 +205,7 @@ TEST_F(SavePageTest, CleanFilenameFromPageTitle) { GURL url = URLRequestMockHTTPJob::GetMockUrl( UTF8ToWide(std::string(kTestDir) + "/" + file_name)); scoped_refptr<TabProxy> tab(GetActiveTab()); + ASSERT_TRUE(tab.get()); ASSERT_TRUE(tab->NavigateToURL(url)); WaitUntilTabCount(1); diff --git a/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc b/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc index 99eff3c..3cd1f88 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc @@ -91,6 +91,7 @@ TEST_F(ResourceDispatcherTest, SyncXMLHttpRequest) { scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); EXPECT_TRUE(browser_proxy.get()); scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); + ASSERT_TRUE(tab.get()); tab->NavigateToURL(server->TestServerPageW( L"files/sync_xmlhttprequest.html")); @@ -111,6 +112,7 @@ TEST_F(ResourceDispatcherTest, SyncXMLHttpRequest_Disallowed) { scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); EXPECT_TRUE(browser_proxy.get()); scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); + ASSERT_TRUE(tab.get()); tab->NavigateToURL(server->TestServerPageW( L"files/sync_xmlhttprequest_disallowed.html")); @@ -134,6 +136,7 @@ TEST_F(ResourceDispatcherTest, SyncXMLHttpRequest_DuringUnload) { scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); EXPECT_TRUE(browser_proxy.get()); scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); + ASSERT_TRUE(tab.get()); tab->NavigateToURL( server->TestServerPageW(L"files/sync_xmlhttprequest_during_unload.html")); @@ -171,6 +174,7 @@ TEST_F(ResourceDispatcherTest, CrossSiteOnunloadCookie) { scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); EXPECT_TRUE(browser_proxy.get()); scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); + ASSERT_TRUE(tab.get()); GURL url(server->TestServerPageW(L"files/onunload_cookie.html")); tab->NavigateToURL(url); @@ -209,6 +213,7 @@ TEST_F(ResourceDispatcherTest, CrossSiteAfterCrash) { scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); EXPECT_TRUE(browser_proxy.get()); scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); + ASSERT_TRUE(tab.get()); // Cause the renderer to crash. // TODO(albertb): We need to disable this on Linux since @@ -233,6 +238,7 @@ TEST_F(ResourceDispatcherTest, CrossSiteNavigationNonBuffered) { scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); EXPECT_TRUE(browser_proxy.get()); scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); + ASSERT_TRUE(tab.get()); // Start with an HTTP page. CheckTitleTest(L"content-sniffer-test0.html", @@ -262,6 +268,7 @@ TEST_F(ResourceDispatcherTest, CrossSiteNavigationErrorPage) { scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); EXPECT_TRUE(browser_proxy.get()); scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); + ASSERT_TRUE(tab.get()); GURL url(server->TestServerPageW(L"files/onunload_cookie.html")); tab->NavigateToURL(url); diff --git a/chrome/browser/sessions/session_restore_uitest.cc b/chrome/browser/sessions/session_restore_uitest.cc index 6b4ea30..e1de219 100644 --- a/chrome/browser/sessions/session_restore_uitest.cc +++ b/chrome/browser/sessions/session_restore_uitest.cc @@ -45,7 +45,7 @@ class SessionRestoreUITest : public UITest { ASSERT_TRUE(browser_proxy.get()); ASSERT_TRUE(browser_proxy->RunCommand(IDC_CLOSE_WINDOW)); int window_count; - automation()->GetBrowserWindowCount(&window_count); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); ASSERT_EQ(initial_count - 1, window_count); } @@ -71,6 +71,7 @@ class SessionRestoreUITest : public UITest { ASSERT_EQ(0, active_tab_index); scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetActiveTab()); + ASSERT_TRUE(tab_proxy.get()); ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms())); ASSERT_TRUE(tab_proxy->GetCurrentURL(url)); @@ -110,6 +111,7 @@ TEST_F(SessionRestoreUITest, RestoresForwardAndBackwardNavs) { NavigateToURL(url3_); scoped_refptr<TabProxy> active_tab(GetActiveTab()); + ASSERT_TRUE(active_tab.get()); ASSERT_TRUE(active_tab->GoBack()); QuitBrowserAndRestore(1); @@ -148,6 +150,7 @@ TEST_F(SessionRestoreUITest, RestoresCrossSiteForwardAndBackwardNavs) { NavigateToURL(url2_); scoped_refptr<TabProxy> active_tab(GetActiveTab()); + ASSERT_TRUE(active_tab.get()); ASSERT_TRUE(active_tab->GoBack()); QuitBrowserAndRestore(1); @@ -199,7 +202,6 @@ TEST_F(SessionRestoreUITest, TwoTabsSecondSelected) { ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count) && window_count == 1); browser_proxy = automation()->GetBrowserWindow(0); - scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetTab(0)); int tab_count; ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count)); @@ -209,13 +211,15 @@ TEST_F(SessionRestoreUITest, TwoTabsSecondSelected) { ASSERT_TRUE(browser_proxy->GetActiveTabIndex(&active_tab_index)); ASSERT_EQ(1, active_tab_index); - tab_proxy = browser_proxy->GetActiveTab(); + scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetActiveTab()); + ASSERT_TRUE(tab_proxy.get()); ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms())); ASSERT_TRUE(GetActiveTabURL() == url2_); ASSERT_TRUE(browser_proxy->ActivateTab(0)); tab_proxy = browser_proxy->GetActiveTab(); + ASSERT_TRUE(tab_proxy.get()); ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms())); ASSERT_TRUE(GetActiveTabURL() == url1_); @@ -236,6 +240,7 @@ TEST_F(SessionRestoreUITest, ClosedTabStaysClosed) { browser_proxy->AppendTab(url2_); scoped_refptr<TabProxy> active_tab(browser_proxy->GetActiveTab()); + ASSERT_TRUE(active_tab.get()); active_tab->Close(true); QuitBrowserAndRestore(1); @@ -263,7 +268,7 @@ TEST_F(SessionRestoreUITest, DontRestoreWhileIncognito) { // Create an off the record window. ASSERT_TRUE(browser_proxy->RunCommand(IDC_NEW_INCOGNITO_WINDOW)); int window_count; - automation()->GetBrowserWindowCount(&window_count); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); ASSERT_EQ(2, window_count); // Close the first window. diff --git a/chrome/browser/tab_contents/view_source_uitest.cc b/chrome/browser/tab_contents/view_source_uitest.cc index dd01e49..04499ff 100644 --- a/chrome/browser/tab_contents/view_source_uitest.cc +++ b/chrome/browser/tab_contents/view_source_uitest.cc @@ -46,6 +46,7 @@ TEST_F(ViewSourceTest, DoesBrowserRenderInViewSource) { GURL url = server->TestServerPageW(test_html_); url = GURL("view-source:" + url.spec()); scoped_refptr<TabProxy> tab(GetActiveTab()); + ASSERT_TRUE(tab.get()); tab->NavigateToURL(url); PlatformThread::Sleep(sleep_timeout_ms()); diff --git a/chrome/browser/tab_restore_uitest.cc b/chrome/browser/tab_restore_uitest.cc index 0cb8f829..679f910 100644 --- a/chrome/browser/tab_restore_uitest.cc +++ b/chrome/browser/tab_restore_uitest.cc @@ -81,6 +81,7 @@ class TabRestoreUITest : public UITest { ASSERT_GT(tab_count, expected_tabstrip_index); scoped_refptr<TabProxy> restored_tab_proxy( browser_proxy->GetTab(expected_tabstrip_index)); + ASSERT_TRUE(restored_tab_proxy.get()); // Wait for the restored tab to finish loading. ASSERT_TRUE(restored_tab_proxy->WaitForTabToBeRestored( action_max_timeout_ms())); @@ -149,6 +150,7 @@ TEST_F(TabRestoreUITest, Basic) { int closed_tab_index = tab_count - 1; scoped_refptr<TabProxy> new_tab(browser_proxy->GetTab(closed_tab_index)); + ASSERT_TRUE(new_tab.get()); // Make sure we're at url. new_tab->NavigateToURL(url1_); // Close the tab. @@ -178,6 +180,7 @@ TEST_F(TabRestoreUITest, MiddleTab) { // Close one in the middle int closed_tab_index = starting_tab_count + 1; scoped_refptr<TabProxy> new_tab(browser_proxy->GetTab(closed_tab_index)); + ASSERT_TRUE(new_tab.get()); // Make sure we're at url. new_tab->NavigateToURL(url1_); // Close the tab. @@ -213,6 +216,7 @@ TEST_F(TabRestoreUITest, DISABLED_RestoreToDifferentWindow) { // Close one in the middle int closed_tab_index = starting_tab_count + 1; scoped_refptr<TabProxy> new_tab(browser_proxy->GetTab(closed_tab_index)); + ASSERT_TRUE(new_tab.get()); // Make sure we're at url. new_tab->NavigateToURL(url1_); // Close the tab. @@ -252,12 +256,14 @@ TEST_F(TabRestoreUITest, MAYBE_BasicRestoreFromClosedWindow) { // Close tabs until we only have one open. while (tab_count > 1) { scoped_refptr<TabProxy> tab_to_close(browser_proxy->GetTab(0)); + ASSERT_TRUE(tab_to_close.get()); tab_to_close->Close(true); ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count)); } // Navigate to url1 then url2. scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetTab(0)); + ASSERT_TRUE(tab_proxy.get()); tab_proxy->NavigateToURL(url1_); tab_proxy->NavigateToURL(url2_); @@ -283,6 +289,7 @@ TEST_F(TabRestoreUITest, MAYBE_BasicRestoreFromClosedWindow) { browser_proxy = automation()->GetBrowserWindow(1); CheckActiveWindow(browser_proxy.get()); tab_proxy = browser_proxy->GetActiveTab(); + ASSERT_TRUE(tab_proxy.get()); // And make sure the URLs matches. EXPECT_EQ(url2_, GetActiveTabURL(1)); EXPECT_TRUE(tab_proxy->GoBack()); @@ -306,6 +313,7 @@ TEST_F(TabRestoreUITest, DISABLED_DontLoadRestoredTab) { // Close one of them. scoped_refptr<TabProxy> tab_to_close(browser_proxy->GetTab(0)); + ASSERT_TRUE(tab_to_close.get()); tab_to_close->Close(true); ASSERT_TRUE(browser_proxy->GetTabCount(¤t_tab_count)); ASSERT_EQ(current_tab_count, starting_tab_count + 1); @@ -340,6 +348,7 @@ TEST_F(TabRestoreUITest, DISABLED_RestoreWindowAndTab) { // Close one in the middle int closed_tab_index = starting_tab_count + 1; scoped_refptr<TabProxy> new_tab(browser_proxy->GetTab(closed_tab_index)); + ASSERT_TRUE(new_tab.get()); // Make sure we're at url. new_tab->NavigateToURL(url1_); // Close the tab. @@ -393,6 +402,7 @@ TEST_F(TabRestoreUITest, RestoreIntoSameWindow) { // Navigate the rightmost one to url2_ for easier identification. scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetTab(tab_count - 1)); + ASSERT_TRUE(tab_proxy.get()); tab_proxy->NavigateToURL(url2_); // Create a new browser. @@ -405,12 +415,14 @@ TEST_F(TabRestoreUITest, RestoreIntoSameWindow) { // Close all but one tab in the first browser, left to right. while (tab_count > 1) { scoped_refptr<TabProxy> tab_to_close(browser_proxy->GetTab(0)); + ASSERT_TRUE(tab_to_close.get()); tab_to_close->Close(true); ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count)); } // Close the last tab, closing the browser. tab_proxy = browser_proxy->GetTab(0); + ASSERT_TRUE(tab_proxy.get()); EXPECT_TRUE(tab_proxy->Close(true)); ASSERT_TRUE(automation()->WaitForWindowCountToBecome( 1, action_max_timeout_ms())); @@ -453,6 +465,7 @@ TEST_F(TabRestoreUITest, RestoreWithExistingSiteInstance) { ASSERT_TRUE(browser_proxy->GetTabCount(&new_tab_count)); EXPECT_EQ(++tab_count, new_tab_count); scoped_refptr<TabProxy> tab(browser_proxy->GetTab(tab_count - 1)); + ASSERT_TRUE(tab.get()); // Navigate to another same-site URL. tab->NavigateToURL(http_url2); @@ -469,6 +482,7 @@ TEST_F(TabRestoreUITest, RestoreWithExistingSiteInstance) { // Restore the closed tab. RestoreTab(0, tab_count - 1); tab = browser_proxy->GetActiveTab(); + ASSERT_TRUE(tab.get()); // And make sure the URLs match. EXPECT_EQ(http_url2, GetActiveTabURL()); @@ -497,6 +511,7 @@ TEST_F(TabRestoreUITest, RestoreCrossSiteWithExistingSiteInstance) { ASSERT_TRUE(browser_proxy->GetTabCount(&new_tab_count)); EXPECT_EQ(++tab_count, new_tab_count); scoped_refptr<TabProxy> tab(browser_proxy->GetTab(tab_count - 1)); + ASSERT_TRUE(tab.get()); // Navigate to more URLs, then a cross-site URL. tab->NavigateToURL(http_url2); @@ -515,6 +530,7 @@ TEST_F(TabRestoreUITest, RestoreCrossSiteWithExistingSiteInstance) { // Restore the closed tab. RestoreTab(0, tab_count - 1); tab = browser_proxy->GetActiveTab(); + ASSERT_TRUE(tab.get()); // And make sure the URLs match. EXPECT_EQ(url1_, GetActiveTabURL()); @@ -545,11 +561,13 @@ TEST_F(TabRestoreUITest, RestoreWindow) { ASSERT_TRUE(browser_proxy->WaitForTabCountToBecome(initial_tab_count + 1, action_max_timeout_ms())); scoped_refptr<TabProxy> new_tab(browser_proxy->GetTab(initial_tab_count)); + ASSERT_TRUE(new_tab.get()); new_tab->NavigateToURL(url1_); browser_proxy->AppendTab(url2_); ASSERT_TRUE(browser_proxy->WaitForTabCountToBecome(initial_tab_count + 2, action_max_timeout_ms())); new_tab = browser_proxy->GetTab(initial_tab_count + 1); + ASSERT_TRUE(new_tab.get()); new_tab->NavigateToURL(url2_); // Close the window. @@ -572,12 +590,14 @@ TEST_F(TabRestoreUITest, RestoreWindow) { scoped_refptr<TabProxy> restored_tab_proxy( browser_proxy->GetTab(initial_tab_count)); + ASSERT_TRUE(restored_tab_proxy.get()); ASSERT_TRUE(restored_tab_proxy->WaitForTabToBeRestored(action_timeout_ms())); GURL url; ASSERT_TRUE(restored_tab_proxy->GetCurrentURL(&url)); EXPECT_TRUE(url == url1_); restored_tab_proxy = browser_proxy->GetTab(initial_tab_count + 1); + ASSERT_TRUE(restored_tab_proxy.get()); ASSERT_TRUE(restored_tab_proxy->WaitForTabToBeRestored(action_timeout_ms())); ASSERT_TRUE(restored_tab_proxy->GetCurrentURL(&url)); EXPECT_TRUE(url == url2_); diff --git a/chrome/browser/unload_uitest.cc b/chrome/browser/unload_uitest.cc index 2015a23..1547ccb 100644 --- a/chrome/browser/unload_uitest.cc +++ b/chrome/browser/unload_uitest.cc @@ -336,7 +336,7 @@ TEST_F(UnloadTest, BrowserCloseTwoSecondBeforeUnloadAlert) { TEST_F(UnloadTest, DISABLED_BrowserCloseTabWhenOtherTabHasListener) { NavigateToDataURL(CLOSE_TAB_WHEN_OTHER_TAB_HAS_LISTENER, L"only_one_unload"); int window_count; - automation()->GetBrowserWindowCount(&window_count); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); ASSERT_EQ(2, window_count); scoped_refptr<BrowserProxy> popup_browser_proxy( @@ -346,6 +346,7 @@ TEST_F(UnloadTest, DISABLED_BrowserCloseTabWhenOtherTabHasListener) { EXPECT_TRUE(popup_browser_proxy->GetTabCount(&popup_tab_count)); EXPECT_EQ(1, popup_tab_count); scoped_refptr<TabProxy> popup_tab(popup_browser_proxy->GetActiveTab()); + ASSERT_TRUE(popup_tab.get()); std::wstring popup_title; ASSERT_TRUE(popup_tab.get() != NULL); EXPECT_TRUE(popup_tab->GetTabTitle(&popup_title)); @@ -359,6 +360,7 @@ TEST_F(UnloadTest, DISABLED_BrowserCloseTabWhenOtherTabHasListener) { EXPECT_TRUE(main_browser_proxy->GetTabCount(&main_tab_count)); EXPECT_EQ(1, main_tab_count); scoped_refptr<TabProxy> main_tab(main_browser_proxy->GetActiveTab()); + ASSERT_TRUE(main_tab.get()); std::wstring main_title; ASSERT_TRUE(main_tab.get() != NULL); EXPECT_TRUE(main_tab->GetTabTitle(&main_title)); diff --git a/chrome/browser/views/find_bar_win_uitest.cc b/chrome/browser/views/find_bar_win_uitest.cc index 5982e9e..9a4ea78 100644 --- a/chrome/browser/views/find_bar_win_uitest.cc +++ b/chrome/browser/views/find_bar_win_uitest.cc @@ -26,6 +26,7 @@ TEST_F(FindInPageControllerTest, FindMovesOnTabClose_Issue1343052) { GURL url = server->TestServerPageW(kSimplePage); scoped_refptr<TabProxy> tabA(GetActiveTab()); + ASSERT_TRUE(tabA.get()); ASSERT_TRUE(tabA->NavigateToURL(url)); WaitUntilTabCount(1); @@ -47,6 +48,7 @@ TEST_F(FindInPageControllerTest, FindMovesOnTabClose_Issue1343052) { // Open another tab (tab B). EXPECT_TRUE(browser->AppendTab(url)); scoped_refptr<TabProxy> tabB(GetActiveTab()); + ASSERT_TRUE(tabB.get()); // Close tab B. EXPECT_TRUE(tabB->Close(true)); @@ -68,6 +70,7 @@ TEST_F(FindInPageControllerTest, FindMovesOnTabClose_Issue1343052) { // Open another tab (tab C). EXPECT_TRUE(browser->AppendTab(url)); scoped_refptr<TabProxy> tabC(GetActiveTab()); + ASSERT_TRUE(tabC.get()); // Close it. EXPECT_TRUE(tabC->Close(true)); diff --git a/chrome/test/automated_ui_tests/automated_ui_test_base.cc b/chrome/test/automated_ui_tests/automated_ui_test_base.cc index 696406aa..4e842a2 100644 --- a/chrome/test/automated_ui_tests/automated_ui_test_base.cc +++ b/chrome/test/automated_ui_tests/automated_ui_test_base.cc @@ -253,7 +253,10 @@ bool AutomatedUITestBase::OpenAndActivateNewBrowserWindow( return false; } int num_browser_windows; - automation()->GetBrowserWindowCount(&num_browser_windows); + if (!automation()->GetBrowserWindowCount(&num_browser_windows)) { + LogErrorMessage("failed_to_get_browser_window_count"); + return false; + } // Get the most recently opened browser window and activate the tab // in order to activate this browser window. scoped_refptr<BrowserProxy> browser( diff --git a/chrome/test/automated_ui_tests/automated_ui_test_test.cc b/chrome/test/automated_ui_tests/automated_ui_test_test.cc index f69f542..7765778 100644 --- a/chrome/test/automated_ui_tests/automated_ui_test_test.cc +++ b/chrome/test/automated_ui_tests/automated_ui_test_test.cc @@ -77,7 +77,7 @@ TEST_F(AutomatedUITestBase, MAYBE_CloseTab) { int num_browser_windows; int tab_count; NewTab(); - automation()->GetBrowserWindowCount(&num_browser_windows); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&num_browser_windows)); ASSERT_EQ(1, num_browser_windows); active_browser()->GetTabCount(&tab_count); ASSERT_EQ(2, tab_count); @@ -87,7 +87,7 @@ TEST_F(AutomatedUITestBase, MAYBE_CloseTab) { NewTab(); active_browser()->GetTabCount(&tab_count); ASSERT_EQ(3, tab_count); - automation()->GetBrowserWindowCount(&num_browser_windows); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&num_browser_windows)); ASSERT_EQ(2, num_browser_windows); ASSERT_TRUE(CloseActiveTab()); @@ -97,12 +97,12 @@ TEST_F(AutomatedUITestBase, MAYBE_CloseTab) { active_browser()->GetTabCount(&tab_count); ASSERT_EQ(1, tab_count); num_browser_windows = 0; - automation()->GetBrowserWindowCount(&num_browser_windows); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&num_browser_windows)); ASSERT_EQ(2, num_browser_windows); // The browser window is closed by closing this tab. ASSERT_TRUE(CloseActiveTab()); - automation()->GetBrowserWindowCount(&num_browser_windows); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&num_browser_windows)); ASSERT_EQ(1, num_browser_windows); // Active_browser_ is now the first created window. active_browser()->GetTabCount(&tab_count); @@ -120,14 +120,14 @@ TEST_F(AutomatedUITestBase, MAYBE_CloseTab) { TEST_F(AutomatedUITestBase, OpenBrowserWindow) { int num_browser_windows; int tab_count; - automation()->GetBrowserWindowCount(&num_browser_windows); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&num_browser_windows)); ASSERT_EQ(1, num_browser_windows); active_browser()->GetTabCount(&tab_count); ASSERT_EQ(1, tab_count); scoped_refptr<BrowserProxy> browser_1; ASSERT_TRUE(OpenAndActivateNewBrowserWindow(&browser_1)); - automation()->GetBrowserWindowCount(&num_browser_windows); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&num_browser_windows)); ASSERT_EQ(2, num_browser_windows); active_browser()->GetTabCount(&tab_count); ASSERT_EQ(1, tab_count); @@ -139,7 +139,7 @@ TEST_F(AutomatedUITestBase, OpenBrowserWindow) { scoped_refptr<BrowserProxy> browser_2; ASSERT_TRUE(OpenAndActivateNewBrowserWindow(&browser_2)); - automation()->GetBrowserWindowCount(&num_browser_windows); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&num_browser_windows)); ASSERT_EQ(3, num_browser_windows); active_browser()->GetTabCount(&tab_count); ASSERT_EQ(1, tab_count); @@ -155,11 +155,11 @@ TEST_F(AutomatedUITestBase, OpenBrowserWindow) { bool application_closed; CloseBrowser(browser_1.get(), &application_closed); ASSERT_FALSE(application_closed); - automation()->GetBrowserWindowCount(&num_browser_windows); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&num_browser_windows)); ASSERT_EQ(2, num_browser_windows); CloseBrowser(browser_2.get(), &application_closed); ASSERT_FALSE(application_closed); - automation()->GetBrowserWindowCount(&num_browser_windows); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&num_browser_windows)); ASSERT_EQ(1, num_browser_windows); } @@ -202,21 +202,21 @@ TEST_F(AutomatedUITestBase, MAYBE_CloseBrowserWindow) { TEST_F(AutomatedUITestBase, MAYBE_IncognitoWindow) { int num_browser_windows; int num_normal_browser_windows; - automation()->GetBrowserWindowCount(&num_browser_windows); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&num_browser_windows)); ASSERT_EQ(1, num_browser_windows); automation()->GetNormalBrowserWindowCount(&num_normal_browser_windows); ASSERT_EQ(1, num_normal_browser_windows); ASSERT_TRUE(GoOffTheRecord()); ASSERT_TRUE(GoOffTheRecord()); - automation()->GetBrowserWindowCount(&num_browser_windows); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&num_browser_windows)); ASSERT_EQ(3, num_browser_windows); automation()->GetNormalBrowserWindowCount(&num_normal_browser_windows); ASSERT_EQ(1, num_normal_browser_windows); // There is only one normal window so it will not be closed. ASSERT_FALSE(CloseActiveWindow()); - automation()->GetBrowserWindowCount(&num_browser_windows); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&num_browser_windows)); ASSERT_EQ(3, num_browser_windows); automation()->GetNormalBrowserWindowCount(&num_normal_browser_windows); ASSERT_EQ(1, num_normal_browser_windows); @@ -225,7 +225,7 @@ TEST_F(AutomatedUITestBase, MAYBE_IncognitoWindow) { ASSERT_TRUE(RunCommand(IDC_CLOSE_WINDOW)); set_active_browser(automation()->GetBrowserWindow(0)); ASSERT_TRUE(RunCommand(IDC_CLOSE_WINDOW)); - automation()->GetBrowserWindowCount(&num_browser_windows); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&num_browser_windows)); ASSERT_EQ(1, num_browser_windows); } @@ -237,19 +237,19 @@ TEST_F(AutomatedUITestBase, MAYBE_OpenCloseBrowserWindowWithAccelerator) { // a unit test for those usage. ASSERT_TRUE(RunCommand(IDC_NEW_WINDOW)); int num_browser_windows; - automation()->GetBrowserWindowCount(&num_browser_windows); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&num_browser_windows)); ASSERT_EQ(2, num_browser_windows); ASSERT_TRUE(RunCommand(IDC_NEW_WINDOW)); ASSERT_TRUE(RunCommand(IDC_NEW_WINDOW)); ASSERT_TRUE(RunCommand(IDC_NEW_WINDOW)); ASSERT_TRUE(RunCommand(IDC_NEW_WINDOW)); ASSERT_TRUE(RunCommand(IDC_NEW_WINDOW)); - automation()->GetBrowserWindowCount(&num_browser_windows); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&num_browser_windows)); ASSERT_EQ(7, num_browser_windows); set_active_browser(automation()->GetBrowserWindow(0)); ASSERT_TRUE(RunCommand(IDC_CLOSE_WINDOW)); - automation()->GetBrowserWindowCount(&num_browser_windows); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&num_browser_windows)); ASSERT_EQ(6, num_browser_windows); set_active_browser(automation()->GetBrowserWindow(0)); ASSERT_TRUE(RunCommand(IDC_CLOSE_WINDOW)); @@ -261,7 +261,7 @@ TEST_F(AutomatedUITestBase, MAYBE_OpenCloseBrowserWindowWithAccelerator) { ASSERT_TRUE(RunCommand(IDC_CLOSE_WINDOW)); set_active_browser(automation()->GetBrowserWindow(0)); ASSERT_TRUE(RunCommand(IDC_CLOSE_WINDOW)); - automation()->GetBrowserWindowCount(&num_browser_windows); + ASSERT_TRUE(automation()->GetBrowserWindowCount(&num_browser_windows)); ASSERT_EQ(1, num_browser_windows); } diff --git a/chrome/test/page_cycler/page_cycler_test.cc b/chrome/test/page_cycler/page_cycler_test.cc index 0836959..b927807 100644 --- a/chrome/test/page_cycler/page_cycler_test.cc +++ b/chrome/test/page_cycler/page_cycler_test.cc @@ -209,6 +209,7 @@ class PageCyclerTest : public UITest { test_url = test_url.ReplaceComponents(replacements); scoped_refptr<TabProxy> tab(GetActiveTab()); + ASSERT_TRUE(tab.get()); tab->NavigateToURL(test_url); // Wait for the test to finish. diff --git a/chrome/test/ui/dom_checker_uitest.cc b/chrome/test/ui/dom_checker_uitest.cc index 3342a29..0737bb4 100644 --- a/chrome/test/ui/dom_checker_uitest.cc +++ b/chrome/test/ui/dom_checker_uitest.cc @@ -200,6 +200,7 @@ class DomCheckerTest : public UITest { } scoped_refptr<TabProxy> tab(GetActiveTab()); + ASSERT_TRUE(tab.get()); tab->NavigateToURL(test_url); // Wait for the test to finish. diff --git a/chrome/test/ui/sunspider_uitest.cc b/chrome/test/ui/sunspider_uitest.cc index 05b15c2..3f6c8f5 100644 --- a/chrome/test/ui/sunspider_uitest.cc +++ b/chrome/test/ui/sunspider_uitest.cc @@ -39,6 +39,7 @@ class SunSpiderTest : public UITest { GURL test_url(net::FilePathToFileURL(test_path)); scoped_refptr<TabProxy> tab(GetActiveTab()); + ASSERT_TRUE(tab.get()); tab->NavigateToURL(test_url); // Wait for the test to finish. diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index a9e4567..2295781 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -546,9 +546,12 @@ void UITest::CleanupAppProcesses() { scoped_refptr<TabProxy> UITest::GetActiveTab(int window_index) { EXPECT_GE(window_index, 0); - int window_count; - // Use EXPECT rather than ASSERT here because ASSERT_* returns void. + int window_count = -1; + // We have to use EXPECT rather than ASSERT here because ASSERT_* only works + // in functions that return void. EXPECT_TRUE(automation()->GetBrowserWindowCount(&window_count)); + if (window_count == -1) + return NULL; EXPECT_GT(window_count, window_index); scoped_refptr<BrowserProxy> window_proxy(automation()-> GetBrowserWindow(window_index)); @@ -895,12 +898,14 @@ void UITest::WaitForFinish(const std::string &name, cookie_name.append(test_complete_cookie); scoped_refptr<TabProxy> tab(GetActiveTab()); - - bool test_result = WaitUntilCookieValue(tab.get(), url, - cookie_name.c_str(), - kIntervalMilliSeconds, wait_time, - expected_cookie_value.c_str()); - EXPECT_EQ(true, test_result); + EXPECT_TRUE(tab.get()); + if (tab.get()) { + bool test_result = WaitUntilCookieValue(tab.get(), url, + cookie_name.c_str(), + kIntervalMilliSeconds, wait_time, + expected_cookie_value.c_str()); + EXPECT_EQ(true, test_result); + } } void UITest::PrintResult(const std::string& measurement, diff --git a/chrome/worker/worker_uitest.cc b/chrome/worker/worker_uitest.cc index 2ef25a9..e664282b 100644 --- a/chrome/worker/worker_uitest.cc +++ b/chrome/worker/worker_uitest.cc @@ -69,6 +69,7 @@ WorkerTest::~WorkerTest() { void WorkerTest::RunTest(const std::wstring& test_case) { scoped_refptr<TabProxy> tab(GetActiveTab()); + ASSERT_TRUE(tab.get()); GURL url = GetTestUrl(L"workers", test_case); ASSERT_TRUE(tab->NavigateToURL(url)); @@ -206,6 +207,7 @@ void WorkerTest::RunLayoutTest(const std::string& test_case_file_name, // Runs the new layout test. scoped_refptr<TabProxy> tab(GetActiveTab()); + ASSERT_TRUE(tab.get()); ASSERT_TRUE(tab->NavigateToURL(*new_test_url.get())); std::string escaped_value = WaitUntilCookieNonEmpty(tab.get(), *new_test_url.get(), @@ -339,6 +341,7 @@ TEST_F(WorkerTest, LimitPerPage) { url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab + 1)); scoped_refptr<TabProxy> tab(GetActiveTab()); + ASSERT_TRUE(tab.get()); ASSERT_TRUE(tab->NavigateToURL(url)); EXPECT_EQ(max_workers_per_tab + 1 + (UITest::in_process_renderer() ? 0 : 1), @@ -354,6 +357,7 @@ TEST_F(WorkerTest, LimitTotal) { url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab)); scoped_refptr<TabProxy> tab(GetActiveTab()); + ASSERT_TRUE(tab.get()); ASSERT_TRUE(tab->NavigateToURL(url)); scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); for (int i = 1; i < tab_count; ++i) |