| 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/wm/workspace/workspace_window_resizer.h" | 5 #include "ash/wm/workspace/workspace_window_resizer.h" |
| 6 | 6 |
| 7 #include "ash/ash_constants.h" | 7 #include "ash/ash_constants.h" |
| 8 #include "ash/ash_switches.h" | 8 #include "ash/ash_switches.h" |
| 9 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
| 10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 // Moving the mouse should show the cursor. | 589 // Moving the mouse should show the cursor. |
| 590 generator.MoveMouseBy(1, 1); | 590 generator.MoveMouseBy(1, 1); |
| 591 EXPECT_TRUE(shell->cursor_manager()->IsCursorVisible()); | 591 EXPECT_TRUE(shell->cursor_manager()->IsCursorVisible()); |
| 592 EXPECT_FALSE(shell->cursor_manager()->IsCursorLocked()); | 592 EXPECT_FALSE(shell->cursor_manager()->IsCursorLocked()); |
| 593 | 593 |
| 594 resizer->RevertDrag(); | 594 resizer->RevertDrag(); |
| 595 } | 595 } |
| 596 | 596 |
| 597 // Assertions around dragging to the left/right edge of the screen. | 597 // Assertions around dragging to the left/right edge of the screen. |
| 598 TEST_F(WorkspaceWindowResizerTest, Edge) { | 598 TEST_F(WorkspaceWindowResizerTest, Edge) { |
| 599 if (!SupportsHostWindowResize()) |
| 600 return; |
| 601 |
| 602 // Resize host window to force insets update. |
| 603 UpdateDisplay("800x700"); |
| 599 // TODO(varkha): Insets are reset after every drag because of | 604 // TODO(varkha): Insets are reset after every drag because of |
| 600 // http://crbug.com/292238. | 605 // http://crbug.com/292238. |
| 601 // Window is wide enough not to get docked right away. | 606 // Window is wide enough not to get docked right away. |
| 602 window_->SetBounds(gfx::Rect(20, 30, 400, 60)); | 607 window_->SetBounds(gfx::Rect(20, 30, 400, 60)); |
| 603 wm::WindowState* window_state = wm::GetWindowState(window_.get()); | 608 wm::WindowState* window_state = wm::GetWindowState(window_.get()); |
| 604 | 609 |
| 605 { | 610 { |
| 606 internal::SnapSizer snap_sizer(window_state, gfx::Point(), | 611 internal::SnapSizer snap_sizer(window_state, gfx::Point(), |
| 607 internal::SnapSizer::LEFT_EDGE, internal::SnapSizer::OTHER_INPUT); | 612 internal::SnapSizer::LEFT_EDGE, internal::SnapSizer::OTHER_INPUT); |
| 608 gfx::Rect expected_bounds(snap_sizer.target_bounds()); | 613 gfx::Rect expected_bounds(snap_sizer.target_bounds()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 629 ASSERT_TRUE(resizer.get()); | 634 ASSERT_TRUE(resizer.get()); |
| 630 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); | 635 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); |
| 631 resizer->CompleteDrag(0); | 636 resizer->CompleteDrag(0); |
| 632 EXPECT_EQ(expected_bounds.ToString(), window_->bounds().ToString()); | 637 EXPECT_EQ(expected_bounds.ToString(), window_->bounds().ToString()); |
| 633 ASSERT_TRUE(window_state->HasRestoreBounds()); | 638 ASSERT_TRUE(window_state->HasRestoreBounds()); |
| 634 EXPECT_EQ("20,30 400x60", | 639 EXPECT_EQ("20,30 400x60", |
| 635 window_state->GetRestoreBoundsInScreen().ToString()); | 640 window_state->GetRestoreBoundsInScreen().ToString()); |
| 636 } | 641 } |
| 637 | 642 |
| 638 // Test if the restore bounds is correct in multiple displays. | 643 // Test if the restore bounds is correct in multiple displays. |
| 639 window_state->ClearRestoreBounds(); | |
| 640 | |
| 641 if (!SupportsMultipleDisplays()) | 644 if (!SupportsMultipleDisplays()) |
| 642 return; | 645 return; |
| 643 | 646 |
| 647 // Restore the window to clear snapped state. |
| 648 window_state->Restore(); |
| 649 |
| 644 UpdateDisplay("800x600,500x600"); | 650 UpdateDisplay("800x600,500x600"); |
| 645 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 651 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 646 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 652 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
| 647 // Window is wide enough not to get docked right away. | 653 // Window is wide enough not to get docked right away. |
| 648 window_->SetBoundsInScreen(gfx::Rect(800, 10, 400, 60), | 654 window_->SetBoundsInScreen(gfx::Rect(800, 10, 400, 60), |
| 649 ScreenAsh::GetSecondaryDisplay()); | 655 ScreenAsh::GetSecondaryDisplay()); |
| 650 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | 656 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
| 651 { | 657 { |
| 652 EXPECT_EQ("800,10 400x60", window_->GetBoundsInScreen().ToString()); | 658 EXPECT_EQ("800,10 400x60", window_->GetBoundsInScreen().ToString()); |
| 653 | 659 |
| 654 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 660 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 655 window_.get(), gfx::Point(), HTCAPTION)); | 661 window_.get(), gfx::Point(), HTCAPTION)); |
| 656 ASSERT_TRUE(resizer.get()); | 662 ASSERT_TRUE(resizer.get()); |
| 657 resizer->Drag(CalculateDragPoint(*resizer, 499, 00), 0); | 663 resizer->Drag(CalculateDragPoint(*resizer, 499, 0), 0); |
| 658 int bottom = | 664 int bottom = |
| 659 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); | 665 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); |
| 660 resizer->CompleteDrag(0); | 666 resizer->CompleteDrag(0); |
| 661 // With the resolution of 500x600 we will hit in this case the 50% screen | 667 // With the resolution of 500x600 we will hit in this case the 50% screen |
| 662 // size setting. | 668 // size setting. |
| 663 // TODO(varkha): Insets are updated because of http://crbug.com/292238 | 669 // TODO(varkha): Insets are updated because of http://crbug.com/292238 |
| 664 EXPECT_EQ("250,0 250x" + base::IntToString(bottom), | 670 EXPECT_EQ("250,0 250x" + base::IntToString(bottom), |
| 665 window_->bounds().ToString()); | 671 window_->bounds().ToString()); |
| 666 EXPECT_EQ("800,10 400x60", | 672 EXPECT_EQ("800,10 400x60", |
| 667 window_state->GetRestoreBoundsInScreen().ToString()); | 673 window_state->GetRestoreBoundsInScreen().ToString()); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); | 782 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); |
| 777 | 783 |
| 778 // Positions the secondary display at the bottom the primary display. | 784 // Positions the secondary display at the bottom the primary display. |
| 779 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( | 785 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
| 780 ash::DisplayLayout(ash::DisplayLayout::BOTTOM, 0)); | 786 ash::DisplayLayout(ash::DisplayLayout::BOTTOM, 0)); |
| 781 | 787 |
| 782 { | 788 { |
| 783 window_->SetBounds(gfx::Rect(100, 200, 300, 20)); | 789 window_->SetBounds(gfx::Rect(100, 200, 300, 20)); |
| 784 DCHECK_LT(window_->bounds().height(), | 790 DCHECK_LT(window_->bounds().height(), |
| 785 WorkspaceWindowResizer::kMinOnscreenHeight); | 791 WorkspaceWindowResizer::kMinOnscreenHeight); |
| 792 // Drag down avoiding dragging along the edge as that would side-snap. |
| 786 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 793 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 787 window_.get(), gfx::Point(), HTCAPTION)); | 794 window_.get(), gfx::Point(10, 0), HTCAPTION)); |
| 788 ASSERT_TRUE(resizer.get()); | 795 ASSERT_TRUE(resizer.get()); |
| 789 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); | 796 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); |
| 790 int expected_y = kRootHeight - window_->bounds().height() - 10; | 797 int expected_y = kRootHeight - window_->bounds().height() - 10; |
| 791 // When the mouse cursor is in the primary display, the window cannot move | 798 // When the mouse cursor is in the primary display, the window cannot move |
| 792 // on non-work area but can get all the way towards the bottom, | 799 // on non-work area but can get all the way towards the bottom, |
| 793 // restricted only by the window height. | 800 // restricted only by the window height. |
| 794 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x20", | 801 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x20", |
| 795 window_->bounds().ToString()); | 802 window_->bounds().ToString()); |
| 796 // Revert the drag in order to not remember the restore bounds. | 803 // Revert the drag in order to not remember the restore bounds. |
| 797 resizer->RevertDrag(); | 804 resizer->RevertDrag(); |
| 798 } | 805 } |
| 799 | 806 |
| 800 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 807 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
| 801 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); | 808 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); |
| 802 { | 809 { |
| 803 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); | 810 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); |
| 804 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 811 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
| 805 window_.get(), gfx::Point(), HTCAPTION)); | 812 window_.get(), gfx::Point(10, 0), HTCAPTION)); |
| 806 ASSERT_TRUE(resizer.get()); | 813 ASSERT_TRUE(resizer.get()); |
| 814 // Drag down avoiding dragging along the edge as that would side-snap. |
| 807 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); | 815 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); |
| 808 int expected_y = | 816 int expected_y = |
| 809 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; | 817 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; |
| 810 // When the mouse cursor is in the primary display, the window cannot move | 818 // When the mouse cursor is in the primary display, the window cannot move |
| 811 // on non-work area with kMinOnscreenHeight margin. | 819 // on non-work area with kMinOnscreenHeight margin. |
| 812 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", | 820 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", |
| 813 window_->bounds().ToString()); | 821 window_->bounds().ToString()); |
| 814 resizer->CompleteDrag(0); | 822 resizer->CompleteDrag(0); |
| 815 } | 823 } |
| 816 | 824 |
| (...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2010 RunAnimationTillComplete(phantom_controller->animation_.get()); | 2018 RunAnimationTillComplete(phantom_controller->animation_.get()); |
| 2011 | 2019 |
| 2012 // Hide phantom controller. Both widgets should close. | 2020 // Hide phantom controller. Both widgets should close. |
| 2013 phantom_controller->Hide(); | 2021 phantom_controller->Hide(); |
| 2014 EXPECT_FALSE(phantom_controller->phantom_widget_); | 2022 EXPECT_FALSE(phantom_controller->phantom_widget_); |
| 2015 EXPECT_FALSE(phantom_controller->phantom_widget_start_); | 2023 EXPECT_FALSE(phantom_controller->phantom_widget_start_); |
| 2016 } | 2024 } |
| 2017 | 2025 |
| 2018 } // namespace internal | 2026 } // namespace internal |
| 2019 } // namespace ash | 2027 } // namespace ash |
| OLD | NEW |