Skip to content

Commit

Permalink
We should not EXPECT to get a browser object or a window object, we s…
Browse files Browse the repository at this point in the history
…hould ASSERT that we got it (which ends the test on NULL pointers). Otherwise we continue on and crash when we try to use these pointers, such as when passing it into GetBrowserForWindow.

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1508 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
finnur@google.com committed Aug 28, 2008
1 parent b588b77 commit 969ff79
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
22 changes: 14 additions & 8 deletions chrome/browser/browser_focus_uitest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ TEST_F(BrowserFocusTest, BrowsersRememberFocus) {

// The focus should be on the Tab contents.
scoped_ptr<WindowProxy> window(automation()->GetActiveWindow());
EXPECT_TRUE(window.get() != NULL);
ASSERT_TRUE(window.get() != NULL);

scoped_ptr<BrowserProxy> browser(automation()->
GetBrowserForWindow(window.get()));
ASSERT_TRUE(browser.get() != NULL);

int focused_view_id;
EXPECT_TRUE(window->GetFocusedViewID(&focused_view_id));
Expand Down Expand Up @@ -99,10 +100,10 @@ TEST_F(BrowserFocusTest, BrowsersRememberFocus) {
// Open a new browser window.
EXPECT_TRUE(automation()->OpenNewBrowserWindow(SW_SHOWNORMAL));
scoped_ptr<WindowProxy> new_window(automation()->GetActiveWindow());
EXPECT_TRUE(new_window.get() != NULL);
ASSERT_TRUE(new_window.get() != NULL);
scoped_ptr<BrowserProxy> new_browser(automation()->
GetBrowserForWindow(new_window.get()));
EXPECT_TRUE(new_browser.get() != NULL);
ASSERT_TRUE(new_browser.get() != NULL);

// Let's make sure we have 2 different browser windows.
EXPECT_TRUE(browser->handle() != new_browser->handle());
Expand Down Expand Up @@ -132,9 +133,10 @@ TEST_F(BrowserFocusTest, TabsRememberFocus) {
TestServer server(kDocRoot);

scoped_ptr<WindowProxy> window(automation()->GetActiveWindow());
EXPECT_TRUE(window.get() != NULL);
ASSERT_TRUE(window.get() != NULL);
scoped_ptr<BrowserProxy> browser(
automation()->GetBrowserForWindow(window.get()));
ASSERT_TRUE(browser.get() != NULL);

// First we navigate to our test page.
GURL url = server.TestServerPageW(kSimplePage);
Expand Down Expand Up @@ -200,16 +202,18 @@ TEST_F(BrowserFocusTest, BackgroundBrowserDontStealFocus) {
tab->NavigateToURL(simple_page_url);

scoped_ptr<WindowProxy> window(automation()->GetActiveWindow());
EXPECT_TRUE(window.get() != NULL);
ASSERT_TRUE(window.get() != NULL);
scoped_ptr<BrowserProxy> browser(
automation()->GetBrowserForWindow(window.get()));
ASSERT_TRUE(browser.get() != NULL);

// Open a new browser window.
EXPECT_TRUE(automation()->OpenNewBrowserWindow(SW_SHOWNORMAL));
scoped_ptr<WindowProxy> new_window(automation()->GetActiveWindow());
EXPECT_TRUE(window.get() != NULL);
ASSERT_TRUE(window.get() != NULL);
scoped_ptr<BrowserProxy> new_browser(
automation()->GetBrowserForWindow(new_window.get()));
ASSERT_TRUE(new_browser.get() != NULL);

GURL steal_focus_url = server.TestServerPageW(kStealFocusPage);
new_browser->AppendTab(steal_focus_url);
Expand All @@ -236,9 +240,10 @@ TEST_F(BrowserFocusTest, LocationBarLockFocus) {
tab->NavigateToURL(url);

scoped_ptr<WindowProxy> window(automation()->GetActiveWindow());
EXPECT_TRUE(window.get() != NULL);
ASSERT_TRUE(window.get() != NULL);
scoped_ptr<BrowserProxy> browser(
automation()->GetBrowserForWindow(window.get()));
ASSERT_TRUE(browser.get() != NULL);

// Click on the location bar.
gfx::Rect bounds;
Expand Down Expand Up @@ -267,9 +272,10 @@ TEST_F(BrowserFocusTest, FocusTraversal) {
tab->NavigateToURL(url);

scoped_ptr<WindowProxy> window(automation()->GetActiveWindow());
EXPECT_TRUE(window.get() != NULL);
ASSERT_TRUE(window.get() != NULL);
scoped_ptr<BrowserProxy> browser(
automation()->GetBrowserForWindow(window.get()));
ASSERT_TRUE(browser.get() != NULL);

// Click on the location bar.
gfx::Rect bounds;
Expand Down
7 changes: 2 additions & 5 deletions chrome/browser/find_in_page_controller_uitest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,8 @@ TEST_F(FindInPageControllerTest, DISABLED_FindMovesOnTabClose_Issue1343052) {
scoped_ptr<TabProxy> tabA(GetActiveTab());
ASSERT_TRUE(tabA->NavigateToURL(url));

scoped_ptr<WindowProxy> window(automation()->GetActiveWindow());
EXPECT_TRUE(window.get() != NULL);

scoped_ptr<BrowserProxy> browser(
automation()->GetBrowserForWindow(window.get()));
scoped_ptr<BrowserProxy> browser(automation()->GetLastActiveBrowserWindow());
ASSERT_TRUE(browser.get() != NULL);

// Toggle the bookmark bar state.
browser->ApplyAccelerator(IDC_SHOW_BOOKMARKS_BAR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ TEST_F(InteractiveConstrainedWindowTest, TestOpenAndResizeTo) {
ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 1000));

scoped_ptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1));
ASSERT_TRUE(popup_browser != NULL);
scoped_ptr<WindowProxy> popup_window(
automation()->GetWindowForBrowser(popup_browser.get()));
ASSERT_TRUE(popup_window != NULL);

// Make sure we were created with the correct width and height.
gfx::Rect rect;
Expand Down

0 comments on commit 969ff79

Please sign in to comment.