Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: chrome/browser/ui/find_bar/find_bar_host_browsertest.cc

Issue 7489019: Fix up various browser tests not to use WaitForNavigation. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "base/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/string_util.h" 6 #include "base/string_util.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/tabs/tab_strip_model.h" 9 #include "chrome/browser/tabs/tab_strip_model.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 browser()->ShowFindBar(); 573 browser()->ShowFindBar();
574 574
575 gfx::Point position; 575 gfx::Point position;
576 bool fully_visible = false; 576 bool fully_visible = false;
577 577
578 // Make sure it is open. 578 // Make sure it is open.
579 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); 579 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
580 EXPECT_TRUE(fully_visible); 580 EXPECT_TRUE(fully_visible);
581 581
582 // Reload the tab and make sure Find window doesn't go away. 582 // Reload the tab and make sure Find window doesn't go away.
583 ui_test_utils::WindowedNotificationObserver observer(*browser());
583 browser()->Reload(CURRENT_TAB); 584 browser()->Reload(CURRENT_TAB);
584 ui_test_utils::WaitForNavigationInCurrentTab(browser()); 585 observer.Wait();
585 586
586 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); 587 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
587 EXPECT_TRUE(fully_visible); 588 EXPECT_TRUE(fully_visible);
588 589
589 // Navigate and make sure the Find window goes away. 590 // Navigate and make sure the Find window goes away.
590 ui_test_utils::NavigateToURL(browser(), url2); 591 ui_test_utils::NavigateToURL(browser(), url2);
591 592
592 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); 593 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
593 EXPECT_FALSE(fully_visible); 594 EXPECT_FALSE(fully_visible);
594 } 595 }
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 EnsureFindBoxOpenForBrowser(browser()); 1041 EnsureFindBoxOpenForBrowser(browser());
1041 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(browser())); 1042 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(browser()));
1042 1043
1043 // Close the Find box. 1044 // Close the Find box.
1044 browser()->GetFindBarController()->EndFindSession( 1045 browser()->GetFindBarController()->EndFindSession(
1045 FindBarController::kKeepSelection); 1046 FindBarController::kKeepSelection);
1046 1047
1047 // Open a new incognito window and navigate to the same page. 1048 // Open a new incognito window and navigate to the same page.
1048 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); 1049 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile();
1049 Browser* incognito_browser = Browser::Create(incognito_profile); 1050 Browser* incognito_browser = Browser::Create(incognito_profile);
1051 ui_test_utils::WindowedNotificationObserver observer(
1052 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources());
1050 incognito_browser->AddSelectedTabWithURL(url, PageTransition::START_PAGE); 1053 incognito_browser->AddSelectedTabWithURL(url, PageTransition::START_PAGE);
1051 ui_test_utils::WaitForNavigation( 1054 observer.Wait();
1052 &incognito_browser->GetSelectedTabContents()->controller());
1053 incognito_browser->window()->Show(); 1055 incognito_browser->window()->Show();
1054 1056
1055 // Open the find box and make sure that it is prepopulated with "page". 1057 // Open the find box and make sure that it is prepopulated with "page".
1056 EnsureFindBoxOpenForBrowser(incognito_browser); 1058 EnsureFindBoxOpenForBrowser(incognito_browser);
1057 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(incognito_browser)); 1059 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(incognito_browser));
1058 1060
1059 // Search for the word "text" in the incognito tab. 1061 // Search for the word "text" in the incognito tab.
1060 TabContentsWrapper* incognito_tab = 1062 TabContentsWrapper* incognito_tab =
1061 incognito_browser->GetSelectedTabContentsWrapper(); 1063 incognito_browser->GetSelectedTabContentsWrapper();
1062 EXPECT_EQ(1, FindInPageWchar(incognito_tab, L"text", 1064 EXPECT_EQ(1, FindInPageWchar(incognito_tab, L"text",
(...skipping 22 matching lines...) Expand all
1085 // First we navigate to our test content. 1087 // First we navigate to our test content.
1086 GURL url = test_server()->GetURL(kLinkPage); 1088 GURL url = test_server()->GetURL(kLinkPage);
1087 ui_test_utils::NavigateToURL(browser(), url); 1089 ui_test_utils::NavigateToURL(browser(), url);
1088 1090
1089 TabContentsWrapper* tab = browser()->GetSelectedTabContentsWrapper(); 1091 TabContentsWrapper* tab = browser()->GetSelectedTabContentsWrapper();
1090 int ordinal = 0; 1092 int ordinal = 0;
1091 FindInPageWchar(tab, L"link", kFwd, kIgnoreCase, &ordinal); 1093 FindInPageWchar(tab, L"link", kFwd, kIgnoreCase, &ordinal);
1092 EXPECT_EQ(ordinal, 1); 1094 EXPECT_EQ(ordinal, 1);
1093 1095
1094 // End the find session, click on the link. 1096 // End the find session, click on the link.
1097 ui_test_utils::WindowedNotificationObserver observer(*browser());
1095 tab->find_tab_helper()->StopFinding(FindBarController::kActivateSelection); 1098 tab->find_tab_helper()->StopFinding(FindBarController::kActivateSelection);
1096 EXPECT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); 1099 observer.Wait();
1097 } 1100 }
1098 1101
1099 // Tests that FindBar fits within a narrow browser window. 1102 // Tests that FindBar fits within a narrow browser window.
1100 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FitWindow) { 1103 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FitWindow) {
1101 Browser::CreateParams params(Browser::TYPE_POPUP, browser()->profile()); 1104 Browser::CreateParams params(Browser::TYPE_POPUP, browser()->profile());
1102 params.initial_bounds = gfx::Rect(0, 0, 250, 500); 1105 params.initial_bounds = gfx::Rect(0, 0, 250, 500);
1103 Browser* popup = Browser::CreateWithParams(params); 1106 Browser* popup = Browser::CreateWithParams(params);
1107 ui_test_utils::WindowedNotificationObserver observer(
1108 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources());
1104 popup->AddSelectedTabWithURL(GURL(chrome::kAboutBlankURL), 1109 popup->AddSelectedTabWithURL(GURL(chrome::kAboutBlankURL),
1105 PageTransition::LINK); 1110 PageTransition::LINK);
1106
1107 // Wait for the page to finish loading. 1111 // Wait for the page to finish loading.
1108 ui_test_utils::WaitForNavigation( 1112 observer.Wait();
1109 &popup->GetSelectedTabContents()->controller());
1110 popup->window()->Show(); 1113 popup->window()->Show();
1111 1114
1112 // On GTK, bounds change is asynchronous. 1115 // On GTK, bounds change is asynchronous.
1113 MessageLoop::current()->RunAllPending(); 1116 MessageLoop::current()->RunAllPending();
1114 1117
1115 EnsureFindBoxOpenForBrowser(popup); 1118 EnsureFindBoxOpenForBrowser(popup);
1116 1119
1117 // GTK adjusts FindBar size asynchronously. 1120 // GTK adjusts FindBar size asynchronously.
1118 MessageLoop::current()->RunAllPending(); 1121 MessageLoop::current()->RunAllPending();
1119 1122
1120 ASSERT_LE(GetFindBarWidthForBrowser(popup), 1123 ASSERT_LE(GetFindBarWidthForBrowser(popup),
1121 popup->window()->GetBounds().width()); 1124 popup->window()->GetBounds().width());
1122 } 1125 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698