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

Side by Side Diff: ash/wm/dock/docked_window_resizer_unittest.cc

Issue 23431009: Windows docking should get triggered by pressing against the screen edge (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Windows docking should get triggered by pressing against the screen edge (comments) Created 7 years, 3 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
« no previous file with comments | « ash/wm/dock/docked_window_resizer.cc ('k') | ash/wm/window_util.cc » ('j') | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/dock/docked_window_resizer.h" 5 #include "ash/wm/dock/docked_window_resizer.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/launcher/launcher.h" 8 #include "ash/launcher/launcher.h"
9 #include "ash/launcher/launcher_model.h" 9 #include "ash/launcher/launcher_model.h"
10 #include "ash/root_window_controller.h" 10 #include "ash/root_window_controller.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 const gfx::Point& point_in_parent, 88 const gfx::Point& point_in_parent,
89 int window_component) { 89 int window_component) {
90 return CreateWindowResizer( 90 return CreateWindowResizer(
91 window, 91 window,
92 point_in_parent, 92 point_in_parent,
93 window_component, 93 window_component,
94 aura::client::WINDOW_MOVE_SOURCE_MOUSE).release(); 94 aura::client::WINDOW_MOVE_SOURCE_MOUSE).release();
95 } 95 }
96 96
97 void DragStart(aura::Window* window) { 97 void DragStart(aura::Window* window) {
98 initial_location_in_parent_ = window->bounds().origin(); 98 DragStartAtOffsetFromwindowOrigin(window, 0, 0);
99 resizer_.reset(CreateSomeWindowResizer(window,
100 initial_location_in_parent_,
101 HTCAPTION));
102 ASSERT_TRUE(resizer_.get());
103 } 99 }
104 100
105 void DragStartAtOffsetFromwindowOrigin(aura::Window* window, 101 void DragStartAtOffsetFromwindowOrigin(aura::Window* window,
106 int dx, 102 int dx,
107 int dy) { 103 int dy) {
108 initial_location_in_parent_ = 104 initial_location_in_parent_ =
109 window->bounds().origin() + gfx::Vector2d(dx, dy); 105 window->bounds().origin() + gfx::Vector2d(dx, dy);
110 resizer_.reset(CreateSomeWindowResizer(window, 106 resizer_.reset(CreateSomeWindowResizer(window,
111 initial_location_in_parent_, 107 initial_location_in_parent_,
112 HTCAPTION)); 108 HTCAPTION));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 146
151 // Test dragging the window vertically (to detach if it is a panel) and then 147 // Test dragging the window vertically (to detach if it is a panel) and then
152 // horizontally to the edge with an added offset from the edge of |dx|. 148 // horizontally to the edge with an added offset from the edge of |dx|.
153 void DragRelativeToEdge(DockedEdge edge, 149 void DragRelativeToEdge(DockedEdge edge,
154 aura::Window* window, 150 aura::Window* window,
155 int dx) { 151 int dx) {
156 DragVerticallyAndRelativeToEdge( 152 DragVerticallyAndRelativeToEdge(
157 edge, 153 edge,
158 window, 154 window,
159 dx, 155 dx,
160 window_type_ == aura::client::WINDOW_TYPE_PANEL ? -100 : 20); 156 window_type_ == aura::client::WINDOW_TYPE_PANEL ? -100 : 20,
157 25,
158 5);
flackr 2013/09/11 18:35:56 nit: As per the style guide http://google-stylegui
varkha 2013/09/11 18:45:56 Done.
161 } 159 }
162 160
163 void DragToVerticalPositionAndToEdge(DockedEdge edge, 161 void DragToVerticalPositionAndToEdge(DockedEdge edge,
164 aura::Window* window, 162 aura::Window* window,
165 int y) { 163 int y) {
166 DragToVerticalPositionRelativeToEdge(edge, window, 0, y); 164 DragToVerticalPositionRelativeToEdge(edge, window, 0, y);
167 } 165 }
168 166
169 void DragToVerticalPositionRelativeToEdge(DockedEdge edge, 167 void DragToVerticalPositionRelativeToEdge(DockedEdge edge,
170 aura::Window* window, 168 aura::Window* window,
171 int dx, 169 int dx,
172 int y) { 170 int y) {
173 gfx::Rect initial_bounds = window->GetBoundsInScreen(); 171 gfx::Rect initial_bounds = window->GetBoundsInScreen();
174 DragVerticallyAndRelativeToEdge(edge, window, dx, y - initial_bounds.y()); 172 DragVerticallyAndRelativeToEdge(edge,
173 window,
174 dx,
175 y - initial_bounds.y(),
176 25,
177 5);
175 } 178 }
176 179
177 // Detach if our window is a panel, then drag it vertically by |dy| and 180 // Detach if our window is a panel, then drag it vertically by |dy| and
178 // horizontally to the edge with an added offset from the edge of |dx|. 181 // horizontally to the edge with an added offset from the edge of |dx|.
179 void DragVerticallyAndRelativeToEdge(DockedEdge edge, 182 void DragVerticallyAndRelativeToEdge(DockedEdge edge,
180 aura::Window* window, 183 aura::Window* window,
181 int dx, 184 int dx,
182 int dy) { 185 int dy,
186 int grab_x,
187 int grab_y) {
183 aura::RootWindow* root_window = window->GetRootWindow(); 188 aura::RootWindow* root_window = window->GetRootWindow();
184 gfx::Rect initial_bounds = window->GetBoundsInScreen(); 189 gfx::Rect initial_bounds = window->GetBoundsInScreen();
185 190
186 if (window_type_ == aura::client::WINDOW_TYPE_PANEL) { 191 if (window_type_ == aura::client::WINDOW_TYPE_PANEL) {
187 ASSERT_NO_FATAL_FAILURE(DragStart(window)); 192 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(window,
193 grab_x,
194 grab_y));
188 EXPECT_TRUE(window->GetProperty(kPanelAttachedKey)); 195 EXPECT_TRUE(window->GetProperty(kPanelAttachedKey));
189 196
190 // Drag enough to detach since our tests assume panels to be initially 197 // Drag enough to detach since our tests assume panels to be initially
191 // detached. 198 // detached.
192 DragMove(0, dy); 199 DragMove(0, dy);
193 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); 200 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id());
194 EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x()); 201 EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x());
195 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y()); 202 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y());
196 203
197 // The panel should be detached when the drag completes. 204 // The panel should be detached when the drag completes.
198 DragEnd(); 205 DragEnd();
199 206
200 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); 207 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey));
201 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, 208 EXPECT_EQ(internal::kShellWindowId_DefaultContainer,
202 window->parent()->id()); 209 window->parent()->id());
203 EXPECT_EQ(root_window, window->GetRootWindow()); 210 EXPECT_EQ(root_window, window->GetRootWindow());
204 } 211 }
205 212
206 // avoid snap by clicking away from the border 213 // avoid snap by clicking away from the border
207 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(window, 25, 5)); 214 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(window,
215 grab_x,
216 grab_y));
208 217
218 gfx::Rect work_area =
219 Shell::GetScreen()->GetDisplayNearestWindow(window).work_area();
209 // Drag the window left or right to the edge (or almost to it). 220 // Drag the window left or right to the edge (or almost to it).
210 if (edge == DOCKED_EDGE_LEFT) 221 if (edge == DOCKED_EDGE_LEFT)
211 dx += window->GetRootWindow()->bounds().x() - initial_bounds.x(); 222 dx += work_area.x() - initial_location_in_parent_.x();
212 else if (edge == DOCKED_EDGE_RIGHT) 223 else if (edge == DOCKED_EDGE_RIGHT)
213 dx += window->GetRootWindow()->bounds().right() - initial_bounds.right(); 224 dx += work_area.right() - 1 - initial_location_in_parent_.x();
214 DragMove(dx, window_type_ == aura::client::WINDOW_TYPE_PANEL ? 0 : dy); 225 DragMove(dx, window_type_ == aura::client::WINDOW_TYPE_PANEL ? 0 : dy);
215 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); 226 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id());
216 // Release the mouse and the panel should be attached to the dock. 227 // Release the mouse and the panel should be attached to the dock.
217 DragEnd(); 228 DragEnd();
218 229
219 // x-coordinate can get adjusted by snapping or sticking. 230 // x-coordinate can get adjusted by snapping or sticking.
220 // y-coordinate could be changed by possible automatic layout if docked. 231 // y-coordinate could be changed by possible automatic layout if docked.
221 if (window->parent()->id() != internal::kShellWindowId_DockedContainer) 232 if (window->parent()->id() != internal::kShellWindowId_DockedContainer &&
233 GetRestoreBoundsInScreen(window) == NULL) {
222 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y()); 234 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y());
235 }
223 } 236 }
224 237
225 bool test_panels() const { 238 bool test_panels() const {
226 return window_type_ == aura::client::WINDOW_TYPE_PANEL; 239 return window_type_ == aura::client::WINDOW_TYPE_PANEL;
227 } 240 }
228 241
229 private: 242 private:
230 scoped_ptr<WindowResizer> resizer_; 243 scoped_ptr<WindowResizer> resizer_;
231 LauncherModel* model_; 244 LauncherModel* model_;
232 aura::client::WindowType window_type_; 245 aura::client::WindowType window_type_;
(...skipping 13 matching lines...) Expand all
246 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 259 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
247 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); 260 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0);
248 261
249 // The window should be attached and snapped to the right edge. 262 // The window should be attached and snapped to the right edge.
250 EXPECT_EQ(window->GetRootWindow()->bounds().right(), 263 EXPECT_EQ(window->GetRootWindow()->bounds().right(),
251 window->GetBoundsInScreen().right()); 264 window->GetBoundsInScreen().right());
252 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 265 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
253 } 266 }
254 267
255 // Verifies a window can be dragged and attached to the dock 268 // Verifies a window can be dragged and attached to the dock
256 // even if we overshoot the screen edge by a few pixels (sticky edge) 269 // even if pointer overshoots the screen edge by a few pixels (sticky edge)
257 TEST_P(DockedWindowResizerTest, AttachRightOvershoot) { 270 TEST_P(DockedWindowResizerTest, AttachRightOvershoot) {
258 if (!SupportsHostWindowResize()) 271 if (!SupportsHostWindowResize())
259 return; 272 return;
260 273
261 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 274 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
262 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), +4); 275 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), +4);
263 276
264 // The window should be attached and snapped to the right edge. 277 // The window should be attached and snapped to the right edge.
265 EXPECT_EQ(window->GetRootWindow()->bounds().right(), 278 EXPECT_EQ(window->GetRootWindow()->bounds().right(),
266 window->GetBoundsInScreen().right()); 279 window->GetBoundsInScreen().right());
267 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 280 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
268 } 281 }
269 282
270 // Verifies a window can be dragged and then if not quite reaching the screen 283 // Verifies a window can be dragged and then if a pointer is not quite reaching
271 // edge it does not get docked to a screen edge and stays in the desktop. 284 // the screen edge the window does not get docked and stays in the desktop.
272 TEST_P(DockedWindowResizerTest, AttachRightUndershoot) { 285 TEST_P(DockedWindowResizerTest, AttachRightUndershoot) {
273 if (!SupportsHostWindowResize()) 286 if (!SupportsHostWindowResize())
274 return; 287 return;
275 288
276 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 289 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
277 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), -1); 290 // Grabbing at 70px ensures that at least 30% of the window is in screen,
291 // otherwise the window would be adjusted in
292 // WorkspaceLayoutManager::AdjustWindowBoundsWhenAdded.
293 const int kGrabOffsetX = 70;
294 const int kUndershootBy = 1;
295 DragVerticallyAndRelativeToEdge(DOCKED_EDGE_RIGHT,
296 window.get(),
297 -kUndershootBy,
298 test_panels() ? -100 : 20,
299 kGrabOffsetX,
300 5);
278 301
279 // The window should not be attached to the dock. 302 // The window right should be past the screen edge but not docked.
280 EXPECT_EQ(window->GetRootWindow()->bounds().right() - 1, 303 // Initial touch point is 70px to the right which helps to find where the edge
304 // should be.
305 EXPECT_EQ(window->GetRootWindow()->bounds().right() +
306 window->bounds().width() - kGrabOffsetX - kUndershootBy - 1,
281 window->GetBoundsInScreen().right()); 307 window->GetBoundsInScreen().right());
282 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, 308 EXPECT_EQ(internal::kShellWindowId_DefaultContainer,
283 window->parent()->id()); 309 window->parent()->id());
284 } 310 }
285 311
286 // Verifies a window can be dragged and attached to the dock. 312 // Verifies a window can be dragged and attached to the dock.
287 TEST_P(DockedWindowResizerTest, AttachLeftPrecise) { 313 TEST_P(DockedWindowResizerTest, AttachLeftPrecise) {
288 if (!SupportsHostWindowResize()) 314 if (!SupportsHostWindowResize())
289 return; 315 return;
290 316
291 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 317 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
292 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 0); 318 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 0);
293 319
294 // The window should be attached and snapped to the left dock. 320 // The window should be attached and snapped to the left dock.
295 EXPECT_EQ(window->GetRootWindow()->bounds().x(), 321 EXPECT_EQ(window->GetRootWindow()->bounds().x(),
296 window->GetBoundsInScreen().x()); 322 window->GetBoundsInScreen().x());
297 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 323 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
298 } 324 }
299 325
300 // Verifies a window can be dragged and attached to the dock 326 // Verifies a window can be dragged and attached to the dock
301 // even if we overshoot the screen edge by a few pixels (sticky edge) 327 // even if pointer overshoots the screen edge by a few pixels (sticky edge)
302 TEST_P(DockedWindowResizerTest, AttachLeftOvershoot) { 328 TEST_P(DockedWindowResizerTest, AttachLeftOvershoot) {
303 if (!SupportsHostWindowResize()) 329 if (!SupportsHostWindowResize())
304 return; 330 return;
305 331
306 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 332 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
307 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), -4); 333 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), -4);
308 334
309 // The window should be attached and snapped to the left dock. 335 // The window should be attached and snapped to the left dock.
310 EXPECT_EQ(window->GetRootWindow()->bounds().x(), 336 EXPECT_EQ(window->GetRootWindow()->bounds().x(),
311 window->GetBoundsInScreen().x()); 337 window->GetBoundsInScreen().x());
312 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 338 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
313 } 339 }
314 340
315 // Verifies a window can be dragged and then if not quite reaching the screen 341 // Verifies a window can be dragged and then if a pointer is not quite reaching
316 // edge it does not get docked to a screen edge and stays in the desktop. 342 // the screen edge the window does not get docked and stays in the desktop.
317 TEST_P(DockedWindowResizerTest, AttachLeftUndershoot) { 343 TEST_P(DockedWindowResizerTest, AttachLeftUndershoot) {
318 if (!SupportsHostWindowResize()) 344 if (!SupportsHostWindowResize())
319 return; 345 return;
320 346
321 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 347 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
322 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 1); 348 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 1);
323 349
324 // The window should not be attached to the dock. 350 // The window should be touching the screen edge but not docked.
325 EXPECT_EQ(window->GetRootWindow()->bounds().x() + 1, 351 EXPECT_EQ(window->GetRootWindow()->bounds().x(),
326 window->GetBoundsInScreen().x()); 352 window->GetBoundsInScreen().x());
327 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, 353 EXPECT_EQ(internal::kShellWindowId_DefaultContainer,
328 window->parent()->id()); 354 window->parent()->id());
329 } 355 }
330 356
331 // Dock on the right side, change shelf alignment, check that windows move to 357 // Dock on the right side, change shelf alignment, check that windows move to
332 // the opposite side. 358 // the opposite side.
333 TEST_P(DockedWindowResizerTest, AttachRightChangeShelf) { 359 TEST_P(DockedWindowResizerTest, AttachRightChangeShelf) {
334 if (!SupportsHostWindowResize()) 360 if (!SupportsHostWindowResize())
335 return; 361 return;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 506 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
481 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); 507 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
482 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w2.get(), 50); 508 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w2.get(), 50);
483 509
484 // The first window should be attached and snapped to the right edge. 510 // The first window should be attached and snapped to the right edge.
485 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), 511 EXPECT_EQ(w1->GetRootWindow()->bounds().right(),
486 w1->GetBoundsInScreen().right()); 512 w1->GetBoundsInScreen().right());
487 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 513 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id());
488 514
489 // The second window should be near the left edge but not snapped. 515 // The second window should be near the left edge but not snapped.
516 // Normal window will get side-maximized while panels will not.
490 EXPECT_EQ(w2->GetRootWindow()->bounds().x(), w2->GetBoundsInScreen().x()); 517 EXPECT_EQ(w2->GetRootWindow()->bounds().x(), w2->GetBoundsInScreen().x());
491 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); 518 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id());
492 } 519 }
493 520
494 // Reverting drag 521 // Reverting drag
495 TEST_P(DockedWindowResizerTest, RevertDragRestoresAttachment) { 522 TEST_P(DockedWindowResizerTest, RevertDragRestoresAttachment) {
496 if (!SupportsHostWindowResize()) 523 if (!SupportsHostWindowResize())
497 return; 524 return;
498 525
499 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 526 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
(...skipping 18 matching lines...) Expand all
518 window->parent()->id()); 545 window->parent()->id());
519 } 546 }
520 547
521 // Move a docked window to the second display 548 // Move a docked window to the second display
522 TEST_P(DockedWindowResizerTest, DragAcrossDisplays) { 549 TEST_P(DockedWindowResizerTest, DragAcrossDisplays) {
523 if (!SupportsMultipleDisplays()) 550 if (!SupportsMultipleDisplays())
524 return; 551 return;
525 552
526 UpdateDisplay("800x800,800x800"); 553 UpdateDisplay("800x800,800x800");
527 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 554 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
555 EXPECT_EQ(2, static_cast<int>(root_windows.size()));
528 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 556 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
529 gfx::Rect initial_bounds = window->GetBoundsInScreen(); 557 gfx::Rect initial_bounds = window->GetBoundsInScreen();
530 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 558 EXPECT_EQ(root_windows[0], window->GetRootWindow());
531 559
532 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); 560 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0);
533 // The window should be attached and snapped to the right edge. 561 // The window should be attached and snapped to the right edge.
534 EXPECT_EQ(window->GetRootWindow()->bounds().right(), 562 EXPECT_EQ(window->GetRootWindow()->bounds().right(),
535 window->GetBoundsInScreen().right()); 563 window->GetBoundsInScreen().right());
536 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 564 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
537 565
538 // Undock and move to the right - enough to get it peeking at the other screen 566 // Try dragging to the right - enough to get it peeking at the other screen
539 // but not enough to land in the other screen 567 // but not enough to land in the other screen.
568 // The window should stay on the left screen.
540 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); 569 ASSERT_NO_FATAL_FAILURE(DragStart(window.get()));
541 DragMove(70, 0); 570 DragMove(100, 0);
542 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id());
543 DragEnd();
544 EXPECT_NE(window->GetRootWindow()->bounds().right(),
545 window->GetBoundsInScreen().right());
546 EXPECT_EQ(internal::kShellWindowId_DefaultContainer,
547 window->parent()->id());
548 EXPECT_EQ(root_windows[0], window->GetRootWindow());
549
550 // Move back left - should dock again.
551 ASSERT_NO_FATAL_FAILURE(DragStart(window.get()));
552 DragMove(-70, 0);
553 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); 571 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id());
554 DragEnd(); 572 DragEnd();
555 EXPECT_EQ(window->GetRootWindow()->bounds().right(), 573 EXPECT_EQ(window->GetRootWindow()->bounds().right(),
556 window->GetBoundsInScreen().right()); 574 window->GetBoundsInScreen().right());
557 EXPECT_EQ(internal::kShellWindowId_DockedContainer, 575 EXPECT_EQ(internal::kShellWindowId_DockedContainer,
558 window->parent()->id()); 576 window->parent()->id());
559 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 577 EXPECT_EQ(root_windows[0], window->GetRootWindow());
560 578
561 // Undock and move to the right - enough to get the mouse pointer past the 579 // Undock and move to the right - enough to get the mouse pointer past the
562 // edge of the screen and into the second screen. The window should now be 580 // edge of the screen and into the second screen. The window should now be
563 // in the second screen and not docked. 581 // in the second screen and not docked.
564 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin( 582 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(
565 window.get(), 583 window.get(),
566 window->bounds().width()/2 + 10, 584 window->bounds().width()/2 + 10,
567 0)); 585 0));
568 DragMove(window->bounds().width()/2 - 5, 0); 586 DragMove(window->bounds().width()/2 - 5, 0);
569 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); 587 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id());
570 DragEnd(); 588 DragEnd();
571 EXPECT_NE(window->GetRootWindow()->bounds().right(), 589 EXPECT_NE(window->GetRootWindow()->bounds().right(),
572 window->GetBoundsInScreen().right()); 590 window->GetBoundsInScreen().right());
573 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, 591 EXPECT_EQ(internal::kShellWindowId_DefaultContainer,
574 window->parent()->id()); 592 window->parent()->id());
575 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 593 EXPECT_EQ(root_windows[1], window->GetRootWindow());
576 594
577 // Keep dragging it to the right until it docks. The window should now be 595 // Keep dragging it to the right until its left edge touches the screen edge.
578 // in the second screen. 596 // The window should now be in the second screen and not docked.
579 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin( 597 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(
580 window.get(), 598 window.get(),
581 window->bounds().width()/2 + 10, 599 window->bounds().width()/2 + 10,
582 0)); 600 0));
583 DragMove(window->GetRootWindow()->GetBoundsInScreen().x() - 601 DragMove(window->GetRootWindow()->GetBoundsInScreen().x() -
584 window->GetBoundsInScreen().x(), 602 window->GetBoundsInScreen().x(),
585 0); 603 0);
586 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); 604 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id());
587 DragEnd(); 605 DragEnd();
588 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(), 606 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(),
589 window->GetBoundsInScreen().x()); 607 window->GetBoundsInScreen().x());
590 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 608 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id());
591 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 609 EXPECT_EQ(root_windows[1], window->GetRootWindow());
592 } 610 }
593 611
594 // Dock two windows, undock one. 612 // Dock two windows, undock one.
595 // Test the docked windows area size and default container resizing. 613 // Test the docked windows area size and default container resizing.
596 TEST_P(DockedWindowResizerTest, AttachTwoWindowsDetachOne) 614 TEST_P(DockedWindowResizerTest, AttachTwoWindowsDetachOne)
597 { 615 {
598 if (!SupportsHostWindowResize()) 616 if (!SupportsHostWindowResize())
599 return; 617 return;
600 618
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 EXPECT_EQ(w2->GetRootWindow()->bounds().right() - 676 EXPECT_EQ(w2->GetRootWindow()->bounds().right() -
659 (w2->bounds().width()/2 + 20), 677 (w2->bounds().width()/2 + 20),
660 w2->GetBoundsInScreen().right()); 678 w2->GetBoundsInScreen().right());
661 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); 679 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id());
662 // Dock width should be set to remaining single docked window. 680 // Dock width should be set to remaining single docked window.
663 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 681 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id());
664 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_); 682 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_);
665 EXPECT_EQ(w1->bounds().width(), manager->docked_width_); 683 EXPECT_EQ(w1->bounds().width(), manager->docked_width_);
666 } 684 }
667 685
668 // Dock one windows. Maximize other testing desktop resizing. 686 // Dock one of the windows. Maximize other testing desktop resizing.
669 TEST_P(DockedWindowResizerTest, AttachWindowMaximizeOther) 687 TEST_P(DockedWindowResizerTest, AttachWindowMaximizeOther)
670 { 688 {
671 if (!SupportsHostWindowResize()) 689 if (!SupportsHostWindowResize())
672 return; 690 return;
673 691
674 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 692 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
675 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); 693 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201)));
676 // Work area should cover the whole screen. 694 // Work area should cover the whole screen.
677 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width(), 695 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width(),
678 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); 696 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width());
679 697
680 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); 698 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
681 // A window should be attached and snapped to the right edge. 699 // A window should be attached and snapped to the right edge.
682 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), 700 EXPECT_EQ(w1->GetRootWindow()->bounds().right(),
683 w1->GetBoundsInScreen().right()); 701 w1->GetBoundsInScreen().right());
684 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 702 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id());
685 DockedWindowLayoutManager* manager = 703 DockedWindowLayoutManager* manager =
686 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); 704 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager());
687 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_); 705 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_);
688 EXPECT_EQ(w1->bounds().width(), manager->docked_width_); 706 EXPECT_EQ(w1->bounds().width(), manager->docked_width_);
689 707
690 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_RIGHT, 708 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(w2.get(), 25, 5));
691 w2.get(), 709 DragMove(w2->GetRootWindow()->bounds().right()
692 -(w2->bounds().width()/2 + 20), 710 -w2->bounds().width()
693 50); 711 -(w2->bounds().width()/2 + 20)
712 -w2->bounds().x(),
713 50 - w2->bounds().y());
714 DragEnd();
694 // The first window should be still docked. 715 // The first window should be still docked.
695 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), 716 EXPECT_EQ(w1->GetRootWindow()->bounds().right(),
696 w1->GetBoundsInScreen().right()); 717 w1->GetBoundsInScreen().right());
697 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 718 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id());
698 719
699 // The second window should be floating on the desktop. 720 // The second window should be floating on the desktop.
700 EXPECT_EQ(w2->GetRootWindow()->bounds().right() - 721 EXPECT_EQ(w2->GetRootWindow()->bounds().right() -
701 (w2->bounds().width()/2 + 20), 722 (w2->bounds().width()/2 + 20),
702 w2->GetBoundsInScreen().right()); 723 w2->GetBoundsInScreen().right());
703 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); 724 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id());
(...skipping 27 matching lines...) Expand all
731 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); 752 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id());
732 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, manager->alignment_); 753 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, manager->alignment_);
733 EXPECT_EQ(0, manager->docked_width_); 754 EXPECT_EQ(0, manager->docked_width_);
734 // The second window should now get resized and take up the whole screen. 755 // The second window should now get resized and take up the whole screen.
735 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width(), 756 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width(),
736 w2->bounds().width()); 757 w2->bounds().width());
737 758
738 // Dock the first window to the left edge. 759 // Dock the first window to the left edge.
739 // Click at an offset from origin to prevent snapping. 760 // Click at an offset from origin to prevent snapping.
740 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(w1.get(), 10, 0)); 761 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(w1.get(), 10, 0));
741 DragMove(-w1->bounds().x(), 0); 762 // Drag left to get pointer touching the screen edge.
763 DragMove(-w1->bounds().x() - 10, 0);
742 // Alignment set to "NONE" during the drag of the window when none are docked. 764 // Alignment set to "NONE" during the drag of the window when none are docked.
743 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, manager->alignment_); 765 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, manager->alignment_);
744 // Release the mouse and the window should be now attached to the edge. 766 // Release the mouse and the window should be now attached to the edge.
745 DragEnd(); 767 DragEnd();
746 // Dock should get expanded and desktop should get shrunk. 768 // Dock should get expanded and desktop should get shrunk.
747 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 769 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id());
748 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, manager->alignment_); 770 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, manager->alignment_);
749 EXPECT_EQ(w1->bounds().width(), manager->docked_width_); 771 EXPECT_EQ(w1->bounds().width(), manager->docked_width_);
750 // Second window should still be in the desktop. 772 // Second window should still be in the desktop.
751 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); 773 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id());
(...skipping 28 matching lines...) Expand all
780 DockedWindowLayoutManager* manager = 802 DockedWindowLayoutManager* manager =
781 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); 803 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager());
782 // The first window should be docked. 804 // The first window should be docked.
783 EXPECT_EQ(w1->GetRootWindow()->bounds().x(), 805 EXPECT_EQ(w1->GetRootWindow()->bounds().x(),
784 w1->GetBoundsInScreen().x()); 806 w1->GetBoundsInScreen().x());
785 // Dock width should be set to that of a single docked window. 807 // Dock width should be set to that of a single docked window.
786 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 808 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id());
787 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, manager->alignment_); 809 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, manager->alignment_);
788 EXPECT_EQ(w1->bounds().width(), manager->docked_width_); 810 EXPECT_EQ(w1->bounds().width(), manager->docked_width_);
789 811
790 // Position second window in the desktop just to the right of the docked w1. 812 // Position second window in the desktop 20px to the right of the docked w1.
791 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_LEFT, 813 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_LEFT,
792 w2.get(), 814 w2.get(),
793 w1->bounds().right() + 20, 815 20 +
816 25 -
817 DockedWindowLayoutManager::kMinDockGap,
794 50); 818 50);
795 // The second window should be floating on the desktop. 819 // The second window should be floating on the desktop.
796 EXPECT_EQ(w2->GetRootWindow()->bounds().x() + (w1->bounds().right() + 20), 820 EXPECT_EQ(w2->GetRootWindow()->bounds().x() + (w1->bounds().right() + 20),
797 w2->GetBoundsInScreen().x()); 821 w2->GetBoundsInScreen().x());
798 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); 822 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id());
799 // Dock width should be set to that of a single docked window. 823 // Dock width should be set to that of a single docked window.
800 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 824 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id());
801 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, manager->alignment_); 825 EXPECT_EQ(DOCKED_ALIGNMENT_LEFT, manager->alignment_);
802 EXPECT_EQ(w1->bounds().width(), manager->docked_width_); 826 EXPECT_EQ(w1->bounds().width(), manager->docked_width_);
803 827
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 // w1 is now wider than w2 and the dock should expand and be as wide as w1. 934 // w1 is now wider than w2 and the dock should expand and be as wide as w1.
911 EXPECT_EQ(previous_width + kResizeSpan1, w1->bounds().width()); 935 EXPECT_EQ(previous_width + kResizeSpan1, w1->bounds().width());
912 EXPECT_GT(w1->bounds().width(), w2->bounds().width()); 936 EXPECT_GT(w1->bounds().width(), w2->bounds().width());
913 EXPECT_EQ(w1->bounds().width(), manager->docked_width_); 937 EXPECT_EQ(w1->bounds().width(), manager->docked_width_);
914 // Desktop work area should shrink. 938 // Desktop work area should shrink.
915 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width() - 939 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width() -
916 manager->docked_width_ - DockedWindowLayoutManager::kMinDockGap, 940 manager->docked_width_ - DockedWindowLayoutManager::kMinDockGap,
917 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); 941 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width());
918 942
919 // Resize the first window left by more than the dock maximum width. 943 // Resize the first window left by more than the dock maximum width.
920 // This should cause the window to overhang and the dock to shrink to w2. 944 // This should cause the window width to be restricted by maximum dock width.
921 previous_width = w1->bounds().width(); 945 previous_width = w1->bounds().width();
922 const int kResizeSpan2 = 250; 946 const int kResizeSpan2 = 250;
923 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromwindowOrigin(w1.get(), 947 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromwindowOrigin(w1.get(),
924 0, 948 0,
925 20, 949 20,
926 HTLEFT)); 950 HTLEFT));
927 DragMove(-kResizeSpan2, 0); 951 DragMove(-kResizeSpan2, 0);
928 // Alignment set to "RIGHT" during the drag because dock has a window in it. 952 // Alignment set to "RIGHT" during the drag because dock has a window in it.
929 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_); 953 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_);
930 // Release the mouse and the window should be attached to the edge. 954 // Release the mouse and the window should be attached to the edge.
931 DragEnd(); 955 DragEnd();
932 // Dock should still have both windows in it. 956 // Dock should still have both windows in it.
933 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 957 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id());
934 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); 958 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id());
935 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_); 959 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_);
936 // w1 is now wider than the maximum dock width and the dock should shrink to 960 // w1 is now as wide as the maximum dock width and the dock should get
937 // the next widest window (w2). 961 // resized to the maximum width.
938 EXPECT_EQ(previous_width + kResizeSpan2, w1->bounds().width()); 962 EXPECT_EQ(DockedWindowLayoutManager::kMaxDockWidth, w1->bounds().width());
939 EXPECT_GT(w1->bounds().width(), w2->bounds().width()); 963 EXPECT_GT(w1->bounds().width(), w2->bounds().width());
940 EXPECT_EQ(w2->bounds().width(), manager->docked_width_); 964 EXPECT_EQ(w1->bounds().width(), manager->docked_width_);
941 // Desktop work area should shrink. 965 // Desktop work area should shrink.
942 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width() - 966 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width() -
943 manager->docked_width_ - DockedWindowLayoutManager::kMinDockGap, 967 manager->docked_width_ - DockedWindowLayoutManager::kMinDockGap,
944 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); 968 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width());
945 969
946 // Resize the first window right to get it completely inside the docked area. 970 // Resize the first window right to get it completely inside the docked area.
947 previous_width = w1->bounds().width(); 971 previous_width = w1->bounds().width();
948 const int kResizeSpan3 = 100; 972 const int kResizeSpan3 = 100;
949 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromwindowOrigin(w1.get(), 973 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromwindowOrigin(w1.get(),
950 0, 974 0,
(...skipping 20 matching lines...) Expand all
971 // Resize the first window left to be overhang again. 995 // Resize the first window left to be overhang again.
972 previous_width = w1->bounds().width(); 996 previous_width = w1->bounds().width();
973 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromwindowOrigin(w1.get(), 997 ASSERT_NO_FATAL_FAILURE(ResizeStartAtOffsetFromwindowOrigin(w1.get(),
974 0, 998 0,
975 20, 999 20,
976 HTLEFT)); 1000 HTLEFT));
977 DragMove(-kResizeSpan3, 0); 1001 DragMove(-kResizeSpan3, 0);
978 DragEnd(); 1002 DragEnd();
979 EXPECT_EQ(previous_width + kResizeSpan3, w1->bounds().width()); 1003 EXPECT_EQ(previous_width + kResizeSpan3, w1->bounds().width());
980 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 1004 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id());
981 // Docked area should be as wide as the second window - the first is too wide. 1005 // Docked area should be as wide as possible (maximum) and same as w1.
982 EXPECT_EQ(w2->bounds().width(), manager->docked_width_); 1006 EXPECT_EQ(DockedWindowLayoutManager::kMaxDockWidth, manager->docked_width_);
1007 EXPECT_EQ(w1->bounds().width(), manager->docked_width_);
983 1008
984 // Undock the second window. Docked area should shrink to its minimum size. 1009 // Undock the second window. Docked area should shrink to its minimum size.
985 ASSERT_NO_FATAL_FAILURE(DragStart(w2.get())); 1010 ASSERT_NO_FATAL_FAILURE(DragStart(w2.get()));
986 // Drag up as well to avoid attaching panels to launcher shelf. 1011 // Drag up as well to avoid attaching panels to launcher shelf.
987 DragMove(-40, -100); 1012 DragMove(-(400 - 201), -100);
988 // Alignment set to "RIGHT" since we have another window docked. 1013 // Alignment set to "RIGHT" since we have another window docked.
989 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_); 1014 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_);
990 // Release the mouse and the window should be no longer attached to the edge. 1015 // Release the mouse and the window should be no longer attached to the edge.
991 DragEnd(); 1016 DragEnd();
992 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); 1017 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id());
993 // Dock should get shrunk to minimum size. 1018 // Dock should be as wide as w1 (and same as maximum width).
994 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_); 1019 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, manager->alignment_);
995 EXPECT_EQ(manager->kMinDockWidth, manager->docked_width_); 1020 EXPECT_EQ(DockedWindowLayoutManager::kMaxDockWidth, manager->docked_width_);
1021 EXPECT_EQ(w1->bounds().width(), manager->docked_width_);
996 // The first window should be still docked. 1022 // The first window should be still docked.
997 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 1023 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id());
998 // Desktop work area should be inset. 1024 // Desktop work area should be inset.
999 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width() - 1025 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width() -
1000 manager->docked_width_ - DockedWindowLayoutManager::kMinDockGap, 1026 manager->docked_width_ - DockedWindowLayoutManager::kMinDockGap,
1001 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); 1027 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width());
1002 } 1028 }
1003 1029
1004 TEST_P(DockedWindowResizerTest, DragToShelf) 1030 TEST_P(DockedWindowResizerTest, DragToShelf)
1005 { 1031 {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 } 1073 }
1048 } 1074 }
1049 1075
1050 // Tests run twice - on both panels and normal windows 1076 // Tests run twice - on both panels and normal windows
1051 INSTANTIATE_TEST_CASE_P(NormalOrPanel, 1077 INSTANTIATE_TEST_CASE_P(NormalOrPanel,
1052 DockedWindowResizerTest, 1078 DockedWindowResizerTest,
1053 testing::Values(aura::client::WINDOW_TYPE_NORMAL, 1079 testing::Values(aura::client::WINDOW_TYPE_NORMAL,
1054 aura::client::WINDOW_TYPE_PANEL)); 1080 aura::client::WINDOW_TYPE_PANEL));
1055 } // namespace internal 1081 } // namespace internal
1056 } // namespace ash 1082 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/dock/docked_window_resizer.cc ('k') | ash/wm/window_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698