OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/dock/docked_window_resizer.h" | 5 #include "ash/common/wm/dock/docked_window_resizer.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/aura/wm_window_aura.h" |
8 #include "ash/common/shell_window_ids.h" | 9 #include "ash/common/shell_window_ids.h" |
9 #include "ash/common/wm/dock/docked_window_layout_manager.h" | 10 #include "ash/common/wm/dock/docked_window_layout_manager.h" |
10 #include "ash/common/wm/panels/panel_layout_manager.h" | 11 #include "ash/common/wm/panels/panel_layout_manager.h" |
11 #include "ash/common/wm/window_state.h" | 12 #include "ash/common/wm/window_state.h" |
12 #include "ash/common/wm/wm_event.h" | 13 #include "ash/common/wm/wm_event.h" |
13 #include "ash/display/window_tree_host_manager.h" | 14 #include "ash/display/window_tree_host_manager.h" |
14 #include "ash/root_window_controller.h" | 15 #include "ash/root_window_controller.h" |
15 #include "ash/screen_util.h" | 16 #include "ash/screen_util.h" |
16 #include "ash/shelf/shelf.h" | 17 #include "ash/shelf/shelf.h" |
17 #include "ash/shelf/shelf_layout_manager.h" | 18 #include "ash/shelf/shelf_layout_manager.h" |
18 #include "ash/shelf/shelf_model.h" | 19 #include "ash/shelf/shelf_model.h" |
19 #include "ash/shelf/shelf_types.h" | 20 #include "ash/shelf/shelf_types.h" |
20 #include "ash/shelf/shelf_widget.h" | 21 #include "ash/shelf/shelf_widget.h" |
21 #include "ash/shell.h" | 22 #include "ash/shell.h" |
22 #include "ash/test/ash_test_base.h" | 23 #include "ash/test/ash_test_base.h" |
23 #include "ash/test/cursor_manager_test_api.h" | 24 #include "ash/test/cursor_manager_test_api.h" |
24 #include "ash/test/shell_test_api.h" | 25 #include "ash/test/shell_test_api.h" |
25 #include "ash/test/test_shelf_delegate.h" | 26 #include "ash/test/test_shelf_delegate.h" |
26 #include "ash/wm/aura/wm_window_aura.h" | |
27 #include "ash/wm/drag_window_resizer.h" | 27 #include "ash/wm/drag_window_resizer.h" |
28 #include "ash/wm/window_state_aura.h" | 28 #include "ash/wm/window_state_aura.h" |
29 #include "ash/wm/window_util.h" | 29 #include "ash/wm/window_util.h" |
30 #include "base/command_line.h" | 30 #include "base/command_line.h" |
31 #include "ui/aura/client/aura_constants.h" | 31 #include "ui/aura/client/aura_constants.h" |
32 #include "ui/aura/client/window_tree_client.h" | 32 #include "ui/aura/client/window_tree_client.h" |
33 #include "ui/aura/test/test_window_delegate.h" | 33 #include "ui/aura/test/test_window_delegate.h" |
34 #include "ui/aura/window_event_dispatcher.h" | 34 #include "ui/aura/window_event_dispatcher.h" |
35 #include "ui/base/hit_test.h" | 35 #include "ui/base/hit_test.h" |
36 #include "ui/base/ui_base_types.h" | 36 #include "ui/base/ui_base_types.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( | 77 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( |
78 &delegate_, | 78 &delegate_, |
79 window_type_, | 79 window_type_, |
80 0, | 80 0, |
81 bounds); | 81 bounds); |
82 if (window_type_ == ui::wm::WINDOW_TYPE_PANEL) { | 82 if (window_type_ == ui::wm::WINDOW_TYPE_PANEL) { |
83 test::TestShelfDelegate* shelf_delegate = | 83 test::TestShelfDelegate* shelf_delegate = |
84 test::TestShelfDelegate::instance(); | 84 test::TestShelfDelegate::instance(); |
85 shelf_delegate->AddShelfItem(window); | 85 shelf_delegate->AddShelfItem(window); |
86 PanelLayoutManager* manager = | 86 PanelLayoutManager* manager = |
87 PanelLayoutManager::Get(wm::WmWindowAura::Get(window)); | 87 PanelLayoutManager::Get(WmWindowAura::Get(window)); |
88 manager->Relayout(); | 88 manager->Relayout(); |
89 } | 89 } |
90 return window; | 90 return window; |
91 } | 91 } |
92 | 92 |
93 aura::Window* CreateModalWindow(const gfx::Rect& bounds) { | 93 aura::Window* CreateModalWindow(const gfx::Rect& bounds) { |
94 aura::Window* window = new aura::Window(&delegate_); | 94 aura::Window* window = new aura::Window(&delegate_); |
95 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); | 95 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); |
96 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 96 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
97 window->Init(ui::LAYER_TEXTURED); | 97 window->Init(ui::LAYER_TEXTURED); |
(...skipping 12 matching lines...) Expand all Loading... |
110 window->SetBounds(gfx::Rect(origin, bounds.size())); | 110 window->SetBounds(gfx::Rect(origin, bounds.size())); |
111 aura::client::ParentWindowWithContext(window, root, bounds); | 111 aura::client::ParentWindowWithContext(window, root, bounds); |
112 } | 112 } |
113 return window; | 113 return window; |
114 } | 114 } |
115 | 115 |
116 static WindowResizer* CreateSomeWindowResizer( | 116 static WindowResizer* CreateSomeWindowResizer( |
117 aura::Window* window, | 117 aura::Window* window, |
118 const gfx::Point& point_in_parent, | 118 const gfx::Point& point_in_parent, |
119 int window_component) { | 119 int window_component) { |
120 return CreateWindowResizer(wm::WmWindowAura::Get(window), point_in_parent, | 120 return CreateWindowResizer(WmWindowAura::Get(window), point_in_parent, |
121 window_component, | 121 window_component, |
122 aura::client::WINDOW_MOVE_SOURCE_MOUSE) | 122 aura::client::WINDOW_MOVE_SOURCE_MOUSE) |
123 .release(); | 123 .release(); |
124 } | 124 } |
125 | 125 |
126 void DragStart(aura::Window* window) { | 126 void DragStart(aura::Window* window) { |
127 DragStartAtOffsetFromWindowOrigin(window, 0, 0); | 127 DragStartAtOffsetFromWindowOrigin(window, 0, 0); |
128 } | 128 } |
129 | 129 |
130 void DragStartAtOffsetFromWindowOrigin(aura::Window* window, | 130 void DragStartAtOffsetFromWindowOrigin(aura::Window* window, |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 std::unique_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegateAndType( | 599 std::unique_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegateAndType( |
600 NULL, ui::wm::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20))); | 600 NULL, ui::wm::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20))); |
601 wm::GetWindowState(w2.get())->Maximize(); | 601 wm::GetWindowState(w2.get())->Maximize(); |
602 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); | 602 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); |
603 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized()); | 603 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized()); |
604 | 604 |
605 gfx::Rect work_area = display::Screen::GetScreen() | 605 gfx::Rect work_area = display::Screen::GetScreen() |
606 ->GetDisplayNearestWindow(w1.get()) | 606 ->GetDisplayNearestWindow(w1.get()) |
607 .work_area(); | 607 .work_area(); |
608 DockedWindowLayoutManager* manager = | 608 DockedWindowLayoutManager* manager = |
609 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(w1.get())); | 609 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); |
610 | 610 |
611 // Docked window should be centered vertically in the work area. | 611 // Docked window should be centered vertically in the work area. |
612 EXPECT_EQ(work_area.CenterPoint().y(), w1->bounds().CenterPoint().y()); | 612 EXPECT_EQ(work_area.CenterPoint().y(), w1->bounds().CenterPoint().y()); |
613 // Docked background should extend to the bottom of work area. | 613 // Docked background should extend to the bottom of work area. |
614 EXPECT_EQ(work_area.bottom(), manager->docked_bounds().bottom()); | 614 EXPECT_EQ(work_area.bottom(), manager->docked_bounds().bottom()); |
615 | 615 |
616 // Turn on shelf auto-hide. | 616 // Turn on shelf auto-hide. |
617 Shelf::ForPrimaryDisplay()->SetAutoHideBehavior( | 617 Shelf::ForPrimaryDisplay()->SetAutoHideBehavior( |
618 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 618 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
619 work_area = display::Screen::GetScreen() | 619 work_area = display::Screen::GetScreen() |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 677 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
678 } | 678 } |
679 | 679 |
680 // Tests that reverting drag restores undocked state if a window was not docked. | 680 // Tests that reverting drag restores undocked state if a window was not docked. |
681 TEST_P(DockedWindowResizerTest, RevertDockedDragRevertsAttachment) { | 681 TEST_P(DockedWindowResizerTest, RevertDockedDragRevertsAttachment) { |
682 if (!SupportsHostWindowResize()) | 682 if (!SupportsHostWindowResize()) |
683 return; | 683 return; |
684 std::unique_ptr<aura::Window> window( | 684 std::unique_ptr<aura::Window> window( |
685 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 685 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
686 DockedWindowLayoutManager* manager = | 686 DockedWindowLayoutManager* manager = |
687 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(window.get())); | 687 DockedWindowLayoutManager::Get(WmWindowAura::Get(window.get())); |
688 int previous_container_id = window->parent()->id(); | 688 int previous_container_id = window->parent()->id(); |
689 // Drag the window out but revert the drag | 689 // Drag the window out but revert the drag |
690 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); | 690 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); |
691 DragMove(-50 - window->bounds().x(), 50 - window->bounds().y()); | 691 DragMove(-50 - window->bounds().x(), 50 - window->bounds().y()); |
692 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); | 692 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); |
693 DragRevert(); | 693 DragRevert(); |
694 EXPECT_EQ(previous_container_id, window->parent()->id()); | 694 EXPECT_EQ(previous_container_id, window->parent()->id()); |
695 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); | 695 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); |
696 | 696 |
697 // Drag a window to the left so that it overlaps the screen edge. | 697 // Drag a window to the left so that it overlaps the screen edge. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 // Work area should cover the whole screen. | 795 // Work area should cover the whole screen. |
796 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), | 796 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), |
797 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 797 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
798 | 798 |
799 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 799 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
800 // A window should be docked at the right edge. | 800 // A window should be docked at the right edge. |
801 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 801 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
802 w1->GetBoundsInScreen().right()); | 802 w1->GetBoundsInScreen().right()); |
803 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 803 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
804 DockedWindowLayoutManager* manager = | 804 DockedWindowLayoutManager* manager = |
805 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(w1.get())); | 805 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); |
806 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 806 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
807 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 807 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
808 | 808 |
809 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); | 809 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); |
810 // Both windows should now be docked at the right edge. | 810 // Both windows should now be docked at the right edge. |
811 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right(), | 811 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right(), |
812 w2->GetBoundsInScreen().right()); | 812 w2->GetBoundsInScreen().right()); |
813 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 813 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
814 // Dock width should be set to a wider window. | 814 // Dock width should be set to a wider window. |
815 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 815 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 // Work area should cover the whole screen. | 867 // Work area should cover the whole screen. |
868 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), | 868 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), |
869 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 869 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
870 | 870 |
871 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 871 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
872 // A window should be docked at the right edge. | 872 // A window should be docked at the right edge. |
873 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 873 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
874 w1->GetBoundsInScreen().right()); | 874 w1->GetBoundsInScreen().right()); |
875 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 875 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
876 DockedWindowLayoutManager* manager = | 876 DockedWindowLayoutManager* manager = |
877 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(w1.get())); | 877 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); |
878 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 878 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
879 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 879 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
880 | 880 |
881 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(w2.get(), 25, 5)); | 881 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(w2.get(), 25, 5)); |
882 DragMove(w2->GetRootWindow()->bounds().width() | 882 DragMove(w2->GetRootWindow()->bounds().width() |
883 -w2->bounds().width() | 883 -w2->bounds().width() |
884 -(w2->bounds().width()/2 + 20) | 884 -(w2->bounds().width()/2 + 20) |
885 -w2->bounds().x(), | 885 -w2->bounds().x(), |
886 50 - w2->bounds().y()); | 886 50 - w2->bounds().y()); |
887 DragEnd(); | 887 DragEnd(); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 // Work area should cover the whole screen. | 966 // Work area should cover the whole screen. |
967 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), | 967 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), |
968 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 968 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
969 | 969 |
970 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w1.get(), 20); | 970 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w1.get(), 20); |
971 // A window should be docked at the left edge. | 971 // A window should be docked at the left edge. |
972 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().x(), | 972 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().x(), |
973 w1->GetBoundsInScreen().x()); | 973 w1->GetBoundsInScreen().x()); |
974 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 974 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
975 DockedWindowLayoutManager* manager = | 975 DockedWindowLayoutManager* manager = |
976 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(w1.get())); | 976 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); |
977 // The first window should be docked. | 977 // The first window should be docked. |
978 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().x(), | 978 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().x(), |
979 w1->GetBoundsInScreen().x()); | 979 w1->GetBoundsInScreen().x()); |
980 // Dock width should be set to that of a single docked window. | 980 // Dock width should be set to that of a single docked window. |
981 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 981 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
982 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager)); | 982 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager)); |
983 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 983 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
984 | 984 |
985 // Position second window in the desktop 20px to the right of the docked w1. | 985 // Position second window in the desktop 20px to the right of the docked w1. |
986 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_LEFT, | 986 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_LEFT, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 // Work area should cover the whole screen. | 1066 // Work area should cover the whole screen. |
1067 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), | 1067 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), |
1068 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 1068 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
1069 | 1069 |
1070 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1070 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
1071 // A window should be docked at the right edge. | 1071 // A window should be docked at the right edge. |
1072 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 1072 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
1073 w1->GetBoundsInScreen().right()); | 1073 w1->GetBoundsInScreen().right()); |
1074 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1074 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1075 DockedWindowLayoutManager* manager = | 1075 DockedWindowLayoutManager* manager = |
1076 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(w1.get())); | 1076 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); |
1077 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1077 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1078 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1078 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
1079 | 1079 |
1080 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); | 1080 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); |
1081 // Both windows should now be docked at the right edge. | 1081 // Both windows should now be docked at the right edge. |
1082 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right(), | 1082 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right(), |
1083 w2->GetBoundsInScreen().right()); | 1083 w2->GetBoundsInScreen().right()); |
1084 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 1084 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
1085 // Dock width should be set to a wider window. | 1085 // Dock width should be set to a wider window. |
1086 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1086 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 const gfx::Size original_size(201, 201); | 1210 const gfx::Size original_size(201, 201); |
1211 std::unique_ptr<aura::Window> w1( | 1211 std::unique_ptr<aura::Window> w1( |
1212 CreateTestWindow(gfx::Rect(gfx::Point(), original_size))); | 1212 CreateTestWindow(gfx::Rect(gfx::Point(), original_size))); |
1213 | 1213 |
1214 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1214 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
1215 // Window should be docked at the right edge. | 1215 // Window should be docked at the right edge. |
1216 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 1216 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
1217 w1->GetBoundsInScreen().right()); | 1217 w1->GetBoundsInScreen().right()); |
1218 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1218 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1219 DockedWindowLayoutManager* manager = | 1219 DockedWindowLayoutManager* manager = |
1220 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(w1.get())); | 1220 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); |
1221 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1221 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1222 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1222 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
1223 | 1223 |
1224 // Resize the window left by a bit and test that the dock expands. | 1224 // Resize the window left by a bit and test that the dock expands. |
1225 int previous_width = w1->bounds().width(); | 1225 int previous_width = w1->bounds().width(); |
1226 const int kResizeSpan1 = 30; | 1226 const int kResizeSpan1 = 30; |
1227 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(), | 1227 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(), |
1228 0, 20, | 1228 0, 20, |
1229 HTLEFT)); | 1229 HTLEFT)); |
1230 DragMove(-kResizeSpan1, 0); | 1230 DragMove(-kResizeSpan1, 0); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 // Wider display to start since panels are limited to half the display width. | 1264 // Wider display to start since panels are limited to half the display width. |
1265 UpdateDisplay("1000x600"); | 1265 UpdateDisplay("1000x600"); |
1266 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 1266 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
1267 | 1267 |
1268 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1268 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
1269 // Window should be docked at the right edge. | 1269 // Window should be docked at the right edge. |
1270 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 1270 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
1271 w1->GetBoundsInScreen().right()); | 1271 w1->GetBoundsInScreen().right()); |
1272 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1272 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1273 DockedWindowLayoutManager* manager = | 1273 DockedWindowLayoutManager* manager = |
1274 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(w1.get())); | 1274 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); |
1275 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1275 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1276 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1276 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
1277 | 1277 |
1278 // Resize the window left by a bit and test that the dock expands. | 1278 // Resize the window left by a bit and test that the dock expands. |
1279 int previous_width = w1->bounds().width(); | 1279 int previous_width = w1->bounds().width(); |
1280 const int kResizeSpan1 = 30; | 1280 const int kResizeSpan1 = 30; |
1281 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin( | 1281 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin( |
1282 w1.get(), 0, 20, HTLEFT)); | 1282 w1.get(), 0, 20, HTLEFT)); |
1283 DragMove(-kResizeSpan1, 0); | 1283 DragMove(-kResizeSpan1, 0); |
1284 // Normally alignment would be reset to "NONE" during the drag when there is | 1284 // Normally alignment would be reset to "NONE" during the drag when there is |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 1324 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
1325 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); | 1325 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); |
1326 | 1326 |
1327 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1327 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
1328 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); | 1328 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); |
1329 // Both windows should now be docked at the right edge. | 1329 // Both windows should now be docked at the right edge. |
1330 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1330 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1331 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 1331 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
1332 // Dock width should be set to ideal width. | 1332 // Dock width should be set to ideal width. |
1333 DockedWindowLayoutManager* manager = | 1333 DockedWindowLayoutManager* manager = |
1334 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(w1.get())); | 1334 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); |
1335 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1335 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1336 EXPECT_EQ(ideal_width(), docked_width(manager)); | 1336 EXPECT_EQ(ideal_width(), docked_width(manager)); |
1337 | 1337 |
1338 // Resize the first window left by a bit and test that the dock expands. | 1338 // Resize the first window left by a bit and test that the dock expands. |
1339 int previous_width = w1->bounds().width(); | 1339 int previous_width = w1->bounds().width(); |
1340 const int kResizeSpan1 = 30; | 1340 const int kResizeSpan1 = 30; |
1341 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(), | 1341 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(), |
1342 0, 20, | 1342 0, 20, |
1343 HTLEFT)); | 1343 HTLEFT)); |
1344 DragMove(-kResizeSpan1, 0); | 1344 DragMove(-kResizeSpan1, 0); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1393 // Work area should cover the whole screen. | 1393 // Work area should cover the whole screen. |
1394 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w1.get()).width(), | 1394 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w1.get()).width(), |
1395 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).width()); | 1395 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).width()); |
1396 | 1396 |
1397 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1397 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
1398 // A window should be docked at the right edge. | 1398 // A window should be docked at the right edge. |
1399 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 1399 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
1400 w1->GetBoundsInScreen().right()); | 1400 w1->GetBoundsInScreen().right()); |
1401 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1401 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1402 DockedWindowLayoutManager* manager = | 1402 DockedWindowLayoutManager* manager = |
1403 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(w1.get())); | 1403 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); |
1404 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1404 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1405 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1405 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
1406 | 1406 |
1407 // Detach and drag down to shelf. | 1407 // Detach and drag down to shelf. |
1408 ASSERT_NO_FATAL_FAILURE(DragStart(w1.get())); | 1408 ASSERT_NO_FATAL_FAILURE(DragStart(w1.get())); |
1409 DragMove(-40, 0); | 1409 DragMove(-40, 0); |
1410 // Alignment is set to "NONE" when drag starts. | 1410 // Alignment is set to "NONE" when drag starts. |
1411 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); | 1411 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); |
1412 // Release the mouse and the window should be no longer attached to the edge. | 1412 // Release the mouse and the window should be no longer attached to the edge. |
1413 DragEnd(); | 1413 DragEnd(); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1522 return; | 1522 return; |
1523 | 1523 |
1524 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 1524 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
1525 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | 1525 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
1526 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1526 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
1527 // A window should be docked at the right edge. | 1527 // A window should be docked at the right edge. |
1528 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 1528 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
1529 w1->GetBoundsInScreen().right()); | 1529 w1->GetBoundsInScreen().right()); |
1530 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1530 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1531 DockedWindowLayoutManager* manager = | 1531 DockedWindowLayoutManager* manager = |
1532 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(w1.get())); | 1532 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); |
1533 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1533 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1534 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1534 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
1535 EXPECT_TRUE(window_state->IsDocked()); | 1535 EXPECT_TRUE(window_state->IsDocked()); |
1536 EXPECT_FALSE(window_state->IsSnapped()); | 1536 EXPECT_FALSE(window_state->IsSnapped()); |
1537 | 1537 |
1538 // Side snap at right edge. | 1538 // Side snap at right edge. |
1539 const wm::WMEvent snap_right(wm::WM_EVENT_SNAP_RIGHT); | 1539 const wm::WMEvent snap_right(wm::WM_EVENT_SNAP_RIGHT); |
1540 window_state->OnWMEvent(&snap_right); | 1540 window_state->OnWMEvent(&snap_right); |
1541 // The window should be snapped at the right edge and the dock should close. | 1541 // The window should be snapped at the right edge and the dock should close. |
1542 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get())); | 1542 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get())); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1581 std::unique_ptr<aura::Window> window( | 1581 std::unique_ptr<aura::Window> window( |
1582 CreateTestWindow(gfx::Rect(0, 0, ideal_width(), 201))); | 1582 CreateTestWindow(gfx::Rect(0, 0, ideal_width(), 201))); |
1583 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 1583 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
1584 | 1584 |
1585 // Dock the window to the right edge. | 1585 // Dock the window to the right edge. |
1586 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20); | 1586 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20); |
1587 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 1587 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
1588 window->GetBoundsInScreen().right()); | 1588 window->GetBoundsInScreen().right()); |
1589 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 1589 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
1590 DockedWindowLayoutManager* manager = | 1590 DockedWindowLayoutManager* manager = |
1591 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(window.get())); | 1591 DockedWindowLayoutManager::Get(WmWindowAura::Get(window.get())); |
1592 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1592 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1593 EXPECT_EQ(window->bounds().width(), docked_width(manager)); | 1593 EXPECT_EQ(window->bounds().width(), docked_width(manager)); |
1594 EXPECT_TRUE(window_state->IsDocked()); | 1594 EXPECT_TRUE(window_state->IsDocked()); |
1595 | 1595 |
1596 // Maximize the window while in a real drag. In particular, | 1596 // Maximize the window while in a real drag. In particular, |
1597 // ToplevelWindowEventHandler::ScopedWindowResizer::OnWindowStateTypeChanged() | 1597 // ToplevelWindowEventHandler::ScopedWindowResizer::OnWindowStateTypeChanged() |
1598 // must be called in order for the maximized window's size to be correct. | 1598 // must be called in order for the maximized window's size to be correct. |
1599 delegate()->set_window_component(HTCAPTION); | 1599 delegate()->set_window_component(HTCAPTION); |
1600 ui::test::EventGenerator& generator = GetEventGenerator(); | 1600 ui::test::EventGenerator& generator = GetEventGenerator(); |
1601 generator.MoveMouseTo(window->GetBoundsInScreen().origin()); | 1601 generator.MoveMouseTo(window->GetBoundsInScreen().origin()); |
(...skipping 11 matching lines...) Expand all Loading... |
1613 EXPECT_TRUE(window_state->IsMaximized()); | 1613 EXPECT_TRUE(window_state->IsMaximized()); |
1614 } | 1614 } |
1615 | 1615 |
1616 // Tests run twice - on both panels and normal windows | 1616 // Tests run twice - on both panels and normal windows |
1617 INSTANTIATE_TEST_CASE_P(NormalOrPanel, | 1617 INSTANTIATE_TEST_CASE_P(NormalOrPanel, |
1618 DockedWindowResizerTest, | 1618 DockedWindowResizerTest, |
1619 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, | 1619 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, |
1620 ui::wm::WINDOW_TYPE_PANEL)); | 1620 ui::wm::WINDOW_TYPE_PANEL)); |
1621 | 1621 |
1622 } // namespace ash | 1622 } // namespace ash |
OLD | NEW |