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/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 20 matching lines...) Expand all Loading... |
31 #if defined(TOOLKIT_VIEWS) | 31 #if defined(TOOLKIT_VIEWS) |
32 #include "chrome/browser/ui/views/find_bar_host.h" | 32 #include "chrome/browser/ui/views/find_bar_host.h" |
33 #include "ui/views/focus/focus_manager.h" | 33 #include "ui/views/focus/focus_manager.h" |
34 #include "ui/views/widget/widget.h" | 34 #include "ui/views/widget/widget.h" |
35 #elif defined(TOOLKIT_GTK) | 35 #elif defined(TOOLKIT_GTK) |
36 #include "chrome/browser/ui/gtk/slide_animator_gtk.h" | 36 #include "chrome/browser/ui/gtk/slide_animator_gtk.h" |
37 #elif defined(OS_MACOSX) | 37 #elif defined(OS_MACOSX) |
38 #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" | 38 #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" |
39 #endif | 39 #endif |
40 | 40 |
| 41 using content::NavigationController; |
| 42 |
41 const std::string kSimplePage = "404_is_enough_for_us.html"; | 43 const std::string kSimplePage = "404_is_enough_for_us.html"; |
42 const std::string kFramePage = "files/find_in_page/frames.html"; | 44 const std::string kFramePage = "files/find_in_page/frames.html"; |
43 const std::string kFrameData = "files/find_in_page/framedata_general.html"; | 45 const std::string kFrameData = "files/find_in_page/framedata_general.html"; |
44 const std::string kUserSelectPage = "files/find_in_page/user-select.html"; | 46 const std::string kUserSelectPage = "files/find_in_page/user-select.html"; |
45 const std::string kCrashPage = "files/find_in_page/crash_1341577.html"; | 47 const std::string kCrashPage = "files/find_in_page/crash_1341577.html"; |
46 const std::string kTooFewMatchesPage = "files/find_in_page/bug_1155639.html"; | 48 const std::string kTooFewMatchesPage = "files/find_in_page/bug_1155639.html"; |
47 const std::string kLongTextareaPage = "files/find_in_page/large_textarea.html"; | 49 const std::string kLongTextareaPage = "files/find_in_page/large_textarea.html"; |
48 const std::string kEndState = "files/find_in_page/end_state.html"; | 50 const std::string kEndState = "files/find_in_page/end_state.html"; |
49 const std::string kPrematureEnd = "files/find_in_page/premature_end.html"; | 51 const std::string kPrematureEnd = "files/find_in_page/premature_end.html"; |
50 const std::string kMoveIfOver = "files/find_in_page/move_if_obscuring.html"; | 52 const std::string kMoveIfOver = "files/find_in_page/move_if_obscuring.html"; |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 gfx::Point position; | 582 gfx::Point position; |
581 bool fully_visible = false; | 583 bool fully_visible = false; |
582 | 584 |
583 // Make sure it is open. | 585 // Make sure it is open. |
584 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); | 586 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); |
585 EXPECT_TRUE(fully_visible); | 587 EXPECT_TRUE(fully_visible); |
586 | 588 |
587 // Reload the tab and make sure Find window doesn't go away. | 589 // Reload the tab and make sure Find window doesn't go away. |
588 ui_test_utils::WindowedNotificationObserver observer( | 590 ui_test_utils::WindowedNotificationObserver observer( |
589 content::NOTIFICATION_LOAD_STOP, | 591 content::NOTIFICATION_LOAD_STOP, |
590 content::Source<content::NavigationController>( | 592 content::Source<NavigationController>( |
591 &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> | 593 &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> |
592 GetController())); | 594 GetController())); |
593 browser()->Reload(CURRENT_TAB); | 595 browser()->Reload(CURRENT_TAB); |
594 observer.Wait(); | 596 observer.Wait(); |
595 | 597 |
596 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); | 598 EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); |
597 EXPECT_TRUE(fully_visible); | 599 EXPECT_TRUE(fully_visible); |
598 | 600 |
599 // Navigate and make sure the Find window goes away. | 601 // Navigate and make sure the Find window goes away. |
600 ui_test_utils::NavigateToURL(browser(), url2); | 602 ui_test_utils::NavigateToURL(browser(), url2); |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 ui_test_utils::NavigateToURL(browser(), url); | 1109 ui_test_utils::NavigateToURL(browser(), url); |
1108 | 1110 |
1109 TabContentsWrapper* tab = browser()->GetSelectedTabContentsWrapper(); | 1111 TabContentsWrapper* tab = browser()->GetSelectedTabContentsWrapper(); |
1110 int ordinal = 0; | 1112 int ordinal = 0; |
1111 FindInPageWchar(tab, L"link", kFwd, kIgnoreCase, &ordinal); | 1113 FindInPageWchar(tab, L"link", kFwd, kIgnoreCase, &ordinal); |
1112 EXPECT_EQ(ordinal, 1); | 1114 EXPECT_EQ(ordinal, 1); |
1113 | 1115 |
1114 // End the find session, click on the link. | 1116 // End the find session, click on the link. |
1115 ui_test_utils::WindowedNotificationObserver observer( | 1117 ui_test_utils::WindowedNotificationObserver observer( |
1116 content::NOTIFICATION_LOAD_STOP, | 1118 content::NOTIFICATION_LOAD_STOP, |
1117 content::Source<content::NavigationController>( | 1119 content::Source<NavigationController>( |
1118 &tab->tab_contents()->GetController())); | 1120 &tab->tab_contents()->GetController())); |
1119 tab->find_tab_helper()->StopFinding(FindBarController::kActivateSelection); | 1121 tab->find_tab_helper()->StopFinding(FindBarController::kActivateSelection); |
1120 observer.Wait(); | 1122 observer.Wait(); |
1121 } | 1123 } |
1122 | 1124 |
1123 // Tests that FindBar fits within a narrow browser window. | 1125 // Tests that FindBar fits within a narrow browser window. |
1124 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FitWindow) { | 1126 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FitWindow) { |
1125 Browser::CreateParams params(Browser::TYPE_POPUP, browser()->profile()); | 1127 Browser::CreateParams params(Browser::TYPE_POPUP, browser()->profile()); |
1126 params.initial_bounds = gfx::Rect(0, 0, 250, 500); | 1128 params.initial_bounds = gfx::Rect(0, 0, 250, 500); |
1127 Browser* popup = Browser::CreateWithParams(params); | 1129 Browser* popup = Browser::CreateWithParams(params); |
(...skipping 10 matching lines...) Expand all Loading... |
1138 MessageLoop::current()->RunAllPending(); | 1140 MessageLoop::current()->RunAllPending(); |
1139 | 1141 |
1140 EnsureFindBoxOpenForBrowser(popup); | 1142 EnsureFindBoxOpenForBrowser(popup); |
1141 | 1143 |
1142 // GTK adjusts FindBar size asynchronously. | 1144 // GTK adjusts FindBar size asynchronously. |
1143 MessageLoop::current()->RunAllPending(); | 1145 MessageLoop::current()->RunAllPending(); |
1144 | 1146 |
1145 ASSERT_LE(GetFindBarWidthForBrowser(popup), | 1147 ASSERT_LE(GetFindBarWidthForBrowser(popup), |
1146 popup->window()->GetBounds().width()); | 1148 popup->window()->GetBounds().width()); |
1147 } | 1149 } |
OLD | NEW |