Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/string_number_conversions.h" | 6 #include "base/string_number_conversions.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/download/download_service.h" | 9 #include "chrome/browser/download/download_service.h" |
| 10 #include "chrome/browser/download/download_service_factory.h" | 10 #include "chrome/browser/download/download_service_factory.h" |
| (...skipping 1477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1488 content::Source<Browser>(panel_browser)); | 1488 content::Source<Browser>(panel_browser)); |
| 1489 panel_browser->ConvertPopupToTabbedBrowser(); | 1489 panel_browser->ConvertPopupToTabbedBrowser(); |
| 1490 signal.Wait(); | 1490 signal.Wait(); |
| 1491 EXPECT_EQ(0, PanelManager::GetInstance()->num_panels()); | 1491 EXPECT_EQ(0, PanelManager::GetInstance()->num_panels()); |
| 1492 | 1492 |
| 1493 Browser* tabbed_browser = BrowserList::FindTabbedBrowser(profile, false); | 1493 Browser* tabbed_browser = BrowserList::FindTabbedBrowser(profile, false); |
| 1494 EXPECT_EQ(contents, tabbed_browser->GetSelectedTabContentsWrapper()); | 1494 EXPECT_EQ(contents, tabbed_browser->GetSelectedTabContentsWrapper()); |
| 1495 tabbed_browser->window()->Close(); | 1495 tabbed_browser->window()->Close(); |
| 1496 } | 1496 } |
| 1497 | 1497 |
| 1498 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, SizeClamping) { | |
| 1499 // Using '0' sizes is equivalent of not providing sizes in API and causes | |
| 1500 // minimum sizes to be applied to facilitate auto-sizing. | |
| 1501 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.
| |
| 1502 Panel* panel = CreatePanelWithParams(params); | |
| 1503 EXPECT_EQ(PanelManager::kPanelMinWidth, panel->GetBounds().width()); | |
| 1504 EXPECT_EQ(PanelManager::kPanelMinHeight, panel->GetBounds().height()); | |
| 1505 panel->Close(); | |
| 1506 | |
| 1507 // Using reasonable actual sizes should avoid clamping. | |
| 1508 int reasonable_width = PanelManager::kPanelMinWidth + 10; | |
| 1509 int reasonable_height = PanelManager::kPanelMinHeight + 20; | |
| 1510 CreatePanelParams params1("Panel1", | |
| 1511 gfx::Rect(0, 0, | |
| 1512 reasonable_width, reasonable_height), | |
| 1513 SHOW_AS_ACTIVE); | |
| 1514 panel = CreatePanelWithParams(params1); | |
| 1515 EXPECT_EQ(reasonable_width, panel->GetBounds().width()); | |
| 1516 EXPECT_EQ(reasonable_height, panel->GetBounds().height()); | |
| 1517 panel->Close(); | |
| 1518 | |
| 1519 // Using just one size should auto-compute some reasonable other size. | |
| 1520 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.
| |
| 1521 panel = CreatePanelWithParams(params2); | |
| 1522 EXPECT_GT(panel->GetBounds().width(), 0); | |
| 1523 EXPECT_EQ(200, panel->GetBounds().height()); | |
| 1524 panel->Close(); | |
| 1525 } | |
| 1526 | |
| 1527 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, TightAutosizeAroundSingleLine) { | |
| 1528 PanelManager::GetInstance()->enable_auto_sizing(true); | |
| 1529 // Using 0 sizes triggers auto-sizing. | |
| 1530 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.
| |
| 1531 params.url = GURL("data:text/html;charset=utf-8,<!doctype html><body>"); | |
| 1532 Panel* panel = CreatePanelWithParams(params); | |
| 1533 | |
| 1534 int initial_width = panel->GetBounds().width(); | |
| 1535 int initial_height = panel->GetBounds().height(); | |
| 1536 | |
| 1537 // Inject some HTML content into the panel. | |
| 1538 ui_test_utils::WindowedNotificationObserver enlarge( | |
| 1539 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, | |
| 1540 content::Source<Panel>(panel)); | |
| 1541 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( | |
| 1542 panel->browser()->GetSelectedTabContents()->render_view_host(), | |
| 1543 std::wstring(), | |
| 1544 L"document.body.innerHTML =" | |
| 1545 L"'<nobr>line of text and a <button>Button</button>';")); | |
| 1546 enlarge.Wait(); | |
| 1547 | |
| 1548 // The panel should have become larger in both dimensions (the minimums | |
| 1549 // has to be set to be smaller then a simple 1-line content, so the autosize | |
| 1550 // can work correctly. | |
| 1551 EXPECT_GT(panel->GetBounds().width(), initial_width); | |
| 1552 EXPECT_GT(panel->GetBounds().height(), initial_height); | |
| 1553 | |
| 1554 panel->Close(); | |
| 1555 } | |
| 1556 | |
| 1498 class PanelDownloadTest : public PanelBrowserTest { | 1557 class PanelDownloadTest : public PanelBrowserTest { |
| 1499 public: | 1558 public: |
| 1500 PanelDownloadTest() : PanelBrowserTest() { } | 1559 PanelDownloadTest() : PanelBrowserTest() { } |
| 1501 | 1560 |
| 1502 // Creates a temporary directory for downloads that is auto-deleted | 1561 // Creates a temporary directory for downloads that is auto-deleted |
| 1503 // on destruction. | 1562 // on destruction. |
| 1504 bool CreateDownloadDirectory(Profile* profile) { | 1563 bool CreateDownloadDirectory(Profile* profile) { |
| 1505 bool created = downloads_directory_.CreateUniqueTempDir(); | 1564 bool created = downloads_directory_.CreateUniqueTempDir(); |
| 1506 if (!created) | 1565 if (!created) |
| 1507 return false; | 1566 return false; |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1822 // position when tall panel brings up its titlebar. | 1881 // position when tall panel brings up its titlebar. |
| 1823 CloseWindowAndWait(panel1->browser()); | 1882 CloseWindowAndWait(panel1->browser()); |
| 1824 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up, | 1883 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up, |
| 1825 GetBalloonBottomPosition(balloon)); | 1884 GetBalloonBottomPosition(balloon)); |
| 1826 | 1885 |
| 1827 // Closing the remaining tall panel should move the notification balloon back | 1886 // Closing the remaining tall panel should move the notification balloon back |
| 1828 // to its original position. | 1887 // to its original position. |
| 1829 CloseWindowAndWait(panel2->browser()); | 1888 CloseWindowAndWait(panel2->browser()); |
| 1830 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon)); | 1889 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon)); |
| 1831 } | 1890 } |
| OLD | NEW |