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

Unified Diff: chrome/browser/ui/panels/panel_browsertest.cc

Issue 8621002: Reduce minimum size of Panels to allow 1-text-line tight autosize. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: hopefully final Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/panels/panel_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/panels/panel_browsertest.cc
diff --git a/chrome/browser/ui/panels/panel_browsertest.cc b/chrome/browser/ui/panels/panel_browsertest.cc
index 78a8a6d1559558d8b733308ccb0247fbb7ac4a28..82c27f242cb6d32b50bba4ef9644b3c553c5ccd8 100644
--- a/chrome/browser/ui/panels/panel_browsertest.cc
+++ b/chrome/browser/ui/panels/panel_browsertest.cc
@@ -881,7 +881,7 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, RestoredBounds) {
// Disable mouse watcher. We don't care about mouse movements in this test.
PanelManager* panel_manager = PanelManager::GetInstance();
panel_manager->disable_mouse_watching();
- Panel* panel = CreatePanel("PanelTest");
+ Panel* panel = CreatePanelWithBounds("PanelTest", gfx::Rect(0, 0, 100, 100));
EXPECT_EQ(Panel::EXPANDED, panel->expansion_state());
EXPECT_EQ(panel->GetBounds(), panel->GetRestoredBounds());
EXPECT_EQ(0, panel_manager->minimized_panel_count());
@@ -1495,6 +1495,67 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreateWithExistingContents) {
tabbed_browser->window()->Close();
}
+IN_PROC_BROWSER_TEST_F(PanelBrowserTest, SizeClamping) {
+ // Using '0' sizes is equivalent of not providing sizes in API and causes
+ // minimum sizes to be applied to facilitate auto-sizing.
+ CreatePanelParams params("Panel", gfx::Rect(), SHOW_AS_ACTIVE);
+ Panel* panel = CreatePanelWithParams(params);
+ EXPECT_EQ(PanelManager::kPanelMinWidth, panel->GetBounds().width());
+ EXPECT_EQ(PanelManager::kPanelMinHeight, panel->GetBounds().height());
+ panel->Close();
+
+ // Using reasonable actual sizes should avoid clamping.
+ int reasonable_width = PanelManager::kPanelMinWidth + 10;
+ int reasonable_height = PanelManager::kPanelMinHeight + 20;
+ CreatePanelParams params1("Panel1",
+ gfx::Rect(0, 0,
+ reasonable_width, reasonable_height),
+ SHOW_AS_ACTIVE);
+ panel = CreatePanelWithParams(params1);
+ EXPECT_EQ(reasonable_width, panel->GetBounds().width());
+ EXPECT_EQ(reasonable_height, panel->GetBounds().height());
+ panel->Close();
+
+ // Using just one size should auto-compute some reasonable other size.
+ int given_height = 200;
+ CreatePanelParams params2("Panel2", gfx::Rect(0, 0, 0, given_height),
+ SHOW_AS_ACTIVE);
+ panel = CreatePanelWithParams(params2);
+ EXPECT_GT(panel->GetBounds().width(), 0);
+ EXPECT_EQ(given_height, panel->GetBounds().height());
+ panel->Close();
+}
+
+IN_PROC_BROWSER_TEST_F(PanelBrowserTest, TightAutosizeAroundSingleLine) {
+ PanelManager::GetInstance()->enable_auto_sizing(true);
+ // Using 0 sizes triggers auto-sizing.
+ CreatePanelParams params("Panel", gfx::Rect(), SHOW_AS_ACTIVE);
+ params.url = GURL("data:text/html;charset=utf-8,<!doctype html><body>");
+ Panel* panel = CreatePanelWithParams(params);
+
+ int initial_width = panel->GetBounds().width();
+ int initial_height = panel->GetBounds().height();
+
+ // Inject some HTML content into the panel.
+ ui_test_utils::WindowedNotificationObserver enlarge(
+ chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED,
+ content::Source<Panel>(panel));
+ EXPECT_TRUE(ui_test_utils::ExecuteJavaScript(
+ panel->browser()->GetSelectedTabContents()->render_view_host(),
+ std::wstring(),
+ L"document.body.innerHTML ="
+ L"'<nobr>line of text and a <button>Button</button>';"));
+ enlarge.Wait();
+
+ // The panel should have become larger in both dimensions (the minimums
+ // has to be set to be smaller then a simple 1-line content, so the autosize
+ // can work correctly.
+ EXPECT_GT(panel->GetBounds().width(), initial_width);
+ EXPECT_GT(panel->GetBounds().height(), initial_height);
+
+ panel->Close();
+}
+
class PanelDownloadTest : public PanelBrowserTest {
public:
PanelDownloadTest() : PanelBrowserTest() { }
« no previous file with comments | « no previous file | chrome/browser/ui/panels/panel_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698