| 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/aura/wm_window_aura.h" | |
| 8 #include "ash/common/ash_switches.h" | 7 #include "ash/common/ash_switches.h" |
| 9 #include "ash/common/shelf/shelf_widget.h" | 8 #include "ash/common/shelf/shelf_widget.h" |
| 10 #include "ash/common/shelf/wm_shelf.h" | 9 #include "ash/common/shelf/wm_shelf.h" |
| 11 #include "ash/common/test/test_shelf_delegate.h" | 10 #include "ash/common/test/test_shelf_delegate.h" |
| 12 #include "ash/common/wm/dock/docked_window_layout_manager.h" | 11 #include "ash/common/wm/dock/docked_window_layout_manager.h" |
| 13 #include "ash/common/wm/panels/panel_layout_manager.h" | 12 #include "ash/common/wm/panels/panel_layout_manager.h" |
| 14 #include "ash/common/wm/window_state.h" | 13 #include "ash/common/wm/window_state.h" |
| 15 #include "ash/common/wm/wm_event.h" | 14 #include "ash/common/wm/wm_event.h" |
| 16 #include "ash/common/wm_shell.h" | 15 #include "ash/common/wm_shell.h" |
| 16 #include "ash/common/wm_window.h" |
| 17 #include "ash/display/window_tree_host_manager.h" | 17 #include "ash/display/window_tree_host_manager.h" |
| 18 #include "ash/public/cpp/shelf_types.h" | 18 #include "ash/public/cpp/shelf_types.h" |
| 19 #include "ash/public/cpp/shell_window_ids.h" | 19 #include "ash/public/cpp/shell_window_ids.h" |
| 20 #include "ash/root_window_controller.h" | 20 #include "ash/root_window_controller.h" |
| 21 #include "ash/screen_util.h" | 21 #include "ash/screen_util.h" |
| 22 #include "ash/shell.h" | 22 #include "ash/shell.h" |
| 23 #include "ash/test/ash_test_base.h" | 23 #include "ash/test/ash_test_base.h" |
| 24 #include "ash/test/cursor_manager_test_api.h" | 24 #include "ash/test/cursor_manager_test_api.h" |
| 25 #include "ash/wm/drag_window_resizer.h" | 25 #include "ash/wm/drag_window_resizer.h" |
| 26 #include "ash/wm/window_properties.h" | 26 #include "ash/wm/window_properties.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 int docked_width(const DockedWindowLayoutManager* layout_manager) const { | 69 int docked_width(const DockedWindowLayoutManager* layout_manager) const { |
| 70 return layout_manager->docked_width_; | 70 return layout_manager->docked_width_; |
| 71 } | 71 } |
| 72 int docked_alignment(const DockedWindowLayoutManager* layout_manager) const { | 72 int docked_alignment(const DockedWindowLayoutManager* layout_manager) const { |
| 73 return layout_manager->alignment_; | 73 return layout_manager->alignment_; |
| 74 } | 74 } |
| 75 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { | 75 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { |
| 76 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( | 76 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( |
| 77 &delegate_, window_type_, 0, bounds); | 77 &delegate_, window_type_, 0, bounds); |
| 78 if (window_type_ == ui::wm::WINDOW_TYPE_PANEL) { | 78 if (window_type_ == ui::wm::WINDOW_TYPE_PANEL) { |
| 79 WmWindow* wm_window = WmWindowAura::Get(window); | 79 WmWindow* wm_window = WmWindow::Get(window); |
| 80 test::TestShelfDelegate::instance()->AddShelfItem(wm_window); | 80 test::TestShelfDelegate::instance()->AddShelfItem(wm_window); |
| 81 PanelLayoutManager::Get(wm_window)->Relayout(); | 81 PanelLayoutManager::Get(wm_window)->Relayout(); |
| 82 } | 82 } |
| 83 return window; | 83 return window; |
| 84 } | 84 } |
| 85 | 85 |
| 86 aura::Window* CreateModalWindow(const gfx::Rect& bounds) { | 86 aura::Window* CreateModalWindow(const gfx::Rect& bounds) { |
| 87 aura::Window* window = new aura::Window(&delegate_); | 87 aura::Window* window = new aura::Window(&delegate_); |
| 88 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); | 88 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); |
| 89 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 89 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 103 window->SetBounds(gfx::Rect(origin, bounds.size())); | 103 window->SetBounds(gfx::Rect(origin, bounds.size())); |
| 104 aura::client::ParentWindowWithContext(window, root, bounds); | 104 aura::client::ParentWindowWithContext(window, root, bounds); |
| 105 } | 105 } |
| 106 return window; | 106 return window; |
| 107 } | 107 } |
| 108 | 108 |
| 109 static WindowResizer* CreateSomeWindowResizer( | 109 static WindowResizer* CreateSomeWindowResizer( |
| 110 aura::Window* window, | 110 aura::Window* window, |
| 111 const gfx::Point& point_in_parent, | 111 const gfx::Point& point_in_parent, |
| 112 int window_component) { | 112 int window_component) { |
| 113 return CreateWindowResizer(WmWindowAura::Get(window), point_in_parent, | 113 return CreateWindowResizer(WmWindow::Get(window), point_in_parent, |
| 114 window_component, | 114 window_component, |
| 115 aura::client::WINDOW_MOVE_SOURCE_MOUSE) | 115 aura::client::WINDOW_MOVE_SOURCE_MOUSE) |
| 116 .release(); | 116 .release(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void DragStart(aura::Window* window) { | 119 void DragStart(aura::Window* window) { |
| 120 DragStartAtOffsetFromWindowOrigin(window, 0, 0); | 120 DragStartAtOffsetFromWindowOrigin(window, 0, 0); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void DragStartAtOffsetFromWindowOrigin(aura::Window* window, int dx, int dy) { | 123 void DragStartAtOffsetFromWindowOrigin(aura::Window* window, int dx, int dy) { |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 std::unique_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegateAndType( | 542 std::unique_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegateAndType( |
| 543 NULL, ui::wm::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20))); | 543 NULL, ui::wm::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20))); |
| 544 wm::GetWindowState(w2.get())->Maximize(); | 544 wm::GetWindowState(w2.get())->Maximize(); |
| 545 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); | 545 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); |
| 546 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized()); | 546 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized()); |
| 547 | 547 |
| 548 gfx::Rect work_area = display::Screen::GetScreen() | 548 gfx::Rect work_area = display::Screen::GetScreen() |
| 549 ->GetDisplayNearestWindow(w1.get()) | 549 ->GetDisplayNearestWindow(w1.get()) |
| 550 .work_area(); | 550 .work_area(); |
| 551 DockedWindowLayoutManager* manager = | 551 DockedWindowLayoutManager* manager = |
| 552 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); | 552 DockedWindowLayoutManager::Get(WmWindow::Get(w1.get())); |
| 553 | 553 |
| 554 // Docked window should be centered vertically in the work area. | 554 // Docked window should be centered vertically in the work area. |
| 555 EXPECT_EQ(work_area.CenterPoint().y(), w1->bounds().CenterPoint().y()); | 555 EXPECT_EQ(work_area.CenterPoint().y(), w1->bounds().CenterPoint().y()); |
| 556 // Docked background should extend to the bottom of work area. | 556 // Docked background should extend to the bottom of work area. |
| 557 EXPECT_EQ(work_area.bottom(), manager->docked_bounds().bottom()); | 557 EXPECT_EQ(work_area.bottom(), manager->docked_bounds().bottom()); |
| 558 | 558 |
| 559 // Turn on shelf auto-hide. | 559 // Turn on shelf auto-hide. |
| 560 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 560 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 561 work_area = display::Screen::GetScreen() | 561 work_area = display::Screen::GetScreen() |
| 562 ->GetDisplayNearestWindow(w1.get()) | 562 ->GetDisplayNearestWindow(w1.get()) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 DragMove(-50, 0); | 612 DragMove(-50, 0); |
| 613 DragEnd(); | 613 DragEnd(); |
| 614 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 614 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
| 615 } | 615 } |
| 616 | 616 |
| 617 // Tests that reverting drag restores undocked state if a window was not docked. | 617 // Tests that reverting drag restores undocked state if a window was not docked. |
| 618 TEST_P(DockedWindowResizerTest, RevertDockedDragRevertsAttachment) { | 618 TEST_P(DockedWindowResizerTest, RevertDockedDragRevertsAttachment) { |
| 619 std::unique_ptr<aura::Window> window( | 619 std::unique_ptr<aura::Window> window( |
| 620 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 620 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
| 621 DockedWindowLayoutManager* manager = | 621 DockedWindowLayoutManager* manager = |
| 622 DockedWindowLayoutManager::Get(WmWindowAura::Get(window.get())); | 622 DockedWindowLayoutManager::Get(WmWindow::Get(window.get())); |
| 623 int previous_container_id = window->parent()->id(); | 623 int previous_container_id = window->parent()->id(); |
| 624 // Drag the window out but revert the drag | 624 // Drag the window out but revert the drag |
| 625 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); | 625 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); |
| 626 DragMove(-50 - window->bounds().x(), 50 - window->bounds().y()); | 626 DragMove(-50 - window->bounds().x(), 50 - window->bounds().y()); |
| 627 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); | 627 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); |
| 628 DragRevert(); | 628 DragRevert(); |
| 629 EXPECT_EQ(previous_container_id, window->parent()->id()); | 629 EXPECT_EQ(previous_container_id, window->parent()->id()); |
| 630 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); | 630 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); |
| 631 | 631 |
| 632 // Drag a window to the left so that it overlaps the screen edge. | 632 // Drag a window to the left so that it overlaps the screen edge. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 // Work area should cover the whole screen. | 719 // Work area should cover the whole screen. |
| 720 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), | 720 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), |
| 721 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 721 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
| 722 | 722 |
| 723 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 723 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
| 724 // A window should be docked at the right edge. | 724 // A window should be docked at the right edge. |
| 725 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 725 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
| 726 w1->GetBoundsInScreen().right()); | 726 w1->GetBoundsInScreen().right()); |
| 727 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 727 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 728 DockedWindowLayoutManager* manager = | 728 DockedWindowLayoutManager* manager = |
| 729 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); | 729 DockedWindowLayoutManager::Get(WmWindow::Get(w1.get())); |
| 730 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 730 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
| 731 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 731 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
| 732 | 732 |
| 733 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); | 733 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); |
| 734 // Both windows should now be docked at the right edge. | 734 // Both windows should now be docked at the right edge. |
| 735 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right(), | 735 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right(), |
| 736 w2->GetBoundsInScreen().right()); | 736 w2->GetBoundsInScreen().right()); |
| 737 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 737 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
| 738 // Dock width should be set to a wider window. | 738 // Dock width should be set to a wider window. |
| 739 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 739 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 // Work area should cover the whole screen. | 786 // Work area should cover the whole screen. |
| 787 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), | 787 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), |
| 788 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 788 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
| 789 | 789 |
| 790 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 790 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
| 791 // A window should be docked at the right edge. | 791 // A window should be docked at the right edge. |
| 792 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 792 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
| 793 w1->GetBoundsInScreen().right()); | 793 w1->GetBoundsInScreen().right()); |
| 794 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 794 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 795 DockedWindowLayoutManager* manager = | 795 DockedWindowLayoutManager* manager = |
| 796 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); | 796 DockedWindowLayoutManager::Get(WmWindow::Get(w1.get())); |
| 797 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 797 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
| 798 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 798 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
| 799 | 799 |
| 800 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(w2.get(), 25, 5)); | 800 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(w2.get(), 25, 5)); |
| 801 DragMove(w2->GetRootWindow()->bounds().width() - w2->bounds().width() - | 801 DragMove(w2->GetRootWindow()->bounds().width() - w2->bounds().width() - |
| 802 (w2->bounds().width() / 2 + 20) - w2->bounds().x(), | 802 (w2->bounds().width() / 2 + 20) - w2->bounds().x(), |
| 803 50 - w2->bounds().y()); | 803 50 - w2->bounds().y()); |
| 804 DragEnd(); | 804 DragEnd(); |
| 805 // The first window should be still docked. | 805 // The first window should be still docked. |
| 806 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 806 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 // Work area should cover the whole screen. | 880 // Work area should cover the whole screen. |
| 881 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), | 881 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), |
| 882 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 882 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
| 883 | 883 |
| 884 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w1.get(), 20); | 884 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w1.get(), 20); |
| 885 // A window should be docked at the left edge. | 885 // A window should be docked at the left edge. |
| 886 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().x(), | 886 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().x(), |
| 887 w1->GetBoundsInScreen().x()); | 887 w1->GetBoundsInScreen().x()); |
| 888 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 888 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 889 DockedWindowLayoutManager* manager = | 889 DockedWindowLayoutManager* manager = |
| 890 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); | 890 DockedWindowLayoutManager::Get(WmWindow::Get(w1.get())); |
| 891 // The first window should be docked. | 891 // The first window should be docked. |
| 892 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().x(), | 892 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().x(), |
| 893 w1->GetBoundsInScreen().x()); | 893 w1->GetBoundsInScreen().x()); |
| 894 // Dock width should be set to that of a single docked window. | 894 // Dock width should be set to that of a single docked window. |
| 895 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 895 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 896 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager)); | 896 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager)); |
| 897 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 897 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
| 898 | 898 |
| 899 // Position second window in the desktop 20px to the right of the docked w1. | 899 // Position second window in the desktop 20px to the right of the docked w1. |
| 900 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_LEFT, w2.get(), | 900 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_LEFT, w2.get(), |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 // Work area should cover the whole screen. | 974 // Work area should cover the whole screen. |
| 975 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), | 975 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), |
| 976 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 976 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
| 977 | 977 |
| 978 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 978 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
| 979 // A window should be docked at the right edge. | 979 // A window should be docked at the right edge. |
| 980 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 980 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
| 981 w1->GetBoundsInScreen().right()); | 981 w1->GetBoundsInScreen().right()); |
| 982 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 982 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 983 DockedWindowLayoutManager* manager = | 983 DockedWindowLayoutManager* manager = |
| 984 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); | 984 DockedWindowLayoutManager::Get(WmWindow::Get(w1.get())); |
| 985 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 985 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
| 986 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 986 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
| 987 | 987 |
| 988 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); | 988 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); |
| 989 // Both windows should now be docked at the right edge. | 989 // Both windows should now be docked at the right edge. |
| 990 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right(), | 990 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right(), |
| 991 w2->GetBoundsInScreen().right()); | 991 w2->GetBoundsInScreen().right()); |
| 992 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 992 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
| 993 // Dock width should be set to a wider window. | 993 // Dock width should be set to a wider window. |
| 994 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 994 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 const gfx::Size original_size(201, 201); | 1111 const gfx::Size original_size(201, 201); |
| 1112 std::unique_ptr<aura::Window> w1( | 1112 std::unique_ptr<aura::Window> w1( |
| 1113 CreateTestWindow(gfx::Rect(gfx::Point(), original_size))); | 1113 CreateTestWindow(gfx::Rect(gfx::Point(), original_size))); |
| 1114 | 1114 |
| 1115 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1115 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
| 1116 // Window should be docked at the right edge. | 1116 // Window should be docked at the right edge. |
| 1117 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 1117 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
| 1118 w1->GetBoundsInScreen().right()); | 1118 w1->GetBoundsInScreen().right()); |
| 1119 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1119 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 1120 DockedWindowLayoutManager* manager = | 1120 DockedWindowLayoutManager* manager = |
| 1121 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); | 1121 DockedWindowLayoutManager::Get(WmWindow::Get(w1.get())); |
| 1122 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1122 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
| 1123 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1123 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
| 1124 | 1124 |
| 1125 // Resize the window left by a bit and test that the dock expands. | 1125 // Resize the window left by a bit and test that the dock expands. |
| 1126 int previous_width = w1->bounds().width(); | 1126 int previous_width = w1->bounds().width(); |
| 1127 const int kResizeSpan1 = 30; | 1127 const int kResizeSpan1 = 30; |
| 1128 ASSERT_NO_FATAL_FAILURE( | 1128 ASSERT_NO_FATAL_FAILURE( |
| 1129 ResizeStartAtOffsetFromWindowOrigin(w1.get(), 0, 20, HTLEFT)); | 1129 ResizeStartAtOffsetFromWindowOrigin(w1.get(), 0, 20, HTLEFT)); |
| 1130 DragMove(-kResizeSpan1, 0); | 1130 DragMove(-kResizeSpan1, 0); |
| 1131 // Alignment stays "RIGHT" during the drag because the only docked window | 1131 // Alignment stays "RIGHT" during the drag because the only docked window |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1161 // Wider display to start since panels are limited to half the display width. | 1161 // Wider display to start since panels are limited to half the display width. |
| 1162 UpdateDisplay("1000x600"); | 1162 UpdateDisplay("1000x600"); |
| 1163 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 1163 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
| 1164 | 1164 |
| 1165 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1165 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
| 1166 // Window should be docked at the right edge. | 1166 // Window should be docked at the right edge. |
| 1167 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 1167 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
| 1168 w1->GetBoundsInScreen().right()); | 1168 w1->GetBoundsInScreen().right()); |
| 1169 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1169 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 1170 DockedWindowLayoutManager* manager = | 1170 DockedWindowLayoutManager* manager = |
| 1171 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); | 1171 DockedWindowLayoutManager::Get(WmWindow::Get(w1.get())); |
| 1172 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1172 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
| 1173 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1173 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
| 1174 | 1174 |
| 1175 // Resize the window left by a bit and test that the dock expands. | 1175 // Resize the window left by a bit and test that the dock expands. |
| 1176 int previous_width = w1->bounds().width(); | 1176 int previous_width = w1->bounds().width(); |
| 1177 const int kResizeSpan1 = 30; | 1177 const int kResizeSpan1 = 30; |
| 1178 ASSERT_NO_FATAL_FAILURE( | 1178 ASSERT_NO_FATAL_FAILURE( |
| 1179 ResizeStartAtOffsetFromWindowOrigin(w1.get(), 0, 20, HTLEFT)); | 1179 ResizeStartAtOffsetFromWindowOrigin(w1.get(), 0, 20, HTLEFT)); |
| 1180 DragMove(-kResizeSpan1, 0); | 1180 DragMove(-kResizeSpan1, 0); |
| 1181 // Normally alignment would be reset to "NONE" during the drag when there is | 1181 // Normally alignment would be reset to "NONE" during the drag when there is |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 1218 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
| 1219 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); | 1219 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); |
| 1220 | 1220 |
| 1221 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1221 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
| 1222 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); | 1222 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); |
| 1223 // Both windows should now be docked at the right edge. | 1223 // Both windows should now be docked at the right edge. |
| 1224 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1224 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 1225 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 1225 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
| 1226 // Dock width should be set to ideal width. | 1226 // Dock width should be set to ideal width. |
| 1227 DockedWindowLayoutManager* manager = | 1227 DockedWindowLayoutManager* manager = |
| 1228 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); | 1228 DockedWindowLayoutManager::Get(WmWindow::Get(w1.get())); |
| 1229 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1229 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
| 1230 EXPECT_EQ(ideal_width(), docked_width(manager)); | 1230 EXPECT_EQ(ideal_width(), docked_width(manager)); |
| 1231 | 1231 |
| 1232 // Resize the first window left by a bit and test that the dock expands. | 1232 // Resize the first window left by a bit and test that the dock expands. |
| 1233 int previous_width = w1->bounds().width(); | 1233 int previous_width = w1->bounds().width(); |
| 1234 const int kResizeSpan1 = 30; | 1234 const int kResizeSpan1 = 30; |
| 1235 ASSERT_NO_FATAL_FAILURE( | 1235 ASSERT_NO_FATAL_FAILURE( |
| 1236 ResizeStartAtOffsetFromWindowOrigin(w1.get(), 0, 20, HTLEFT)); | 1236 ResizeStartAtOffsetFromWindowOrigin(w1.get(), 0, 20, HTLEFT)); |
| 1237 DragMove(-kResizeSpan1, 0); | 1237 DragMove(-kResizeSpan1, 0); |
| 1238 DragEnd(); | 1238 DragEnd(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 // Work area should cover the whole screen. | 1281 // Work area should cover the whole screen. |
| 1282 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w1.get()).width(), | 1282 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w1.get()).width(), |
| 1283 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).width()); | 1283 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).width()); |
| 1284 | 1284 |
| 1285 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1285 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
| 1286 // A window should be docked at the right edge. | 1286 // A window should be docked at the right edge. |
| 1287 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 1287 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
| 1288 w1->GetBoundsInScreen().right()); | 1288 w1->GetBoundsInScreen().right()); |
| 1289 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1289 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 1290 DockedWindowLayoutManager* manager = | 1290 DockedWindowLayoutManager* manager = |
| 1291 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); | 1291 DockedWindowLayoutManager::Get(WmWindow::Get(w1.get())); |
| 1292 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1292 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
| 1293 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1293 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
| 1294 | 1294 |
| 1295 // Detach and drag down to shelf. | 1295 // Detach and drag down to shelf. |
| 1296 ASSERT_NO_FATAL_FAILURE(DragStart(w1.get())); | 1296 ASSERT_NO_FATAL_FAILURE(DragStart(w1.get())); |
| 1297 DragMove(-40, 0); | 1297 DragMove(-40, 0); |
| 1298 // Alignment is set to "NONE" when drag starts. | 1298 // Alignment is set to "NONE" when drag starts. |
| 1299 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); | 1299 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); |
| 1300 // Release the mouse and the window should be no longer attached to the edge. | 1300 // Release the mouse and the window should be no longer attached to the edge. |
| 1301 DragEnd(); | 1301 DragEnd(); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1404 return; | 1404 return; |
| 1405 | 1405 |
| 1406 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 1406 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
| 1407 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | 1407 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
| 1408 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1408 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
| 1409 // A window should be docked at the right edge. | 1409 // A window should be docked at the right edge. |
| 1410 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 1410 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
| 1411 w1->GetBoundsInScreen().right()); | 1411 w1->GetBoundsInScreen().right()); |
| 1412 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1412 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
| 1413 DockedWindowLayoutManager* manager = | 1413 DockedWindowLayoutManager* manager = |
| 1414 DockedWindowLayoutManager::Get(WmWindowAura::Get(w1.get())); | 1414 DockedWindowLayoutManager::Get(WmWindow::Get(w1.get())); |
| 1415 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1415 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
| 1416 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1416 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
| 1417 EXPECT_TRUE(window_state->IsDocked()); | 1417 EXPECT_TRUE(window_state->IsDocked()); |
| 1418 EXPECT_FALSE(window_state->IsSnapped()); | 1418 EXPECT_FALSE(window_state->IsSnapped()); |
| 1419 | 1419 |
| 1420 // Side snap at right edge. | 1420 // Side snap at right edge. |
| 1421 const wm::WMEvent snap_right(wm::WM_EVENT_SNAP_RIGHT); | 1421 const wm::WMEvent snap_right(wm::WM_EVENT_SNAP_RIGHT); |
| 1422 window_state->OnWMEvent(&snap_right); | 1422 window_state->OnWMEvent(&snap_right); |
| 1423 // The window should be snapped at the right edge and the dock should close. | 1423 // The window should be snapped at the right edge and the dock should close. |
| 1424 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get())); | 1424 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get())); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1463 std::unique_ptr<aura::Window> window( | 1463 std::unique_ptr<aura::Window> window( |
| 1464 CreateTestWindow(gfx::Rect(0, 0, ideal_width(), 201))); | 1464 CreateTestWindow(gfx::Rect(0, 0, ideal_width(), 201))); |
| 1465 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 1465 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
| 1466 | 1466 |
| 1467 // Dock the window to the right edge. | 1467 // Dock the window to the right edge. |
| 1468 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20); | 1468 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20); |
| 1469 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 1469 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
| 1470 window->GetBoundsInScreen().right()); | 1470 window->GetBoundsInScreen().right()); |
| 1471 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 1471 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
| 1472 DockedWindowLayoutManager* manager = | 1472 DockedWindowLayoutManager* manager = |
| 1473 DockedWindowLayoutManager::Get(WmWindowAura::Get(window.get())); | 1473 DockedWindowLayoutManager::Get(WmWindow::Get(window.get())); |
| 1474 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1474 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
| 1475 EXPECT_EQ(window->bounds().width(), docked_width(manager)); | 1475 EXPECT_EQ(window->bounds().width(), docked_width(manager)); |
| 1476 EXPECT_TRUE(window_state->IsDocked()); | 1476 EXPECT_TRUE(window_state->IsDocked()); |
| 1477 | 1477 |
| 1478 // Maximize the window while in a real drag. In particular, | 1478 // Maximize the window while in a real drag. In particular, |
| 1479 // ToplevelWindowEventHandler::ScopedWindowResizer::OnWindowStateTypeChanged() | 1479 // ToplevelWindowEventHandler::ScopedWindowResizer::OnWindowStateTypeChanged() |
| 1480 // must be called in order for the maximized window's size to be correct. | 1480 // must be called in order for the maximized window's size to be correct. |
| 1481 delegate()->set_window_component(HTCAPTION); | 1481 delegate()->set_window_component(HTCAPTION); |
| 1482 ui::test::EventGenerator& generator = GetEventGenerator(); | 1482 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 1483 generator.MoveMouseTo(window->GetBoundsInScreen().origin()); | 1483 generator.MoveMouseTo(window->GetBoundsInScreen().origin()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1495 EXPECT_TRUE(window_state->IsMaximized()); | 1495 EXPECT_TRUE(window_state->IsMaximized()); |
| 1496 } | 1496 } |
| 1497 | 1497 |
| 1498 // Tests run twice - on both panels and normal windows | 1498 // Tests run twice - on both panels and normal windows |
| 1499 INSTANTIATE_TEST_CASE_P(NormalOrPanel, | 1499 INSTANTIATE_TEST_CASE_P(NormalOrPanel, |
| 1500 DockedWindowResizerTest, | 1500 DockedWindowResizerTest, |
| 1501 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, | 1501 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, |
| 1502 ui::wm::WINDOW_TYPE_PANEL)); | 1502 ui::wm::WINDOW_TYPE_PANEL)); |
| 1503 | 1503 |
| 1504 } // namespace ash | 1504 } // namespace ash |
| OLD | NEW |