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

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

Issue 8892011: Clean up TCW, make it solely a hub for 1:1 observer/helper objects. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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/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/tabs/tab_strip_model.h" 10 #include "chrome/browser/tabs/tab_strip_model.h"
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 ASSERT_TRUE(FocusedOnPage(tab_contents->tab_contents(), &result)); 264 ASSERT_TRUE(FocusedOnPage(tab_contents->tab_contents(), &result));
265 EXPECT_STREQ("link1", result.c_str()); 265 EXPECT_STREQ("link1", result.c_str());
266 266
267 // Search for a text that exists within a link on the page. 267 // Search for a text that exists within a link on the page.
268 EXPECT_EQ(1, FindInPageWchar(tab_contents, L"Google", 268 EXPECT_EQ(1, FindInPageWchar(tab_contents, L"Google",
269 kFwd, kIgnoreCase, &ordinal)); 269 kFwd, kIgnoreCase, &ordinal));
270 EXPECT_EQ(1, ordinal); 270 EXPECT_EQ(1, ordinal);
271 271
272 // Move the selection to link 1, after searching. 272 // Move the selection to link 1, after searching.
273 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( 273 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString(
274 tab_contents->render_view_host(), 274 tab_contents->tab_contents()->render_view_host(),
275 L"", 275 L"",
276 L"window.domAutomationController.send(selectLink1());", 276 L"window.domAutomationController.send(selectLink1());",
277 &result)); 277 &result));
278 278
279 // End the find session. 279 // End the find session.
280 tab_contents-> 280 tab_contents->
281 find_tab_helper()->StopFinding(FindBarController::kKeepSelection); 281 find_tab_helper()->StopFinding(FindBarController::kKeepSelection);
282 282
283 // Verify that link2 is not focused. 283 // Verify that link2 is not focused.
284 ASSERT_TRUE(FocusedOnPage(tab_contents->tab_contents(), &result)); 284 ASSERT_TRUE(FocusedOnPage(tab_contents->tab_contents(), &result));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 ASSERT_TRUE(NULL != tab); 338 ASSERT_TRUE(NULL != tab);
339 int ordinal = 0; 339 int ordinal = 0;
340 EXPECT_EQ(4, FindInPageWchar(tab, 340 EXPECT_EQ(4, FindInPageWchar(tab,
341 L"google", 341 L"google",
342 kFwd, kIgnoreCase, &ordinal)); 342 kFwd, kIgnoreCase, &ordinal));
343 EXPECT_EQ(1, ordinal); 343 EXPECT_EQ(1, ordinal);
344 344
345 // Move the selection to link 1, after searching. 345 // Move the selection to link 1, after searching.
346 std::string result; 346 std::string result;
347 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( 347 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString(
348 tab->render_view_host(), 348 tab->tab_contents()->render_view_host(),
349 L"", 349 L"",
350 L"window.domAutomationController.send(selectLink1());", 350 L"window.domAutomationController.send(selectLink1());",
351 &result)); 351 &result));
352 352
353 // Do a find-next after the selection. This should move forward 353 // Do a find-next after the selection. This should move forward
354 // from there to the 3rd instance of 'google'. 354 // from there to the 3rd instance of 'google'.
355 EXPECT_EQ(4, FindInPageWchar(tab, 355 EXPECT_EQ(4, FindInPageWchar(tab,
356 L"google", 356 L"google",
357 kFwd, kIgnoreCase, &ordinal)); 357 kFwd, kIgnoreCase, &ordinal));
358 EXPECT_EQ(3, ordinal); 358 EXPECT_EQ(3, ordinal);
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 bool fully_visible = false; 581 bool fully_visible = false;
582 582
583 // Make sure it is open. 583 // Make sure it is open.
584 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); 584 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
585 EXPECT_TRUE(fully_visible); 585 EXPECT_TRUE(fully_visible);
586 586
587 // Reload the tab and make sure Find window doesn't go away. 587 // Reload the tab and make sure Find window doesn't go away.
588 ui_test_utils::WindowedNotificationObserver observer( 588 ui_test_utils::WindowedNotificationObserver observer(
589 content::NOTIFICATION_LOAD_STOP, 589 content::NOTIFICATION_LOAD_STOP,
590 content::Source<NavigationController>( 590 content::Source<NavigationController>(
591 &browser()->GetSelectedTabContentsWrapper()->controller())); 591 &browser()->GetSelectedTabContentsWrapper()->tab_contents()->
592 controller()));
592 browser()->Reload(CURRENT_TAB); 593 browser()->Reload(CURRENT_TAB);
593 observer.Wait(); 594 observer.Wait();
594 595
595 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); 596 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
596 EXPECT_TRUE(fully_visible); 597 EXPECT_TRUE(fully_visible);
597 598
598 // Navigate and make sure the Find window goes away. 599 // Navigate and make sure the Find window goes away.
599 ui_test_utils::NavigateToURL(browser(), url2); 600 ui_test_utils::NavigateToURL(browser(), url2);
600 601
601 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); 602 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 ui_test_utils::NavigateToURL(browser(), url); 1107 ui_test_utils::NavigateToURL(browser(), url);
1107 1108
1108 TabContentsWrapper* tab = browser()->GetSelectedTabContentsWrapper(); 1109 TabContentsWrapper* tab = browser()->GetSelectedTabContentsWrapper();
1109 int ordinal = 0; 1110 int ordinal = 0;
1110 FindInPageWchar(tab, L"link", kFwd, kIgnoreCase, &ordinal); 1111 FindInPageWchar(tab, L"link", kFwd, kIgnoreCase, &ordinal);
1111 EXPECT_EQ(ordinal, 1); 1112 EXPECT_EQ(ordinal, 1);
1112 1113
1113 // End the find session, click on the link. 1114 // End the find session, click on the link.
1114 ui_test_utils::WindowedNotificationObserver observer( 1115 ui_test_utils::WindowedNotificationObserver observer(
1115 content::NOTIFICATION_LOAD_STOP, 1116 content::NOTIFICATION_LOAD_STOP,
1116 content::Source<NavigationController>(&tab->controller())); 1117 content::Source<NavigationController>(
1118 &tab->tab_contents()->controller()));
1117 tab->find_tab_helper()->StopFinding(FindBarController::kActivateSelection); 1119 tab->find_tab_helper()->StopFinding(FindBarController::kActivateSelection);
1118 observer.Wait(); 1120 observer.Wait();
1119 } 1121 }
1120 1122
1121 // Tests that FindBar fits within a narrow browser window. 1123 // Tests that FindBar fits within a narrow browser window.
1122 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FitWindow) { 1124 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FitWindow) {
1123 Browser::CreateParams params(Browser::TYPE_POPUP, browser()->profile()); 1125 Browser::CreateParams params(Browser::TYPE_POPUP, browser()->profile());
1124 params.initial_bounds = gfx::Rect(0, 0, 250, 500); 1126 params.initial_bounds = gfx::Rect(0, 0, 250, 500);
1125 Browser* popup = Browser::CreateWithParams(params); 1127 Browser* popup = Browser::CreateWithParams(params);
1126 ui_test_utils::WindowedNotificationObserver observer( 1128 ui_test_utils::WindowedNotificationObserver observer(
1127 content::NOTIFICATION_LOAD_STOP, 1129 content::NOTIFICATION_LOAD_STOP,
1128 content::NotificationService::AllSources()); 1130 content::NotificationService::AllSources());
1129 popup->AddSelectedTabWithURL(GURL(chrome::kAboutBlankURL), 1131 popup->AddSelectedTabWithURL(GURL(chrome::kAboutBlankURL),
1130 content::PAGE_TRANSITION_LINK); 1132 content::PAGE_TRANSITION_LINK);
1131 // Wait for the page to finish loading. 1133 // Wait for the page to finish loading.
1132 observer.Wait(); 1134 observer.Wait();
1133 popup->window()->Show(); 1135 popup->window()->Show();
1134 1136
1135 // On GTK, bounds change is asynchronous. 1137 // On GTK, bounds change is asynchronous.
1136 MessageLoop::current()->RunAllPending(); 1138 MessageLoop::current()->RunAllPending();
1137 1139
1138 EnsureFindBoxOpenForBrowser(popup); 1140 EnsureFindBoxOpenForBrowser(popup);
1139 1141
1140 // GTK adjusts FindBar size asynchronously. 1142 // GTK adjusts FindBar size asynchronously.
1141 MessageLoop::current()->RunAllPending(); 1143 MessageLoop::current()->RunAllPending();
1142 1144
1143 ASSERT_LE(GetFindBarWidthForBrowser(popup), 1145 ASSERT_LE(GetFindBarWidthForBrowser(popup),
1144 popup->window()->GetBounds().width()); 1146 popup->window()->GetBounds().width());
1145 } 1147 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/find_bar/find_bar_controller.cc ('k') | chrome/browser/ui/fullscreen_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698