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

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

Issue 7063003: Make FindBar obey dialog bounds for GTK. Will fix other platforms in separate patches. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Switched to container_->allocation.width Created 9 years, 7 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
« no previous file with comments | « chrome/browser/ui/find_bar/find_bar.h ('k') | chrome/browser/ui/gtk/find_bar_gtk.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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/test/in_process_browser_test.h" 19 #include "chrome/test/in_process_browser_test.h"
19 #include "chrome/test/ui_test_utils.h" 20 #include "chrome/test/ui_test_utils.h"
20 #include "content/browser/renderer_host/render_view_host.h" 21 #include "content/browser/renderer_host/render_view_host.h"
21 #include "content/browser/tab_contents/tab_contents.h" 22 #include "content/browser/tab_contents/tab_contents.h"
22 #include "content/browser/tab_contents/tab_contents_view.h" 23 #include "content/browser/tab_contents/tab_contents_view.h"
23 #include "net/test/test_server.h" 24 #include "net/test/test_server.h"
24 #include "ui/base/keycodes/keyboard_codes.h" 25 #include "ui/base/keycodes/keyboard_codes.h"
25 26
26 #if defined(TOOLKIT_VIEWS) 27 #if defined(TOOLKIT_VIEWS)
27 #include "chrome/browser/ui/views/find_bar_host.h" 28 #include "chrome/browser/ui/views/find_bar_host.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 browser->GetFindBarController()->find_bar()->GetFindBarTesting(); 88 browser->GetFindBarController()->find_bar()->GetFindBarTesting();
88 return find_bar->GetFindText(); 89 return find_bar->GetFindText();
89 } 90 }
90 91
91 string16 GetFindBarText() { 92 string16 GetFindBarText() {
92 return GetFindBarTextForBrowser(browser()); 93 return GetFindBarTextForBrowser(browser());
93 } 94 }
94 95
95 string16 GetFindBarMatchCountTextForBrowser(Browser* browser) { 96 string16 GetFindBarMatchCountTextForBrowser(Browser* browser) {
96 FindBarTesting* find_bar = 97 FindBarTesting* find_bar =
97 browser->GetFindBarController()->find_bar()->GetFindBarTesting(); 98 browser->GetFindBarController()->find_bar()->GetFindBarTesting();
98 return find_bar->GetMatchCountText(); 99 return find_bar->GetMatchCountText();
99 } 100 }
100 101
101 string16 GetMatchCountText() { 102 string16 GetMatchCountText() {
102 return GetFindBarMatchCountTextForBrowser(browser()); 103 return GetFindBarMatchCountTextForBrowser(browser());
103 } 104 }
104 105
106 int GetFindBarWidthForBrowser(Browser* browser) {
107 FindBarTesting* find_bar =
108 browser->GetFindBarController()->find_bar()->GetFindBarTesting();
109 return find_bar->GetWidth();
110 }
111
105 void EnsureFindBoxOpenForBrowser(Browser* browser) { 112 void EnsureFindBoxOpenForBrowser(Browser* browser) {
106 browser->ShowFindBar(); 113 browser->ShowFindBar();
107 gfx::Point position; 114 gfx::Point position;
108 bool fully_visible = false; 115 bool fully_visible = false;
109 EXPECT_TRUE(GetFindBarWindowInfoForBrowser( 116 EXPECT_TRUE(GetFindBarWindowInfoForBrowser(
110 browser, &position, &fully_visible)); 117 browser, &position, &fully_visible));
111 EXPECT_TRUE(fully_visible); 118 EXPECT_TRUE(fully_visible);
112 } 119 }
113 120
114 void EnsureFindBoxOpen() { 121 void EnsureFindBoxOpen() {
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 1080
1074 TabContentsWrapper* tab = browser()->GetSelectedTabContentsWrapper(); 1081 TabContentsWrapper* tab = browser()->GetSelectedTabContentsWrapper();
1075 int ordinal = 0; 1082 int ordinal = 0;
1076 FindInPageWchar(tab, L"link", kFwd, kIgnoreCase, &ordinal); 1083 FindInPageWchar(tab, L"link", kFwd, kIgnoreCase, &ordinal);
1077 EXPECT_EQ(ordinal, 1); 1084 EXPECT_EQ(ordinal, 1);
1078 1085
1079 // End the find session, click on the link. 1086 // End the find session, click on the link.
1080 tab->find_tab_helper()->StopFinding(FindBarController::kActivateSelection); 1087 tab->find_tab_helper()->StopFinding(FindBarController::kActivateSelection);
1081 EXPECT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); 1088 EXPECT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
1082 } 1089 }
1090
1091 // Tests that FindBar fits within a narrow browser window.
1092 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FitWindow) {
1093 Browser::CreateParams params(Browser::TYPE_POPUP, browser()->profile());
1094 params.initial_bounds = gfx::Rect(0, 0, 250, 500);
1095 Browser* popup = Browser::CreateWithParams(params);
1096 popup->AddSelectedTabWithURL(GURL(chrome::kAboutBlankURL),
1097 PageTransition::LINK);
1098
1099 // Wait for the page to finish loading.
1100 ui_test_utils::WaitForNavigation(
1101 &popup->GetSelectedTabContents()->controller());
1102 popup->window()->Show();
1103
1104 // On GTK, bounds change is asynchronous.
1105 MessageLoop::current()->RunAllPending();
1106
1107 EnsureFindBoxOpenForBrowser(popup);
1108
1109 // GTK adjusts FindBar size asynchronously.
1110 MessageLoop::current()->RunAllPending();
1111
1112 ASSERT_LE(GetFindBarWidthForBrowser(popup),
1113 popup->window()->GetBounds().width());
1114 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/find_bar/find_bar.h ('k') | chrome/browser/ui/gtk/find_bar_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698