| 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 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 ASSERT_TRUE(resizer.get()); | 579 ASSERT_TRUE(resizer.get()); |
| 580 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); | 580 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); |
| 581 resizer->CompleteDrag(); | 581 resizer->CompleteDrag(); |
| 582 EXPECT_EQ(expected_bounds_in_parent.ToString(), | 582 EXPECT_EQ(expected_bounds_in_parent.ToString(), |
| 583 window_->bounds().ToString()); | 583 window_->bounds().ToString()); |
| 584 ASSERT_TRUE(window_state->HasRestoreBounds()); | 584 ASSERT_TRUE(window_state->HasRestoreBounds()); |
| 585 EXPECT_EQ("20,30 400x60", | 585 EXPECT_EQ("20,30 400x60", |
| 586 window_state->GetRestoreBoundsInScreen().ToString()); | 586 window_state->GetRestoreBoundsInScreen().ToString()); |
| 587 } | 587 } |
| 588 | 588 |
| 589 // Test if the restore bounds is correct in multiple displays. | |
| 590 if (!SupportsMultipleDisplays()) | |
| 591 return; | |
| 592 | |
| 593 // Restore the window to clear snapped state. | 589 // Restore the window to clear snapped state. |
| 594 window_state->Restore(); | 590 window_state->Restore(); |
| 595 | 591 |
| 592 // Test if the restore bounds is correct in multiple displays. |
| 596 UpdateDisplay("800x600,500x600"); | 593 UpdateDisplay("800x600,500x600"); |
| 597 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 594 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 598 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 595 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
| 599 // Window is wide enough not to get docked right away. | 596 // Window is wide enough not to get docked right away. |
| 600 window_->SetBoundsInScreen(gfx::Rect(800, 10, 400, 60), | 597 window_->SetBoundsInScreen(gfx::Rect(800, 10, 400, 60), |
| 601 display_manager()->GetSecondaryDisplay()); | 598 display_manager()->GetSecondaryDisplay()); |
| 602 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | 599 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
| 603 { | 600 { |
| 604 EXPECT_EQ("800,10 400x60", window_->GetBoundsInScreen().ToString()); | 601 EXPECT_EQ("800,10 400x60", window_->GetBoundsInScreen().ToString()); |
| 605 | 602 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 628 | 625 |
| 629 std::unique_ptr<WindowResizer> resizer( | 626 std::unique_ptr<WindowResizer> resizer( |
| 630 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); | 627 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); |
| 631 ASSERT_TRUE(resizer.get()); | 628 ASSERT_TRUE(resizer.get()); |
| 632 resizer->Drag(CalculateDragPoint(*resizer, -20, 0), 0); | 629 resizer->Drag(CalculateDragPoint(*resizer, -20, 0), 0); |
| 633 resizer->CompleteDrag(); | 630 resizer->CompleteDrag(); |
| 634 EXPECT_EQ("0,30 50x60", window_->bounds().ToString()); | 631 EXPECT_EQ("0,30 50x60", window_->bounds().ToString()); |
| 635 } | 632 } |
| 636 | 633 |
| 637 TEST_P(WorkspaceWindowResizerTest, CancelSnapPhantom) { | 634 TEST_P(WorkspaceWindowResizerTest, CancelSnapPhantom) { |
| 638 if (!SupportsMultipleDisplays()) | |
| 639 return; | |
| 640 | |
| 641 UpdateDisplay("800x600,800x600"); | 635 UpdateDisplay("800x600,800x600"); |
| 642 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 636 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 643 ASSERT_EQ(2U, root_windows.size()); | 637 ASSERT_EQ(2U, root_windows.size()); |
| 644 | 638 |
| 645 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), | 639 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), |
| 646 display::Screen::GetScreen()->GetPrimaryDisplay()); | 640 display::Screen::GetScreen()->GetPrimaryDisplay()); |
| 647 | 641 |
| 648 // Make the window snappable by making it resizable and maximizable. | 642 // Make the window snappable by making it resizable and maximizable. |
| 649 window_->SetProperty(aura::client::kResizeBehaviorKey, | 643 window_->SetProperty(aura::client::kResizeBehaviorKey, |
| 650 ui::mojom::kResizeBehaviorCanResize | | 644 ui::mojom::kResizeBehaviorCanResize | |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 ASSERT_TRUE(resizer.get()); | 797 ASSERT_TRUE(resizer.get()); |
| 804 resizer->Drag(CalculateDragPoint(*resizer, 0, 600), 0); | 798 resizer->Drag(CalculateDragPoint(*resizer, 0, 600), 0); |
| 805 int expected_y = | 799 int expected_y = |
| 806 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; | 800 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; |
| 807 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", | 801 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", |
| 808 window_->bounds().ToString()); | 802 window_->bounds().ToString()); |
| 809 } | 803 } |
| 810 | 804 |
| 811 // Makes sure we don't allow dragging on the work area with multidisplay. | 805 // Makes sure we don't allow dragging on the work area with multidisplay. |
| 812 TEST_P(WorkspaceWindowResizerTest, DontDragOffBottomWithMultiDisplay) { | 806 TEST_P(WorkspaceWindowResizerTest, DontDragOffBottomWithMultiDisplay) { |
| 813 if (!SupportsMultipleDisplays()) | |
| 814 return; | |
| 815 | |
| 816 UpdateDisplay("800x600,800x600"); | 807 UpdateDisplay("800x600,800x600"); |
| 817 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); | 808 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); |
| 818 | 809 |
| 819 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), | 810 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), |
| 820 gfx::Insets(0, 0, 10, 0)); | 811 gfx::Insets(0, 0, 10, 0)); |
| 821 | 812 |
| 822 // Positions the secondary display at the bottom the primary display. | 813 // Positions the secondary display at the bottom the primary display. |
| 823 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( | 814 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
| 824 display::test::CreateDisplayLayout(display_manager(), | 815 display::test::CreateDisplayLayout(display_manager(), |
| 825 display::DisplayPlacement::BOTTOM, 0)); | 816 display::DisplayPlacement::BOTTOM, 0)); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 int window_x = right - pixels_to_right_border; | 961 int window_x = right - pixels_to_right_border; |
| 971 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 962 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
| 972 std::unique_ptr<WindowResizer> resizer( | 963 std::unique_ptr<WindowResizer> resizer( |
| 973 CreateResizerForTest(window_.get(), gfx::Point(window_x, 0), HTCAPTION)); | 964 CreateResizerForTest(window_.get(), gfx::Point(window_x, 0), HTCAPTION)); |
| 974 ASSERT_TRUE(resizer.get()); | 965 ASSERT_TRUE(resizer.get()); |
| 975 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); | 966 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); |
| 976 EXPECT_EQ(base::IntToString(right - wm::kMinimumOnScreenArea) + ",100 " + | 967 EXPECT_EQ(base::IntToString(right - wm::kMinimumOnScreenArea) + ",100 " + |
| 977 base::IntToString(window_width) + "x380", | 968 base::IntToString(window_width) + "x380", |
| 978 window_->bounds().ToString()); | 969 window_->bounds().ToString()); |
| 979 | 970 |
| 980 if (!SupportsMultipleDisplays()) | |
| 981 return; | |
| 982 | |
| 983 // With secondary display. Operation itself is same but doesn't change | 971 // With secondary display. Operation itself is same but doesn't change |
| 984 // the position because the window is still within the secondary display. | 972 // the position because the window is still within the secondary display. |
| 985 UpdateDisplay("1000x600,600x400"); | 973 UpdateDisplay("1000x600,600x400"); |
| 986 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), | 974 Shell::GetInstance()->SetDisplayWorkAreaInsets(Shell::GetPrimaryRootWindow(), |
| 987 gfx::Insets(0, 0, 50, 0)); | 975 gfx::Insets(0, 0, 50, 0)); |
| 988 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 976 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
| 989 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); | 977 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); |
| 990 EXPECT_EQ(base::IntToString(window_x + window_width) + ",100 " + | 978 EXPECT_EQ(base::IntToString(window_x + window_width) + ",100 " + |
| 991 base::IntToString(window_width) + "x380", | 979 base::IntToString(window_width) + "x380", |
| 992 window_->bounds().ToString()); | 980 window_->bounds().ToString()); |
| (...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1894 touch_resize_window_->bounds().ToString()); | 1882 touch_resize_window_->bounds().ToString()); |
| 1895 // Drag even more to snap to the edge. | 1883 // Drag even more to snap to the edge. |
| 1896 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), | 1884 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), |
| 1897 gfx::Point(400, kRootHeight - 25), | 1885 gfx::Point(400, kRootHeight - 25), |
| 1898 base::TimeDelta::FromMilliseconds(10), 5); | 1886 base::TimeDelta::FromMilliseconds(10), 5); |
| 1899 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), | 1887 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), |
| 1900 touch_resize_window_->bounds().ToString()); | 1888 touch_resize_window_->bounds().ToString()); |
| 1901 } | 1889 } |
| 1902 | 1890 |
| 1903 } // namespace ash | 1891 } // namespace ash |
| OLD | NEW |