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 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 EXPECT_GT(bounds_on_shrink.width(), initial_bounds.width()); | 874 EXPECT_GT(bounds_on_shrink.width(), initial_bounds.width()); |
875 EXPECT_EQ(bounds_on_shrink.height(), initial_bounds.height()); | 875 EXPECT_EQ(bounds_on_shrink.height(), initial_bounds.height()); |
876 | 876 |
877 panel->Close(); | 877 panel->Close(); |
878 } | 878 } |
879 | 879 |
880 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, RestoredBounds) { | 880 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, RestoredBounds) { |
881 // Disable mouse watcher. We don't care about mouse movements in this test. | 881 // Disable mouse watcher. We don't care about mouse movements in this test. |
882 PanelManager* panel_manager = PanelManager::GetInstance(); | 882 PanelManager* panel_manager = PanelManager::GetInstance(); |
883 panel_manager->disable_mouse_watching(); | 883 panel_manager->disable_mouse_watching(); |
884 Panel* panel = CreatePanel("PanelTest"); | 884 Panel* panel = CreatePanelWithBounds("PanelTest", gfx::Rect(0, 0, 100, 100)); |
885 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); | 885 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); |
886 EXPECT_EQ(panel->GetBounds(), panel->GetRestoredBounds()); | 886 EXPECT_EQ(panel->GetBounds(), panel->GetRestoredBounds()); |
887 EXPECT_EQ(0, panel_manager->minimized_panel_count()); | 887 EXPECT_EQ(0, panel_manager->minimized_panel_count()); |
888 | 888 |
889 panel->SetExpansionState(Panel::MINIMIZED); | 889 panel->SetExpansionState(Panel::MINIMIZED); |
890 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); | 890 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
891 gfx::Rect bounds = panel->GetBounds(); | 891 gfx::Rect bounds = panel->GetBounds(); |
892 gfx::Rect restored = panel->GetRestoredBounds(); | 892 gfx::Rect restored = panel->GetRestoredBounds(); |
893 EXPECT_EQ(bounds.x(), restored.x()); | 893 EXPECT_EQ(bounds.x(), restored.x()); |
894 EXPECT_GT(bounds.y(), restored.y()); | 894 EXPECT_GT(bounds.y(), restored.y()); |
(...skipping 593 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(), SHOW_AS_ACTIVE); |
| 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 int given_height = 200; |
| 1521 CreatePanelParams params2("Panel2", gfx::Rect(0, 0, 0, given_height), |
| 1522 SHOW_AS_ACTIVE); |
| 1523 panel = CreatePanelWithParams(params2); |
| 1524 EXPECT_GT(panel->GetBounds().width(), 0); |
| 1525 EXPECT_EQ(given_height, panel->GetBounds().height()); |
| 1526 panel->Close(); |
| 1527 } |
| 1528 |
| 1529 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, TightAutosizeAroundSingleLine) { |
| 1530 PanelManager::GetInstance()->enable_auto_sizing(true); |
| 1531 // Using 0 sizes triggers auto-sizing. |
| 1532 CreatePanelParams params("Panel", gfx::Rect(), SHOW_AS_ACTIVE); |
| 1533 params.url = GURL("data:text/html;charset=utf-8,<!doctype html><body>"); |
| 1534 Panel* panel = CreatePanelWithParams(params); |
| 1535 |
| 1536 int initial_width = panel->GetBounds().width(); |
| 1537 int initial_height = panel->GetBounds().height(); |
| 1538 |
| 1539 // Inject some HTML content into the panel. |
| 1540 ui_test_utils::WindowedNotificationObserver enlarge( |
| 1541 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, |
| 1542 content::Source<Panel>(panel)); |
| 1543 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( |
| 1544 panel->browser()->GetSelectedTabContents()->render_view_host(), |
| 1545 std::wstring(), |
| 1546 L"document.body.innerHTML =" |
| 1547 L"'<nobr>line of text and a <button>Button</button>';")); |
| 1548 enlarge.Wait(); |
| 1549 |
| 1550 // The panel should have become larger in both dimensions (the minimums |
| 1551 // has to be set to be smaller then a simple 1-line content, so the autosize |
| 1552 // can work correctly. |
| 1553 EXPECT_GT(panel->GetBounds().width(), initial_width); |
| 1554 EXPECT_GT(panel->GetBounds().height(), initial_height); |
| 1555 |
| 1556 panel->Close(); |
| 1557 } |
| 1558 |
1498 class PanelDownloadTest : public PanelBrowserTest { | 1559 class PanelDownloadTest : public PanelBrowserTest { |
1499 public: | 1560 public: |
1500 PanelDownloadTest() : PanelBrowserTest() { } | 1561 PanelDownloadTest() : PanelBrowserTest() { } |
1501 | 1562 |
1502 // Creates a temporary directory for downloads that is auto-deleted | 1563 // Creates a temporary directory for downloads that is auto-deleted |
1503 // on destruction. | 1564 // on destruction. |
1504 bool CreateDownloadDirectory(Profile* profile) { | 1565 bool CreateDownloadDirectory(Profile* profile) { |
1505 bool created = downloads_directory_.CreateUniqueTempDir(); | 1566 bool created = downloads_directory_.CreateUniqueTempDir(); |
1506 if (!created) | 1567 if (!created) |
1507 return false; | 1568 return false; |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1822 // position when tall panel brings up its titlebar. | 1883 // position when tall panel brings up its titlebar. |
1823 CloseWindowAndWait(panel1->browser()); | 1884 CloseWindowAndWait(panel1->browser()); |
1824 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up, | 1885 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up, |
1825 GetBalloonBottomPosition(balloon)); | 1886 GetBalloonBottomPosition(balloon)); |
1826 | 1887 |
1827 // Closing the remaining tall panel should move the notification balloon back | 1888 // Closing the remaining tall panel should move the notification balloon back |
1828 // to its original position. | 1889 // to its original position. |
1829 CloseWindowAndWait(panel2->browser()); | 1890 CloseWindowAndWait(panel2->browser()); |
1830 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon)); | 1891 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon)); |
1831 } | 1892 } |
OLD | NEW |