| Index: ash/wm/dock/docked_window_resizer_unittest.cc
|
| diff --git a/ash/wm/dock/docked_window_resizer_unittest.cc b/ash/wm/dock/docked_window_resizer_unittest.cc
|
| index 49aeca25318991c5c3d91a05028aab19931fa142..0155d6723893f344c03b3c2ecebf458b2dd6ea8d 100644
|
| --- a/ash/wm/dock/docked_window_resizer_unittest.cc
|
| +++ b/ash/wm/dock/docked_window_resizer_unittest.cc
|
| @@ -95,11 +95,7 @@ class DockedWindowResizerTest
|
| }
|
|
|
| void DragStart(aura::Window* window) {
|
| - initial_location_in_parent_ = window->bounds().origin();
|
| - resizer_.reset(CreateSomeWindowResizer(window,
|
| - initial_location_in_parent_,
|
| - HTCAPTION));
|
| - ASSERT_TRUE(resizer_.get());
|
| + DragStartAtOffsetFromwindowOrigin(window, 0, 0);
|
| }
|
|
|
| void DragStartAtOffsetFromwindowOrigin(aura::Window* window,
|
| @@ -184,7 +180,7 @@ class DockedWindowResizerTest
|
| gfx::Rect initial_bounds = window->GetBoundsInScreen();
|
|
|
| if (window_type_ == aura::client::WINDOW_TYPE_PANEL) {
|
| - ASSERT_NO_FATAL_FAILURE(DragStart(window));
|
| + ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(window, 25, 5));
|
| EXPECT_TRUE(window->GetProperty(kPanelAttachedKey));
|
|
|
| // Drag enough to detach since our tests assume panels to be initially
|
| @@ -206,11 +202,13 @@ class DockedWindowResizerTest
|
| // avoid snap by clicking away from the border
|
| ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(window, 25, 5));
|
|
|
| + gfx::Rect work_area =
|
| + Shell::GetScreen()->GetDisplayNearestWindow(window).work_area();
|
| // Drag the window left or right to the edge (or almost to it).
|
| if (edge == DOCKED_EDGE_LEFT)
|
| - dx += window->GetRootWindow()->bounds().x() - initial_bounds.x();
|
| + dx += work_area.x() - initial_location_in_parent_.x();
|
| else if (edge == DOCKED_EDGE_RIGHT)
|
| - dx += window->GetRootWindow()->bounds().right() - initial_bounds.right();
|
| + dx += work_area.right() - 1 - initial_location_in_parent_.x();
|
| DragMove(dx, window_type_ == aura::client::WINDOW_TYPE_PANEL ? 0 : dy);
|
| EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id());
|
| // Release the mouse and the panel should be attached to the dock.
|
| @@ -218,8 +216,10 @@ class DockedWindowResizerTest
|
|
|
| // x-coordinate can get adjusted by snapping or sticking.
|
| // y-coordinate could be changed by possible automatic layout if docked.
|
| - if (window->parent()->id() != internal::kShellWindowId_DockedContainer)
|
| + if (window->parent()->id() != internal::kShellWindowId_DockedContainer &&
|
| + GetRestoreBoundsInScreen(window) == NULL) {
|
| EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y());
|
| + }
|
| }
|
|
|
| bool test_panels() const {
|
| @@ -253,7 +253,7 @@ TEST_P(DockedWindowResizerTest, AttachRightPrecise) {
|
| }
|
|
|
| // Verifies a window can be dragged and attached to the dock
|
| -// even if we overshoot the screen edge by a few pixels (sticky edge)
|
| +// even if pointer overshoots the screen edge by a few pixels (sticky edge)
|
| TEST_P(DockedWindowResizerTest, AttachRightOvershoot) {
|
| if (!SupportsHostWindowResize())
|
| return;
|
| @@ -267,8 +267,8 @@ TEST_P(DockedWindowResizerTest, AttachRightOvershoot) {
|
| EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
|
| }
|
|
|
| -// Verifies a window can be dragged and then if not quite reaching the screen
|
| -// edge it does not get docked to a screen edge and stays in the desktop.
|
| +// Verifies a window can be dragged and then if a pointer is not quite reaching
|
| +// the screen edge the window does not get docked and stays in the desktop.
|
| TEST_P(DockedWindowResizerTest, AttachRightUndershoot) {
|
| if (!SupportsHostWindowResize())
|
| return;
|
| @@ -276,8 +276,10 @@ TEST_P(DockedWindowResizerTest, AttachRightUndershoot) {
|
| scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
|
| DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), -1);
|
|
|
| - // The window should not be attached to the dock.
|
| - EXPECT_EQ(window->GetRootWindow()->bounds().right() - 1,
|
| + // The window right should be past the screen edge but not docked.
|
| + // Initial touch point is 25px to the right which helps to find where the edge
|
| + // should be.
|
| + EXPECT_EQ(window->GetRootWindow()->bounds().right() + 201 - 25 - 1 - 1,
|
| window->GetBoundsInScreen().right());
|
| EXPECT_EQ(internal::kShellWindowId_DefaultContainer,
|
| window->parent()->id());
|
| @@ -298,7 +300,7 @@ TEST_P(DockedWindowResizerTest, AttachLeftPrecise) {
|
| }
|
|
|
| // Verifies a window can be dragged and attached to the dock
|
| -// even if we overshoot the screen edge by a few pixels (sticky edge)
|
| +// even if pointer overshoots the screen edge by a few pixels (sticky edge)
|
| TEST_P(DockedWindowResizerTest, AttachLeftOvershoot) {
|
| if (!SupportsHostWindowResize())
|
| return;
|
| @@ -312,8 +314,8 @@ TEST_P(DockedWindowResizerTest, AttachLeftOvershoot) {
|
| EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
|
| }
|
|
|
| -// Verifies a window can be dragged and then if not quite reaching the screen
|
| -// edge it does not get docked to a screen edge and stays in the desktop.
|
| +// Verifies a window can be dragged and then if a pointer is not quite reaching
|
| +// the screen edge the window does not get docked and stays in the desktop.
|
| TEST_P(DockedWindowResizerTest, AttachLeftUndershoot) {
|
| if (!SupportsHostWindowResize())
|
| return;
|
| @@ -321,8 +323,8 @@ TEST_P(DockedWindowResizerTest, AttachLeftUndershoot) {
|
| scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
|
| DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 1);
|
|
|
| - // The window should not be attached to the dock.
|
| - EXPECT_EQ(window->GetRootWindow()->bounds().x() + 1,
|
| + // The window should be touching the screen edge but not docked.
|
| + EXPECT_EQ(window->GetRootWindow()->bounds().x(),
|
| window->GetBoundsInScreen().x());
|
| EXPECT_EQ(internal::kShellWindowId_DefaultContainer,
|
| window->parent()->id());
|
| @@ -487,6 +489,7 @@ TEST_P(DockedWindowResizerTest, AttachOnTwoSides)
|
| EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id());
|
|
|
| // The second window should be near the left edge but not snapped.
|
| + // Normal window will get side-maximized while panels will not.
|
| EXPECT_EQ(w2->GetRootWindow()->bounds().x(), w2->GetBoundsInScreen().x());
|
| EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id());
|
| }
|
| @@ -525,6 +528,7 @@ TEST_P(DockedWindowResizerTest, DragAcrossDisplays) {
|
|
|
| UpdateDisplay("800x800,800x800");
|
| Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
|
| + EXPECT_EQ(2, static_cast<int>(root_windows.size()));
|
| scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
|
| gfx::Rect initial_bounds = window->GetBoundsInScreen();
|
| EXPECT_EQ(root_windows[0], window->GetRootWindow());
|
| @@ -535,21 +539,11 @@ TEST_P(DockedWindowResizerTest, DragAcrossDisplays) {
|
| window->GetBoundsInScreen().right());
|
| EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
|
|
|
| - // Undock and move to the right - enough to get it peeking at the other screen
|
| - // but not enough to land in the other screen
|
| - ASSERT_NO_FATAL_FAILURE(DragStart(window.get()));
|
| - DragMove(70, 0);
|
| - EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id());
|
| - DragEnd();
|
| - EXPECT_NE(window->GetRootWindow()->bounds().right(),
|
| - window->GetBoundsInScreen().right());
|
| - EXPECT_EQ(internal::kShellWindowId_DefaultContainer,
|
| - window->parent()->id());
|
| - EXPECT_EQ(root_windows[0], window->GetRootWindow());
|
| -
|
| - // Move back left - should dock again.
|
| + // Try dragging to the right - enough to get it peeking at the other screen
|
| + // but not enough to land in the other screen.
|
| + // The window should stay on the left screen.
|
| ASSERT_NO_FATAL_FAILURE(DragStart(window.get()));
|
| - DragMove(-70, 0);
|
| + DragMove(100, 0);
|
| EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id());
|
| DragEnd();
|
| EXPECT_EQ(window->GetRootWindow()->bounds().right(),
|
| @@ -574,8 +568,8 @@ TEST_P(DockedWindowResizerTest, DragAcrossDisplays) {
|
| window->parent()->id());
|
| EXPECT_EQ(root_windows[1], window->GetRootWindow());
|
|
|
| - // Keep dragging it to the right until it docks. The window should now be
|
| - // in the second screen.
|
| + // Keep dragging it to the right until its left edge touches the screen edge.
|
| + // The window should now be in the second screen and not docked.
|
| ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(
|
| window.get(),
|
| window->bounds().width()/2 + 10,
|
| @@ -587,7 +581,7 @@ TEST_P(DockedWindowResizerTest, DragAcrossDisplays) {
|
| DragEnd();
|
| EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(),
|
| window->GetBoundsInScreen().x());
|
| - EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
|
| + EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id());
|
| EXPECT_EQ(root_windows[1], window->GetRootWindow());
|
| }
|
|
|
| @@ -665,7 +659,7 @@ TEST_P(DockedWindowResizerTest, AttachTwoWindowsDetachOne)
|
| EXPECT_EQ(w1->bounds().width(), manager->docked_width_);
|
| }
|
|
|
| -// Dock one windows. Maximize other testing desktop resizing.
|
| +// Dock one of the windows. Maximize other testing desktop resizing.
|
| TEST_P(DockedWindowResizerTest, AttachWindowMaximizeOther)
|
| {
|
| if (!SupportsHostWindowResize())
|
| @@ -687,10 +681,13 @@ TEST_P(DockedWindowResizerTest, AttachWindowMaximizeOther)
|
| EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_);
|
| EXPECT_EQ(w1->bounds().width(), manager->docked_width_);
|
|
|
| - DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_RIGHT,
|
| - w2.get(),
|
| - -(w2->bounds().width()/2 + 20),
|
| - 50);
|
| + ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(w2.get(), 25, 5));
|
| + DragMove(w2->GetRootWindow()->bounds().right()
|
| + -w2->bounds().width()
|
| + -(w2->bounds().width()/2 + 20)
|
| + -w2->bounds().x(),
|
| + 50 - w2->bounds().y());
|
| + DragEnd();
|
| // The first window should be still docked.
|
| EXPECT_EQ(w1->GetRootWindow()->bounds().right(),
|
| w1->GetBoundsInScreen().right());
|
| @@ -738,7 +735,8 @@ TEST_P(DockedWindowResizerTest, AttachWindowMaximizeOther)
|
| // Dock the first window to the left edge.
|
| // Click at an offset from origin to prevent snapping.
|
| ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(w1.get(), 10, 0));
|
| - DragMove(-w1->bounds().x(), 0);
|
| + // Drag left to get pointer touching the screen edge.
|
| + DragMove(-w1->bounds().x() - 10, 0);
|
| // Alignment set to "NONE" during the drag of the window when none are docked.
|
| EXPECT_EQ(DOCKED_ALIGNMENT_NONE, manager->alignment_);
|
| // Release the mouse and the window should be now attached to the edge.
|
| @@ -787,10 +785,12 @@ TEST_P(DockedWindowResizerTest, AttachOneTestSticky)
|
| EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, manager->alignment_);
|
| EXPECT_EQ(w1->bounds().width(), manager->docked_width_);
|
|
|
| - // Position second window in the desktop just to the right of the docked w1.
|
| + // Position second window in the desktop 20px to the right of the docked w1.
|
| DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_LEFT,
|
| w2.get(),
|
| - w1->bounds().right() + 20,
|
| + 20 +
|
| + 25 -
|
| + DockedWindowLayoutManager::kMinDockGap,
|
| 50);
|
| // The second window should be floating on the desktop.
|
| EXPECT_EQ(w2->GetRootWindow()->bounds().x() + (w1->bounds().right() + 20),
|
| @@ -917,7 +917,7 @@ TEST_P(DockedWindowResizerTest, ResizeTwoWindows)
|
| ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width());
|
|
|
| // Resize the first window left by more than the dock maximum width.
|
| - // This should cause the window to overhang and the dock to shrink to w2.
|
| + // This should cause the window width to be restricted by maximum dock width.
|
| previous_width = w1->bounds().width();
|
| const int kResizeSpan2 = 250;
|
| ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromwindowOrigin(w1.get(),
|
| @@ -933,11 +933,11 @@ TEST_P(DockedWindowResizerTest, ResizeTwoWindows)
|
| EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id());
|
| EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id());
|
| EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_);
|
| - // w1 is now wider than the maximum dock width and the dock should shrink to
|
| - // the next widest window (w2).
|
| - EXPECT_EQ(previous_width + kResizeSpan2, w1->bounds().width());
|
| + // w1 is now as wide as the maximum dock width and the dock should get
|
| + // resized to the maximum width.
|
| + EXPECT_EQ(DockedWindowLayoutManager::kMaxDockWidth, w1->bounds().width());
|
| EXPECT_GT(w1->bounds().width(), w2->bounds().width());
|
| - EXPECT_EQ(w2->bounds().width(), manager->docked_width_);
|
| + EXPECT_EQ(w1->bounds().width(), manager->docked_width_);
|
| // Desktop work area should shrink.
|
| EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width() -
|
| manager->docked_width_ - DockedWindowLayoutManager::kMinDockGap,
|
| @@ -978,21 +978,23 @@ TEST_P(DockedWindowResizerTest, ResizeTwoWindows)
|
| DragEnd();
|
| EXPECT_EQ(previous_width + kResizeSpan3, w1->bounds().width());
|
| EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id());
|
| - // Docked area should be as wide as the second window - the first is too wide.
|
| - EXPECT_EQ(w2->bounds().width(), manager->docked_width_);
|
| + // Docked area should be as wide as possible (maximum) and same as w1.
|
| + EXPECT_EQ(DockedWindowLayoutManager::kMaxDockWidth, manager->docked_width_);
|
| + EXPECT_EQ(w1->bounds().width(), manager->docked_width_);
|
|
|
| // Undock the second window. Docked area should shrink to its minimum size.
|
| ASSERT_NO_FATAL_FAILURE(DragStart(w2.get()));
|
| // Drag up as well to avoid attaching panels to launcher shelf.
|
| - DragMove(-40, -100);
|
| + DragMove(-(400 - 201), -100);
|
| // Alignment set to "RIGHT" since we have another window docked.
|
| EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_);
|
| // Release the mouse and the window should be no longer attached to the edge.
|
| DragEnd();
|
| EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id());
|
| - // Dock should get shrunk to minimum size.
|
| + // Dock should be as wide as w1 (and same as maximum width).
|
| EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_);
|
| - EXPECT_EQ(manager->kMinDockWidth, manager->docked_width_);
|
| + EXPECT_EQ(DockedWindowLayoutManager::kMaxDockWidth, manager->docked_width_);
|
| + EXPECT_EQ(w1->bounds().width(), manager->docked_width_);
|
| // The first window should be still docked.
|
| EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id());
|
| // Desktop work area should be inset.
|
|
|