Chromium Code Reviews| 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..61eaeab93811f090071b803a45cd5cee9c624bf6 100644 |
| --- a/chrome/browser/ui/panels/panel_browsertest.cc |
| +++ b/chrome/browser/ui/panels/panel_browsertest.cc |
| @@ -1495,6 +1495,65 @@ 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(0, 0, 0, 0), SHOW_AS_ACTIVE); |
|
jennb
2011/11/23 04:38:42
gfx::Rect() is the same as passing all zeroes.
Dmitry Titov
2011/11/23 18:47:49
Done.
|
| + 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. |
| + CreatePanelParams params2("Panel2", gfx::Rect(0, 0, 0, 200), SHOW_AS_ACTIVE); |
|
jennb
2011/11/23 04:38:42
nit: use a var for the 200 literal.
Dmitry Titov
2011/11/23 18:47:49
Done.
|
| + panel = CreatePanelWithParams(params2); |
| + EXPECT_GT(panel->GetBounds().width(), 0); |
| + EXPECT_EQ(200, 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(0, 0, 0, 0), SHOW_AS_ACTIVE); |
|
jennb
2011/11/23 04:38:42
gfx::Rect()
Dmitry Titov
2011/11/23 18:47:49
Done.
|
| + 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() { } |