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 0c1a4c6f3a6316bb4beb43a86babdd998561027c..adbfaa4db4a3dfc615bc4aded0301ef04c83c3ad 100644 |
--- a/ash/wm/dock/docked_window_resizer_unittest.cc |
+++ b/ash/wm/dock/docked_window_resizer_unittest.cc |
@@ -24,6 +24,7 @@ |
#include "ash/wm/panels/panel_layout_manager.h" |
#include "ash/wm/window_state.h" |
#include "ash/wm/window_util.h" |
+#include "ash/wm/workspace/snap_sizer.h" |
#include "base/command_line.h" |
#include "ui/aura/client/aura_constants.h" |
#include "ui/aura/root_window.h" |
@@ -238,7 +239,7 @@ TEST_P(DockedWindowResizerTest, AttachRightPrecise) { |
scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
- // The window should be attached and snapped to the right edge. |
+ // The window should be docked at the right edge. |
EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
window->GetBoundsInScreen().right()); |
EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
@@ -253,7 +254,7 @@ TEST_P(DockedWindowResizerTest, AttachRightOvershoot) { |
scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), +4); |
- // The window should be attached and snapped to the right edge. |
+ // The window should be docked at the right edge. |
EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
window->GetBoundsInScreen().right()); |
EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
@@ -294,7 +295,7 @@ TEST_P(DockedWindowResizerTest, AttachLeftPrecise) { |
scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 0); |
- // The window should be attached and snapped to the left dock. |
+ // The window should be docked at the left edge. |
EXPECT_EQ(window->GetRootWindow()->bounds().x(), |
window->GetBoundsInScreen().x()); |
EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
@@ -309,7 +310,7 @@ TEST_P(DockedWindowResizerTest, AttachLeftOvershoot) { |
scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), -4); |
- // The window should be attached and snapped to the left dock. |
+ // The window should be docked at the left edge. |
EXPECT_EQ(window->GetRootWindow()->bounds().x(), |
window->GetBoundsInScreen().x()); |
EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
@@ -341,7 +342,7 @@ TEST_P(DockedWindowResizerTest, AttachRightChangeShelf) { |
scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
- // The window should be attached and snapped to the right edge. |
+ // The window should be docked at the right edge. |
EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
window->GetBoundsInScreen().right()); |
EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
@@ -381,7 +382,7 @@ TEST_P(DockedWindowResizerTest, AttachTryDetach) { |
gfx::Rect(0, 0, ideal_width() + 10, 201))); |
DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
- // The window should be attached and docked at the right edge. |
+ // The window should be docked at the right edge. |
// Its width should shrink to ideal width. |
EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
window->GetBoundsInScreen().right()); |
@@ -423,7 +424,7 @@ TEST_P(DockedWindowResizerTest, AttachMinimizeRestore) { |
scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
- // The window should be attached and snapped to the right edge. |
+ // The window should be docked at the right edge. |
EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
window->GetBoundsInScreen().right()); |
EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
@@ -449,7 +450,7 @@ TEST_P(DockedWindowResizerTest, AttachMaximize) { |
scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
- // The window should be attached and snapped to the right edge. |
+ // The window should be docked at the right edge. |
EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
window->GetBoundsInScreen().right()); |
EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
@@ -473,7 +474,7 @@ TEST_P(DockedWindowResizerTest, AttachTwoWindows) { |
DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 50); |
- // Both windows should be attached and snapped to the right edge. |
+ // Both windows should be docked at the right edge. |
EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
w1->GetBoundsInScreen().right()); |
EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
@@ -509,7 +510,7 @@ TEST_P(DockedWindowResizerTest, AttachOneAutoHideShelf) { |
scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
- // w1 should be attached and snapped to the right edge. |
+ // w1 should be docked at the right edge. |
EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
w1->GetBoundsInScreen().right()); |
EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
@@ -554,7 +555,7 @@ TEST_P(DockedWindowResizerTest, AttachOnTwoSides) { |
gfx::Rect initial_bounds(w2->bounds()); |
DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w2.get(), 50); |
- // The first window should be attached and snapped to the right edge. |
+ // The first window should be docked at the right edge. |
EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
w1->GetBoundsInScreen().right()); |
EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
@@ -575,7 +576,7 @@ TEST_P(DockedWindowResizerTest, RevertDragRestoresAttachment) { |
scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
- // The window should be attached and snapped to the right edge. |
+ // The window should be docked at the right edge. |
EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
window->GetBoundsInScreen().right()); |
EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
@@ -621,7 +622,7 @@ TEST_P(DockedWindowResizerTest, DragAcrossDisplays) { |
EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
- // The window should be attached and snapped to the right edge. |
+ // The window should be docked at the right edge. |
EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
window->GetBoundsInScreen().right()); |
EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
@@ -686,7 +687,7 @@ TEST_P(DockedWindowResizerTest, AttachTwoWindowsDetachOne) { |
ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
- // A window should be attached and snapped to the right edge. |
+ // A window should be docked at the right edge. |
EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
w1->GetBoundsInScreen().right()); |
EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
@@ -696,7 +697,7 @@ TEST_P(DockedWindowResizerTest, AttachTwoWindowsDetachOne) { |
EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); |
- // Both windows should now be attached and snapped to the right edge. |
+ // Both windows should now be docked at the right edge. |
EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
w2->GetBoundsInScreen().right()); |
EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); |
@@ -758,7 +759,7 @@ TEST_P(DockedWindowResizerTest, AttachWindowMaximizeOther) { |
ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
- // A window should be attached and snapped to the right edge. |
+ // A window should be docked at the right edge. |
EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
w1->GetBoundsInScreen().right()); |
EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
@@ -857,7 +858,7 @@ TEST_P(DockedWindowResizerTest, AttachOneTestSticky) { |
ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w1.get(), 20); |
- // A window should be attached and snapped to the left edge. |
+ // A window should be docked at the left edge. |
EXPECT_EQ(w1->GetRootWindow()->bounds().x(), |
w1->GetBoundsInScreen().x()); |
EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
@@ -956,7 +957,7 @@ TEST_P(DockedWindowResizerTest, ResizeOneOfTwoWindows) { |
ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
- // A window should be attached and snapped to the right edge. |
+ // A window should be docked at the right edge. |
EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
w1->GetBoundsInScreen().right()); |
EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
@@ -966,7 +967,7 @@ TEST_P(DockedWindowResizerTest, ResizeOneOfTwoWindows) { |
EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); |
- // Both windows should now be attached and snapped to the right edge. |
+ // Both windows should now be docked at the right edge. |
EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
w2->GetBoundsInScreen().right()); |
EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); |
@@ -1097,7 +1098,7 @@ TEST_P(DockedWindowResizerTest, ResizingKeepsWidth) { |
scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
- // A window should be attached and snapped to the right edge. |
+ // A window should be docked at the right edge. |
EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
w1->GetBoundsInScreen().right()); |
EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
@@ -1226,7 +1227,7 @@ TEST_P(DockedWindowResizerTest, DragToShelf) { |
ScreenAsh::GetDisplayWorkAreaBoundsInParent(w1.get()).width()); |
DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
- // A window should be attached and snapped to the right edge. |
+ // A window should be docked at the right edge. |
EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
w1->GetBoundsInScreen().right()); |
EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
@@ -1278,7 +1279,7 @@ TEST_P(DockedWindowResizerTest, DragWindowWithTransientChild) { |
DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20); |
- // A window should be attached and snapped to the right edge. |
+ // A window should be docked at the right edge. |
EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
EXPECT_EQ(internal::kShellWindowId_DockedContainer, child->parent()->id()); |
@@ -1302,6 +1303,62 @@ TEST_P(DockedWindowResizerTest, DragWindowWithTransientChild) { |
child->GetBoundsInScreen().origin().ToString()); |
} |
+// Tests that side snapping a window undocks it, closes the dock and then snaps. |
+TEST_P(DockedWindowResizerTest, SideSnapDocked) { |
+ if (!SupportsHostWindowResize() || test_panels()) |
+ return; |
+ |
+ scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
+ wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
+ DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
+ // A window should be docked at the right edge. |
+ EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
+ w1->GetBoundsInScreen().right()); |
+ EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
+ DockedWindowLayoutManager* manager = |
+ static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); |
+ EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
+ EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
+ EXPECT_TRUE(window_state->IsDocked()); |
+ EXPECT_FALSE(window_state->IsSnapped()); |
+ |
+ // Side snap at right edge. |
+ internal::SnapSizer::SnapWindow(window_state, |
+ internal::SnapSizer::RIGHT_EDGE); |
+ // The window should be snapped at the right edge and the dock should close. |
+ gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(w1.get())); |
+ EXPECT_EQ(0, docked_width(manager)); |
+ EXPECT_EQ(work_area.height(), w1->bounds().height()); |
+ EXPECT_EQ(work_area.right(), w1->bounds().right()); |
+ EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w1->parent()->id()); |
+ EXPECT_FALSE(window_state->IsDocked()); |
+ EXPECT_TRUE(window_state->IsSnapped()); |
+ |
+ // Dock again. |
+ DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
+ // A window should be docked at the right edge. |
+ EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
+ w1->GetBoundsInScreen().right()); |
+ EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
+ EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
+ EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
+ EXPECT_TRUE(window_state->IsDocked()); |
+ EXPECT_FALSE(window_state->IsSnapped()); |
+ |
+ // Side snap at left edge. |
+ internal::SnapSizer::SnapWindow(window_state, |
+ internal::SnapSizer::LEFT_EDGE); |
+ // The window should be snapped at the right edge and the dock should close. |
+ EXPECT_EQ(work_area.ToString(), |
+ ScreenAsh::GetDisplayWorkAreaBoundsInParent(w1.get()).ToString()); |
+ EXPECT_EQ(0, docked_width(manager)); |
+ EXPECT_EQ(work_area.height(), w1->bounds().height()); |
+ EXPECT_EQ(work_area.x(), w1->bounds().x()); |
+ EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w1->parent()->id()); |
+ EXPECT_FALSE(window_state->IsDocked()); |
+ EXPECT_TRUE(window_state->IsSnapped()); |
+} |
+ |
// Tests run twice - on both panels and normal windows |
INSTANTIATE_TEST_CASE_P(NormalOrPanel, |
DockedWindowResizerTest, |