Chromium Code Reviews| 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..627caaf43bfcd1a02f9a237bb75dc6ad3087d169 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" |
| @@ -1302,6 +1303,63 @@ 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 attached and snapped to the right edge. |
|
pkotwicz
2013/11/27 20:24:43
For the sake of sanity a window is either docked o
varkha
2013/11/28 01:09:37
Done.
|
| + 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. |
| + EXPECT_EQ(0, docked_width(manager)); |
| + EXPECT_EQ(ScreenAsh::GetDisplayWorkAreaBoundsInParent(w1.get()).height(), |
| + w1->bounds().height()); |
| + EXPECT_EQ(ScreenAsh::GetDisplayWorkAreaBoundsInParent(w1.get()).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 attached and snapped to the right edge. |
|
pkotwicz
2013/11/27 20:24:43
Can you change this comment too?
varkha
2013/11/28 01:09:37
Done. Also changed throughout this file. Seems lik
|
| + 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(0, docked_width(manager)); |
| + EXPECT_EQ(ScreenAsh::GetDisplayWorkAreaBoundsInParent(w1.get()).height(), |
| + w1->bounds().height()); |
| + EXPECT_EQ(ScreenAsh::GetDisplayWorkAreaBoundsInParent(w1.get()).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, |