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

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

Issue 7633032: Revert 96593 - Fix up various browser tests not to use WaitForNavigation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 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
« no previous file with comments | « chrome/browser/ssl/ssl_browser_tests.cc ('k') | chrome/test/base/ui_test_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 browser()->ShowFindBar(); 574 browser()->ShowFindBar();
575 575
576 gfx::Point position; 576 gfx::Point position;
577 bool fully_visible = false; 577 bool fully_visible = false;
578 578
579 // Make sure it is open. 579 // Make sure it is open.
580 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); 580 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
581 EXPECT_TRUE(fully_visible); 581 EXPECT_TRUE(fully_visible);
582 582
583 // Reload the tab and make sure Find window doesn't go away. 583 // Reload the tab and make sure Find window doesn't go away.
584 ui_test_utils::WindowedNotificationObserver observer(
585 content::NOTIFICATION_LOAD_STOP,
586 Source<NavigationController>(
587 &browser()->GetSelectedTabContentsWrapper()->controller()));
588 browser()->Reload(CURRENT_TAB); 584 browser()->Reload(CURRENT_TAB);
589 observer.Wait(); 585 ui_test_utils::WaitForNavigationInCurrentTab(browser());
590 586
591 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); 587 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
592 EXPECT_TRUE(fully_visible); 588 EXPECT_TRUE(fully_visible);
593 589
594 // Navigate and make sure the Find window goes away. 590 // Navigate and make sure the Find window goes away.
595 ui_test_utils::NavigateToURL(browser(), url2); 591 ui_test_utils::NavigateToURL(browser(), url2);
596 592
597 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); 593 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
598 EXPECT_FALSE(fully_visible); 594 EXPECT_FALSE(fully_visible);
599 } 595 }
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 EnsureFindBoxOpenForBrowser(browser()); 1041 EnsureFindBoxOpenForBrowser(browser());
1046 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(browser())); 1042 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(browser()));
1047 1043
1048 // Close the Find box. 1044 // Close the Find box.
1049 browser()->GetFindBarController()->EndFindSession( 1045 browser()->GetFindBarController()->EndFindSession(
1050 FindBarController::kKeepSelection); 1046 FindBarController::kKeepSelection);
1051 1047
1052 // Open a new incognito window and navigate to the same page. 1048 // Open a new incognito window and navigate to the same page.
1053 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); 1049 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile();
1054 Browser* incognito_browser = Browser::Create(incognito_profile); 1050 Browser* incognito_browser = Browser::Create(incognito_profile);
1055 ui_test_utils::WindowedNotificationObserver observer(
1056 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources());
1057 incognito_browser->AddSelectedTabWithURL(url, PageTransition::START_PAGE); 1051 incognito_browser->AddSelectedTabWithURL(url, PageTransition::START_PAGE);
1058 observer.Wait(); 1052 ui_test_utils::WaitForNavigation(
1053 &incognito_browser->GetSelectedTabContents()->controller());
1059 incognito_browser->window()->Show(); 1054 incognito_browser->window()->Show();
1060 1055
1061 // Open the find box and make sure that it is prepopulated with "page". 1056 // Open the find box and make sure that it is prepopulated with "page".
1062 EnsureFindBoxOpenForBrowser(incognito_browser); 1057 EnsureFindBoxOpenForBrowser(incognito_browser);
1063 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(incognito_browser)); 1058 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(incognito_browser));
1064 1059
1065 // Search for the word "text" in the incognito tab. 1060 // Search for the word "text" in the incognito tab.
1066 TabContentsWrapper* incognito_tab = 1061 TabContentsWrapper* incognito_tab =
1067 incognito_browser->GetSelectedTabContentsWrapper(); 1062 incognito_browser->GetSelectedTabContentsWrapper();
1068 EXPECT_EQ(1, FindInPageWchar(incognito_tab, L"text", 1063 EXPECT_EQ(1, FindInPageWchar(incognito_tab, L"text",
(...skipping 22 matching lines...) Expand all
1091 // First we navigate to our test content. 1086 // First we navigate to our test content.
1092 GURL url = test_server()->GetURL(kLinkPage); 1087 GURL url = test_server()->GetURL(kLinkPage);
1093 ui_test_utils::NavigateToURL(browser(), url); 1088 ui_test_utils::NavigateToURL(browser(), url);
1094 1089
1095 TabContentsWrapper* tab = browser()->GetSelectedTabContentsWrapper(); 1090 TabContentsWrapper* tab = browser()->GetSelectedTabContentsWrapper();
1096 int ordinal = 0; 1091 int ordinal = 0;
1097 FindInPageWchar(tab, L"link", kFwd, kIgnoreCase, &ordinal); 1092 FindInPageWchar(tab, L"link", kFwd, kIgnoreCase, &ordinal);
1098 EXPECT_EQ(ordinal, 1); 1093 EXPECT_EQ(ordinal, 1);
1099 1094
1100 // End the find session, click on the link. 1095 // End the find session, click on the link.
1101 ui_test_utils::WindowedNotificationObserver observer(
1102 content::NOTIFICATION_LOAD_STOP,
1103 Source<NavigationController>(&tab->controller()));
1104 tab->find_tab_helper()->StopFinding(FindBarController::kActivateSelection); 1096 tab->find_tab_helper()->StopFinding(FindBarController::kActivateSelection);
1105 observer.Wait(); 1097 EXPECT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
1106 } 1098 }
1107 1099
1108 // Tests that FindBar fits within a narrow browser window. 1100 // Tests that FindBar fits within a narrow browser window.
1109 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FitWindow) { 1101 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FitWindow) {
1110 Browser::CreateParams params(Browser::TYPE_POPUP, browser()->profile()); 1102 Browser::CreateParams params(Browser::TYPE_POPUP, browser()->profile());
1111 params.initial_bounds = gfx::Rect(0, 0, 250, 500); 1103 params.initial_bounds = gfx::Rect(0, 0, 250, 500);
1112 Browser* popup = Browser::CreateWithParams(params); 1104 Browser* popup = Browser::CreateWithParams(params);
1113 ui_test_utils::WindowedNotificationObserver observer(
1114 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources());
1115 popup->AddSelectedTabWithURL(GURL(chrome::kAboutBlankURL), 1105 popup->AddSelectedTabWithURL(GURL(chrome::kAboutBlankURL),
1116 PageTransition::LINK); 1106 PageTransition::LINK);
1107
1117 // Wait for the page to finish loading. 1108 // Wait for the page to finish loading.
1118 observer.Wait(); 1109 ui_test_utils::WaitForNavigation(
1110 &popup->GetSelectedTabContents()->controller());
1119 popup->window()->Show(); 1111 popup->window()->Show();
1120 1112
1121 // On GTK, bounds change is asynchronous. 1113 // On GTK, bounds change is asynchronous.
1122 MessageLoop::current()->RunAllPending(); 1114 MessageLoop::current()->RunAllPending();
1123 1115
1124 EnsureFindBoxOpenForBrowser(popup); 1116 EnsureFindBoxOpenForBrowser(popup);
1125 1117
1126 // GTK adjusts FindBar size asynchronously. 1118 // GTK adjusts FindBar size asynchronously.
1127 MessageLoop::current()->RunAllPending(); 1119 MessageLoop::current()->RunAllPending();
1128 1120
1129 ASSERT_LE(GetFindBarWidthForBrowser(popup), 1121 ASSERT_LE(GetFindBarWidthForBrowser(popup),
1130 popup->window()->GetBounds().width()); 1122 popup->window()->GetBounds().width());
1131 } 1123 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_browser_tests.cc ('k') | chrome/test/base/ui_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698