| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/common/wm/workspace/workspace_window_resizer.h" | 5 #include "ash/common/wm/workspace/workspace_window_resizer.h" |
| 6 | 6 |
| 7 #include "ash/common/ash_switches.h" | 7 #include "ash/common/ash_switches.h" |
| 8 #include "ash/common/shelf/shelf_constants.h" | 8 #include "ash/common/shelf/shelf_constants.h" |
| 9 #include "ash/common/shelf/wm_shelf.h" | 9 #include "ash/common/shelf/wm_shelf.h" |
| 10 #include "ash/common/wm/window_positioning_utils.h" | 10 #include "ash/common/wm/window_positioning_utils.h" |
| (...skipping 1609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1620 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1620 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
| 1621 ASSERT_TRUE(resizer.get()); | 1621 ASSERT_TRUE(resizer.get()); |
| 1622 // Move it 52 up, which should contract w1 and expand w2-4. | 1622 // Move it 52 up, which should contract w1 and expand w2-4. |
| 1623 resizer->Drag(CalculateDragPoint(*resizer, 0, -52), 0); | 1623 resizer->Drag(CalculateDragPoint(*resizer, 0, -52), 0); |
| 1624 EXPECT_EQ("100,100 100x48", window_->bounds().ToString()); | 1624 EXPECT_EQ("100,100 100x48", window_->bounds().ToString()); |
| 1625 EXPECT_EQ("100,148 100x101", window2_->bounds().ToString()); | 1625 EXPECT_EQ("100,148 100x101", window2_->bounds().ToString()); |
| 1626 EXPECT_EQ("100,249 100x101", window3_->bounds().ToString()); | 1626 EXPECT_EQ("100,249 100x101", window3_->bounds().ToString()); |
| 1627 EXPECT_EQ("100,350 100x150", window4_->bounds().ToString()); | 1627 EXPECT_EQ("100,350 100x150", window4_->bounds().ToString()); |
| 1628 } | 1628 } |
| 1629 | 1629 |
| 1630 #if defined(OS_CHROMEOS) | |
| 1631 TEST_P(WorkspaceWindowResizerTest, DontExceedMinHeight) { | 1630 TEST_P(WorkspaceWindowResizerTest, DontExceedMinHeight) { |
| 1632 UpdateDisplay("600x500"); | 1631 UpdateDisplay("600x500"); |
| 1633 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1632 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 1634 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1633 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
| 1635 | 1634 |
| 1636 // Four 100x100 windows flush against eachother, starting at 100,100. | 1635 // Four 100x100 windows flush against eachother, starting at 100,100. |
| 1637 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); | 1636 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); |
| 1638 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); | 1637 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); |
| 1639 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); | 1638 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); |
| 1640 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); | 1639 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); |
| 1641 delegate2_.set_min_size(gfx::Size(0, 99)); | 1640 delegate2_.set_min_size(gfx::Size(0, 99)); |
| 1642 delegate3_.set_min_size(gfx::Size(0, 99)); | 1641 delegate3_.set_min_size(gfx::Size(0, 99)); |
| 1643 | 1642 |
| 1644 std::vector<aura::Window*> windows; | 1643 std::vector<aura::Window*> windows; |
| 1645 windows.push_back(window2_.get()); | 1644 windows.push_back(window2_.get()); |
| 1646 windows.push_back(window3_.get()); | 1645 windows.push_back(window3_.get()); |
| 1647 windows.push_back(window4_.get()); | 1646 windows.push_back(window4_.get()); |
| 1648 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 1647 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
| 1649 window_.get(), gfx::Point(), HTBOTTOM, | 1648 window_.get(), gfx::Point(), HTBOTTOM, |
| 1650 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1649 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
| 1651 ASSERT_TRUE(resizer.get()); | 1650 ASSERT_TRUE(resizer.get()); |
| 1652 // Move it 52 down, which should expand w1 and contract w2-4. | 1651 // Move it 52 down, which should expand w1 and contract w2-4. |
| 1653 resizer->Drag(CalculateDragPoint(*resizer, 0, 52), 0); | 1652 resizer->Drag(CalculateDragPoint(*resizer, 0, 52), 0); |
| 1654 EXPECT_EQ("100,100 100x152", window_->bounds().ToString()); | 1653 EXPECT_EQ("100,100 100x152", window_->bounds().ToString()); |
| 1655 EXPECT_EQ("100,252 100x99", window2_->bounds().ToString()); | 1654 EXPECT_EQ("100,252 100x99", window2_->bounds().ToString()); |
| 1656 EXPECT_EQ("100,351 100x99", window3_->bounds().ToString()); | 1655 EXPECT_EQ("100,351 100x99", window3_->bounds().ToString()); |
| 1657 EXPECT_EQ("100,450 100x50", window4_->bounds().ToString()); | 1656 EXPECT_EQ("100,450 100x50", window4_->bounds().ToString()); |
| 1658 } | 1657 } |
| 1659 #endif // defined(OS_CHROMEOS) | |
| 1660 | 1658 |
| 1661 TEST_P(WorkspaceWindowResizerTest, DontExpandRightmostPastMaxWidth) { | 1659 TEST_P(WorkspaceWindowResizerTest, DontExpandRightmostPastMaxWidth) { |
| 1662 UpdateDisplay("600x800"); | 1660 UpdateDisplay("600x800"); |
| 1663 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1661 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 1664 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1662 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
| 1665 | 1663 |
| 1666 // Three 100x100 windows flush against eachother, starting at 100,100. | 1664 // Three 100x100 windows flush against eachother, starting at 100,100. |
| 1667 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); | 1665 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); |
| 1668 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1666 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
| 1669 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1667 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1704 window_.get(), gfx::Point(), HTRIGHT, | 1702 window_.get(), gfx::Point(), HTRIGHT, |
| 1705 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1703 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
| 1706 ASSERT_TRUE(resizer.get()); | 1704 ASSERT_TRUE(resizer.get()); |
| 1707 // Move it 52 to the left, which should contract w1 and expand and move w2-3. | 1705 // Move it 52 to the left, which should contract w1 and expand and move w2-3. |
| 1708 resizer->Drag(CalculateDragPoint(*resizer, -52, 0), 0); | 1706 resizer->Drag(CalculateDragPoint(*resizer, -52, 0), 0); |
| 1709 EXPECT_EQ("100,100 48x100", window_->bounds().ToString()); | 1707 EXPECT_EQ("100,100 48x100", window_->bounds().ToString()); |
| 1710 EXPECT_EQ("148,100 101x100", window2_->bounds().ToString()); | 1708 EXPECT_EQ("148,100 101x100", window2_->bounds().ToString()); |
| 1711 EXPECT_EQ("249,100 101x100", window3_->bounds().ToString()); | 1709 EXPECT_EQ("249,100 101x100", window3_->bounds().ToString()); |
| 1712 } | 1710 } |
| 1713 | 1711 |
| 1714 #if defined(OS_CHROMEOS) | |
| 1715 TEST_P(WorkspaceWindowResizerTest, MainWindowHonoursMaxWidth) { | 1712 TEST_P(WorkspaceWindowResizerTest, MainWindowHonoursMaxWidth) { |
| 1716 UpdateDisplay("400x800"); | 1713 UpdateDisplay("400x800"); |
| 1717 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1714 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 1718 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1715 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
| 1719 | 1716 |
| 1720 // Three 100x100 windows flush against eachother, starting at 100,100. | 1717 // Three 100x100 windows flush against eachother, starting at 100,100. |
| 1721 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); | 1718 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); |
| 1722 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1719 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
| 1723 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1720 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
| 1724 delegate_.set_max_size(gfx::Size(102, 0)); | 1721 delegate_.set_max_size(gfx::Size(102, 0)); |
| 1725 | 1722 |
| 1726 std::vector<aura::Window*> windows; | 1723 std::vector<aura::Window*> windows; |
| 1727 windows.push_back(window2_.get()); | 1724 windows.push_back(window2_.get()); |
| 1728 windows.push_back(window3_.get()); | 1725 windows.push_back(window3_.get()); |
| 1729 windows.push_back(window4_.get()); | 1726 windows.push_back(window4_.get()); |
| 1730 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 1727 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
| 1731 window_.get(), gfx::Point(), HTRIGHT, | 1728 window_.get(), gfx::Point(), HTRIGHT, |
| 1732 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1729 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
| 1733 ASSERT_TRUE(resizer.get()); | 1730 ASSERT_TRUE(resizer.get()); |
| 1734 // Move it 50 to the right, which should expand w1 and contract w2-3, as they | 1731 // Move it 50 to the right, which should expand w1 and contract w2-3, as they |
| 1735 // won't fit in the root window in their original sizes. | 1732 // won't fit in the root window in their original sizes. |
| 1736 resizer->Drag(CalculateDragPoint(*resizer, 50, 0), 0); | 1733 resizer->Drag(CalculateDragPoint(*resizer, 50, 0), 0); |
| 1737 EXPECT_EQ("100,100 102x100", window_->bounds().ToString()); | 1734 EXPECT_EQ("100,100 102x100", window_->bounds().ToString()); |
| 1738 EXPECT_EQ("202,100 99x100", window2_->bounds().ToString()); | 1735 EXPECT_EQ("202,100 99x100", window2_->bounds().ToString()); |
| 1739 EXPECT_EQ("301,100 99x100", window3_->bounds().ToString()); | 1736 EXPECT_EQ("301,100 99x100", window3_->bounds().ToString()); |
| 1740 } | 1737 } |
| 1741 #endif // defined(OS_CHROMEOS) | |
| 1742 | 1738 |
| 1743 TEST_P(WorkspaceWindowResizerTest, MainWindowHonoursMinWidth) { | 1739 TEST_P(WorkspaceWindowResizerTest, MainWindowHonoursMinWidth) { |
| 1744 UpdateDisplay("400x800"); | 1740 UpdateDisplay("400x800"); |
| 1745 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1741 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 1746 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1742 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); |
| 1747 | 1743 |
| 1748 // Three 100x100 windows flush against eachother, starting at 100,100. | 1744 // Three 100x100 windows flush against eachother, starting at 100,100. |
| 1749 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); | 1745 window_->SetBounds(gfx::Rect(100, 100, 100, 100)); |
| 1750 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1746 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
| 1751 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1747 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1882 touch_resize_window_->bounds().ToString()); | 1878 touch_resize_window_->bounds().ToString()); |
| 1883 // Drag even more to snap to the edge. | 1879 // Drag even more to snap to the edge. |
| 1884 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), | 1880 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), |
| 1885 gfx::Point(400, kRootHeight - 25), | 1881 gfx::Point(400, kRootHeight - 25), |
| 1886 base::TimeDelta::FromMilliseconds(10), 5); | 1882 base::TimeDelta::FromMilliseconds(10), 5); |
| 1887 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), | 1883 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), |
| 1888 touch_resize_window_->bounds().ToString()); | 1884 touch_resize_window_->bounds().ToString()); |
| 1889 } | 1885 } |
| 1890 | 1886 |
| 1891 } // namespace ash | 1887 } // namespace ash |
| OLD | NEW |