OLD | NEW |
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/common/wm/dock/docked_window_resizer.h" | 5 #include "ash/common/wm/dock/docked_window_resizer.h" |
6 | 6 |
7 #include "ash/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
8 #include "ash/common/shelf/shelf_types.h" | 8 #include "ash/common/shelf/shelf_types.h" |
9 #include "ash/common/shelf/shelf_widget.h" | 9 #include "ash/common/shelf/shelf_widget.h" |
10 #include "ash/common/shelf/wm_shelf.h" | 10 #include "ash/common/shelf/wm_shelf.h" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 aura::test::TestWindowDelegate delegate_; | 234 aura::test::TestWindowDelegate delegate_; |
235 | 235 |
236 // Location at start of the drag in |window->parent()|'s coordinates. | 236 // Location at start of the drag in |window->parent()|'s coordinates. |
237 gfx::Point initial_location_in_parent_; | 237 gfx::Point initial_location_in_parent_; |
238 | 238 |
239 DISALLOW_COPY_AND_ASSIGN(DockedWindowResizerTest); | 239 DISALLOW_COPY_AND_ASSIGN(DockedWindowResizerTest); |
240 }; | 240 }; |
241 | 241 |
242 // Verifies a window can be dragged and attached to the dock. | 242 // Verifies a window can be dragged and attached to the dock. |
243 TEST_P(DockedWindowResizerTest, AttachRightPrecise) { | 243 TEST_P(DockedWindowResizerTest, AttachRightPrecise) { |
244 if (!SupportsHostWindowResize()) | |
245 return; | |
246 | |
247 std::unique_ptr<aura::Window> window( | 244 std::unique_ptr<aura::Window> window( |
248 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 245 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
249 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 246 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
250 | 247 |
251 // The window should be docked at the right edge. | 248 // The window should be docked at the right edge. |
252 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 249 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
253 window->GetBoundsInScreen().right()); | 250 window->GetBoundsInScreen().right()); |
254 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 251 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
255 } | 252 } |
256 | 253 |
257 // Verifies a window can be dragged and attached to the dock | 254 // Verifies a window can be dragged and attached to the dock |
258 // even if pointer overshoots the screen edge by a few pixels (sticky edge) | 255 // even if pointer overshoots the screen edge by a few pixels (sticky edge) |
259 TEST_P(DockedWindowResizerTest, AttachRightOvershoot) { | 256 TEST_P(DockedWindowResizerTest, AttachRightOvershoot) { |
260 if (!SupportsHostWindowResize()) | |
261 return; | |
262 | |
263 std::unique_ptr<aura::Window> window( | 257 std::unique_ptr<aura::Window> window( |
264 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 258 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
265 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), +4); | 259 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), +4); |
266 | 260 |
267 // The window should be docked at the right edge. | 261 // The window should be docked at the right edge. |
268 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 262 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
269 window->GetBoundsInScreen().right()); | 263 window->GetBoundsInScreen().right()); |
270 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 264 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
271 } | 265 } |
272 | 266 |
273 // Verifies a window can be dragged and then if a pointer is not quite reaching | 267 // Verifies a window can be dragged and then if a pointer is not quite reaching |
274 // the screen edge the window does not get docked and stays in the desktop. | 268 // the screen edge the window does not get docked and stays in the desktop. |
275 TEST_P(DockedWindowResizerTest, AttachRightUndershoot) { | 269 TEST_P(DockedWindowResizerTest, AttachRightUndershoot) { |
276 if (!SupportsHostWindowResize()) | |
277 return; | |
278 | |
279 std::unique_ptr<aura::Window> window( | 270 std::unique_ptr<aura::Window> window( |
280 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 271 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
281 // Grabbing at 70px ensures that at least 30% of the window is in screen, | 272 // Grabbing at 70px ensures that at least 30% of the window is in screen, |
282 // otherwise the window would be adjusted in | 273 // otherwise the window would be adjusted in |
283 // WorkspaceLayoutManager::AdjustWindowBoundsWhenAdded. | 274 // WorkspaceLayoutManager::AdjustWindowBoundsWhenAdded. |
284 const int kGrabOffsetX = 70; | 275 const int kGrabOffsetX = 70; |
285 const int kUndershootBy = 1; | 276 const int kUndershootBy = 1; |
286 DragVerticallyAndRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), | 277 DragVerticallyAndRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), |
287 -kUndershootBy, test_panels() ? -100 : 20, | 278 -kUndershootBy, test_panels() ? -100 : 20, |
288 kGrabOffsetX, 5); | 279 kGrabOffsetX, 5); |
289 | 280 |
290 // The window right should be past the screen edge but not docked. | 281 // The window right should be past the screen edge but not docked. |
291 // Initial touch point is 70px to the right which helps to find where the edge | 282 // Initial touch point is 70px to the right which helps to find where the edge |
292 // should be. | 283 // should be. |
293 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right() + | 284 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right() + |
294 window->bounds().width() - kGrabOffsetX - kUndershootBy - 1, | 285 window->bounds().width() - kGrabOffsetX - kUndershootBy - 1, |
295 window->GetBoundsInScreen().right()); | 286 window->GetBoundsInScreen().right()); |
296 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 287 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
297 } | 288 } |
298 | 289 |
299 // Verifies a window can be dragged and attached to the dock. | 290 // Verifies a window can be dragged and attached to the dock. |
300 TEST_P(DockedWindowResizerTest, AttachLeftPrecise) { | 291 TEST_P(DockedWindowResizerTest, AttachLeftPrecise) { |
301 if (!SupportsHostWindowResize()) | |
302 return; | |
303 | |
304 std::unique_ptr<aura::Window> window( | 292 std::unique_ptr<aura::Window> window( |
305 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 293 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
306 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 0); | 294 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 0); |
307 | 295 |
308 // The window should be docked at the left edge. | 296 // The window should be docked at the left edge. |
309 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(), | 297 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(), |
310 window->GetBoundsInScreen().x()); | 298 window->GetBoundsInScreen().x()); |
311 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 299 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
312 } | 300 } |
313 | 301 |
314 // Verifies a window can be dragged and attached to the dock | 302 // Verifies a window can be dragged and attached to the dock |
315 // even if pointer overshoots the screen edge by a few pixels (sticky edge) | 303 // even if pointer overshoots the screen edge by a few pixels (sticky edge) |
316 TEST_P(DockedWindowResizerTest, AttachLeftOvershoot) { | 304 TEST_P(DockedWindowResizerTest, AttachLeftOvershoot) { |
317 if (!SupportsHostWindowResize()) | |
318 return; | |
319 | |
320 std::unique_ptr<aura::Window> window( | 305 std::unique_ptr<aura::Window> window( |
321 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 306 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
322 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), -4); | 307 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), -4); |
323 | 308 |
324 // The window should be docked at the left edge. | 309 // The window should be docked at the left edge. |
325 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(), | 310 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(), |
326 window->GetBoundsInScreen().x()); | 311 window->GetBoundsInScreen().x()); |
327 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 312 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
328 } | 313 } |
329 | 314 |
330 // Verifies a window can be dragged and then if a pointer is not quite reaching | 315 // Verifies a window can be dragged and then if a pointer is not quite reaching |
331 // the screen edge the window does not get docked and stays in the desktop. | 316 // the screen edge the window does not get docked and stays in the desktop. |
332 TEST_P(DockedWindowResizerTest, AttachLeftUndershoot) { | 317 TEST_P(DockedWindowResizerTest, AttachLeftUndershoot) { |
333 if (!SupportsHostWindowResize()) | |
334 return; | |
335 | |
336 std::unique_ptr<aura::Window> window( | 318 std::unique_ptr<aura::Window> window( |
337 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 319 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
338 gfx::Rect initial_bounds(window->bounds()); | 320 gfx::Rect initial_bounds(window->bounds()); |
339 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 1); | 321 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 1); |
340 | 322 |
341 // The window should be crossing the screen edge but not docked. | 323 // The window should be crossing the screen edge but not docked. |
342 int expected_x = initial_bounds.x() - initial_location_in_parent().x() + 1; | 324 int expected_x = initial_bounds.x() - initial_location_in_parent().x() + 1; |
343 EXPECT_EQ(expected_x, window->GetBoundsInScreen().x()); | 325 EXPECT_EQ(expected_x, window->GetBoundsInScreen().x()); |
344 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 326 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
345 } | 327 } |
346 | 328 |
347 // Dock on the right side, change shelf alignment, check that windows move to | 329 // Dock on the right side, change shelf alignment, check that windows move to |
348 // the opposite side. | 330 // the opposite side. |
349 TEST_P(DockedWindowResizerTest, AttachRightChangeShelf) { | 331 TEST_P(DockedWindowResizerTest, AttachRightChangeShelf) { |
350 if (!SupportsHostWindowResize()) | |
351 return; | |
352 | |
353 std::unique_ptr<aura::Window> window( | 332 std::unique_ptr<aura::Window> window( |
354 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 333 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
355 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 334 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
356 | 335 |
357 // The window should be docked at the right edge. | 336 // The window should be docked at the right edge. |
358 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 337 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
359 window->GetBoundsInScreen().right()); | 338 window->GetBoundsInScreen().right()); |
360 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 339 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
361 | 340 |
362 // set launcher shelf to be aligned on the right | 341 // set launcher shelf to be aligned on the right |
(...skipping 13 matching lines...) Expand all Loading... |
376 // set launcher shelf to be aligned at the bottom | 355 // set launcher shelf to be aligned at the bottom |
377 GetPrimaryShelf()->SetAlignment(SHELF_ALIGNMENT_BOTTOM); | 356 GetPrimaryShelf()->SetAlignment(SHELF_ALIGNMENT_BOTTOM); |
378 // The window should stay in the right edge. | 357 // The window should stay in the right edge. |
379 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 358 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
380 window->GetBoundsInScreen().right()); | 359 window->GetBoundsInScreen().right()); |
381 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 360 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
382 } | 361 } |
383 | 362 |
384 // Dock on the right side, try to undock, then drag more to really undock | 363 // Dock on the right side, try to undock, then drag more to really undock |
385 TEST_P(DockedWindowResizerTest, AttachTryDetach) { | 364 TEST_P(DockedWindowResizerTest, AttachTryDetach) { |
386 if (!SupportsHostWindowResize()) | |
387 return; | |
388 | |
389 std::unique_ptr<aura::Window> window( | 365 std::unique_ptr<aura::Window> window( |
390 CreateTestWindow(gfx::Rect(0, 0, ideal_width() + 10, 201))); | 366 CreateTestWindow(gfx::Rect(0, 0, ideal_width() + 10, 201))); |
391 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 367 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
392 | 368 |
393 // The window should be docked at the right edge. | 369 // The window should be docked at the right edge. |
394 // Its width should shrink to ideal width. | 370 // Its width should shrink to ideal width. |
395 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 371 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
396 window->GetBoundsInScreen().right()); | 372 window->GetBoundsInScreen().right()); |
397 EXPECT_EQ(ideal_width(), window->GetBoundsInScreen().width()); | 373 EXPECT_EQ(ideal_width(), window->GetBoundsInScreen().width()); |
398 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 374 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
(...skipping 23 matching lines...) Expand all Loading... |
422 // The window should be floating on the desktop again and moved to the left. | 398 // The window should be floating on the desktop again and moved to the left. |
423 EXPECT_EQ(left_edge - 32, window->GetBoundsInScreen().x()); | 399 EXPECT_EQ(left_edge - 32, window->GetBoundsInScreen().x()); |
424 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 400 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
425 } | 401 } |
426 | 402 |
427 // Dock on the right side, and undock by dragging the right edge of the window | 403 // Dock on the right side, and undock by dragging the right edge of the window |
428 // header. This test is useful because both the position of the dragged window | 404 // header. This test is useful because both the position of the dragged window |
429 // and the position of the mouse are used in determining whether a window should | 405 // and the position of the mouse are used in determining whether a window should |
430 // be undocked. | 406 // be undocked. |
431 TEST_P(DockedWindowResizerTest, AttachTryDetachDragRightEdgeOfHeader) { | 407 TEST_P(DockedWindowResizerTest, AttachTryDetachDragRightEdgeOfHeader) { |
432 if (!SupportsHostWindowResize()) | |
433 return; | |
434 | |
435 std::unique_ptr<aura::Window> window( | 408 std::unique_ptr<aura::Window> window( |
436 CreateTestWindow(gfx::Rect(0, 0, ideal_width() + 10, 201))); | 409 CreateTestWindow(gfx::Rect(0, 0, ideal_width() + 10, 201))); |
437 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 410 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
438 | 411 |
439 // The window should be docked at the right edge. | 412 // The window should be docked at the right edge. |
440 // Its width should shrink to ideal width. | 413 // Its width should shrink to ideal width. |
441 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 414 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
442 window->GetBoundsInScreen().right()); | 415 window->GetBoundsInScreen().right()); |
443 EXPECT_EQ(ideal_width(), window->GetBoundsInScreen().width()); | 416 EXPECT_EQ(ideal_width(), window->GetBoundsInScreen().width()); |
444 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 417 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
(...skipping 20 matching lines...) Expand all Loading... |
465 // Release the mouse and the window should be no longer attached to the dock. | 438 // Release the mouse and the window should be no longer attached to the dock. |
466 DragEnd(); | 439 DragEnd(); |
467 | 440 |
468 // The window should be floating on the desktop again and moved to the left. | 441 // The window should be floating on the desktop again and moved to the left. |
469 EXPECT_EQ(left_edge - 32, window->GetBoundsInScreen().x()); | 442 EXPECT_EQ(left_edge - 32, window->GetBoundsInScreen().x()); |
470 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 443 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
471 } | 444 } |
472 | 445 |
473 // Minimize a docked window, then restore it and check that it is still docked. | 446 // Minimize a docked window, then restore it and check that it is still docked. |
474 TEST_P(DockedWindowResizerTest, AttachMinimizeRestore) { | 447 TEST_P(DockedWindowResizerTest, AttachMinimizeRestore) { |
475 if (!SupportsHostWindowResize()) | |
476 return; | |
477 | |
478 std::unique_ptr<aura::Window> window( | 448 std::unique_ptr<aura::Window> window( |
479 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 449 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
480 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 450 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
481 | 451 |
482 // The window should be docked at the right edge. | 452 // The window should be docked at the right edge. |
483 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 453 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
484 window->GetBoundsInScreen().right()); | 454 window->GetBoundsInScreen().right()); |
485 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 455 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
486 | 456 |
487 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 457 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
488 // Minimize the window, it should be hidden. | 458 // Minimize the window, it should be hidden. |
489 window_state->Minimize(); | 459 window_state->Minimize(); |
490 RunAllPendingInMessageLoop(); | 460 RunAllPendingInMessageLoop(); |
491 EXPECT_FALSE(window->IsVisible()); | 461 EXPECT_FALSE(window->IsVisible()); |
492 EXPECT_TRUE(window_state->IsMinimized()); | 462 EXPECT_TRUE(window_state->IsMinimized()); |
493 // Restore the window; window should be visible. | 463 // Restore the window; window should be visible. |
494 window_state->Restore(); | 464 window_state->Restore(); |
495 RunAllPendingInMessageLoop(); | 465 RunAllPendingInMessageLoop(); |
496 EXPECT_TRUE(window->IsVisible()); | 466 EXPECT_TRUE(window->IsVisible()); |
497 EXPECT_TRUE(window_state->IsDocked()); | 467 EXPECT_TRUE(window_state->IsDocked()); |
498 } | 468 } |
499 | 469 |
500 // Maximize a docked window and check that it is maximized and no longer docked. | 470 // Maximize a docked window and check that it is maximized and no longer docked. |
501 TEST_P(DockedWindowResizerTest, AttachMaximize) { | 471 TEST_P(DockedWindowResizerTest, AttachMaximize) { |
502 if (!SupportsHostWindowResize()) | |
503 return; | |
504 | |
505 std::unique_ptr<aura::Window> window( | 472 std::unique_ptr<aura::Window> window( |
506 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 473 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
507 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 474 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
508 | 475 |
509 // The window should be docked at the right edge. | 476 // The window should be docked at the right edge. |
510 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 477 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
511 window->GetBoundsInScreen().right()); | 478 window->GetBoundsInScreen().right()); |
512 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 479 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
513 | 480 |
514 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 481 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
515 // Maximize the window, it should get undocked and maximized in a desktop. | 482 // Maximize the window, it should get undocked and maximized in a desktop. |
516 window_state->Maximize(); | 483 window_state->Maximize(); |
517 RunAllPendingInMessageLoop(); | 484 RunAllPendingInMessageLoop(); |
518 EXPECT_TRUE(window->IsVisible()); | 485 EXPECT_TRUE(window->IsVisible()); |
519 EXPECT_TRUE(window_state->IsMaximized()); | 486 EXPECT_TRUE(window_state->IsMaximized()); |
520 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 487 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
521 } | 488 } |
522 | 489 |
523 // Dock two windows, undock one, check that the other one is still docked. | 490 // Dock two windows, undock one, check that the other one is still docked. |
524 TEST_P(DockedWindowResizerTest, AttachTwoWindows) { | 491 TEST_P(DockedWindowResizerTest, AttachTwoWindows) { |
525 if (!SupportsHostWindowResize()) | |
526 return; | |
527 UpdateDisplay("600x600"); | 492 UpdateDisplay("600x600"); |
528 | 493 |
529 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 494 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
530 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 495 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
531 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 496 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
532 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 50); | 497 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 50); |
533 | 498 |
534 // Docking second window should not minimize the first. | 499 // Docking second window should not minimize the first. |
535 wm::WindowState* window_state1 = wm::GetWindowState(w1.get()); | 500 wm::WindowState* window_state1 = wm::GetWindowState(w1.get()); |
536 EXPECT_FALSE(window_state1->IsMinimized()); | 501 EXPECT_FALSE(window_state1->IsMinimized()); |
(...skipping 21 matching lines...) Expand all Loading... |
558 w1->GetBoundsInScreen().right()); | 523 w1->GetBoundsInScreen().right()); |
559 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 524 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
560 | 525 |
561 // The window should be floating on the desktop again and moved to the left. | 526 // The window should be floating on the desktop again and moved to the left. |
562 EXPECT_EQ(left_edge - 32, w2->GetBoundsInScreen().x()); | 527 EXPECT_EQ(left_edge - 32, w2->GetBoundsInScreen().x()); |
563 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); | 528 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); |
564 } | 529 } |
565 | 530 |
566 // Create two windows, dock one and change shelf to auto-hide. | 531 // Create two windows, dock one and change shelf to auto-hide. |
567 TEST_P(DockedWindowResizerTest, AttachOneAutoHideShelf) { | 532 TEST_P(DockedWindowResizerTest, AttachOneAutoHideShelf) { |
568 if (!SupportsHostWindowResize()) | |
569 return; | |
570 | |
571 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 533 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
572 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 534 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
573 | 535 |
574 // w1 should be docked at the right edge. | 536 // w1 should be docked at the right edge. |
575 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 537 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
576 w1->GetBoundsInScreen().right()); | 538 w1->GetBoundsInScreen().right()); |
577 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 539 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
578 | 540 |
579 std::unique_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegateAndType( | 541 std::unique_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegateAndType( |
580 NULL, ui::wm::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20))); | 542 NULL, ui::wm::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20))); |
(...skipping 19 matching lines...) Expand all Loading... |
600 .work_area(); | 562 .work_area(); |
601 // Docked window should be centered vertically in the work area. | 563 // Docked window should be centered vertically in the work area. |
602 EXPECT_EQ(work_area.CenterPoint().y(), w1->bounds().CenterPoint().y()); | 564 EXPECT_EQ(work_area.CenterPoint().y(), w1->bounds().CenterPoint().y()); |
603 // Docked background should extend to the bottom of work area. | 565 // Docked background should extend to the bottom of work area. |
604 EXPECT_EQ(work_area.bottom(), manager->docked_bounds().bottom()); | 566 EXPECT_EQ(work_area.bottom(), manager->docked_bounds().bottom()); |
605 } | 567 } |
606 | 568 |
607 // Dock one window, try to dock another window on the opposite side (should not | 569 // Dock one window, try to dock another window on the opposite side (should not |
608 // dock). | 570 // dock). |
609 TEST_P(DockedWindowResizerTest, AttachOnTwoSides) { | 571 TEST_P(DockedWindowResizerTest, AttachOnTwoSides) { |
610 if (!SupportsHostWindowResize()) | |
611 return; | |
612 | |
613 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 572 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
614 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 573 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
615 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 574 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
616 gfx::Rect initial_bounds(w2->bounds()); | 575 gfx::Rect initial_bounds(w2->bounds()); |
617 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w2.get(), 50); | 576 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w2.get(), 50); |
618 | 577 |
619 // The first window should be docked at the right edge. | 578 // The first window should be docked at the right edge. |
620 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 579 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
621 w1->GetBoundsInScreen().right()); | 580 w1->GetBoundsInScreen().right()); |
622 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 581 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
623 | 582 |
624 // The second window should be near the left edge but not snapped. | 583 // The second window should be near the left edge but not snapped. |
625 // Normal window will get side-maximized while panels will not. | 584 // Normal window will get side-maximized while panels will not. |
626 int expected_x = test_panels() | 585 int expected_x = test_panels() |
627 ? (initial_bounds.x() - initial_location_in_parent().x()) | 586 ? (initial_bounds.x() - initial_location_in_parent().x()) |
628 : 0; | 587 : 0; |
629 EXPECT_EQ(expected_x, w2->GetBoundsInScreen().x()); | 588 EXPECT_EQ(expected_x, w2->GetBoundsInScreen().x()); |
630 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); | 589 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); |
631 } | 590 } |
632 | 591 |
633 // Tests that reverting a drag restores docked state if a window was docked. | 592 // Tests that reverting a drag restores docked state if a window was docked. |
634 TEST_P(DockedWindowResizerTest, RevertDragRestoresAttachment) { | 593 TEST_P(DockedWindowResizerTest, RevertDragRestoresAttachment) { |
635 if (!SupportsHostWindowResize()) | |
636 return; | |
637 | |
638 std::unique_ptr<aura::Window> window( | 594 std::unique_ptr<aura::Window> window( |
639 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 595 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
640 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 596 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
641 | 597 |
642 // The window should be docked at the right edge. | 598 // The window should be docked at the right edge. |
643 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 599 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
644 window->GetBoundsInScreen().right()); | 600 window->GetBoundsInScreen().right()); |
645 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 601 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
646 | 602 |
647 // Drag the window out but revert the drag | 603 // Drag the window out but revert the drag |
648 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); | 604 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); |
649 DragMove(-50, 0); | 605 DragMove(-50, 0); |
650 DragRevert(); | 606 DragRevert(); |
651 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 607 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
652 | 608 |
653 // Detach window. | 609 // Detach window. |
654 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); | 610 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); |
655 DragMove(-50, 0); | 611 DragMove(-50, 0); |
656 DragEnd(); | 612 DragEnd(); |
657 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 613 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
658 } | 614 } |
659 | 615 |
660 // Tests that reverting drag restores undocked state if a window was not docked. | 616 // Tests that reverting drag restores undocked state if a window was not docked. |
661 TEST_P(DockedWindowResizerTest, RevertDockedDragRevertsAttachment) { | 617 TEST_P(DockedWindowResizerTest, RevertDockedDragRevertsAttachment) { |
662 if (!SupportsHostWindowResize()) | |
663 return; | |
664 std::unique_ptr<aura::Window> window( | 618 std::unique_ptr<aura::Window> window( |
665 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 619 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
666 DockedWindowLayoutManager* manager = | 620 DockedWindowLayoutManager* manager = |
667 DockedWindowLayoutManager::Get(WmWindowAura::Get(window.get())); | 621 DockedWindowLayoutManager::Get(WmWindowAura::Get(window.get())); |
668 int previous_container_id = window->parent()->id(); | 622 int previous_container_id = window->parent()->id(); |
669 // Drag the window out but revert the drag | 623 // Drag the window out but revert the drag |
670 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); | 624 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); |
671 DragMove(-50 - window->bounds().x(), 50 - window->bounds().y()); | 625 DragMove(-50 - window->bounds().x(), 50 - window->bounds().y()); |
672 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); | 626 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); |
673 DragRevert(); | 627 DragRevert(); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 DragEnd(); | 704 DragEnd(); |
751 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(), | 705 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(), |
752 window->GetBoundsInScreen().x()); | 706 window->GetBoundsInScreen().x()); |
753 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 707 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
754 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 708 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
755 } | 709 } |
756 | 710 |
757 // Dock two windows, undock one. | 711 // Dock two windows, undock one. |
758 // Test the docked windows area size and default container resizing. | 712 // Test the docked windows area size and default container resizing. |
759 TEST_P(DockedWindowResizerTest, AttachTwoWindowsDetachOne) { | 713 TEST_P(DockedWindowResizerTest, AttachTwoWindowsDetachOne) { |
760 if (!SupportsHostWindowResize()) | |
761 return; | |
762 UpdateDisplay("600x600"); | 714 UpdateDisplay("600x600"); |
763 | 715 |
764 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 716 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
765 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); | 717 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); |
766 // Work area should cover the whole screen. | 718 // Work area should cover the whole screen. |
767 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), | 719 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), |
768 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 720 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
769 | 721 |
770 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 722 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
771 // A window should be docked at the right edge. | 723 // A window should be docked at the right edge. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 EXPECT_EQ(left_edge + drag_x, w2->bounds().x()); | 773 EXPECT_EQ(left_edge + drag_x, w2->bounds().x()); |
822 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); | 774 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); |
823 // Dock width should be set to remaining single docked window. | 775 // Dock width should be set to remaining single docked window. |
824 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 776 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
825 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 777 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
826 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 778 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
827 } | 779 } |
828 | 780 |
829 // Dock one of the windows. Maximize other testing desktop resizing. | 781 // Dock one of the windows. Maximize other testing desktop resizing. |
830 TEST_P(DockedWindowResizerTest, AttachWindowMaximizeOther) { | 782 TEST_P(DockedWindowResizerTest, AttachWindowMaximizeOther) { |
831 if (!SupportsHostWindowResize()) | |
832 return; | |
833 | |
834 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 783 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
835 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); | 784 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); |
836 // Work area should cover the whole screen. | 785 // Work area should cover the whole screen. |
837 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), | 786 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), |
838 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 787 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
839 | 788 |
840 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 789 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
841 // A window should be docked at the right edge. | 790 // A window should be docked at the right edge. |
842 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 791 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
843 w1->GetBoundsInScreen().right()); | 792 w1->GetBoundsInScreen().right()); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 w2->bounds().width()); | 867 w2->bounds().width()); |
919 | 868 |
920 // Unmaximize the second window. | 869 // Unmaximize the second window. |
921 w2_state->Restore(); | 870 w2_state->Restore(); |
922 // Its bounds should get restored. | 871 // Its bounds should get restored. |
923 EXPECT_EQ(restored_bounds, w2->bounds()); | 872 EXPECT_EQ(restored_bounds, w2->bounds()); |
924 } | 873 } |
925 | 874 |
926 // Dock one window. Test the sticky behavior near screen or desktop edge. | 875 // Dock one window. Test the sticky behavior near screen or desktop edge. |
927 TEST_P(DockedWindowResizerTest, AttachOneTestSticky) { | 876 TEST_P(DockedWindowResizerTest, AttachOneTestSticky) { |
928 if (!SupportsHostWindowResize()) | |
929 return; | |
930 | |
931 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 877 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
932 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); | 878 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); |
933 // Work area should cover the whole screen. | 879 // Work area should cover the whole screen. |
934 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), | 880 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), |
935 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 881 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
936 | 882 |
937 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w1.get(), 20); | 883 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w1.get(), 20); |
938 // A window should be docked at the left edge. | 884 // A window should be docked at the left edge. |
939 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().x(), | 885 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().x(), |
940 w1->GetBoundsInScreen().x()); | 886 w1->GetBoundsInScreen().x()); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 docked_width(manager)); | 959 docked_width(manager)); |
1014 // Desktop work area should now shrink by dock width. | 960 // Desktop work area should now shrink by dock width. |
1015 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - | 961 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - |
1016 docked_width(manager) - min_dock_gap(), | 962 docked_width(manager) - min_dock_gap(), |
1017 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 963 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
1018 } | 964 } |
1019 | 965 |
1020 // Dock two windows, resize one. | 966 // Dock two windows, resize one. |
1021 // Test the docked windows area size and remaining desktop resizing. | 967 // Test the docked windows area size and remaining desktop resizing. |
1022 TEST_P(DockedWindowResizerTest, ResizeOneOfTwoWindows) { | 968 TEST_P(DockedWindowResizerTest, ResizeOneOfTwoWindows) { |
1023 if (!SupportsHostWindowResize()) | |
1024 return; | |
1025 | |
1026 // Wider display to start since panels are limited to half the display width. | 969 // Wider display to start since panels are limited to half the display width. |
1027 UpdateDisplay("1000x600"); | 970 UpdateDisplay("1000x600"); |
1028 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 971 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
1029 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); | 972 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); |
1030 // Work area should cover the whole screen. | 973 // Work area should cover the whole screen. |
1031 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), | 974 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), |
1032 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 975 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
1033 | 976 |
1034 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 977 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
1035 // A window should be docked at the right edge. | 978 // A window should be docked at the right edge. |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1155 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 1098 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
1156 // Desktop work area should be inset. | 1099 // Desktop work area should be inset. |
1157 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w1.get()).width() - | 1100 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w1.get()).width() - |
1158 docked_width(manager) - min_dock_gap(), | 1101 docked_width(manager) - min_dock_gap(), |
1159 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).width()); | 1102 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).width()); |
1160 } | 1103 } |
1161 | 1104 |
1162 // Dock a window, resize it and test that undocking it restores the pre-docked | 1105 // Dock a window, resize it and test that undocking it restores the pre-docked |
1163 // size. | 1106 // size. |
1164 TEST_P(DockedWindowResizerTest, ResizingKeepsSize) { | 1107 TEST_P(DockedWindowResizerTest, ResizingKeepsSize) { |
1165 if (!SupportsHostWindowResize()) | |
1166 return; | |
1167 | |
1168 // Wider display to start since panels are limited to half the display width. | 1108 // Wider display to start since panels are limited to half the display width. |
1169 UpdateDisplay("1000x600"); | 1109 UpdateDisplay("1000x600"); |
1170 const gfx::Size original_size(201, 201); | 1110 const gfx::Size original_size(201, 201); |
1171 std::unique_ptr<aura::Window> w1( | 1111 std::unique_ptr<aura::Window> w1( |
1172 CreateTestWindow(gfx::Rect(gfx::Point(), original_size))); | 1112 CreateTestWindow(gfx::Rect(gfx::Point(), original_size))); |
1173 | 1113 |
1174 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1114 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
1175 // Window should be docked at the right edge. | 1115 // Window should be docked at the right edge. |
1176 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 1116 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
1177 w1->GetBoundsInScreen().right()); | 1117 w1->GetBoundsInScreen().right()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 EXPECT_EQ(ideal_width(), w1->bounds().width()); | 1150 EXPECT_EQ(ideal_width(), w1->bounds().width()); |
1211 | 1151 |
1212 // Undock again by dragging left. | 1152 // Undock again by dragging left. |
1213 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_LEFT, w1.get(), 100, 20); | 1153 DragToVerticalPositionRelativeToEdge(DOCKED_EDGE_LEFT, w1.get(), 100, 20); |
1214 // Size should be restored to what it was originally. | 1154 // Size should be restored to what it was originally. |
1215 EXPECT_EQ(original_size.ToString(), w1->bounds().size().ToString()); | 1155 EXPECT_EQ(original_size.ToString(), w1->bounds().size().ToString()); |
1216 } | 1156 } |
1217 | 1157 |
1218 // Dock a window, resize it and test that it stays docked. | 1158 // Dock a window, resize it and test that it stays docked. |
1219 TEST_P(DockedWindowResizerTest, ResizingKeepsDockedState) { | 1159 TEST_P(DockedWindowResizerTest, ResizingKeepsDockedState) { |
1220 if (!SupportsHostWindowResize()) | |
1221 return; | |
1222 | |
1223 // Wider display to start since panels are limited to half the display width. | 1160 // Wider display to start since panels are limited to half the display width. |
1224 UpdateDisplay("1000x600"); | 1161 UpdateDisplay("1000x600"); |
1225 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 1162 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
1226 | 1163 |
1227 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1164 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
1228 // Window should be docked at the right edge. | 1165 // Window should be docked at the right edge. |
1229 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 1166 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
1230 w1->GetBoundsInScreen().right()); | 1167 w1->GetBoundsInScreen().right()); |
1231 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1168 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1232 DockedWindowLayoutManager* manager = | 1169 DockedWindowLayoutManager* manager = |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 // The window should stay docked. | 1205 // The window should stay docked. |
1269 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1206 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1270 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1207 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1271 // The dock should stay as wide as w1 is now (a bit less than before). | 1208 // The dock should stay as wide as w1 is now (a bit less than before). |
1272 EXPECT_EQ(previous_width - kResizeSpan2, w1->bounds().width()); | 1209 EXPECT_EQ(previous_width - kResizeSpan2, w1->bounds().width()); |
1273 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1210 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
1274 } | 1211 } |
1275 | 1212 |
1276 // Dock two windows, resize one. Test the docked windows area size. | 1213 // Dock two windows, resize one. Test the docked windows area size. |
1277 TEST_P(DockedWindowResizerTest, ResizeTwoWindows) { | 1214 TEST_P(DockedWindowResizerTest, ResizeTwoWindows) { |
1278 if (!SupportsHostWindowResize()) | |
1279 return; | |
1280 | |
1281 // Wider display to start since panels are limited to half the display width. | 1215 // Wider display to start since panels are limited to half the display width. |
1282 UpdateDisplay("1000x600"); | 1216 UpdateDisplay("1000x600"); |
1283 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 1217 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
1284 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); | 1218 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); |
1285 | 1219 |
1286 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1220 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
1287 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); | 1221 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); |
1288 // Both windows should now be docked at the right edge. | 1222 // Both windows should now be docked at the right edge. |
1289 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1223 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1290 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 1224 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 DragEnd(); | 1269 DragEnd(); |
1336 // Making w1 wider should make both windows wider since w2 no longer remembers | 1270 // Making w1 wider should make both windows wider since w2 no longer remembers |
1337 // user width. | 1271 // user width. |
1338 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); | 1272 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); |
1339 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1273 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
1340 } | 1274 } |
1341 | 1275 |
1342 // Tests that dragging a window down to shelf attaches a panel but does not | 1276 // Tests that dragging a window down to shelf attaches a panel but does not |
1343 // attach a regular window. | 1277 // attach a regular window. |
1344 TEST_P(DockedWindowResizerTest, DragToShelf) { | 1278 TEST_P(DockedWindowResizerTest, DragToShelf) { |
1345 if (!SupportsHostWindowResize()) | |
1346 return; | |
1347 | |
1348 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 1279 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
1349 // Work area should cover the whole screen. | 1280 // Work area should cover the whole screen. |
1350 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w1.get()).width(), | 1281 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w1.get()).width(), |
1351 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).width()); | 1282 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).width()); |
1352 | 1283 |
1353 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1284 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
1354 // A window should be docked at the right edge. | 1285 // A window should be docked at the right edge. |
1355 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 1286 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
1356 w1->GetBoundsInScreen().right()); | 1287 w1->GetBoundsInScreen().right()); |
1357 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1288 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
(...skipping 24 matching lines...) Expand all Loading... |
1382 EXPECT_TRUE(wm::GetWindowState(w1.get())->panel_attached()); | 1313 EXPECT_TRUE(wm::GetWindowState(w1.get())->panel_attached()); |
1383 } else { | 1314 } else { |
1384 // The window should not be touching the shelf. | 1315 // The window should not be touching the shelf. |
1385 EXPECT_EQ(shelf_y - kDistanceFromShelf, w1->bounds().bottom()); | 1316 EXPECT_EQ(shelf_y - kDistanceFromShelf, w1->bounds().bottom()); |
1386 } | 1317 } |
1387 } | 1318 } |
1388 | 1319 |
1389 // Tests that docking and undocking a |window| with a transient child properly | 1320 // Tests that docking and undocking a |window| with a transient child properly |
1390 // maintains the parent of that transient child to be the same as the |window|. | 1321 // maintains the parent of that transient child to be the same as the |window|. |
1391 TEST_P(DockedWindowResizerTest, DragWindowWithTransientChild) { | 1322 TEST_P(DockedWindowResizerTest, DragWindowWithTransientChild) { |
1392 if (!SupportsHostWindowResize()) | |
1393 return; | |
1394 | |
1395 // Create a window with a transient child. | 1323 // Create a window with a transient child. |
1396 std::unique_ptr<aura::Window> window( | 1324 std::unique_ptr<aura::Window> window( |
1397 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 1325 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
1398 std::unique_ptr<aura::Window> child( | 1326 std::unique_ptr<aura::Window> child( |
1399 CreateTestWindowInShellWithDelegateAndType( | 1327 CreateTestWindowInShellWithDelegateAndType( |
1400 NULL, ui::wm::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20))); | 1328 NULL, ui::wm::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20))); |
1401 ::wm::AddTransientChild(window.get(), child.get()); | 1329 ::wm::AddTransientChild(window.get(), child.get()); |
1402 if (window->parent() != child->parent()) | 1330 if (window->parent() != child->parent()) |
1403 window->parent()->AddChild(child.get()); | 1331 window->parent()->AddChild(child.get()); |
1404 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get())); | 1332 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get())); |
(...skipping 20 matching lines...) Expand all Loading... |
1425 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 1353 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
1426 EXPECT_EQ(kShellWindowId_DefaultContainer, child->parent()->id()); | 1354 EXPECT_EQ(kShellWindowId_DefaultContainer, child->parent()->id()); |
1427 // The child should not have moved. | 1355 // The child should not have moved. |
1428 EXPECT_EQ(gfx::Point(20 + 500, 20 + 20).ToString(), | 1356 EXPECT_EQ(gfx::Point(20 + 500, 20 + 20).ToString(), |
1429 child->GetBoundsInScreen().origin().ToString()); | 1357 child->GetBoundsInScreen().origin().ToString()); |
1430 } | 1358 } |
1431 | 1359 |
1432 // Tests that reparenting windows during the drag does not affect system modal | 1360 // Tests that reparenting windows during the drag does not affect system modal |
1433 // windows that are transient children of the dragged windows. | 1361 // windows that are transient children of the dragged windows. |
1434 TEST_P(DockedWindowResizerTest, DragWindowWithModalTransientChild) { | 1362 TEST_P(DockedWindowResizerTest, DragWindowWithModalTransientChild) { |
1435 if (!SupportsHostWindowResize()) | |
1436 return; | |
1437 | |
1438 // Create a window. | 1363 // Create a window. |
1439 std::unique_ptr<aura::Window> window( | 1364 std::unique_ptr<aura::Window> window( |
1440 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 1365 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
1441 gfx::Rect bounds(window->bounds()); | 1366 gfx::Rect bounds(window->bounds()); |
1442 | 1367 |
1443 // Start dragging the window. | 1368 // Start dragging the window. |
1444 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); | 1369 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); |
1445 gfx::Vector2d move_vector(40, test_panels() ? -60 : 60); | 1370 gfx::Vector2d move_vector(40, test_panels() ? -60 : 60); |
1446 DragMove(move_vector.x(), move_vector.y()); | 1371 DragMove(move_vector.x(), move_vector.y()); |
1447 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); | 1372 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); |
(...skipping 19 matching lines...) Expand all Loading... |
1467 EXPECT_EQ(kShellWindowId_SystemModalContainer, child->parent()->id()); | 1392 EXPECT_EQ(kShellWindowId_SystemModalContainer, child->parent()->id()); |
1468 // The |child| should not have moved. | 1393 // The |child| should not have moved. |
1469 EXPECT_EQ(gfx::Point(20, 20).ToString(), | 1394 EXPECT_EQ(gfx::Point(20, 20).ToString(), |
1470 child->GetBoundsInScreen().origin().ToString()); | 1395 child->GetBoundsInScreen().origin().ToString()); |
1471 // The |child| should still be a transient child of |window|. | 1396 // The |child| should still be a transient child of |window|. |
1472 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get())); | 1397 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get())); |
1473 } | 1398 } |
1474 | 1399 |
1475 // Tests that side snapping a window undocks it, closes the dock and then snaps. | 1400 // Tests that side snapping a window undocks it, closes the dock and then snaps. |
1476 TEST_P(DockedWindowResizerTest, SideSnapDocked) { | 1401 TEST_P(DockedWindowResizerTest, SideSnapDocked) { |
1477 if (!SupportsHostWindowResize() || test_panels()) | 1402 if (test_panels()) |
1478 return; | 1403 return; |
1479 | 1404 |
1480 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 1405 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
1481 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | 1406 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
1482 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1407 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
1483 // A window should be docked at the right edge. | 1408 // A window should be docked at the right edge. |
1484 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 1409 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
1485 w1->GetBoundsInScreen().right()); | 1410 w1->GetBoundsInScreen().right()); |
1486 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1411 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1487 DockedWindowLayoutManager* manager = | 1412 DockedWindowLayoutManager* manager = |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1524 EXPECT_EQ(work_area.height(), w1->bounds().height()); | 1449 EXPECT_EQ(work_area.height(), w1->bounds().height()); |
1525 EXPECT_EQ(work_area.x(), w1->bounds().x()); | 1450 EXPECT_EQ(work_area.x(), w1->bounds().x()); |
1526 EXPECT_EQ(kShellWindowId_DefaultContainer, w1->parent()->id()); | 1451 EXPECT_EQ(kShellWindowId_DefaultContainer, w1->parent()->id()); |
1527 EXPECT_FALSE(window_state->IsDocked()); | 1452 EXPECT_FALSE(window_state->IsDocked()); |
1528 EXPECT_TRUE(window_state->IsSnapped()); | 1453 EXPECT_TRUE(window_state->IsSnapped()); |
1529 } | 1454 } |
1530 | 1455 |
1531 // Tests that a window is undocked if the window is maximized via a keyboard | 1456 // Tests that a window is undocked if the window is maximized via a keyboard |
1532 // accelerator during a drag. | 1457 // accelerator during a drag. |
1533 TEST_P(DockedWindowResizerTest, MaximizedDuringDrag) { | 1458 TEST_P(DockedWindowResizerTest, MaximizedDuringDrag) { |
1534 if (!SupportsHostWindowResize() || test_panels()) | 1459 if (test_panels()) |
1535 return; | 1460 return; |
1536 | 1461 |
1537 std::unique_ptr<aura::Window> window( | 1462 std::unique_ptr<aura::Window> window( |
1538 CreateTestWindow(gfx::Rect(0, 0, ideal_width(), 201))); | 1463 CreateTestWindow(gfx::Rect(0, 0, ideal_width(), 201))); |
1539 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 1464 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
1540 | 1465 |
1541 // Dock the window to the right edge. | 1466 // Dock the window to the right edge. |
1542 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20); | 1467 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20); |
1543 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 1468 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
1544 window->GetBoundsInScreen().right()); | 1469 window->GetBoundsInScreen().right()); |
(...skipping 24 matching lines...) Expand all Loading... |
1569 EXPECT_TRUE(window_state->IsMaximized()); | 1494 EXPECT_TRUE(window_state->IsMaximized()); |
1570 } | 1495 } |
1571 | 1496 |
1572 // Tests run twice - on both panels and normal windows | 1497 // Tests run twice - on both panels and normal windows |
1573 INSTANTIATE_TEST_CASE_P(NormalOrPanel, | 1498 INSTANTIATE_TEST_CASE_P(NormalOrPanel, |
1574 DockedWindowResizerTest, | 1499 DockedWindowResizerTest, |
1575 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, | 1500 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, |
1576 ui::wm::WINDOW_TYPE_PANEL)); | 1501 ui::wm::WINDOW_TYPE_PANEL)); |
1577 | 1502 |
1578 } // namespace ash | 1503 } // namespace ash |
OLD | NEW |