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

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

Issue 10807047: Create content\public\test\test_utils.h to hold common test classes that are used by unit and brows… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/string16.h" 6 #include "base/string16.h"
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 chrome::ShowFindBar(browser()); 628 chrome::ShowFindBar(browser());
629 629
630 gfx::Point position; 630 gfx::Point position;
631 bool fully_visible = false; 631 bool fully_visible = false;
632 632
633 // Make sure it is open. 633 // Make sure it is open.
634 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); 634 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
635 EXPECT_TRUE(fully_visible); 635 EXPECT_TRUE(fully_visible);
636 636
637 // Reload the tab and make sure Find window doesn't go away. 637 // Reload the tab and make sure Find window doesn't go away.
638 ui_test_utils::WindowedNotificationObserver observer( 638 content::WindowedNotificationObserver observer(
639 content::NOTIFICATION_LOAD_STOP, 639 content::NOTIFICATION_LOAD_STOP,
640 content::Source<NavigationController>( 640 content::Source<NavigationController>(
641 &chrome::GetActiveTabContents(browser())->web_contents()-> 641 &chrome::GetActiveTabContents(browser())->web_contents()->
642 GetController())); 642 GetController()));
643 chrome::Reload(browser(), CURRENT_TAB); 643 chrome::Reload(browser(), CURRENT_TAB);
644 observer.Wait(); 644 observer.Wait();
645 645
646 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); 646 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
647 EXPECT_TRUE(fully_visible); 647 EXPECT_TRUE(fully_visible);
648 648
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(browser())); 1120 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(browser()));
1121 1121
1122 // Close the Find box. 1122 // Close the Find box.
1123 browser()->GetFindBarController()->EndFindSession( 1123 browser()->GetFindBarController()->EndFindSession(
1124 FindBarController::kKeepSelectionOnPage, 1124 FindBarController::kKeepSelectionOnPage,
1125 FindBarController::kKeepResultsInFindBox); 1125 FindBarController::kKeepResultsInFindBox);
1126 1126
1127 // Open a new incognito window and navigate to the same page. 1127 // Open a new incognito window and navigate to the same page.
1128 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); 1128 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile();
1129 Browser* incognito_browser = Browser::Create(incognito_profile); 1129 Browser* incognito_browser = Browser::Create(incognito_profile);
1130 ui_test_utils::WindowedNotificationObserver observer( 1130 content::WindowedNotificationObserver observer(
1131 content::NOTIFICATION_LOAD_STOP, 1131 content::NOTIFICATION_LOAD_STOP,
1132 content::NotificationService::AllSources()); 1132 content::NotificationService::AllSources());
1133 chrome::AddSelectedTabWithURL(incognito_browser, url, 1133 chrome::AddSelectedTabWithURL(incognito_browser, url,
1134 content::PAGE_TRANSITION_START_PAGE); 1134 content::PAGE_TRANSITION_START_PAGE);
1135 observer.Wait(); 1135 observer.Wait();
1136 incognito_browser->window()->Show(); 1136 incognito_browser->window()->Show();
1137 1137
1138 // Open the find box and make sure that it is prepopulated with "page". 1138 // Open the find box and make sure that it is prepopulated with "page".
1139 EnsureFindBoxOpenForBrowser(incognito_browser); 1139 EnsureFindBoxOpenForBrowser(incognito_browser);
1140 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(incognito_browser)); 1140 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(incognito_browser));
(...skipping 25 matching lines...) Expand all
1166 // First we navigate to our test content. 1166 // First we navigate to our test content.
1167 GURL url = GetURL(kLinkPage); 1167 GURL url = GetURL(kLinkPage);
1168 ui_test_utils::NavigateToURL(browser(), url); 1168 ui_test_utils::NavigateToURL(browser(), url);
1169 1169
1170 TabContents* tab = chrome::GetActiveTabContents(browser()); 1170 TabContents* tab = chrome::GetActiveTabContents(browser());
1171 int ordinal = 0; 1171 int ordinal = 0;
1172 FindInPageWchar(tab, L"link", kFwd, kIgnoreCase, &ordinal); 1172 FindInPageWchar(tab, L"link", kFwd, kIgnoreCase, &ordinal);
1173 EXPECT_EQ(ordinal, 1); 1173 EXPECT_EQ(ordinal, 1);
1174 1174
1175 // End the find session, click on the link. 1175 // End the find session, click on the link.
1176 ui_test_utils::WindowedNotificationObserver observer( 1176 content::WindowedNotificationObserver observer(
1177 content::NOTIFICATION_LOAD_STOP, 1177 content::NOTIFICATION_LOAD_STOP,
1178 content::Source<NavigationController>( 1178 content::Source<NavigationController>(
1179 &tab->web_contents()->GetController())); 1179 &tab->web_contents()->GetController()));
1180 tab->find_tab_helper()->StopFinding( 1180 tab->find_tab_helper()->StopFinding(
1181 FindBarController::kActivateSelectionOnPage); 1181 FindBarController::kActivateSelectionOnPage);
1182 observer.Wait(); 1182 observer.Wait();
1183 } 1183 }
1184 1184
1185 // Tests that FindBar fits within a narrow browser window. 1185 // Tests that FindBar fits within a narrow browser window.
1186 // Flaky on Linux/GTK: http://crbug.com/136443. 1186 // Flaky on Linux/GTK: http://crbug.com/136443.
1187 #if defined(TOOLKIT_GTK) 1187 #if defined(TOOLKIT_GTK)
1188 #define MAYBE_FitWindow DISABLED_FitWindow 1188 #define MAYBE_FitWindow DISABLED_FitWindow
1189 #else 1189 #else
1190 #define MAYBE_FitWindow FitWindow 1190 #define MAYBE_FitWindow FitWindow
1191 #endif 1191 #endif
1192 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_FitWindow) { 1192 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_FitWindow) {
1193 Browser::CreateParams params(Browser::TYPE_POPUP, browser()->profile()); 1193 Browser::CreateParams params(Browser::TYPE_POPUP, browser()->profile());
1194 params.initial_bounds = gfx::Rect(0, 0, 250, 500); 1194 params.initial_bounds = gfx::Rect(0, 0, 250, 500);
1195 Browser* popup = Browser::CreateWithParams(params); 1195 Browser* popup = Browser::CreateWithParams(params);
1196 ui_test_utils::WindowedNotificationObserver observer( 1196 content::WindowedNotificationObserver observer(
1197 content::NOTIFICATION_LOAD_STOP, 1197 content::NOTIFICATION_LOAD_STOP,
1198 content::NotificationService::AllSources()); 1198 content::NotificationService::AllSources());
1199 chrome::AddSelectedTabWithURL(popup, GURL(chrome::kAboutBlankURL), 1199 chrome::AddSelectedTabWithURL(popup, GURL(chrome::kAboutBlankURL),
1200 content::PAGE_TRANSITION_LINK); 1200 content::PAGE_TRANSITION_LINK);
1201 // Wait for the page to finish loading. 1201 // Wait for the page to finish loading.
1202 observer.Wait(); 1202 observer.Wait();
1203 popup->window()->Show(); 1203 popup->window()->Show();
1204 1204
1205 // On GTK, bounds change is asynchronous. 1205 // On GTK, bounds change is asynchronous.
1206 MessageLoop::current()->RunAllPending(); 1206 MessageLoop::current()->RunAllPending();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 ui_test_utils::RunAllPendingInMessageLoop(); // Needed on Linux. 1250 ui_test_utils::RunAllPendingInMessageLoop(); // Needed on Linux.
1251 EXPECT_TRUE(GetFindBarWindowInfo(&position, NULL)); 1251 EXPECT_TRUE(GetFindBarWindowInfo(&position, NULL));
1252 1252
1253 ui_test_utils::NavigateToURLWithDisposition( 1253 ui_test_utils::NavigateToURLWithDisposition(
1254 browser(), url, NEW_FOREGROUND_TAB, 1254 browser(), url, NEW_FOREGROUND_TAB,
1255 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 1255 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
1256 chrome::CloseTab(browser()); 1256 chrome::CloseTab(browser());
1257 EXPECT_TRUE(GetFindBarWindowInfo(&position2, NULL)); 1257 EXPECT_TRUE(GetFindBarWindowInfo(&position2, NULL));
1258 EXPECT_EQ(position, position2); 1258 EXPECT_EQ(position, position2);
1259 } 1259 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698