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

Side by Side Diff: ash/wm/workspace/workspace_window_resizer_unittest.cc

Issue 163833003: Stick edge to both window and work area at the same time (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/wm/workspace/workspace_window_resizer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/workspace/workspace_window_resizer.h" 5 #include "ash/wm/workspace/workspace_window_resizer.h"
6 6
7 #include "ash/ash_constants.h" 7 #include "ash/ash_constants.h"
8 #include "ash/ash_switches.h" 8 #include "ash/ash_switches.h"
9 #include "ash/display/display_manager.h" 9 #include "ash/display/display_manager.h"
10 #include "ash/root_window_controller.h" 10 #include "ash/root_window_controller.h"
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1108 scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
1109 window_.get(), gfx::Point(), HTCAPTION)); 1109 window_.get(), gfx::Point(), HTCAPTION));
1110 ASSERT_TRUE(resizer.get()); 1110 ASSERT_TRUE(resizer.get());
1111 // Move to an x-coordinate of 15, which should not stick. 1111 // Move to an x-coordinate of 15, which should not stick.
1112 resizer->Drag(CalculateDragPoint(*resizer, 15 - 96, 0), 0); 1112 resizer->Drag(CalculateDragPoint(*resizer, 15 - 96, 0), 0);
1113 // Move to -15, should still stick to 0. 1113 // Move to -15, should still stick to 0.
1114 resizer->Drag(CalculateDragPoint(*resizer, -15 - 96, 0), 0); 1114 resizer->Drag(CalculateDragPoint(*resizer, -15 - 96, 0), 0);
1115 EXPECT_EQ("-15,112 320x160", window_->bounds().ToString()); 1115 EXPECT_EQ("-15,112 320x160", window_->bounds().ToString());
1116 } 1116 }
1117 1117
1118 // Verifies window sticks to both window and work area.
1119 TEST_F(WorkspaceWindowResizerTest, StickToBothEdgeAndWindow) {
1120 window_->SetBounds(gfx::Rect(10, 10, 20, 50));
1121 window_->Show();
1122 window2_->SetBounds(gfx::Rect(150, 160, 25, 1000));
1123 window2_->Show();
1124
1125 scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
1126 window_.get(), gfx::Point(10, 10), HTCAPTION));
1127 ASSERT_TRUE(resizer.get());
1128
1129 // Move |window| one pixel to the left of |window2|. Should snap to right.
1130 resizer->Drag(CalculateDragPoint(*resizer, 119, 145), 0);
1131 gfx::Rect expected(130, 160, 20, 50);
1132 EXPECT_EQ(expected.ToString(), window_->bounds().ToString());
1133
1134 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent(
1135 window_.get()));
1136
1137 // The initial y position of |window_|.
1138 int initial_y = 10;
1139 // The drag position where the window is exactly attached to the bottom.
1140 int attach_y = work_area.bottom() - window_->bounds().height() - initial_y;
1141
1142 // Dragging 10px above should not attach to the bottom.
1143 resizer->Drag(CalculateDragPoint(*resizer, 119, attach_y - 10), 0);
1144 expected.set_y(attach_y + initial_y - 10);
1145 EXPECT_EQ(expected.ToString(), window_->bounds().ToString());
1146
1147 // Stick to the work area.
1148 resizer->Drag(CalculateDragPoint(*resizer, 119, attach_y - 1), 0);
1149 expected.set_y(attach_y + initial_y);
1150 EXPECT_EQ(expected.ToString(), window_->bounds().ToString());
1151
1152 resizer->Drag(CalculateDragPoint(*resizer, 119, attach_y), 0);
1153 expected.set_y(attach_y + initial_y);
1154 EXPECT_EQ(expected.ToString(), window_->bounds().ToString());
1155
1156 resizer->Drag(CalculateDragPoint(*resizer, 119, attach_y + 1), 0);
1157 expected.set_y(attach_y + initial_y);
1158 EXPECT_EQ(expected.ToString(), window_->bounds().ToString());
1159
1160 // Moving down further should move the window.
1161 resizer->Drag(CalculateDragPoint(*resizer, 119, attach_y + 18), 0);
1162 expected.set_y(attach_y + initial_y + 18);
1163 EXPECT_EQ(expected.ToString(), window_->bounds().ToString());
1164 }
1165
1118 // Verifies a resize sticks when dragging TOPLEFT. 1166 // Verifies a resize sticks when dragging TOPLEFT.
1119 TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_TOPLEFT) { 1167 TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_TOPLEFT) {
1120 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); 1168 window_->SetBounds(gfx::Rect(100, 200, 20, 30));
1121 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1169 scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
1122 window_.get(), gfx::Point(), HTTOPLEFT)); 1170 window_.get(), gfx::Point(), HTTOPLEFT));
1123 ASSERT_TRUE(resizer.get()); 1171 ASSERT_TRUE(resizer.get());
1124 resizer->Drag(CalculateDragPoint(*resizer, -15 - 100, -15 -200), 0); 1172 resizer->Drag(CalculateDragPoint(*resizer, -15 - 100, -15 -200), 0);
1125 EXPECT_EQ("0,0 120x230", window_->bounds().ToString()); 1173 EXPECT_EQ("0,0 120x230", window_->bounds().ToString());
1126 } 1174 }
1127 1175
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), 1917 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40),
1870 gfx::Point(400, kRootHeight - 25), 1918 gfx::Point(400, kRootHeight - 25),
1871 base::TimeDelta::FromMilliseconds(10), 1919 base::TimeDelta::FromMilliseconds(10),
1872 5); 1920 5);
1873 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), 1921 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(),
1874 touch_resize_window_->bounds().ToString()); 1922 touch_resize_window_->bounds().ToString());
1875 } 1923 }
1876 1924
1877 } // namespace internal 1925 } // namespace internal
1878 } // namespace ash 1926 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_window_resizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698