OLD | NEW |
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 Loading... |
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())); |
584 browser()->Reload(CURRENT_TAB); | 588 browser()->Reload(CURRENT_TAB); |
585 ui_test_utils::WaitForNavigationInCurrentTab(browser()); | 589 observer.Wait(); |
586 | 590 |
587 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); | 591 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); |
588 EXPECT_TRUE(fully_visible); | 592 EXPECT_TRUE(fully_visible); |
589 | 593 |
590 // Navigate and make sure the Find window goes away. | 594 // Navigate and make sure the Find window goes away. |
591 ui_test_utils::NavigateToURL(browser(), url2); | 595 ui_test_utils::NavigateToURL(browser(), url2); |
592 | 596 |
593 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); | 597 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); |
594 EXPECT_FALSE(fully_visible); | 598 EXPECT_FALSE(fully_visible); |
595 } | 599 } |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 EnsureFindBoxOpenForBrowser(browser()); | 1045 EnsureFindBoxOpenForBrowser(browser()); |
1042 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(browser())); | 1046 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(browser())); |
1043 | 1047 |
1044 // Close the Find box. | 1048 // Close the Find box. |
1045 browser()->GetFindBarController()->EndFindSession( | 1049 browser()->GetFindBarController()->EndFindSession( |
1046 FindBarController::kKeepSelection); | 1050 FindBarController::kKeepSelection); |
1047 | 1051 |
1048 // Open a new incognito window and navigate to the same page. | 1052 // Open a new incognito window and navigate to the same page. |
1049 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); | 1053 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); |
1050 Browser* incognito_browser = Browser::Create(incognito_profile); | 1054 Browser* incognito_browser = Browser::Create(incognito_profile); |
| 1055 ui_test_utils::WindowedNotificationObserver observer( |
| 1056 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
1051 incognito_browser->AddSelectedTabWithURL(url, PageTransition::START_PAGE); | 1057 incognito_browser->AddSelectedTabWithURL(url, PageTransition::START_PAGE); |
1052 ui_test_utils::WaitForNavigation( | 1058 observer.Wait(); |
1053 &incognito_browser->GetSelectedTabContents()->controller()); | |
1054 incognito_browser->window()->Show(); | 1059 incognito_browser->window()->Show(); |
1055 | 1060 |
1056 // Open the find box and make sure that it is prepopulated with "page". | 1061 // Open the find box and make sure that it is prepopulated with "page". |
1057 EnsureFindBoxOpenForBrowser(incognito_browser); | 1062 EnsureFindBoxOpenForBrowser(incognito_browser); |
1058 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(incognito_browser)); | 1063 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(incognito_browser)); |
1059 | 1064 |
1060 // Search for the word "text" in the incognito tab. | 1065 // Search for the word "text" in the incognito tab. |
1061 TabContentsWrapper* incognito_tab = | 1066 TabContentsWrapper* incognito_tab = |
1062 incognito_browser->GetSelectedTabContentsWrapper(); | 1067 incognito_browser->GetSelectedTabContentsWrapper(); |
1063 EXPECT_EQ(1, FindInPageWchar(incognito_tab, L"text", | 1068 EXPECT_EQ(1, FindInPageWchar(incognito_tab, L"text", |
(...skipping 22 matching lines...) Expand all Loading... |
1086 // First we navigate to our test content. | 1091 // First we navigate to our test content. |
1087 GURL url = test_server()->GetURL(kLinkPage); | 1092 GURL url = test_server()->GetURL(kLinkPage); |
1088 ui_test_utils::NavigateToURL(browser(), url); | 1093 ui_test_utils::NavigateToURL(browser(), url); |
1089 | 1094 |
1090 TabContentsWrapper* tab = browser()->GetSelectedTabContentsWrapper(); | 1095 TabContentsWrapper* tab = browser()->GetSelectedTabContentsWrapper(); |
1091 int ordinal = 0; | 1096 int ordinal = 0; |
1092 FindInPageWchar(tab, L"link", kFwd, kIgnoreCase, &ordinal); | 1097 FindInPageWchar(tab, L"link", kFwd, kIgnoreCase, &ordinal); |
1093 EXPECT_EQ(ordinal, 1); | 1098 EXPECT_EQ(ordinal, 1); |
1094 | 1099 |
1095 // End the find session, click on the link. | 1100 // End the find session, click on the link. |
| 1101 ui_test_utils::WindowedNotificationObserver observer( |
| 1102 content::NOTIFICATION_LOAD_STOP, |
| 1103 Source<NavigationController>(&tab->controller())); |
1096 tab->find_tab_helper()->StopFinding(FindBarController::kActivateSelection); | 1104 tab->find_tab_helper()->StopFinding(FindBarController::kActivateSelection); |
1097 EXPECT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); | 1105 observer.Wait(); |
1098 } | 1106 } |
1099 | 1107 |
1100 // Tests that FindBar fits within a narrow browser window. | 1108 // Tests that FindBar fits within a narrow browser window. |
1101 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FitWindow) { | 1109 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FitWindow) { |
1102 Browser::CreateParams params(Browser::TYPE_POPUP, browser()->profile()); | 1110 Browser::CreateParams params(Browser::TYPE_POPUP, browser()->profile()); |
1103 params.initial_bounds = gfx::Rect(0, 0, 250, 500); | 1111 params.initial_bounds = gfx::Rect(0, 0, 250, 500); |
1104 Browser* popup = Browser::CreateWithParams(params); | 1112 Browser* popup = Browser::CreateWithParams(params); |
| 1113 ui_test_utils::WindowedNotificationObserver observer( |
| 1114 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
1105 popup->AddSelectedTabWithURL(GURL(chrome::kAboutBlankURL), | 1115 popup->AddSelectedTabWithURL(GURL(chrome::kAboutBlankURL), |
1106 PageTransition::LINK); | 1116 PageTransition::LINK); |
1107 | |
1108 // Wait for the page to finish loading. | 1117 // Wait for the page to finish loading. |
1109 ui_test_utils::WaitForNavigation( | 1118 observer.Wait(); |
1110 &popup->GetSelectedTabContents()->controller()); | |
1111 popup->window()->Show(); | 1119 popup->window()->Show(); |
1112 | 1120 |
1113 // On GTK, bounds change is asynchronous. | 1121 // On GTK, bounds change is asynchronous. |
1114 MessageLoop::current()->RunAllPending(); | 1122 MessageLoop::current()->RunAllPending(); |
1115 | 1123 |
1116 EnsureFindBoxOpenForBrowser(popup); | 1124 EnsureFindBoxOpenForBrowser(popup); |
1117 | 1125 |
1118 // GTK adjusts FindBar size asynchronously. | 1126 // GTK adjusts FindBar size asynchronously. |
1119 MessageLoop::current()->RunAllPending(); | 1127 MessageLoop::current()->RunAllPending(); |
1120 | 1128 |
1121 ASSERT_LE(GetFindBarWidthForBrowser(popup), | 1129 ASSERT_LE(GetFindBarWidthForBrowser(popup), |
1122 popup->window()->GetBounds().width()); | 1130 popup->window()->GetBounds().width()); |
1123 } | 1131 } |
OLD | NEW |