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

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

Issue 19054013: Implement automatic layout and stacking for docked windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_233331_sized
Patch Set: Implement automatic layout and stacking (test on win_aura) Created 7 years, 5 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
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/launcher/launcher.h" 8 #include "ash/launcher/launcher.h"
9 #include "ash/launcher/launcher_model.h" 9 #include "ash/launcher/launcher_model.h"
10 #include "ash/root_window_controller.h" 10 #include "ash/root_window_controller.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 if (edge == DOCKED_EDGE_LEFT) 217 if (edge == DOCKED_EDGE_LEFT)
218 dx += window->GetRootWindow()->bounds().x() - initial_bounds.x(); 218 dx += window->GetRootWindow()->bounds().x() - initial_bounds.x();
219 else if (edge == DOCKED_EDGE_RIGHT) 219 else if (edge == DOCKED_EDGE_RIGHT)
220 dx += window->GetRootWindow()->bounds().right() - initial_bounds.right(); 220 dx += window->GetRootWindow()->bounds().right() - initial_bounds.right();
221 DragMove(dx, window_type_ == aura::client::WINDOW_TYPE_PANEL ? 0 : dy); 221 DragMove(dx, window_type_ == aura::client::WINDOW_TYPE_PANEL ? 0 : dy);
222 EXPECT_EQ(CorrectContainerIdDuringDrag(UNDOCKED), window->parent()->id()); 222 EXPECT_EQ(CorrectContainerIdDuringDrag(UNDOCKED), window->parent()->id());
223 // Release the mouse and the panel should be attached to the dock. 223 // Release the mouse and the panel should be attached to the dock.
224 DragEnd(); 224 DragEnd();
225 225
226 // x-coordinate can get adjusted by snapping or sticking. 226 // x-coordinate can get adjusted by snapping or sticking.
227 // y-coordinate should not change by possible docking. 227 // y-coordinate could be changed by possible automatic layout if docked.
228 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y()); 228 if (window->parent()->id() != internal::kShellWindowId_DockedContainer)
229 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y());
229 } 230 }
230 231
231 bool test_panels() const { 232 bool test_panels() const {
232 return window_type_ == aura::client::WINDOW_TYPE_PANEL; 233 return window_type_ == aura::client::WINDOW_TYPE_PANEL;
233 } 234 }
234 235
235 private: 236 private:
236 scoped_ptr<WindowResizer> resizer_; 237 scoped_ptr<WindowResizer> resizer_;
237 LauncherModel* model_; 238 LauncherModel* model_;
238 aura::client::WindowType window_type_; 239 aura::client::WindowType window_type_;
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 448
448 // Both windows should be attached and snapped to the right edge. 449 // Both windows should be attached and snapped to the right edge.
449 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), 450 EXPECT_EQ(w1->GetRootWindow()->bounds().right(),
450 w1->GetBoundsInScreen().right()); 451 w1->GetBoundsInScreen().right());
451 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 452 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id());
452 453
453 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), 454 EXPECT_EQ(w2->GetRootWindow()->bounds().right(),
454 w2->GetBoundsInScreen().right()); 455 w2->GetBoundsInScreen().right());
455 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); 456 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id());
456 457
457 // Detach by dragging left (should get undocked) 458 // Detach by dragging left (should get undocked).
458 ASSERT_NO_FATAL_FAILURE(DragStart(w2.get())); 459 ASSERT_NO_FATAL_FAILURE(DragStart(w2.get()));
459 DragMove(-32, -10); 460 // Drag up as well to avoid attaching panels to launcher shelf.
461 DragMove(-32, -100);
460 // Release the mouse and the window should be no longer attached to the edge. 462 // Release the mouse and the window should be no longer attached to the edge.
461 DragEnd(); 463 DragEnd();
462 464
463 // The first window should be still docked. 465 // The first window should be still docked.
464 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), 466 EXPECT_EQ(w1->GetRootWindow()->bounds().right(),
465 w1->GetBoundsInScreen().right()); 467 w1->GetBoundsInScreen().right());
466 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 468 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id());
467 469
468 // The second window should be floating on a workspace again. 470 // The second window should be floating on a workspace again.
469 EXPECT_EQ(w2->GetRootWindow()->bounds().right() - 32, 471 EXPECT_EQ(w2->GetRootWindow()->bounds().right() - 32,
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 // The second window should be still docked. 646 // The second window should be still docked.
645 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), 647 EXPECT_EQ(w2->GetRootWindow()->bounds().right(),
646 w2->GetBoundsInScreen().right()); 648 w2->GetBoundsInScreen().right());
647 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); 649 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id());
648 650
649 // Detach by dragging left more (should get undocked). 651 // Detach by dragging left more (should get undocked).
650 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin( 652 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(
651 w2.get(), 653 w2.get(),
652 w2->bounds().width()/2 + 10, 654 w2->bounds().width()/2 + 10,
653 0)); 655 0));
654 DragMove(-(w2->bounds().width()/2 + 20), 10); 656 // Drag up as well to avoid attaching panels to launcher shelf.
657 DragMove(-(w2->bounds().width()/2 + 20), -100);
655 // Release the mouse and the window should be no longer attached to the edge. 658 // Release the mouse and the window should be no longer attached to the edge.
656 DragEnd(); 659 DragEnd();
657 660
658 // The second window should be floating on a workspace again. 661 // The second window should be floating on a workspace again.
659 EXPECT_EQ(w2->GetRootWindow()->bounds().right() - 662 EXPECT_EQ(w2->GetRootWindow()->bounds().right() -
660 (w2->bounds().width()/2 + 20), 663 (w2->bounds().width()/2 + 20),
661 w2->GetBoundsInScreen().right()); 664 w2->GetBoundsInScreen().right());
662 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer, w2->parent()->id()); 665 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer, w2->parent()->id());
663 // Dock width should be set to remaining single docked window. 666 // Dock width should be set to remaining single docked window.
664 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 667 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id());
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 HTLEFT)); 981 HTLEFT));
979 DragMove(-kResizeSpan3, 0); 982 DragMove(-kResizeSpan3, 0);
980 DragEnd(); 983 DragEnd();
981 EXPECT_EQ(previous_width + kResizeSpan3, w1->bounds().width()); 984 EXPECT_EQ(previous_width + kResizeSpan3, w1->bounds().width());
982 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 985 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id());
983 // Docked area should be as wide as the second window - the first is too wide. 986 // Docked area should be as wide as the second window - the first is too wide.
984 EXPECT_EQ(w2->bounds().width(), manager->docked_width_); 987 EXPECT_EQ(w2->bounds().width(), manager->docked_width_);
985 988
986 // Undock the second window. Docked area should shrink to its minimum size. 989 // Undock the second window. Docked area should shrink to its minimum size.
987 ASSERT_NO_FATAL_FAILURE(DragStart(w2.get())); 990 ASSERT_NO_FATAL_FAILURE(DragStart(w2.get()));
988 DragMove(-40, 10); 991 // Drag up as well to avoid attaching panels to launcher shelf.
992 DragMove(-40, -100);
989 // Alignment set to "RIGHT" since we have another window docked. 993 // Alignment set to "RIGHT" since we have another window docked.
990 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_); 994 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_);
991 // Release the mouse and the window should be no longer attached to the edge. 995 // Release the mouse and the window should be no longer attached to the edge.
992 DragEnd(); 996 DragEnd();
993 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer, w2->parent()->id()); 997 EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer, w2->parent()->id());
994 // Dock should get shrunk to minimum size. 998 // Dock should get shrunk to minimum size.
995 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_); 999 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_);
996 EXPECT_EQ(manager->kMinDockWidth, manager->docked_width_); 1000 EXPECT_EQ(manager->kMinDockWidth, manager->docked_width_);
997 // The first window should be still docked. 1001 // The first window should be still docked.
998 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 1002 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 } 1053 }
1050 } 1054 }
1051 1055
1052 // Tests run twice - on both panels and normal windows 1056 // Tests run twice - on both panels and normal windows
1053 INSTANTIATE_TEST_CASE_P(NormalOrPanel, 1057 INSTANTIATE_TEST_CASE_P(NormalOrPanel,
1054 DockedWindowResizerTest, 1058 DockedWindowResizerTest,
1055 testing::Values(aura::client::WINDOW_TYPE_NORMAL, 1059 testing::Values(aura::client::WINDOW_TYPE_NORMAL,
1056 aura::client::WINDOW_TYPE_PANEL)); 1060 aura::client::WINDOW_TYPE_PANEL));
1057 } // namespace internal 1061 } // namespace internal
1058 } // namespace ash 1062 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/dock/docked_window_layout_manager_unittest.cc ('k') | ash/wm/panels/panel_layout_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698