diff options
author | jennb@chromium.org <jennb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-26 18:45:17 +0000 |
---|---|---|
committer | jennb@chromium.org <jennb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-26 18:45:17 +0000 |
commit | b419e056c5446e75851711ee5f84e1889b024ccb (patch) | |
tree | 60944918b426cde36c242f6fcf39e9e4b9a59662 | |
parent | 26b4b454ad7e293052c63bf899d1158b41abe964 (diff) | |
download | chromium_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
-rw-r--r-- | chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h | 3 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/find_bar/find_bar_bridge.mm | 7 | ||||
-rw-r--r-- | chrome/browser/ui/find_bar/find_bar.h | 5 | ||||
-rw-r--r-- | chrome/browser/ui/find_bar/find_bar_host_browsertest.cc | 34 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/find_bar_gtk.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/find_bar_gtk.h | 1 | ||||
-rw-r--r-- | chrome/browser/ui/views/find_bar_host.cc | 5 | ||||
-rw-r--r-- | chrome/browser/ui/views/find_bar_host.h | 1 |
8 files changed, 56 insertions, 4 deletions
diff --git a/chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h b/chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h index fe0a39d..a88df5d 100644 --- a/chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h +++ b/chrome/browser/ui/cocoa/find_bar/find_bar_bridge.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. @@ -71,6 +71,7 @@ class FindBarBridge : public FindBar, virtual string16 GetFindText(); virtual string16 GetFindSelectedText(); virtual string16 GetMatchCountText(); + virtual int GetWidth(); // Used to disable find bar animations when testing. static bool disable_animations_during_testing_; diff --git a/chrome/browser/ui/cocoa/find_bar/find_bar_bridge.mm b/chrome/browser/ui/cocoa/find_bar/find_bar_bridge.mm index 2d44325..2ddb5ac 100644 --- a/chrome/browser/ui/cocoa/find_bar/find_bar_bridge.mm +++ b/chrome/browser/ui/cocoa/find_bar/find_bar_bridge.mm @@ -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. @@ -127,3 +127,8 @@ string16 FindBarBridge::GetMatchCountText() { NOTIMPLEMENTED(); return string16(); } + +int FindBarBridge::GetWidth() { + NOTIMPLEMENTED(); + return 0; +} 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()); +} diff --git a/chrome/browser/ui/gtk/find_bar_gtk.cc b/chrome/browser/ui/gtk/find_bar_gtk.cc index d32e6c9..8e3be1a 100644 --- a/chrome/browser/ui/gtk/find_bar_gtk.cc +++ b/chrome/browser/ui/gtk/find_bar_gtk.cc @@ -573,6 +573,10 @@ string16 FindBarGtk::GetMatchCountText() { return UTF8ToUTF16(contents); } +int FindBarGtk::GetWidth() { + return container_->allocation.width; +} + void FindBarGtk::FindEntryTextInContents(bool forward_search) { TabContentsWrapper* tab_contents = find_bar_controller_->tab_contents(); if (!tab_contents) diff --git a/chrome/browser/ui/gtk/find_bar_gtk.h b/chrome/browser/ui/gtk/find_bar_gtk.h index a970b91..10606b2 100644 --- a/chrome/browser/ui/gtk/find_bar_gtk.h +++ b/chrome/browser/ui/gtk/find_bar_gtk.h @@ -65,6 +65,7 @@ class FindBarGtk : public FindBar, virtual string16 GetFindText(); virtual string16 GetFindSelectedText(); virtual string16 GetMatchCountText(); + virtual int GetWidth(); // Overridden from NotificationObserver: virtual void Observe(NotificationType type, diff --git a/chrome/browser/ui/views/find_bar_host.cc b/chrome/browser/ui/views/find_bar_host.cc index 06f89b2..eaee774 100644 --- a/chrome/browser/ui/views/find_bar_host.cc +++ b/chrome/browser/ui/views/find_bar_host.cc @@ -229,6 +229,11 @@ string16 FindBarHost::GetMatchCountText() { return find_bar_view()->GetMatchCountText(); } +int FindBarHost::GetWidth() { + NOTIMPLEMENTED(); + return 0; +} + //////////////////////////////////////////////////////////////////////////////// // Overridden from DropdownBarHost: diff --git a/chrome/browser/ui/views/find_bar_host.h b/chrome/browser/ui/views/find_bar_host.h index 1fc26b5..beacf51 100644 --- a/chrome/browser/ui/views/find_bar_host.h +++ b/chrome/browser/ui/views/find_bar_host.h @@ -73,6 +73,7 @@ class FindBarHost : public DropdownBarHost, virtual string16 GetFindText(); virtual string16 GetFindSelectedText(); virtual string16 GetMatchCountText(); + virtual int GetWidth(); // Overridden from DropdownBarHost: // Returns the rectangle representing where to position the find bar. It uses |