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 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
628 window_.get(), gfx::Point(), HTCAPTION)); | 628 window_.get(), gfx::Point(), HTCAPTION)); |
629 ASSERT_TRUE(resizer.get()); | 629 ASSERT_TRUE(resizer.get()); |
630 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); | 630 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); |
631 resizer->CompleteDrag(0); | 631 resizer->CompleteDrag(0); |
632 EXPECT_EQ(expected_bounds.ToString(), window_->bounds().ToString()); | 632 EXPECT_EQ(expected_bounds.ToString(), window_->bounds().ToString()); |
633 ASSERT_TRUE(window_state->HasRestoreBounds()); | 633 ASSERT_TRUE(window_state->HasRestoreBounds()); |
634 EXPECT_EQ("20,30 400x60", | 634 EXPECT_EQ("20,30 400x60", |
635 window_state->GetRestoreBoundsInScreen().ToString()); | 635 window_state->GetRestoreBoundsInScreen().ToString()); |
636 } | 636 } |
637 | 637 |
638 // Test if the restore bounds is correct in multiple displays. | 638 // Test if the restore bounds is correct in multiple displays. |
pkotwicz
2013/11/27 20:24:43
Do we still need to clear the restored bounds if w
varkha
2013/11/28 01:09:37
Done.
| |
639 window_state->ClearRestoreBounds(); | 639 window_state->ClearRestoreBounds(); |
640 // Restore to clear snapped state. | |
641 window_state->Restore(); | |
640 | 642 |
641 if (!SupportsMultipleDisplays()) | 643 if (!SupportsMultipleDisplays()) |
642 return; | 644 return; |
643 | 645 |
644 UpdateDisplay("800x600,500x600"); | 646 UpdateDisplay("800x600,500x600"); |
645 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 647 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
646 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 648 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
647 // Window is wide enough not to get docked right away. | 649 // Window is wide enough not to get docked right away. |
648 window_->SetBoundsInScreen(gfx::Rect(800, 10, 400, 60), | 650 window_->SetBoundsInScreen(gfx::Rect(800, 10, 400, 60), |
649 ScreenAsh::GetSecondaryDisplay()); | 651 ScreenAsh::GetSecondaryDisplay()); |
650 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | 652 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
651 { | 653 { |
652 EXPECT_EQ("800,10 400x60", window_->GetBoundsInScreen().ToString()); | 654 EXPECT_EQ("800,10 400x60", window_->GetBoundsInScreen().ToString()); |
653 | 655 |
654 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 656 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
655 window_.get(), gfx::Point(), HTCAPTION)); | 657 window_.get(), gfx::Point(), HTCAPTION)); |
656 ASSERT_TRUE(resizer.get()); | 658 ASSERT_TRUE(resizer.get()); |
657 resizer->Drag(CalculateDragPoint(*resizer, 499, 00), 0); | 659 resizer->Drag(CalculateDragPoint(*resizer, 499, 00), 0); |
pkotwicz
2013/11/27 20:24:43
Nit: 00 -> 0
varkha
2013/11/28 01:09:37
Done.
| |
658 int bottom = | 660 int bottom = |
659 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); | 661 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); |
660 resizer->CompleteDrag(0); | 662 resizer->CompleteDrag(0); |
661 // With the resolution of 500x600 we will hit in this case the 50% screen | 663 // With the resolution of 500x600 we will hit in this case the 50% screen |
662 // size setting. | 664 // size setting. |
663 // TODO(varkha): Insets are updated because of http://crbug.com/292238 | 665 // TODO(varkha): Insets are updated because of http://crbug.com/292238 |
664 EXPECT_EQ("250,0 250x" + base::IntToString(bottom), | 666 EXPECT_EQ("250,0 250x" + base::IntToString(bottom), |
665 window_->bounds().ToString()); | 667 window_->bounds().ToString()); |
666 EXPECT_EQ("800,10 400x60", | 668 EXPECT_EQ("800,10 400x60", |
667 window_state->GetRestoreBoundsInScreen().ToString()); | 669 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)); | 778 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); |
777 | 779 |
778 // Positions the secondary display at the bottom the primary display. | 780 // Positions the secondary display at the bottom the primary display. |
779 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( | 781 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
780 ash::DisplayLayout(ash::DisplayLayout::BOTTOM, 0)); | 782 ash::DisplayLayout(ash::DisplayLayout::BOTTOM, 0)); |
781 | 783 |
782 { | 784 { |
783 window_->SetBounds(gfx::Rect(100, 200, 300, 20)); | 785 window_->SetBounds(gfx::Rect(100, 200, 300, 20)); |
784 DCHECK_LT(window_->bounds().height(), | 786 DCHECK_LT(window_->bounds().height(), |
785 WorkspaceWindowResizer::kMinOnscreenHeight); | 787 WorkspaceWindowResizer::kMinOnscreenHeight); |
788 // Drag down avoiding dragging along the edge as that would side-snap. | |
786 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 789 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
787 window_.get(), gfx::Point(), HTCAPTION)); | 790 window_.get(), gfx::Point(10, 0), HTCAPTION)); |
788 ASSERT_TRUE(resizer.get()); | 791 ASSERT_TRUE(resizer.get()); |
789 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); | 792 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); |
790 int expected_y = kRootHeight - window_->bounds().height() - 10; | 793 int expected_y = kRootHeight - window_->bounds().height() - 10; |
791 // When the mouse cursor is in the primary display, the window cannot move | 794 // 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, | 795 // on non-work area but can get all the way towards the bottom, |
793 // restricted only by the window height. | 796 // restricted only by the window height. |
794 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x20", | 797 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x20", |
795 window_->bounds().ToString()); | 798 window_->bounds().ToString()); |
796 // Revert the drag in order to not remember the restore bounds. | 799 // Revert the drag in order to not remember the restore bounds. |
797 resizer->RevertDrag(); | 800 resizer->RevertDrag(); |
798 } | 801 } |
799 | 802 |
800 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 803 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
801 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); | 804 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); |
802 { | 805 { |
803 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); | 806 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); |
804 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 807 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
805 window_.get(), gfx::Point(), HTCAPTION)); | 808 window_.get(), gfx::Point(10, 0), HTCAPTION)); |
806 ASSERT_TRUE(resizer.get()); | 809 ASSERT_TRUE(resizer.get()); |
810 // Drag down avoiding dragging along the edge as that would side-snap. | |
807 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); | 811 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); |
808 int expected_y = | 812 int expected_y = |
809 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; | 813 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; |
810 // When the mouse cursor is in the primary display, the window cannot move | 814 // When the mouse cursor is in the primary display, the window cannot move |
811 // on non-work area with kMinOnscreenHeight margin. | 815 // on non-work area with kMinOnscreenHeight margin. |
812 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", | 816 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", |
813 window_->bounds().ToString()); | 817 window_->bounds().ToString()); |
814 resizer->CompleteDrag(0); | 818 resizer->CompleteDrag(0); |
815 } | 819 } |
816 | 820 |
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2010 RunAnimationTillComplete(phantom_controller->animation_.get()); | 2014 RunAnimationTillComplete(phantom_controller->animation_.get()); |
2011 | 2015 |
2012 // Hide phantom controller. Both widgets should close. | 2016 // Hide phantom controller. Both widgets should close. |
2013 phantom_controller->Hide(); | 2017 phantom_controller->Hide(); |
2014 EXPECT_FALSE(phantom_controller->phantom_widget_); | 2018 EXPECT_FALSE(phantom_controller->phantom_widget_); |
2015 EXPECT_FALSE(phantom_controller->phantom_widget_start_); | 2019 EXPECT_FALSE(phantom_controller->phantom_widget_start_); |
2016 } | 2020 } |
2017 | 2021 |
2018 } // namespace internal | 2022 } // namespace internal |
2019 } // namespace ash | 2023 } // namespace ash |
OLD | NEW |