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

Unified Diff: ash/wm/dock/docked_window_resizer_unittest.cc

Issue 68033003: Undocks window first before side-snapping bounds (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Undocks window first before side-snapping bounds (nit) Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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,

Powered by Google App Engine
This is Rietveld 408576698