summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/find_bar
diff options
context:
space:
mode:
authorjennb@chromium.org <jennb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-26 18:45:17 +0000
committerjennb@chromium.org <jennb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-26 18:45:17 +0000
commitb419e056c5446e75851711ee5f84e1889b024ccb (patch)
tree60944918b426cde36c242f6fcf39e9e4b9a59662 /chrome/browser/ui/find_bar
parent26b4b454ad7e293052c63bf899d1158b41abe964 (diff)
downloadchromium_src-b419e056c5446e75851711ee5f84e1889b024ccb.zip
chromium_src-b419e056c5446e75851711ee5f84e1889b024ccb.tar.gz
chromium_src-b419e056c5446e75851711ee5f84e1889b024ccb.tar.bz2
Test to verify that FindBar fits within narrow browser window.
BUG=None TEST=FindInPageControllerTest.FitWindow Review URL: http://codereview.chromium.org/7063003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86865 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/find_bar')
-rw-r--r--chrome/browser/ui/find_bar/find_bar.h5
-rw-r--r--chrome/browser/ui/find_bar/find_bar_host_browsertest.cc34
2 files changed, 37 insertions, 2 deletions
diff --git a/chrome/browser/ui/find_bar/find_bar.h b/chrome/browser/ui/find_bar/find_bar.h
index c8d0f15..c0a7a1c 100644
--- a/chrome/browser/ui/find_bar/find_bar.h
+++ b/chrome/browser/ui/find_bar/find_bar.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@@ -96,6 +96,9 @@ class FindBarTesting {
// Gets the match count text (ie. 1 of 3) visible in the Find box.
virtual string16 GetMatchCountText() = 0;
+
+ // Gets the pixel width of the FindBar.
+ virtual int GetWidth() = 0;
};
#endif // CHROME_BROWSER_UI_FIND_BAR_FIND_BAR_H_
diff --git a/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc b/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
index 30f2f70..921f577 100644
--- a/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
+++ b/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/ui/find_bar/find_notification_details.h"
#include "chrome/browser/ui/find_bar/find_tab_helper.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
+#include "chrome/common/url_constants.h"
#include "chrome/test/in_process_browser_test.h"
#include "chrome/test/ui_test_utils.h"
#include "content/browser/renderer_host/render_view_host.h"
@@ -94,7 +95,7 @@ class FindInPageControllerTest : public InProcessBrowserTest {
string16 GetFindBarMatchCountTextForBrowser(Browser* browser) {
FindBarTesting* find_bar =
- browser->GetFindBarController()->find_bar()->GetFindBarTesting();
+ browser->GetFindBarController()->find_bar()->GetFindBarTesting();
return find_bar->GetMatchCountText();
}
@@ -102,6 +103,12 @@ class FindInPageControllerTest : public InProcessBrowserTest {
return GetFindBarMatchCountTextForBrowser(browser());
}
+ int GetFindBarWidthForBrowser(Browser* browser) {
+ FindBarTesting* find_bar =
+ browser->GetFindBarController()->find_bar()->GetFindBarTesting();
+ return find_bar->GetWidth();
+ }
+
void EnsureFindBoxOpenForBrowser(Browser* browser) {
browser->ShowFindBar();
gfx::Point position;
@@ -1080,3 +1087,28 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, ActivateLinkNavigatesPage) {
tab->find_tab_helper()->StopFinding(FindBarController::kActivateSelection);
EXPECT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
}
+
+// Tests that FindBar fits within a narrow browser window.
+IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FitWindow) {
+ Browser::CreateParams params(Browser::TYPE_POPUP, browser()->profile());
+ params.initial_bounds = gfx::Rect(0, 0, 250, 500);
+ Browser* popup = Browser::CreateWithParams(params);
+ popup->AddSelectedTabWithURL(GURL(chrome::kAboutBlankURL),
+ PageTransition::LINK);
+
+ // Wait for the page to finish loading.
+ ui_test_utils::WaitForNavigation(
+ &popup->GetSelectedTabContents()->controller());
+ popup->window()->Show();
+
+ // On GTK, bounds change is asynchronous.
+ MessageLoop::current()->RunAllPending();
+
+ EnsureFindBoxOpenForBrowser(popup);
+
+ // GTK adjusts FindBar size asynchronously.
+ MessageLoop::current()->RunAllPending();
+
+ ASSERT_LE(GetFindBarWidthForBrowser(popup),
+ popup->window()->GetBounds().width());
+}