summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-11 14:26:31 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-11 14:26:31 +0000
commit8c899745075cbd3a3abead137ca0b151529898a2 (patch)
treec0b33b7b1a0a1b7b430060b78b165e79700d4972
parent03f7f4f98a9c241ed05862158e10120bfe64472f (diff)
downloadchromium_src-8c899745075cbd3a3abead137ca0b151529898a2.zip
chromium_src-8c899745075cbd3a3abead137ca0b151529898a2.tar.gz
chromium_src-8c899745075cbd3a3abead137ca0b151529898a2.tar.bz2
[GTTF] Add more NULL-checks to UI tests that were lacking them to avoid crashiness.
TEST=none BUG=none Review URL: http://codereview.chromium.org/841002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41273 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_uitest.cc3
-rw-r--r--chrome/browser/dom_ui/new_tab_ui_uitest.cc4
-rw-r--r--chrome/browser/download/download_uitest.cc16
-rw-r--r--chrome/browser/download/save_page_uitest.cc1
-rw-r--r--chrome/browser/login_prompt_uitest.cc28
-rw-r--r--chrome/browser/notifications/notifications_uitest.cc4
-rw-r--r--chrome/browser/pref_service_uitest.cc1
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc16
-rw-r--r--chrome/browser/sessions/session_restore_uitest.cc8
-rw-r--r--chrome/browser/tab_restore_uitest.cc17
-rw-r--r--chrome/browser/unload_uitest.cc5
11 files changed, 72 insertions, 31 deletions
diff --git a/chrome/browser/browser_uitest.cc b/chrome/browser/browser_uitest.cc
index fdde99d..55cb332 100644
--- a/chrome/browser/browser_uitest.cc
+++ b/chrome/browser/browser_uitest.cc
@@ -34,6 +34,7 @@ class BrowserTest : public UITest {
void TerminateBrowser() {
#if defined(OS_WIN)
scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser.get());
ASSERT_TRUE(browser->TerminateSession());
#elif defined(OS_POSIX)
// There's nothing to do here if the browser is not running.
@@ -136,6 +137,7 @@ TEST_F(BrowserTest, NullOpenerRedirectForksProcess) {
ASSERT_TRUE(NULL != server.get());
FilePath test_file(test_data_directory_);
scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(window.get());
scoped_refptr<TabProxy> tab(window->GetActiveTab());
ASSERT_TRUE(tab.get());
@@ -185,6 +187,7 @@ TEST_F(BrowserTest, MAYBE_OtherRedirectsDontForkProcess) {
ASSERT_TRUE(NULL != server.get());
FilePath test_file(test_data_directory_);
scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(window.get());
scoped_refptr<TabProxy> tab(window->GetActiveTab());
ASSERT_TRUE(tab.get());
diff --git a/chrome/browser/dom_ui/new_tab_ui_uitest.cc b/chrome/browser/dom_ui/new_tab_ui_uitest.cc
index d2ad788..2235bf9 100644
--- a/chrome/browser/dom_ui/new_tab_ui_uitest.cc
+++ b/chrome/browser/dom_ui/new_tab_ui_uitest.cc
@@ -47,6 +47,8 @@ TEST_F(NewTabUITest, NTPHasThumbnails) {
// Blank thumbnails on the NTP have the class 'filler' applied to the div.
// If all the thumbnails load, there should be no div's with 'filler'.
scoped_refptr<TabProxy> tab = window->GetActiveTab();
+ ASSERT_TRUE(tab.get());
+
int filler_thumbnails_count = -1;
const int kWaitDuration = 100;
int wait_time = action_max_timeout_ms();
@@ -73,6 +75,7 @@ TEST_F(NewTabUITest, ChromeInternalLoadsNTP) {
// Go to the "new tab page" using its old url, rather than chrome://newtab.
scoped_refptr<TabProxy> tab = window->GetTab(0);
+ ASSERT_TRUE(tab.get());
tab->NavigateToURLAsync(GURL("chrome-internal:"));
int load_time;
ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time));
@@ -127,6 +130,7 @@ TEST_F(NewTabUITest, HomePageLink) {
ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time));
scoped_refptr<TabProxy> tab = browser->GetActiveTab();
+ ASSERT_TRUE(tab.get());
// TODO(arv): Extract common patterns for doing js testing.
diff --git a/chrome/browser/download/download_uitest.cc b/chrome/browser/download/download_uitest.cc
index f4b370f..17aa989 100644
--- a/chrome/browser/download/download_uitest.cc
+++ b/chrome/browser/download/download_uitest.cc
@@ -15,6 +15,7 @@
#include "base/path_service.h"
#include "base/platform_thread.h"
#include "base/string_util.h"
+#include "base/test/test_file_util.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/net/url_request_mock_http_job.h"
#include "chrome/browser/net/url_request_slow_download_job.h"
@@ -106,6 +107,7 @@ class DownloadTest : public UITest {
// Complete sending the request. We do this by loading a second URL in a
// separate tab.
scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(window.get());
EXPECT_TRUE(window->AppendTab(GURL(
URLRequestSlowDownloadJob::kFinishDownloadUrl)));
EXPECT_EQ(2, GetTabCount());
@@ -122,11 +124,7 @@ class DownloadTest : public UITest {
EXPECT_TRUE(file_util::PathExists(download_path));
// Delete the file we just downloaded.
- for (int i = 0; i < 10; ++i) {
- if (file_util::Delete(download_path, false))
- break;
- PlatformThread::Sleep(action_max_timeout_ms() / 10);
- }
+ EXPECT_TRUE(file_util::DieFileDie(download_path, true));
EXPECT_FALSE(file_util::PathExists(download_path));
}
@@ -329,6 +327,7 @@ TEST_F(DownloadTest, FLAKY_IncognitoDownload) {
// Open a regular window and sanity check default values for window / tab
// count and shelf visibility.
scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser.get());
int window_count = 0;
ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
ASSERT_EQ(1, window_count);
@@ -339,14 +338,15 @@ TEST_F(DownloadTest, FLAKY_IncognitoDownload) {
// Open an Incognito window.
ASSERT_TRUE(browser->RunCommand(IDC_NEW_INCOGNITO_WINDOW));
- scoped_refptr<BrowserProxy> incognito(automation()->GetBrowserWindow(1));
- scoped_refptr<TabProxy> tab(incognito->GetTab(0));
ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
ASSERT_EQ(2, window_count);
+ scoped_refptr<BrowserProxy> incognito(automation()->GetBrowserWindow(1));
+ ASSERT_TRUE(incognito.get());
// Download something.
FilePath file(FILE_PATH_LITERAL("download-test1.lib"));
- //PlatformThread::Sleep(1000);
+ scoped_refptr<TabProxy> tab(incognito->GetTab(0));
+ ASSERT_TRUE(tab.get());
ASSERT_TRUE(tab->NavigateToURL(URLRequestMockHTTPJob::GetMockUrl(file)));
PlatformThread::Sleep(action_timeout_ms());
diff --git a/chrome/browser/download/save_page_uitest.cc b/chrome/browser/download/save_page_uitest.cc
index 8774637..563333c 100644
--- a/chrome/browser/download/save_page_uitest.cc
+++ b/chrome/browser/download/save_page_uitest.cc
@@ -76,6 +76,7 @@ TEST_F(SavePageTest, CleanFilenameFromPageTitle) {
WaitUntilTabCount(1);
scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser.get());
automation()->SavePackageShouldPromptUser(false);
EXPECT_TRUE(browser->RunCommandAsync(IDC_SAVE_PAGE));
EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get()));
diff --git a/chrome/browser/login_prompt_uitest.cc b/chrome/browser/login_prompt_uitest.cc
index 0888182..df081e3 100644
--- a/chrome/browser/login_prompt_uitest.cc
+++ b/chrome/browser/login_prompt_uitest.cc
@@ -30,23 +30,14 @@ class LoginPromptTest : public UITest {
password_bad_(L"denyme") {
}
- scoped_refptr<TabProxy> GetActiveTabProxy() {
- scoped_refptr<BrowserProxy> window_proxy(automation()->GetBrowserWindow(0));
- EXPECT_TRUE(window_proxy.get());
-
- int active_tab_index = 0;
- EXPECT_TRUE(window_proxy->GetActiveTabIndex(&active_tab_index));
- return window_proxy->GetTab(active_tab_index);
- }
-
void NavigateTab(TabProxy* tab_proxy, const GURL& url) {
ASSERT_TRUE(tab_proxy->NavigateToURL(url));
}
void AppendTab(const GURL& url) {
scoped_refptr<BrowserProxy> window_proxy(automation()->GetBrowserWindow(0));
- EXPECT_TRUE(window_proxy.get());
- EXPECT_TRUE(window_proxy->AppendTab(url));
+ ASSERT_TRUE(window_proxy.get());
+ ASSERT_TRUE(window_proxy->AppendTab(url));
}
protected:
@@ -67,7 +58,8 @@ TEST_F(LoginPromptTest, TestBasicAuth) {
scoped_refptr<HTTPTestServer> server =
HTTPTestServer::CreateServer(kDocRoot, NULL);
ASSERT_TRUE(NULL != server.get());
- scoped_refptr<TabProxy> tab(GetActiveTabProxy());
+ scoped_refptr<TabProxy> tab(GetActiveTab());
+ ASSERT_TRUE(tab.get());
NavigateTab(tab.get(), server->TestServerPageW(L"auth-basic"));
EXPECT_TRUE(tab->NeedsAuth());
@@ -89,7 +81,8 @@ TEST_F(LoginPromptTest, TestDigestAuth) {
scoped_refptr<HTTPTestServer> server =
HTTPTestServer::CreateServer(kDocRoot, NULL);
ASSERT_TRUE(NULL != server.get());
- scoped_refptr<TabProxy> tab(GetActiveTabProxy());
+ scoped_refptr<TabProxy> tab(GetActiveTab());
+ ASSERT_TRUE(tab.get());
NavigateTab(tab.get(), server->TestServerPageW(L"auth-digest"));
EXPECT_TRUE(tab->NeedsAuth());
@@ -112,11 +105,13 @@ TEST_F(LoginPromptTest, FLAKY_TestTwoAuths) {
HTTPTestServer::CreateServer(kDocRoot, NULL);
ASSERT_TRUE(NULL != server.get());
- scoped_refptr<TabProxy> basic_tab(GetActiveTabProxy());
+ scoped_refptr<TabProxy> basic_tab(GetActiveTab());
+ ASSERT_TRUE(basic_tab.get());
NavigateTab(basic_tab.get(), server->TestServerPageW(L"auth-basic"));
AppendTab(GURL(chrome::kAboutBlankURL));
- scoped_refptr<TabProxy> digest_tab(GetActiveTabProxy());
+ scoped_refptr<TabProxy> digest_tab(GetActiveTab());
+ ASSERT_TRUE(digest_tab.get());
NavigateTab(digest_tab.get(), server->TestServerPageW(L"auth-digest"));
// TODO(devint): http://b/1158262 basic_tab is not active, so this logs in to
@@ -141,7 +136,8 @@ TEST_F(LoginPromptTest, TestCancelAuth) {
scoped_refptr<HTTPTestServer> server =
HTTPTestServer::CreateServer(kDocRoot, NULL);
ASSERT_TRUE(NULL != server.get());
- scoped_refptr<TabProxy> tab(GetActiveTabProxy());
+ scoped_refptr<TabProxy> tab(GetActiveTab());
+ ASSERT_TRUE(tab.get());
// First navigate to a test server page so we have something to go back to.
EXPECT_TRUE(tab->NavigateToURL(server->TestServerPageW(L"a")));
diff --git a/chrome/browser/notifications/notifications_uitest.cc b/chrome/browser/notifications/notifications_uitest.cc
index e6c1d32..66f35dc 100644
--- a/chrome/browser/notifications/notifications_uitest.cc
+++ b/chrome/browser/notifications/notifications_uitest.cc
@@ -26,7 +26,9 @@ TEST_F(NotificationsPermissionTest, FLAKY_TestUserGestureInfobar) {
ASSERT_TRUE(server.get() != NULL);
scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser.get());
scoped_refptr<TabProxy> tab(browser->GetActiveTab());
+ ASSERT_TRUE(tab.get());
tab->NavigateToURL(server->TestServerPageW(
L"files/notifications/notifications_request_function.html"));
WaitUntilTabCount(1);
@@ -49,7 +51,9 @@ TEST_F(NotificationsPermissionTest, TestNoUserGestureInfobar) {
ASSERT_TRUE(server.get() != NULL);
scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser.get());
scoped_refptr<TabProxy> tab(browser->GetActiveTab());
+ ASSERT_TRUE(tab.get());
// Load a page which just does a request; no user gesture should result
// in no infobar.
diff --git a/chrome/browser/pref_service_uitest.cc b/chrome/browser/pref_service_uitest.cc
index 04430b5..ca547a3 100644
--- a/chrome/browser/pref_service_uitest.cc
+++ b/chrome/browser/pref_service_uitest.cc
@@ -96,6 +96,7 @@ TEST_F(PreferenceServiceTest, PreservedWindowPlacementIsLoaded) {
scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
ASSERT_TRUE(browser.get());
scoped_refptr<WindowProxy> window(browser->GetWindow());
+ ASSERT_TRUE(window.get());
gfx::Rect bounds;
ASSERT_TRUE(window->GetBounds(&bounds));
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc b/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc
index 3c22b13..5b3bc5b 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc
+++ b/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc
@@ -61,6 +61,7 @@ TEST_F(ResourceDispatcherTest, SniffNoContentTypeNoData) {
// Make sure the download shelf is not showing.
scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser.get());
bool visible = false;
ASSERT_TRUE(browser->IsShelfVisible(&visible));
EXPECT_FALSE(visible);
@@ -82,7 +83,7 @@ TEST_F(ResourceDispatcherTest, SyncXMLHttpRequest) {
ASSERT_TRUE(NULL != server.get());
scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
- EXPECT_TRUE(browser_proxy.get());
+ ASSERT_TRUE(browser_proxy.get());
scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab());
ASSERT_TRUE(tab.get());
tab->NavigateToURL(server->TestServerPageW(
@@ -103,7 +104,7 @@ TEST_F(ResourceDispatcherTest, SyncXMLHttpRequest_Disallowed) {
ASSERT_TRUE(NULL != server.get());
scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
- EXPECT_TRUE(browser_proxy.get());
+ ASSERT_TRUE(browser_proxy.get());
scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab());
ASSERT_TRUE(tab.get());
tab->NavigateToURL(server->TestServerPageW(
@@ -127,7 +128,7 @@ TEST_F(ResourceDispatcherTest, SyncXMLHttpRequest_DuringUnload) {
ASSERT_TRUE(NULL != server.get());
scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
- EXPECT_TRUE(browser_proxy.get());
+ ASSERT_TRUE(browser_proxy.get());
scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab());
ASSERT_TRUE(tab.get());
@@ -149,6 +150,7 @@ TEST_F(ResourceDispatcherTest, SyncXMLHttpRequest_DuringUnload) {
bool shelf_is_visible = false;
scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser.get());
EXPECT_TRUE(browser->IsShelfVisible(&shelf_is_visible));
EXPECT_FALSE(shelf_is_visible);
}
@@ -161,7 +163,7 @@ TEST_F(ResourceDispatcherTest, CrossSiteOnunloadCookie) {
ASSERT_TRUE(NULL != server.get());
scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
- EXPECT_TRUE(browser_proxy.get());
+ ASSERT_TRUE(browser_proxy.get());
scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab());
ASSERT_TRUE(tab.get());
@@ -204,7 +206,7 @@ TEST_F(ResourceDispatcherTest, CrossSiteAfterCrash) {
return;
scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
- EXPECT_TRUE(browser_proxy.get());
+ ASSERT_TRUE(browser_proxy.get());
scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab());
ASSERT_TRUE(tab.get());
@@ -229,7 +231,7 @@ TEST_F(ResourceDispatcherTest, CrossSiteAfterCrash) {
// the BufferedEventHandler (e.g., non-http{s} URLs). (Bug 1225872)
TEST_F(ResourceDispatcherTest, CrossSiteNavigationNonBuffered) {
scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
- EXPECT_TRUE(browser_proxy.get());
+ ASSERT_TRUE(browser_proxy.get());
scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab());
ASSERT_TRUE(tab.get());
@@ -255,7 +257,7 @@ TEST_F(ResourceDispatcherTest, CrossSiteNavigationErrorPage) {
ASSERT_TRUE(NULL != server.get());
scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
- EXPECT_TRUE(browser_proxy.get());
+ ASSERT_TRUE(browser_proxy.get());
scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab());
ASSERT_TRUE(tab.get());
diff --git a/chrome/browser/sessions/session_restore_uitest.cc b/chrome/browser/sessions/session_restore_uitest.cc
index a1eaa4a..966717c 100644
--- a/chrome/browser/sessions/session_restore_uitest.cc
+++ b/chrome/browser/sessions/session_restore_uitest.cc
@@ -98,6 +98,7 @@ TEST_F(SessionRestoreUITest, Basic) {
ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
ASSERT_EQ(1, window_count);
scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser_proxy.get());
scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetTab(0));
ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms()));
@@ -123,6 +124,7 @@ TEST_F(SessionRestoreUITest, RestoresForwardAndBackwardNavs) {
ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
ASSERT_EQ(1, window_count);
scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser_proxy.get());
scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetTab(0));
ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms()));
@@ -162,10 +164,12 @@ TEST_F(SessionRestoreUITest, RestoresCrossSiteForwardAndBackwardNavs) {
ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
ASSERT_EQ(1, window_count);
scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser_proxy.get());
int tab_count;
ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count));
ASSERT_EQ(1, tab_count);
scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetTab(0));
+ ASSERT_TRUE(tab_proxy.get());
ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_max_timeout_ms()));
// Check that back and forward work as expected.
@@ -195,6 +199,7 @@ TEST_F(SessionRestoreUITest, TwoTabsSecondSelected) {
ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
ASSERT_EQ(1, window_count);
scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser_proxy.get());
ASSERT_TRUE(browser_proxy->AppendTab(url2_));
@@ -237,7 +242,9 @@ TEST_F(SessionRestoreUITest, ClosedTabStaysClosed) {
ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
ASSERT_EQ(1, window_count);
scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser_proxy.get());
scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetTab(0));
+ ASSERT_TRUE(tab_proxy.get());
browser_proxy->AppendTab(url2_);
@@ -329,6 +336,7 @@ TEST_F(SessionRestoreUITest, DontRestoreWhileIncognito) {
ASSERT_EQ(1, initial_window_count);
scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser_proxy.get());
// Create an off the record window.
ASSERT_TRUE(browser_proxy->RunCommand(IDC_NEW_INCOGNITO_WINDOW));
diff --git a/chrome/browser/tab_restore_uitest.cc b/chrome/browser/tab_restore_uitest.cc
index 4b4d28b..f0725ca 100644
--- a/chrome/browser/tab_restore_uitest.cc
+++ b/chrome/browser/tab_restore_uitest.cc
@@ -59,6 +59,7 @@ class TabRestoreUITest : public UITest {
ASSERT_GT(window_count, expected_window_index);
browser_proxy = automation()->GetBrowserWindow(expected_window_index);
}
+ ASSERT_TRUE(browser_proxy.get());
ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count));
ASSERT_GT(tab_count, 0);
@@ -70,6 +71,7 @@ class TabRestoreUITest : public UITest {
ASSERT_TRUE(automation()->GetBrowserWindowCount(&new_window_count));
EXPECT_EQ(++window_count, new_window_count);
browser_proxy = automation()->GetBrowserWindow(expected_window_index);
+ ASSERT_TRUE(browser_proxy.get());
} else {
int new_tab_count = 0;
ASSERT_TRUE(browser_proxy->GetTabCount(&new_tab_count));
@@ -122,6 +124,7 @@ class TabRestoreUITest : public UITest {
bool is_active = false;
scoped_refptr<WindowProxy> window_proxy(browser->GetWindow());
+ ASSERT_TRUE(window_proxy.get());
ASSERT_TRUE(window_proxy->IsActive(&is_active));
// The check for is_active may fail if other apps are active while running
// the tests, because Chromium won't be the foremost application at all.
@@ -143,6 +146,7 @@ class TabRestoreUITest : public UITest {
// in its original position, and active.
TEST_F(TabRestoreUITest, Basic) {
scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser_proxy.get());
int starting_tab_count;
ASSERT_TRUE(browser_proxy->GetTabCount(&starting_tab_count));
@@ -172,6 +176,7 @@ TEST_F(TabRestoreUITest, Basic) {
// should be in its original position, and active.
TEST_F(TabRestoreUITest, MiddleTab) {
scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser_proxy.get());
int starting_tab_count;
ASSERT_TRUE(browser_proxy->GetTabCount(&starting_tab_count));
@@ -203,6 +208,7 @@ TEST_F(TabRestoreUITest, MiddleTab) {
// This test is flaky. See http://crbug.com/14132 and 11213.
TEST_F(TabRestoreUITest, FLAKY_RestoreToDifferentWindow) {
scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser_proxy.get());
// This call is virtually guaranteed to pass, assuming that Chromium is the
// active application, which will establish a baseline for later calls to
@@ -248,6 +254,7 @@ TEST_F(TabRestoreUITest, FLAKY_RestoreToDifferentWindow) {
// tab. It should be in a new window.
TEST_F(TabRestoreUITest, MAYBE_BasicRestoreFromClosedWindow) {
scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser_proxy.get());
CheckActiveWindow(browser_proxy.get());
int tab_count;
@@ -287,6 +294,7 @@ TEST_F(TabRestoreUITest, MAYBE_BasicRestoreFromClosedWindow) {
// Tab should be in a new window.
browser_proxy = automation()->GetBrowserWindow(1);
+ ASSERT_TRUE(browser_proxy.get());
CheckActiveWindow(browser_proxy.get());
tab_proxy = browser_proxy->GetActiveTab();
ASSERT_TRUE(tab_proxy.get());
@@ -301,6 +309,7 @@ TEST_F(TabRestoreUITest, MAYBE_BasicRestoreFromClosedWindow) {
// the tab restore command. http://crbug.com/14428.
TEST_F(TabRestoreUITest, DISABLED_DontLoadRestoredTab) {
scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser_proxy.get());
CheckActiveWindow(browser_proxy.get());
// Add two tabs
@@ -337,6 +346,7 @@ TEST_F(TabRestoreUITest, DISABLED_DontLoadRestoredTab) {
// This test is flaky. See http://crbug.com/14132
TEST_F(TabRestoreUITest, FLAKY_RestoreWindowAndTab) {
scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser_proxy.get());
CheckActiveWindow(browser_proxy.get());
int starting_tab_count;
@@ -376,6 +386,7 @@ TEST_F(TabRestoreUITest, FLAKY_RestoreWindowAndTab) {
// indicates the expected active tab.
RestoreTab(1, starting_tab_count + 1);
browser_proxy = automation()->GetBrowserWindow(1);
+ ASSERT_TRUE(browser_proxy.get());
CheckActiveWindow(browser_proxy.get());
ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count));
EXPECT_EQ(starting_tab_count + 2, tab_count);
@@ -392,6 +403,7 @@ TEST_F(TabRestoreUITest, FLAKY_RestoreWindowAndTab) {
// both. Make sure both restored tabs are in the same window.
TEST_F(TabRestoreUITest, RestoreIntoSameWindow) {
scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser_proxy.get());
CheckActiveWindow(browser_proxy.get());
int starting_tab_count;
@@ -430,6 +442,7 @@ TEST_F(TabRestoreUITest, RestoreIntoSameWindow) {
// Restore the last-closed tab into a new window.
RestoreTab(1, 0);
browser_proxy = automation()->GetBrowserWindow(1);
+ ASSERT_TRUE(browser_proxy.get());
CheckActiveWindow(browser_proxy.get());
ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count));
EXPECT_EQ(1, tab_count);
@@ -454,6 +467,7 @@ TEST_F(TabRestoreUITest, RestoreWithExistingSiteInstance) {
GURL http_url2(server->TestServerPageW(L"files/title2.html"));
scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser_proxy.get());
int tab_count;
ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count));
@@ -500,6 +514,7 @@ TEST_F(TabRestoreUITest, RestoreCrossSiteWithExistingSiteInstance) {
GURL http_url2(server->TestServerPageW(L"files/title2.html"));
scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser_proxy.get());
int tab_count;
ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count));
@@ -553,6 +568,7 @@ TEST_F(TabRestoreUITest, RestoreWindow) {
// Create two more tabs, one with url1, the other url2.
scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser_proxy.get());
int initial_tab_count;
ASSERT_TRUE(browser_proxy->GetTabCount(&initial_tab_count));
browser_proxy->AppendTab(url1_);
@@ -577,6 +593,7 @@ TEST_F(TabRestoreUITest, RestoreWindow) {
// Restore the window.
browser_proxy = automation()->GetBrowserWindow(0);
+ ASSERT_TRUE(browser_proxy.get());
ASSERT_TRUE(browser_proxy->RunCommand(IDC_RESTORE_TAB));
ASSERT_TRUE(automation()->GetBrowserWindowCount(&new_window_count));
EXPECT_EQ(window_count, new_window_count);
diff --git a/chrome/browser/unload_uitest.cc b/chrome/browser/unload_uitest.cc
index 880d180..b4b311c 100644
--- a/chrome/browser/unload_uitest.cc
+++ b/chrome/browser/unload_uitest.cc
@@ -160,6 +160,7 @@ class UnloadTest : public UITest {
void LoadUrlAndQuitBrowser(const std::string& html_content,
const std::wstring& expected_title = L"") {
scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser.get());
NavigateToDataURL(html_content, expected_title);
bool application_closed = false;
EXPECT_TRUE(CloseBrowser(browser.get(), &application_closed));
@@ -254,6 +255,7 @@ TEST_F(UnloadTest, BrowserCloseUnload) {
#if !defined(OS_LINUX)
TEST_F(UnloadTest, BrowserCloseBeforeUnloadOK) {
scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser.get());
NavigateToDataURL(BEFORE_UNLOAD_HTML, L"beforeunload");
CloseBrowserAsync(browser.get());
@@ -266,6 +268,7 @@ TEST_F(UnloadTest, BrowserCloseBeforeUnloadOK) {
// CANCEL in the beforeunload confirm dialog.
TEST_F(UnloadTest, BrowserCloseBeforeUnloadCancel) {
scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser.get());
NavigateToDataURL(BEFORE_UNLOAD_HTML, L"beforeunload");
CloseBrowserAsync(browser.get());
@@ -283,6 +286,8 @@ TEST_F(UnloadTest, BrowserCloseBeforeUnloadCancel) {
// if an inner frame has the focus. See crbug.com/32615.
TEST_F(UnloadTest, BrowserCloseWithInnerFocusedFrame) {
scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser.get());
+
NavigateToDataURL(INNER_FRAME_WITH_FOCUS_HTML, L"innerframewithfocus");
CloseBrowserAsync(browser.get());