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 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 resizer->CompleteDrag(0); | 627 resizer->CompleteDrag(0); |
628 EXPECT_EQ("80,0 720x" + base::IntToString(bottom), | 628 EXPECT_EQ("80,0 720x" + base::IntToString(bottom), |
629 window_->bounds().ToString()); | 629 window_->bounds().ToString()); |
630 ASSERT_TRUE(window_state->HasRestoreBounds()); | 630 ASSERT_TRUE(window_state->HasRestoreBounds()); |
631 EXPECT_EQ("20,30 400x60", | 631 EXPECT_EQ("20,30 400x60", |
632 window_state->GetRestoreBoundsInScreen().ToString()); | 632 window_state->GetRestoreBoundsInScreen().ToString()); |
633 } | 633 } |
634 | 634 |
635 // Test if the restore bounds is correct in multiple displays. | 635 // Test if the restore bounds is correct in multiple displays. |
636 window_state->ClearRestoreBounds(); | 636 window_state->ClearRestoreBounds(); |
| 637 // Emulate user drag to clear snapped state. |
| 638 window_state->SetBoundsChangedByUser(true); |
637 | 639 |
638 if (!SupportsMultipleDisplays()) | 640 if (!SupportsMultipleDisplays()) |
639 return; | 641 return; |
640 | 642 |
641 UpdateDisplay("800x600,500x600"); | 643 UpdateDisplay("800x600,500x600"); |
642 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 644 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
643 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 645 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
644 // Window is wide enough not to get docked right away. | 646 // Window is wide enough not to get docked right away. |
645 window_->SetBoundsInScreen(gfx::Rect(800, 10, 400, 60), | 647 window_->SetBoundsInScreen(gfx::Rect(800, 10, 400, 60), |
646 ScreenAsh::GetSecondaryDisplay()); | 648 ScreenAsh::GetSecondaryDisplay()); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); | 775 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); |
774 | 776 |
775 // Positions the secondary display at the bottom the primary display. | 777 // Positions the secondary display at the bottom the primary display. |
776 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( | 778 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
777 ash::DisplayLayout(ash::DisplayLayout::BOTTOM, 0)); | 779 ash::DisplayLayout(ash::DisplayLayout::BOTTOM, 0)); |
778 | 780 |
779 { | 781 { |
780 window_->SetBounds(gfx::Rect(100, 200, 300, 20)); | 782 window_->SetBounds(gfx::Rect(100, 200, 300, 20)); |
781 DCHECK_LT(window_->bounds().height(), | 783 DCHECK_LT(window_->bounds().height(), |
782 WorkspaceWindowResizer::kMinOnscreenHeight); | 784 WorkspaceWindowResizer::kMinOnscreenHeight); |
| 785 // Drag down avoiding dragging along the edge as that would side-snap. |
783 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 786 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
784 window_.get(), gfx::Point(), HTCAPTION)); | 787 window_.get(), gfx::Point(10, 0), HTCAPTION)); |
785 ASSERT_TRUE(resizer.get()); | 788 ASSERT_TRUE(resizer.get()); |
786 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); | 789 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); |
787 int expected_y = kRootHeight - window_->bounds().height() - 10; | 790 int expected_y = kRootHeight - window_->bounds().height() - 10; |
788 // When the mouse cursor is in the primary display, the window cannot move | 791 // When the mouse cursor is in the primary display, the window cannot move |
789 // on non-work area but can get all the way towards the bottom, | 792 // on non-work area but can get all the way towards the bottom, |
790 // restricted only by the window height. | 793 // restricted only by the window height. |
791 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x20", | 794 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x20", |
792 window_->bounds().ToString()); | 795 window_->bounds().ToString()); |
793 // Revert the drag in order to not remember the restore bounds. | 796 // Revert the drag in order to not remember the restore bounds. |
794 resizer->RevertDrag(); | 797 resizer->RevertDrag(); |
795 } | 798 } |
796 | 799 |
797 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 800 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
798 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); | 801 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); |
799 { | 802 { |
800 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); | 803 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); |
801 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 804 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
802 window_.get(), gfx::Point(), HTCAPTION)); | 805 window_.get(), gfx::Point(10, 0), HTCAPTION)); |
803 ASSERT_TRUE(resizer.get()); | 806 ASSERT_TRUE(resizer.get()); |
| 807 // Drag down avoiding dragging along the edge as that would side-snap. |
804 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); | 808 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); |
805 int expected_y = | 809 int expected_y = |
806 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; | 810 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; |
807 // When the mouse cursor is in the primary display, the window cannot move | 811 // When the mouse cursor is in the primary display, the window cannot move |
808 // on non-work area with kMinOnscreenHeight margin. | 812 // on non-work area with kMinOnscreenHeight margin. |
809 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", | 813 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", |
810 window_->bounds().ToString()); | 814 window_->bounds().ToString()); |
811 resizer->CompleteDrag(0); | 815 resizer->CompleteDrag(0); |
812 } | 816 } |
813 | 817 |
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2007 RunAnimationTillComplete(phantom_controller->animation_.get()); | 2011 RunAnimationTillComplete(phantom_controller->animation_.get()); |
2008 | 2012 |
2009 // Hide phantom controller. Both widgets should close. | 2013 // Hide phantom controller. Both widgets should close. |
2010 phantom_controller->Hide(); | 2014 phantom_controller->Hide(); |
2011 EXPECT_FALSE(phantom_controller->phantom_widget_); | 2015 EXPECT_FALSE(phantom_controller->phantom_widget_); |
2012 EXPECT_FALSE(phantom_controller->phantom_widget_start_); | 2016 EXPECT_FALSE(phantom_controller->phantom_widget_start_); |
2013 } | 2017 } |
2014 | 2018 |
2015 } // namespace internal | 2019 } // namespace internal |
2016 } // namespace ash | 2020 } // namespace ash |
OLD | NEW |