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

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 (more comments) 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..018a6ed3efdb21c3b676432b89194be378d817f2 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,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 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.
+ EXPECT_EQ(0, docked_width(manager));
+ EXPECT_EQ(ScreenAsh::GetDisplayWorkAreaBoundsInParent(w1.get()).height(),
pkotwicz 2013/11/28 06:15:10 Nit: You could probably cache the work area bounds
varkha 2013/11/28 15:39:40 Done.
+ 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 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(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