| 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" |
| 11 #include "chrome/browser/ui/browser_navigator.h" | 11 #include "chrome/browser/ui/browser_navigator.h" |
| 12 #include "chrome/browser/ui/browser_window.h" | 12 #include "chrome/browser/ui/browser_window.h" |
| 13 #include "chrome/browser/ui/find_bar/find_bar.h" | 13 #include "chrome/browser/ui/find_bar/find_bar.h" |
| 14 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 14 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| 15 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 15 #include "chrome/browser/ui/find_bar/find_notification_details.h" |
| 16 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 16 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
| 17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 18 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| 19 #include "chrome/test/base/in_process_browser_test.h" | 19 #include "chrome/test/base/in_process_browser_test.h" |
| 20 #include "chrome/test/base/ui_test_utils.h" | 20 #include "chrome/test/base/ui_test_utils.h" |
| 21 #include "content/browser/renderer_host/render_view_host.h" | 21 #include "content/browser/renderer_host/render_view_host.h" |
| 22 #include "content/browser/tab_contents/tab_contents.h" | 22 #include "content/browser/tab_contents/tab_contents.h" |
| 23 #include "content/browser/tab_contents/tab_contents_view.h" | 23 #include "content/browser/tab_contents/tab_contents_view.h" |
| 24 #include "content/public/browser/notification_service.h" |
| 24 #include "content/public/browser/notification_types.h" | 25 #include "content/public/browser/notification_types.h" |
| 25 #include "net/test/test_server.h" | 26 #include "net/test/test_server.h" |
| 26 #include "ui/base/keycodes/keyboard_codes.h" | 27 #include "ui/base/keycodes/keyboard_codes.h" |
| 27 | 28 |
| 28 #if defined(TOOLKIT_VIEWS) | 29 #if defined(TOOLKIT_VIEWS) |
| 29 #include "chrome/browser/ui/views/find_bar_host.h" | 30 #include "chrome/browser/ui/views/find_bar_host.h" |
| 30 #include "views/focus/focus_manager.h" | 31 #include "views/focus/focus_manager.h" |
| 31 #include "views/widget/widget.h" | 32 #include "views/widget/widget.h" |
| 32 #elif defined(TOOLKIT_GTK) | 33 #elif defined(TOOLKIT_GTK) |
| 33 #include "chrome/browser/ui/gtk/slide_animator_gtk.h" | 34 #include "chrome/browser/ui/gtk/slide_animator_gtk.h" |
| (...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(browser())); | 1055 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(browser())); |
| 1055 | 1056 |
| 1056 // Close the Find box. | 1057 // Close the Find box. |
| 1057 browser()->GetFindBarController()->EndFindSession( | 1058 browser()->GetFindBarController()->EndFindSession( |
| 1058 FindBarController::kKeepSelection); | 1059 FindBarController::kKeepSelection); |
| 1059 | 1060 |
| 1060 // Open a new incognito window and navigate to the same page. | 1061 // Open a new incognito window and navigate to the same page. |
| 1061 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); | 1062 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); |
| 1062 Browser* incognito_browser = Browser::Create(incognito_profile); | 1063 Browser* incognito_browser = Browser::Create(incognito_profile); |
| 1063 ui_test_utils::WindowedNotificationObserver observer( | 1064 ui_test_utils::WindowedNotificationObserver observer( |
| 1064 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); | 1065 content::NOTIFICATION_LOAD_STOP, |
| 1066 content::NotificationService::AllSources()); |
| 1065 incognito_browser->AddSelectedTabWithURL( | 1067 incognito_browser->AddSelectedTabWithURL( |
| 1066 url, content::PAGE_TRANSITION_START_PAGE); | 1068 url, content::PAGE_TRANSITION_START_PAGE); |
| 1067 observer.Wait(); | 1069 observer.Wait(); |
| 1068 incognito_browser->window()->Show(); | 1070 incognito_browser->window()->Show(); |
| 1069 | 1071 |
| 1070 // Open the find box and make sure that it is prepopulated with "page". | 1072 // Open the find box and make sure that it is prepopulated with "page". |
| 1071 EnsureFindBoxOpenForBrowser(incognito_browser); | 1073 EnsureFindBoxOpenForBrowser(incognito_browser); |
| 1072 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(incognito_browser)); | 1074 EXPECT_EQ(ASCIIToUTF16("page"), GetFindBarTextForBrowser(incognito_browser)); |
| 1073 | 1075 |
| 1074 // Search for the word "text" in the incognito tab. | 1076 // Search for the word "text" in the incognito tab. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 tab->find_tab_helper()->StopFinding(FindBarController::kActivateSelection); | 1115 tab->find_tab_helper()->StopFinding(FindBarController::kActivateSelection); |
| 1114 observer.Wait(); | 1116 observer.Wait(); |
| 1115 } | 1117 } |
| 1116 | 1118 |
| 1117 // Tests that FindBar fits within a narrow browser window. | 1119 // Tests that FindBar fits within a narrow browser window. |
| 1118 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FitWindow) { | 1120 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FitWindow) { |
| 1119 Browser::CreateParams params(Browser::TYPE_POPUP, browser()->profile()); | 1121 Browser::CreateParams params(Browser::TYPE_POPUP, browser()->profile()); |
| 1120 params.initial_bounds = gfx::Rect(0, 0, 250, 500); | 1122 params.initial_bounds = gfx::Rect(0, 0, 250, 500); |
| 1121 Browser* popup = Browser::CreateWithParams(params); | 1123 Browser* popup = Browser::CreateWithParams(params); |
| 1122 ui_test_utils::WindowedNotificationObserver observer( | 1124 ui_test_utils::WindowedNotificationObserver observer( |
| 1123 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); | 1125 content::NOTIFICATION_LOAD_STOP, |
| 1126 content::NotificationService::AllSources()); |
| 1124 popup->AddSelectedTabWithURL(GURL(chrome::kAboutBlankURL), | 1127 popup->AddSelectedTabWithURL(GURL(chrome::kAboutBlankURL), |
| 1125 content::PAGE_TRANSITION_LINK); | 1128 content::PAGE_TRANSITION_LINK); |
| 1126 // Wait for the page to finish loading. | 1129 // Wait for the page to finish loading. |
| 1127 observer.Wait(); | 1130 observer.Wait(); |
| 1128 popup->window()->Show(); | 1131 popup->window()->Show(); |
| 1129 | 1132 |
| 1130 // On GTK, bounds change is asynchronous. | 1133 // On GTK, bounds change is asynchronous. |
| 1131 MessageLoop::current()->RunAllPending(); | 1134 MessageLoop::current()->RunAllPending(); |
| 1132 | 1135 |
| 1133 EnsureFindBoxOpenForBrowser(popup); | 1136 EnsureFindBoxOpenForBrowser(popup); |
| 1134 | 1137 |
| 1135 // GTK adjusts FindBar size asynchronously. | 1138 // GTK adjusts FindBar size asynchronously. |
| 1136 MessageLoop::current()->RunAllPending(); | 1139 MessageLoop::current()->RunAllPending(); |
| 1137 | 1140 |
| 1138 ASSERT_LE(GetFindBarWidthForBrowser(popup), | 1141 ASSERT_LE(GetFindBarWidthForBrowser(popup), |
| 1139 popup->window()->GetBounds().width()); | 1142 popup->window()->GetBounds().width()); |
| 1140 } | 1143 } |
| OLD | NEW |