Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Side by Side Diff: ash/wm/dock/docked_window_resizer_unittest.cc

Issue 1907863002: Converts DockedWindowLayoutManager to common ash/wm types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/wm/dock/docked_window_resizer.cc ('k') | ash/wm/window_resizer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/wm/dock/docked_window_resizer.h" 5 #include "ash/wm/dock/docked_window_resizer.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/display/window_tree_host_manager.h" 8 #include "ash/display/window_tree_host_manager.h"
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/screen_util.h" 10 #include "ash/screen_util.h"
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 602
603 std::unique_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegateAndType( 603 std::unique_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegateAndType(
604 NULL, ui::wm::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20))); 604 NULL, ui::wm::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20)));
605 wm::GetWindowState(w2.get())->Maximize(); 605 wm::GetWindowState(w2.get())->Maximize();
606 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); 606 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id());
607 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized()); 607 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized());
608 608
609 gfx::Rect work_area = 609 gfx::Rect work_area =
610 gfx::Screen::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); 610 gfx::Screen::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area();
611 DockedWindowLayoutManager* manager = 611 DockedWindowLayoutManager* manager =
612 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); 612 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(w1.get()));
613 613
614 // Docked window should be centered vertically in the work area. 614 // Docked window should be centered vertically in the work area.
615 EXPECT_EQ(work_area.CenterPoint().y(), w1->bounds().CenterPoint().y()); 615 EXPECT_EQ(work_area.CenterPoint().y(), w1->bounds().CenterPoint().y());
616 // Docked background should extend to the bottom of work area. 616 // Docked background should extend to the bottom of work area.
617 EXPECT_EQ(work_area.bottom(), manager->docked_bounds().bottom()); 617 EXPECT_EQ(work_area.bottom(), manager->docked_bounds().bottom());
618 618
619 // set launcher shelf to be aligned on the right 619 // set launcher shelf to be aligned on the right
620 ash::Shell* shell = ash::Shell::GetInstance(); 620 ash::Shell* shell = ash::Shell::GetInstance();
621 shell->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 621 shell->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
622 shell->GetPrimaryRootWindow()); 622 shell->GetPrimaryRootWindow());
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 DragEnd(); 679 DragEnd();
680 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); 680 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
681 } 681 }
682 682
683 // Tests that reverting drag restores undocked state if a window was not docked. 683 // Tests that reverting drag restores undocked state if a window was not docked.
684 TEST_P(DockedWindowResizerTest, RevertDockedDragRevertsAttachment) { 684 TEST_P(DockedWindowResizerTest, RevertDockedDragRevertsAttachment) {
685 if (!SupportsHostWindowResize()) 685 if (!SupportsHostWindowResize())
686 return; 686 return;
687 std::unique_ptr<aura::Window> window( 687 std::unique_ptr<aura::Window> window(
688 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 688 CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
689 aura::Window* dock_container = Shell::GetContainer(
690 window->GetRootWindow(),
691 kShellWindowId_DockedContainer);
692 DockedWindowLayoutManager* manager = 689 DockedWindowLayoutManager* manager =
693 static_cast<DockedWindowLayoutManager*>(dock_container->layout_manager()); 690 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(window.get()));
694 int previous_container_id = window->parent()->id(); 691 int previous_container_id = window->parent()->id();
695 // Drag the window out but revert the drag 692 // Drag the window out but revert the drag
696 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); 693 ASSERT_NO_FATAL_FAILURE(DragStart(window.get()));
697 DragMove(-50 - window->bounds().x(), 50 - window->bounds().y()); 694 DragMove(-50 - window->bounds().x(), 50 - window->bounds().y());
698 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); 695 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id());
699 DragRevert(); 696 DragRevert();
700 EXPECT_EQ(previous_container_id, window->parent()->id()); 697 EXPECT_EQ(previous_container_id, window->parent()->id());
701 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); 698 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager));
702 699
703 // Drag a window to the left so that it overlaps the screen edge. 700 // 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
801 // Work area should cover the whole screen. 798 // Work area should cover the whole screen.
802 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), 799 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(),
803 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); 800 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width());
804 801
805 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); 802 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
806 // A window should be docked at the right edge. 803 // A window should be docked at the right edge.
807 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), 804 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(),
808 w1->GetBoundsInScreen().right()); 805 w1->GetBoundsInScreen().right());
809 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); 806 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
810 DockedWindowLayoutManager* manager = 807 DockedWindowLayoutManager* manager =
811 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); 808 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(w1.get()));
812 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 809 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
813 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 810 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
814 811
815 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); 812 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100);
816 // Both windows should now be docked at the right edge. 813 // Both windows should now be docked at the right edge.
817 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right(), 814 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right(),
818 w2->GetBoundsInScreen().right()); 815 w2->GetBoundsInScreen().right());
819 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); 816 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id());
820 // Dock width should be set to a wider window. 817 // Dock width should be set to a wider window.
821 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 818 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 // Work area should cover the whole screen. 870 // Work area should cover the whole screen.
874 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), 871 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(),
875 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); 872 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width());
876 873
877 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); 874 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
878 // A window should be docked at the right edge. 875 // A window should be docked at the right edge.
879 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), 876 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(),
880 w1->GetBoundsInScreen().right()); 877 w1->GetBoundsInScreen().right());
881 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); 878 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
882 DockedWindowLayoutManager* manager = 879 DockedWindowLayoutManager* manager =
883 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); 880 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(w1.get()));
884 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 881 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
885 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 882 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
886 883
887 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(w2.get(), 25, 5)); 884 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(w2.get(), 25, 5));
888 DragMove(w2->GetRootWindow()->bounds().width() 885 DragMove(w2->GetRootWindow()->bounds().width()
889 -w2->bounds().width() 886 -w2->bounds().width()
890 -(w2->bounds().width()/2 + 20) 887 -(w2->bounds().width()/2 + 20)
891 -w2->bounds().x(), 888 -w2->bounds().x(),
892 50 - w2->bounds().y()); 889 50 - w2->bounds().y());
893 DragEnd(); 890 DragEnd();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 // Work area should cover the whole screen. 969 // Work area should cover the whole screen.
973 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), 970 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(),
974 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); 971 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width());
975 972
976 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w1.get(), 20); 973 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w1.get(), 20);
977 // A window should be docked at the left edge. 974 // A window should be docked at the left edge.
978 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().x(), 975 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().x(),
979 w1->GetBoundsInScreen().x()); 976 w1->GetBoundsInScreen().x());
980 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); 977 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
981 DockedWindowLayoutManager* manager = 978 DockedWindowLayoutManager* manager =
982 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); 979 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(w1.get()));
983 // The first window should be docked. 980 // The first window should be docked.
984 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().x(), 981 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().x(),
985 w1->GetBoundsInScreen().x()); 982 w1->GetBoundsInScreen().x());
986 // Dock width should be set to that of a single docked window. 983 // Dock width should be set to that of a single docked window.
987 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); 984 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
988 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager)); 985 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, docked_alignment(manager));
989 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 986 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
990 987
991 // Position second window in the desktop 20px to the right of the docked w1. 988 // Position second window in the desktop 20px to the right of the docked w1.
992 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_LEFT, 989 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_LEFT,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 // Work area should cover the whole screen. 1069 // Work area should cover the whole screen.
1073 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), 1070 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(),
1074 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); 1071 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width());
1075 1072
1076 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); 1073 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
1077 // A window should be docked at the right edge. 1074 // A window should be docked at the right edge.
1078 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), 1075 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(),
1079 w1->GetBoundsInScreen().right()); 1076 w1->GetBoundsInScreen().right());
1080 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); 1077 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1081 DockedWindowLayoutManager* manager = 1078 DockedWindowLayoutManager* manager =
1082 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); 1079 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(w1.get()));
1083 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1080 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1084 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 1081 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
1085 1082
1086 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); 1083 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100);
1087 // Both windows should now be docked at the right edge. 1084 // Both windows should now be docked at the right edge.
1088 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right(), 1085 EXPECT_EQ(w2->GetRootWindow()->GetBoundsInScreen().right(),
1089 w2->GetBoundsInScreen().right()); 1086 w2->GetBoundsInScreen().right());
1090 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); 1087 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id());
1091 // Dock width should be set to a wider window. 1088 // Dock width should be set to a wider window.
1092 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1089 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 const gfx::Size original_size(201, 201); 1213 const gfx::Size original_size(201, 201);
1217 std::unique_ptr<aura::Window> w1( 1214 std::unique_ptr<aura::Window> w1(
1218 CreateTestWindow(gfx::Rect(gfx::Point(), original_size))); 1215 CreateTestWindow(gfx::Rect(gfx::Point(), original_size)));
1219 1216
1220 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); 1217 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
1221 // Window should be docked at the right edge. 1218 // Window should be docked at the right edge.
1222 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), 1219 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(),
1223 w1->GetBoundsInScreen().right()); 1220 w1->GetBoundsInScreen().right());
1224 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); 1221 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1225 DockedWindowLayoutManager* manager = 1222 DockedWindowLayoutManager* manager =
1226 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); 1223 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(w1.get()));
1227 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1224 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1228 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 1225 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
1229 1226
1230 // Resize the window left by a bit and test that the dock expands. 1227 // Resize the window left by a bit and test that the dock expands.
1231 int previous_width = w1->bounds().width(); 1228 int previous_width = w1->bounds().width();
1232 const int kResizeSpan1 = 30; 1229 const int kResizeSpan1 = 30;
1233 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(), 1230 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(),
1234 0, 20, 1231 0, 20,
1235 HTLEFT)); 1232 HTLEFT));
1236 DragMove(-kResizeSpan1, 0); 1233 DragMove(-kResizeSpan1, 0);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 // Wider display to start since panels are limited to half the display width. 1267 // Wider display to start since panels are limited to half the display width.
1271 UpdateDisplay("1000x600"); 1268 UpdateDisplay("1000x600");
1272 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 1269 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
1273 1270
1274 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); 1271 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
1275 // Window should be docked at the right edge. 1272 // Window should be docked at the right edge.
1276 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), 1273 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(),
1277 w1->GetBoundsInScreen().right()); 1274 w1->GetBoundsInScreen().right());
1278 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); 1275 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1279 DockedWindowLayoutManager* manager = 1276 DockedWindowLayoutManager* manager =
1280 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); 1277 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(w1.get()));
1281 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1278 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1282 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 1279 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
1283 1280
1284 // Resize the window left by a bit and test that the dock expands. 1281 // Resize the window left by a bit and test that the dock expands.
1285 int previous_width = w1->bounds().width(); 1282 int previous_width = w1->bounds().width();
1286 const int kResizeSpan1 = 30; 1283 const int kResizeSpan1 = 30;
1287 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin( 1284 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(
1288 w1.get(), 0, 20, HTLEFT)); 1285 w1.get(), 0, 20, HTLEFT));
1289 DragMove(-kResizeSpan1, 0); 1286 DragMove(-kResizeSpan1, 0);
1290 // Normally alignment would be reset to "NONE" during the drag when there is 1287 // 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
1330 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 1327 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
1331 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); 1328 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201)));
1332 1329
1333 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); 1330 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
1334 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); 1331 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100);
1335 // Both windows should now be docked at the right edge. 1332 // Both windows should now be docked at the right edge.
1336 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); 1333 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1337 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); 1334 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id());
1338 // Dock width should be set to ideal width. 1335 // Dock width should be set to ideal width.
1339 DockedWindowLayoutManager* manager = 1336 DockedWindowLayoutManager* manager =
1340 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); 1337 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(w1.get()));
1341 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1338 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1342 EXPECT_EQ(ideal_width(), docked_width(manager)); 1339 EXPECT_EQ(ideal_width(), docked_width(manager));
1343 1340
1344 // Resize the first window left by a bit and test that the dock expands. 1341 // Resize the first window left by a bit and test that the dock expands.
1345 int previous_width = w1->bounds().width(); 1342 int previous_width = w1->bounds().width();
1346 const int kResizeSpan1 = 30; 1343 const int kResizeSpan1 = 30;
1347 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(), 1344 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromWindowOrigin(w1.get(),
1348 0, 20, 1345 0, 20,
1349 HTLEFT)); 1346 HTLEFT));
1350 DragMove(-kResizeSpan1, 0); 1347 DragMove(-kResizeSpan1, 0);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 // Work area should cover the whole screen. 1396 // Work area should cover the whole screen.
1400 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w1.get()).width(), 1397 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w1.get()).width(),
1401 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).width()); 1398 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).width());
1402 1399
1403 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); 1400 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
1404 // A window should be docked at the right edge. 1401 // A window should be docked at the right edge.
1405 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), 1402 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(),
1406 w1->GetBoundsInScreen().right()); 1403 w1->GetBoundsInScreen().right());
1407 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); 1404 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1408 DockedWindowLayoutManager* manager = 1405 DockedWindowLayoutManager* manager =
1409 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); 1406 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(w1.get()));
1410 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1407 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1411 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 1408 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
1412 1409
1413 // Detach and drag down to shelf. 1410 // Detach and drag down to shelf.
1414 ASSERT_NO_FATAL_FAILURE(DragStart(w1.get())); 1411 ASSERT_NO_FATAL_FAILURE(DragStart(w1.get()));
1415 DragMove(-40, 0); 1412 DragMove(-40, 0);
1416 // Alignment is set to "NONE" when drag starts. 1413 // Alignment is set to "NONE" when drag starts.
1417 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); 1414 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager));
1418 // Release the mouse and the window should be no longer attached to the edge. 1415 // Release the mouse and the window should be no longer attached to the edge.
1419 DragEnd(); 1416 DragEnd();
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 return; 1525 return;
1529 1526
1530 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 1527 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
1531 wm::WindowState* window_state = wm::GetWindowState(w1.get()); 1528 wm::WindowState* window_state = wm::GetWindowState(w1.get());
1532 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); 1529 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
1533 // A window should be docked at the right edge. 1530 // A window should be docked at the right edge.
1534 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), 1531 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(),
1535 w1->GetBoundsInScreen().right()); 1532 w1->GetBoundsInScreen().right());
1536 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); 1533 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id());
1537 DockedWindowLayoutManager* manager = 1534 DockedWindowLayoutManager* manager =
1538 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); 1535 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(w1.get()));
1539 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1536 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1540 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); 1537 EXPECT_EQ(w1->bounds().width(), docked_width(manager));
1541 EXPECT_TRUE(window_state->IsDocked()); 1538 EXPECT_TRUE(window_state->IsDocked());
1542 EXPECT_FALSE(window_state->IsSnapped()); 1539 EXPECT_FALSE(window_state->IsSnapped());
1543 1540
1544 // Side snap at right edge. 1541 // Side snap at right edge.
1545 const wm::WMEvent snap_right(wm::WM_EVENT_SNAP_RIGHT); 1542 const wm::WMEvent snap_right(wm::WM_EVENT_SNAP_RIGHT);
1546 window_state->OnWMEvent(&snap_right); 1543 window_state->OnWMEvent(&snap_right);
1547 // The window should be snapped at the right edge and the dock should close. 1544 // The window should be snapped at the right edge and the dock should close.
1548 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get())); 1545 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 std::unique_ptr<aura::Window> window( 1584 std::unique_ptr<aura::Window> window(
1588 CreateTestWindow(gfx::Rect(0, 0, ideal_width(), 201))); 1585 CreateTestWindow(gfx::Rect(0, 0, ideal_width(), 201)));
1589 wm::WindowState* window_state = wm::GetWindowState(window.get()); 1586 wm::WindowState* window_state = wm::GetWindowState(window.get());
1590 1587
1591 // Dock the window to the right edge. 1588 // Dock the window to the right edge.
1592 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20); 1589 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20);
1593 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), 1590 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(),
1594 window->GetBoundsInScreen().right()); 1591 window->GetBoundsInScreen().right());
1595 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); 1592 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id());
1596 DockedWindowLayoutManager* manager = 1593 DockedWindowLayoutManager* manager =
1597 static_cast<DockedWindowLayoutManager*>( 1594 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(window.get()));
1598 window->parent()->layout_manager());
1599 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); 1595 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager));
1600 EXPECT_EQ(window->bounds().width(), docked_width(manager)); 1596 EXPECT_EQ(window->bounds().width(), docked_width(manager));
1601 EXPECT_TRUE(window_state->IsDocked()); 1597 EXPECT_TRUE(window_state->IsDocked());
1602 1598
1603 // Maximize the window while in a real drag. In particular, 1599 // Maximize the window while in a real drag. In particular,
1604 // ToplevelWindowEventHandler::ScopedWindowResizer::OnWindowStateTypeChanged() 1600 // ToplevelWindowEventHandler::ScopedWindowResizer::OnWindowStateTypeChanged()
1605 // must be called in order for the maximized window's size to be correct. 1601 // must be called in order for the maximized window's size to be correct.
1606 delegate()->set_window_component(HTCAPTION); 1602 delegate()->set_window_component(HTCAPTION);
1607 ui::test::EventGenerator& generator = GetEventGenerator(); 1603 ui::test::EventGenerator& generator = GetEventGenerator();
1608 generator.MoveMouseTo(window->GetBoundsInScreen().origin()); 1604 generator.MoveMouseTo(window->GetBoundsInScreen().origin());
(...skipping 11 matching lines...) Expand all
1620 EXPECT_TRUE(window_state->IsMaximized()); 1616 EXPECT_TRUE(window_state->IsMaximized());
1621 } 1617 }
1622 1618
1623 // Tests run twice - on both panels and normal windows 1619 // Tests run twice - on both panels and normal windows
1624 INSTANTIATE_TEST_CASE_P(NormalOrPanel, 1620 INSTANTIATE_TEST_CASE_P(NormalOrPanel,
1625 DockedWindowResizerTest, 1621 DockedWindowResizerTest,
1626 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, 1622 testing::Values(ui::wm::WINDOW_TYPE_NORMAL,
1627 ui::wm::WINDOW_TYPE_PANEL)); 1623 ui::wm::WINDOW_TYPE_PANEL));
1628 1624
1629 } // namespace ash 1625 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/dock/docked_window_resizer.cc ('k') | ash/wm/window_resizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698