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/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/display/window_tree_host_manager.h" | 8 #include "ash/display/window_tree_host_manager.h" |
9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 239 |
240 aura::test::TestWindowDelegate* delegate() { | 240 aura::test::TestWindowDelegate* delegate() { |
241 return &delegate_; | 241 return &delegate_; |
242 } | 242 } |
243 | 243 |
244 const gfx::Point& initial_location_in_parent() const { | 244 const gfx::Point& initial_location_in_parent() const { |
245 return initial_location_in_parent_; | 245 return initial_location_in_parent_; |
246 } | 246 } |
247 | 247 |
248 private: | 248 private: |
249 scoped_ptr<WindowResizer> resizer_; | 249 std::unique_ptr<WindowResizer> resizer_; |
250 ShelfModel* model_; | 250 ShelfModel* model_; |
251 ui::wm::WindowType window_type_; | 251 ui::wm::WindowType window_type_; |
252 aura::test::TestWindowDelegate delegate_; | 252 aura::test::TestWindowDelegate delegate_; |
253 | 253 |
254 // Location at start of the drag in |window->parent()|'s coordinates. | 254 // Location at start of the drag in |window->parent()|'s coordinates. |
255 gfx::Point initial_location_in_parent_; | 255 gfx::Point initial_location_in_parent_; |
256 | 256 |
257 DISALLOW_COPY_AND_ASSIGN(DockedWindowResizerTest); | 257 DISALLOW_COPY_AND_ASSIGN(DockedWindowResizerTest); |
258 }; | 258 }; |
259 | 259 |
260 // Verifies a window can be dragged and attached to the dock. | 260 // Verifies a window can be dragged and attached to the dock. |
261 TEST_P(DockedWindowResizerTest, AttachRightPrecise) { | 261 TEST_P(DockedWindowResizerTest, AttachRightPrecise) { |
262 if (!SupportsHostWindowResize()) | 262 if (!SupportsHostWindowResize()) |
263 return; | 263 return; |
264 | 264 |
265 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 265 std::unique_ptr<aura::Window> window( |
| 266 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
266 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 267 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
267 | 268 |
268 // The window should be docked at the right edge. | 269 // The window should be docked at the right edge. |
269 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 270 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
270 window->GetBoundsInScreen().right()); | 271 window->GetBoundsInScreen().right()); |
271 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 272 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
272 } | 273 } |
273 | 274 |
274 // Verifies a window can be dragged and attached to the dock | 275 // Verifies a window can be dragged and attached to the dock |
275 // even if pointer overshoots the screen edge by a few pixels (sticky edge) | 276 // even if pointer overshoots the screen edge by a few pixels (sticky edge) |
276 TEST_P(DockedWindowResizerTest, AttachRightOvershoot) { | 277 TEST_P(DockedWindowResizerTest, AttachRightOvershoot) { |
277 if (!SupportsHostWindowResize()) | 278 if (!SupportsHostWindowResize()) |
278 return; | 279 return; |
279 | 280 |
280 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 281 std::unique_ptr<aura::Window> window( |
| 282 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
281 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), +4); | 283 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), +4); |
282 | 284 |
283 // The window should be docked at the right edge. | 285 // The window should be docked at the right edge. |
284 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 286 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
285 window->GetBoundsInScreen().right()); | 287 window->GetBoundsInScreen().right()); |
286 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 288 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
287 } | 289 } |
288 | 290 |
289 // Verifies a window can be dragged and then if a pointer is not quite reaching | 291 // Verifies a window can be dragged and then if a pointer is not quite reaching |
290 // the screen edge the window does not get docked and stays in the desktop. | 292 // the screen edge the window does not get docked and stays in the desktop. |
291 TEST_P(DockedWindowResizerTest, AttachRightUndershoot) { | 293 TEST_P(DockedWindowResizerTest, AttachRightUndershoot) { |
292 if (!SupportsHostWindowResize()) | 294 if (!SupportsHostWindowResize()) |
293 return; | 295 return; |
294 | 296 |
295 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 297 std::unique_ptr<aura::Window> window( |
| 298 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
296 // Grabbing at 70px ensures that at least 30% of the window is in screen, | 299 // Grabbing at 70px ensures that at least 30% of the window is in screen, |
297 // otherwise the window would be adjusted in | 300 // otherwise the window would be adjusted in |
298 // WorkspaceLayoutManager::AdjustWindowBoundsWhenAdded. | 301 // WorkspaceLayoutManager::AdjustWindowBoundsWhenAdded. |
299 const int kGrabOffsetX = 70; | 302 const int kGrabOffsetX = 70; |
300 const int kUndershootBy = 1; | 303 const int kUndershootBy = 1; |
301 DragVerticallyAndRelativeToEdge(DOCKED_EDGE_RIGHT, | 304 DragVerticallyAndRelativeToEdge(DOCKED_EDGE_RIGHT, |
302 window.get(), | 305 window.get(), |
303 -kUndershootBy, test_panels() ? -100 : 20, | 306 -kUndershootBy, test_panels() ? -100 : 20, |
304 kGrabOffsetX, 5); | 307 kGrabOffsetX, 5); |
305 | 308 |
306 // The window right should be past the screen edge but not docked. | 309 // The window right should be past the screen edge but not docked. |
307 // Initial touch point is 70px to the right which helps to find where the edge | 310 // Initial touch point is 70px to the right which helps to find where the edge |
308 // should be. | 311 // should be. |
309 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right() + | 312 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right() + |
310 window->bounds().width() - kGrabOffsetX - kUndershootBy - 1, | 313 window->bounds().width() - kGrabOffsetX - kUndershootBy - 1, |
311 window->GetBoundsInScreen().right()); | 314 window->GetBoundsInScreen().right()); |
312 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 315 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
313 } | 316 } |
314 | 317 |
315 // Verifies a window can be dragged and attached to the dock. | 318 // Verifies a window can be dragged and attached to the dock. |
316 TEST_P(DockedWindowResizerTest, AttachLeftPrecise) { | 319 TEST_P(DockedWindowResizerTest, AttachLeftPrecise) { |
317 if (!SupportsHostWindowResize()) | 320 if (!SupportsHostWindowResize()) |
318 return; | 321 return; |
319 | 322 |
320 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 323 std::unique_ptr<aura::Window> window( |
| 324 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
321 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 0); | 325 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 0); |
322 | 326 |
323 // The window should be docked at the left edge. | 327 // The window should be docked at the left edge. |
324 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(), | 328 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(), |
325 window->GetBoundsInScreen().x()); | 329 window->GetBoundsInScreen().x()); |
326 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 330 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
327 } | 331 } |
328 | 332 |
329 // Verifies a window can be dragged and attached to the dock | 333 // Verifies a window can be dragged and attached to the dock |
330 // even if pointer overshoots the screen edge by a few pixels (sticky edge) | 334 // even if pointer overshoots the screen edge by a few pixels (sticky edge) |
331 TEST_P(DockedWindowResizerTest, AttachLeftOvershoot) { | 335 TEST_P(DockedWindowResizerTest, AttachLeftOvershoot) { |
332 if (!SupportsHostWindowResize()) | 336 if (!SupportsHostWindowResize()) |
333 return; | 337 return; |
334 | 338 |
335 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 339 std::unique_ptr<aura::Window> window( |
| 340 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
336 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), -4); | 341 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), -4); |
337 | 342 |
338 // The window should be docked at the left edge. | 343 // The window should be docked at the left edge. |
339 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(), | 344 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(), |
340 window->GetBoundsInScreen().x()); | 345 window->GetBoundsInScreen().x()); |
341 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 346 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
342 } | 347 } |
343 | 348 |
344 // Verifies a window can be dragged and then if a pointer is not quite reaching | 349 // Verifies a window can be dragged and then if a pointer is not quite reaching |
345 // the screen edge the window does not get docked and stays in the desktop. | 350 // the screen edge the window does not get docked and stays in the desktop. |
346 TEST_P(DockedWindowResizerTest, AttachLeftUndershoot) { | 351 TEST_P(DockedWindowResizerTest, AttachLeftUndershoot) { |
347 if (!SupportsHostWindowResize()) | 352 if (!SupportsHostWindowResize()) |
348 return; | 353 return; |
349 | 354 |
350 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 355 std::unique_ptr<aura::Window> window( |
| 356 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
351 gfx::Rect initial_bounds(window->bounds()); | 357 gfx::Rect initial_bounds(window->bounds()); |
352 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 1); | 358 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 1); |
353 | 359 |
354 // The window should be crossing the screen edge but not docked. | 360 // The window should be crossing the screen edge but not docked. |
355 int expected_x = initial_bounds.x() - initial_location_in_parent().x() + 1; | 361 int expected_x = initial_bounds.x() - initial_location_in_parent().x() + 1; |
356 EXPECT_EQ(expected_x, window->GetBoundsInScreen().x()); | 362 EXPECT_EQ(expected_x, window->GetBoundsInScreen().x()); |
357 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 363 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
358 } | 364 } |
359 | 365 |
360 // Dock on the right side, change shelf alignment, check that windows move to | 366 // Dock on the right side, change shelf alignment, check that windows move to |
361 // the opposite side. | 367 // the opposite side. |
362 TEST_P(DockedWindowResizerTest, AttachRightChangeShelf) { | 368 TEST_P(DockedWindowResizerTest, AttachRightChangeShelf) { |
363 if (!SupportsHostWindowResize()) | 369 if (!SupportsHostWindowResize()) |
364 return; | 370 return; |
365 | 371 |
366 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 372 std::unique_ptr<aura::Window> window( |
| 373 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
367 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 374 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
368 | 375 |
369 // The window should be docked at the right edge. | 376 // The window should be docked at the right edge. |
370 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 377 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
371 window->GetBoundsInScreen().right()); | 378 window->GetBoundsInScreen().right()); |
372 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 379 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
373 | 380 |
374 // set launcher shelf to be aligned on the right | 381 // set launcher shelf to be aligned on the right |
375 ash::Shell* shell = ash::Shell::GetInstance(); | 382 ash::Shell* shell = ash::Shell::GetInstance(); |
376 shell->SetShelfAlignment(SHELF_ALIGNMENT_RIGHT, | 383 shell->SetShelfAlignment(SHELF_ALIGNMENT_RIGHT, |
(...skipping 18 matching lines...) Expand all Loading... |
395 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 402 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
396 window->GetBoundsInScreen().right()); | 403 window->GetBoundsInScreen().right()); |
397 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 404 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
398 } | 405 } |
399 | 406 |
400 // Dock on the right side, try to undock, then drag more to really undock | 407 // Dock on the right side, try to undock, then drag more to really undock |
401 TEST_P(DockedWindowResizerTest, AttachTryDetach) { | 408 TEST_P(DockedWindowResizerTest, AttachTryDetach) { |
402 if (!SupportsHostWindowResize()) | 409 if (!SupportsHostWindowResize()) |
403 return; | 410 return; |
404 | 411 |
405 scoped_ptr<aura::Window> window(CreateTestWindow( | 412 std::unique_ptr<aura::Window> window( |
406 gfx::Rect(0, 0, ideal_width() + 10, 201))); | 413 CreateTestWindow(gfx::Rect(0, 0, ideal_width() + 10, 201))); |
407 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 414 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
408 | 415 |
409 // The window should be docked at the right edge. | 416 // The window should be docked at the right edge. |
410 // Its width should shrink to ideal width. | 417 // Its width should shrink to ideal width. |
411 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 418 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
412 window->GetBoundsInScreen().right()); | 419 window->GetBoundsInScreen().right()); |
413 EXPECT_EQ(ideal_width(), window->GetBoundsInScreen().width()); | 420 EXPECT_EQ(ideal_width(), window->GetBoundsInScreen().width()); |
414 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 421 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
415 | 422 |
416 // Try to detach by dragging left less than kSnapToDockDistance. | 423 // Try to detach by dragging left less than kSnapToDockDistance. |
(...skipping 24 matching lines...) Expand all Loading... |
441 } | 448 } |
442 | 449 |
443 // Dock on the right side, and undock by dragging the right edge of the window | 450 // Dock on the right side, and undock by dragging the right edge of the window |
444 // header. This test is useful because both the position of the dragged window | 451 // header. This test is useful because both the position of the dragged window |
445 // and the position of the mouse are used in determining whether a window should | 452 // and the position of the mouse are used in determining whether a window should |
446 // be undocked. | 453 // be undocked. |
447 TEST_P(DockedWindowResizerTest, AttachTryDetachDragRightEdgeOfHeader) { | 454 TEST_P(DockedWindowResizerTest, AttachTryDetachDragRightEdgeOfHeader) { |
448 if (!SupportsHostWindowResize()) | 455 if (!SupportsHostWindowResize()) |
449 return; | 456 return; |
450 | 457 |
451 scoped_ptr<aura::Window> window(CreateTestWindow( | 458 std::unique_ptr<aura::Window> window( |
452 gfx::Rect(0, 0, ideal_width() + 10, 201))); | 459 CreateTestWindow(gfx::Rect(0, 0, ideal_width() + 10, 201))); |
453 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 460 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
454 | 461 |
455 // The window should be docked at the right edge. | 462 // The window should be docked at the right edge. |
456 // Its width should shrink to ideal width. | 463 // Its width should shrink to ideal width. |
457 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 464 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
458 window->GetBoundsInScreen().right()); | 465 window->GetBoundsInScreen().right()); |
459 EXPECT_EQ(ideal_width(), window->GetBoundsInScreen().width()); | 466 EXPECT_EQ(ideal_width(), window->GetBoundsInScreen().width()); |
460 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 467 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
461 | 468 |
462 // Try to detach by dragging left less than kSnapToDockDistance. | 469 // Try to detach by dragging left less than kSnapToDockDistance. |
(...skipping 21 matching lines...) Expand all Loading... |
484 // The window should be floating on the desktop again and moved to the left. | 491 // The window should be floating on the desktop again and moved to the left. |
485 EXPECT_EQ(left_edge - 32, window->GetBoundsInScreen().x()); | 492 EXPECT_EQ(left_edge - 32, window->GetBoundsInScreen().x()); |
486 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 493 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
487 } | 494 } |
488 | 495 |
489 // Minimize a docked window, then restore it and check that it is still docked. | 496 // Minimize a docked window, then restore it and check that it is still docked. |
490 TEST_P(DockedWindowResizerTest, AttachMinimizeRestore) { | 497 TEST_P(DockedWindowResizerTest, AttachMinimizeRestore) { |
491 if (!SupportsHostWindowResize()) | 498 if (!SupportsHostWindowResize()) |
492 return; | 499 return; |
493 | 500 |
494 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 501 std::unique_ptr<aura::Window> window( |
| 502 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
495 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 503 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
496 | 504 |
497 // The window should be docked at the right edge. | 505 // The window should be docked at the right edge. |
498 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 506 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
499 window->GetBoundsInScreen().right()); | 507 window->GetBoundsInScreen().right()); |
500 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 508 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
501 | 509 |
502 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 510 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
503 // Minimize the window, it should be hidden. | 511 // Minimize the window, it should be hidden. |
504 window_state->Minimize(); | 512 window_state->Minimize(); |
505 RunAllPendingInMessageLoop(); | 513 RunAllPendingInMessageLoop(); |
506 EXPECT_FALSE(window->IsVisible()); | 514 EXPECT_FALSE(window->IsVisible()); |
507 EXPECT_TRUE(window_state->IsMinimized()); | 515 EXPECT_TRUE(window_state->IsMinimized()); |
508 // Restore the window; window should be visible. | 516 // Restore the window; window should be visible. |
509 window_state->Restore(); | 517 window_state->Restore(); |
510 RunAllPendingInMessageLoop(); | 518 RunAllPendingInMessageLoop(); |
511 EXPECT_TRUE(window->IsVisible()); | 519 EXPECT_TRUE(window->IsVisible()); |
512 EXPECT_TRUE(window_state->IsDocked()); | 520 EXPECT_TRUE(window_state->IsDocked()); |
513 } | 521 } |
514 | 522 |
515 // Maximize a docked window and check that it is maximized and no longer docked. | 523 // Maximize a docked window and check that it is maximized and no longer docked. |
516 TEST_P(DockedWindowResizerTest, AttachMaximize) { | 524 TEST_P(DockedWindowResizerTest, AttachMaximize) { |
517 if (!SupportsHostWindowResize()) | 525 if (!SupportsHostWindowResize()) |
518 return; | 526 return; |
519 | 527 |
520 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 528 std::unique_ptr<aura::Window> window( |
| 529 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
521 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 530 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
522 | 531 |
523 // The window should be docked at the right edge. | 532 // The window should be docked at the right edge. |
524 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 533 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
525 window->GetBoundsInScreen().right()); | 534 window->GetBoundsInScreen().right()); |
526 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 535 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
527 | 536 |
528 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 537 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
529 // Maximize the window, it should get undocked and maximized in a desktop. | 538 // Maximize the window, it should get undocked and maximized in a desktop. |
530 window_state->Maximize(); | 539 window_state->Maximize(); |
531 RunAllPendingInMessageLoop(); | 540 RunAllPendingInMessageLoop(); |
532 EXPECT_TRUE(window->IsVisible()); | 541 EXPECT_TRUE(window->IsVisible()); |
533 EXPECT_TRUE(window_state->IsMaximized()); | 542 EXPECT_TRUE(window_state->IsMaximized()); |
534 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 543 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
535 } | 544 } |
536 | 545 |
537 // Dock two windows, undock one, check that the other one is still docked. | 546 // Dock two windows, undock one, check that the other one is still docked. |
538 TEST_P(DockedWindowResizerTest, AttachTwoWindows) { | 547 TEST_P(DockedWindowResizerTest, AttachTwoWindows) { |
539 if (!SupportsHostWindowResize()) | 548 if (!SupportsHostWindowResize()) |
540 return; | 549 return; |
541 UpdateDisplay("600x600"); | 550 UpdateDisplay("600x600"); |
542 | 551 |
543 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 552 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
544 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 553 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
545 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 554 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
546 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 50); | 555 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 50); |
547 | 556 |
548 // Docking second window should not minimize the first. | 557 // Docking second window should not minimize the first. |
549 wm::WindowState* window_state1 = wm::GetWindowState(w1.get()); | 558 wm::WindowState* window_state1 = wm::GetWindowState(w1.get()); |
550 EXPECT_FALSE(window_state1->IsMinimized()); | 559 EXPECT_FALSE(window_state1->IsMinimized()); |
551 | 560 |
552 // Both windows should be docked at the right edge. | 561 // Both windows should be docked at the right edge. |
553 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 562 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
554 w1->GetBoundsInScreen().right()); | 563 w1->GetBoundsInScreen().right()); |
(...skipping 20 matching lines...) Expand all Loading... |
575 // The window should be floating on the desktop again and moved to the left. | 584 // The window should be floating on the desktop again and moved to the left. |
576 EXPECT_EQ(left_edge - 32, w2->GetBoundsInScreen().x()); | 585 EXPECT_EQ(left_edge - 32, w2->GetBoundsInScreen().x()); |
577 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); | 586 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); |
578 } | 587 } |
579 | 588 |
580 // Create two windows, dock one and change shelf to auto-hide. | 589 // Create two windows, dock one and change shelf to auto-hide. |
581 TEST_P(DockedWindowResizerTest, AttachOneAutoHideShelf) { | 590 TEST_P(DockedWindowResizerTest, AttachOneAutoHideShelf) { |
582 if (!SupportsHostWindowResize()) | 591 if (!SupportsHostWindowResize()) |
583 return; | 592 return; |
584 | 593 |
585 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 594 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
586 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 595 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
587 | 596 |
588 // w1 should be docked at the right edge. | 597 // w1 should be docked at the right edge. |
589 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 598 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
590 w1->GetBoundsInScreen().right()); | 599 w1->GetBoundsInScreen().right()); |
591 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 600 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
592 | 601 |
593 scoped_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegateAndType( | 602 std::unique_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegateAndType( |
594 NULL, ui::wm::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20))); | 603 NULL, ui::wm::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20))); |
595 wm::GetWindowState(w2.get())->Maximize(); | 604 wm::GetWindowState(w2.get())->Maximize(); |
596 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); | 605 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); |
597 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized()); | 606 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized()); |
598 | 607 |
599 gfx::Rect work_area = | 608 gfx::Rect work_area = |
600 gfx::Screen::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); | 609 gfx::Screen::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); |
601 DockedWindowLayoutManager* manager = | 610 DockedWindowLayoutManager* manager = |
602 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); | 611 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); |
603 | 612 |
(...skipping 13 matching lines...) Expand all Loading... |
617 // Docked background should extend to the bottom of work area. | 626 // Docked background should extend to the bottom of work area. |
618 EXPECT_EQ(work_area.bottom(), manager->docked_bounds().bottom()); | 627 EXPECT_EQ(work_area.bottom(), manager->docked_bounds().bottom()); |
619 } | 628 } |
620 | 629 |
621 // Dock one window, try to dock another window on the opposite side (should not | 630 // Dock one window, try to dock another window on the opposite side (should not |
622 // dock). | 631 // dock). |
623 TEST_P(DockedWindowResizerTest, AttachOnTwoSides) { | 632 TEST_P(DockedWindowResizerTest, AttachOnTwoSides) { |
624 if (!SupportsHostWindowResize()) | 633 if (!SupportsHostWindowResize()) |
625 return; | 634 return; |
626 | 635 |
627 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 636 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
628 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 637 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
629 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 638 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
630 gfx::Rect initial_bounds(w2->bounds()); | 639 gfx::Rect initial_bounds(w2->bounds()); |
631 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w2.get(), 50); | 640 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w2.get(), 50); |
632 | 641 |
633 // The first window should be docked at the right edge. | 642 // The first window should be docked at the right edge. |
634 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 643 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
635 w1->GetBoundsInScreen().right()); | 644 w1->GetBoundsInScreen().right()); |
636 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 645 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
637 | 646 |
638 // The second window should be near the left edge but not snapped. | 647 // The second window should be near the left edge but not snapped. |
639 // Normal window will get side-maximized while panels will not. | 648 // Normal window will get side-maximized while panels will not. |
640 int expected_x = test_panels() ? | 649 int expected_x = test_panels() ? |
641 (initial_bounds.x() - initial_location_in_parent().x()) : 0; | 650 (initial_bounds.x() - initial_location_in_parent().x()) : 0; |
642 EXPECT_EQ(expected_x, w2->GetBoundsInScreen().x()); | 651 EXPECT_EQ(expected_x, w2->GetBoundsInScreen().x()); |
643 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); | 652 EXPECT_EQ(kShellWindowId_DefaultContainer, w2->parent()->id()); |
644 } | 653 } |
645 | 654 |
646 // Tests that reverting a drag restores docked state if a window was docked. | 655 // Tests that reverting a drag restores docked state if a window was docked. |
647 TEST_P(DockedWindowResizerTest, RevertDragRestoresAttachment) { | 656 TEST_P(DockedWindowResizerTest, RevertDragRestoresAttachment) { |
648 if (!SupportsHostWindowResize()) | 657 if (!SupportsHostWindowResize()) |
649 return; | 658 return; |
650 | 659 |
651 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 660 std::unique_ptr<aura::Window> window( |
| 661 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
652 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 662 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
653 | 663 |
654 // The window should be docked at the right edge. | 664 // The window should be docked at the right edge. |
655 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 665 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
656 window->GetBoundsInScreen().right()); | 666 window->GetBoundsInScreen().right()); |
657 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 667 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
658 | 668 |
659 // Drag the window out but revert the drag | 669 // Drag the window out but revert the drag |
660 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); | 670 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); |
661 DragMove(-50, 0); | 671 DragMove(-50, 0); |
662 DragRevert(); | 672 DragRevert(); |
663 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 673 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
664 | 674 |
665 // Detach window. | 675 // Detach window. |
666 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); | 676 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); |
667 DragMove(-50, 0); | 677 DragMove(-50, 0); |
668 DragEnd(); | 678 DragEnd(); |
669 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 679 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
670 } | 680 } |
671 | 681 |
672 // Tests that reverting drag restores undocked state if a window was not docked. | 682 // Tests that reverting drag restores undocked state if a window was not docked. |
673 TEST_P(DockedWindowResizerTest, RevertDockedDragRevertsAttachment) { | 683 TEST_P(DockedWindowResizerTest, RevertDockedDragRevertsAttachment) { |
674 if (!SupportsHostWindowResize()) | 684 if (!SupportsHostWindowResize()) |
675 return; | 685 return; |
676 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 686 std::unique_ptr<aura::Window> window( |
| 687 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
677 aura::Window* dock_container = Shell::GetContainer( | 688 aura::Window* dock_container = Shell::GetContainer( |
678 window->GetRootWindow(), | 689 window->GetRootWindow(), |
679 kShellWindowId_DockedContainer); | 690 kShellWindowId_DockedContainer); |
680 DockedWindowLayoutManager* manager = | 691 DockedWindowLayoutManager* manager = |
681 static_cast<DockedWindowLayoutManager*>(dock_container->layout_manager()); | 692 static_cast<DockedWindowLayoutManager*>(dock_container->layout_manager()); |
682 int previous_container_id = window->parent()->id(); | 693 int previous_container_id = window->parent()->id(); |
683 // Drag the window out but revert the drag | 694 // Drag the window out but revert the drag |
684 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); | 695 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); |
685 DragMove(-50 - window->bounds().x(), 50 - window->bounds().y()); | 696 DragMove(-50 - window->bounds().x(), 50 - window->bounds().y()); |
686 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); | 697 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); |
(...skipping 28 matching lines...) Expand all Loading... |
715 } | 726 } |
716 | 727 |
717 // Move a docked window to the second display | 728 // Move a docked window to the second display |
718 TEST_P(DockedWindowResizerTest, DragAcrossDisplays) { | 729 TEST_P(DockedWindowResizerTest, DragAcrossDisplays) { |
719 if (!SupportsMultipleDisplays()) | 730 if (!SupportsMultipleDisplays()) |
720 return; | 731 return; |
721 | 732 |
722 UpdateDisplay("800x800,800x800"); | 733 UpdateDisplay("800x800,800x800"); |
723 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 734 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
724 EXPECT_EQ(2, static_cast<int>(root_windows.size())); | 735 EXPECT_EQ(2, static_cast<int>(root_windows.size())); |
725 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 736 std::unique_ptr<aura::Window> window( |
| 737 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
726 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 738 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
727 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 739 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
728 | 740 |
729 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 741 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
730 // The window should be docked at the right edge. | 742 // The window should be docked at the right edge. |
731 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 743 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
732 window->GetBoundsInScreen().right()); | 744 window->GetBoundsInScreen().right()); |
733 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 745 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
734 | 746 |
735 // Try dragging to the right - enough to get it peeking at the other screen | 747 // Try dragging to the right - enough to get it peeking at the other screen |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 788 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
777 } | 789 } |
778 | 790 |
779 // Dock two windows, undock one. | 791 // Dock two windows, undock one. |
780 // Test the docked windows area size and default container resizing. | 792 // Test the docked windows area size and default container resizing. |
781 TEST_P(DockedWindowResizerTest, AttachTwoWindowsDetachOne) { | 793 TEST_P(DockedWindowResizerTest, AttachTwoWindowsDetachOne) { |
782 if (!SupportsHostWindowResize()) | 794 if (!SupportsHostWindowResize()) |
783 return; | 795 return; |
784 UpdateDisplay("600x600"); | 796 UpdateDisplay("600x600"); |
785 | 797 |
786 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 798 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
787 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); | 799 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); |
788 // Work area should cover the whole screen. | 800 // Work area should cover the whole screen. |
789 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), | 801 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), |
790 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 802 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
791 | 803 |
792 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 804 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
793 // A window should be docked at the right edge. | 805 // A window should be docked at the right edge. |
794 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 806 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
795 w1->GetBoundsInScreen().right()); | 807 w1->GetBoundsInScreen().right()); |
796 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 808 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
797 DockedWindowLayoutManager* manager = | 809 DockedWindowLayoutManager* manager = |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 860 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
849 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 861 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
850 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 862 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
851 } | 863 } |
852 | 864 |
853 // Dock one of the windows. Maximize other testing desktop resizing. | 865 // Dock one of the windows. Maximize other testing desktop resizing. |
854 TEST_P(DockedWindowResizerTest, AttachWindowMaximizeOther) { | 866 TEST_P(DockedWindowResizerTest, AttachWindowMaximizeOther) { |
855 if (!SupportsHostWindowResize()) | 867 if (!SupportsHostWindowResize()) |
856 return; | 868 return; |
857 | 869 |
858 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 870 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
859 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); | 871 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); |
860 // Work area should cover the whole screen. | 872 // Work area should cover the whole screen. |
861 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), | 873 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), |
862 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 874 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
863 | 875 |
864 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 876 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
865 // A window should be docked at the right edge. | 877 // A window should be docked at the right edge. |
866 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 878 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
867 w1->GetBoundsInScreen().right()); | 879 w1->GetBoundsInScreen().right()); |
868 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 880 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
869 DockedWindowLayoutManager* manager = | 881 DockedWindowLayoutManager* manager = |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 w2_state->Restore(); | 959 w2_state->Restore(); |
948 // Its bounds should get restored. | 960 // Its bounds should get restored. |
949 EXPECT_EQ(restored_bounds, w2->bounds()); | 961 EXPECT_EQ(restored_bounds, w2->bounds()); |
950 } | 962 } |
951 | 963 |
952 // Dock one window. Test the sticky behavior near screen or desktop edge. | 964 // Dock one window. Test the sticky behavior near screen or desktop edge. |
953 TEST_P(DockedWindowResizerTest, AttachOneTestSticky) { | 965 TEST_P(DockedWindowResizerTest, AttachOneTestSticky) { |
954 if (!SupportsHostWindowResize()) | 966 if (!SupportsHostWindowResize()) |
955 return; | 967 return; |
956 | 968 |
957 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 969 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
958 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); | 970 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); |
959 // Work area should cover the whole screen. | 971 // Work area should cover the whole screen. |
960 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), | 972 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), |
961 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 973 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
962 | 974 |
963 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w1.get(), 20); | 975 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w1.get(), 20); |
964 // A window should be docked at the left edge. | 976 // A window should be docked at the left edge. |
965 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().x(), | 977 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().x(), |
966 w1->GetBoundsInScreen().x()); | 978 w1->GetBoundsInScreen().x()); |
967 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 979 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
968 DockedWindowLayoutManager* manager = | 980 DockedWindowLayoutManager* manager = |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1047 } | 1059 } |
1048 | 1060 |
1049 // Dock two windows, resize one. | 1061 // Dock two windows, resize one. |
1050 // Test the docked windows area size and remaining desktop resizing. | 1062 // Test the docked windows area size and remaining desktop resizing. |
1051 TEST_P(DockedWindowResizerTest, ResizeOneOfTwoWindows) { | 1063 TEST_P(DockedWindowResizerTest, ResizeOneOfTwoWindows) { |
1052 if (!SupportsHostWindowResize()) | 1064 if (!SupportsHostWindowResize()) |
1053 return; | 1065 return; |
1054 | 1066 |
1055 // Wider display to start since panels are limited to half the display width. | 1067 // Wider display to start since panels are limited to half the display width. |
1056 UpdateDisplay("1000x600"); | 1068 UpdateDisplay("1000x600"); |
1057 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 1069 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
1058 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); | 1070 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); |
1059 // Work area should cover the whole screen. | 1071 // Work area should cover the whole screen. |
1060 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), | 1072 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), |
1061 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 1073 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
1062 | 1074 |
1063 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1075 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
1064 // A window should be docked at the right edge. | 1076 // A window should be docked at the right edge. |
1065 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 1077 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
1066 w1->GetBoundsInScreen().right()); | 1078 w1->GetBoundsInScreen().right()); |
1067 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1079 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1068 DockedWindowLayoutManager* manager = | 1080 DockedWindowLayoutManager* manager = |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 | 1206 |
1195 // Dock a window, resize it and test that undocking it restores the pre-docked | 1207 // Dock a window, resize it and test that undocking it restores the pre-docked |
1196 // size. | 1208 // size. |
1197 TEST_P(DockedWindowResizerTest, ResizingKeepsSize) { | 1209 TEST_P(DockedWindowResizerTest, ResizingKeepsSize) { |
1198 if (!SupportsHostWindowResize()) | 1210 if (!SupportsHostWindowResize()) |
1199 return; | 1211 return; |
1200 | 1212 |
1201 // Wider display to start since panels are limited to half the display width. | 1213 // Wider display to start since panels are limited to half the display width. |
1202 UpdateDisplay("1000x600"); | 1214 UpdateDisplay("1000x600"); |
1203 const gfx::Size original_size(201, 201); | 1215 const gfx::Size original_size(201, 201); |
1204 scoped_ptr<aura::Window> w1( | 1216 std::unique_ptr<aura::Window> w1( |
1205 CreateTestWindow(gfx::Rect(gfx::Point(), original_size))); | 1217 CreateTestWindow(gfx::Rect(gfx::Point(), original_size))); |
1206 | 1218 |
1207 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1219 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
1208 // Window should be docked at the right edge. | 1220 // Window should be docked at the right edge. |
1209 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 1221 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
1210 w1->GetBoundsInScreen().right()); | 1222 w1->GetBoundsInScreen().right()); |
1211 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1223 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1212 DockedWindowLayoutManager* manager = | 1224 DockedWindowLayoutManager* manager = |
1213 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); | 1225 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); |
1214 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1226 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1249 EXPECT_EQ(original_size.ToString(), w1->bounds().size().ToString()); | 1261 EXPECT_EQ(original_size.ToString(), w1->bounds().size().ToString()); |
1250 } | 1262 } |
1251 | 1263 |
1252 // Dock a window, resize it and test that it stays docked. | 1264 // Dock a window, resize it and test that it stays docked. |
1253 TEST_P(DockedWindowResizerTest, ResizingKeepsDockedState) { | 1265 TEST_P(DockedWindowResizerTest, ResizingKeepsDockedState) { |
1254 if (!SupportsHostWindowResize()) | 1266 if (!SupportsHostWindowResize()) |
1255 return; | 1267 return; |
1256 | 1268 |
1257 // Wider display to start since panels are limited to half the display width. | 1269 // Wider display to start since panels are limited to half the display width. |
1258 UpdateDisplay("1000x600"); | 1270 UpdateDisplay("1000x600"); |
1259 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 1271 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
1260 | 1272 |
1261 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1273 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
1262 // Window should be docked at the right edge. | 1274 // Window should be docked at the right edge. |
1263 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 1275 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
1264 w1->GetBoundsInScreen().right()); | 1276 w1->GetBoundsInScreen().right()); |
1265 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1277 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1266 DockedWindowLayoutManager* manager = | 1278 DockedWindowLayoutManager* manager = |
1267 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); | 1279 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); |
1268 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1280 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1269 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1281 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1307 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1319 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
1308 } | 1320 } |
1309 | 1321 |
1310 // Dock two windows, resize one. Test the docked windows area size. | 1322 // Dock two windows, resize one. Test the docked windows area size. |
1311 TEST_P(DockedWindowResizerTest, ResizeTwoWindows) { | 1323 TEST_P(DockedWindowResizerTest, ResizeTwoWindows) { |
1312 if (!SupportsHostWindowResize()) | 1324 if (!SupportsHostWindowResize()) |
1313 return; | 1325 return; |
1314 | 1326 |
1315 // Wider display to start since panels are limited to half the display width. | 1327 // Wider display to start since panels are limited to half the display width. |
1316 UpdateDisplay("1000x600"); | 1328 UpdateDisplay("1000x600"); |
1317 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 1329 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
1318 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); | 1330 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); |
1319 | 1331 |
1320 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1332 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
1321 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); | 1333 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); |
1322 // Both windows should now be docked at the right edge. | 1334 // Both windows should now be docked at the right edge. |
1323 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1335 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1324 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 1336 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
1325 // Dock width should be set to ideal width. | 1337 // Dock width should be set to ideal width. |
1326 DockedWindowLayoutManager* manager = | 1338 DockedWindowLayoutManager* manager = |
1327 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); | 1339 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); |
1328 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1340 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1375 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); | 1387 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); |
1376 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1388 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
1377 } | 1389 } |
1378 | 1390 |
1379 // Tests that dragging a window down to shelf attaches a panel but does not | 1391 // Tests that dragging a window down to shelf attaches a panel but does not |
1380 // attach a regular window. | 1392 // attach a regular window. |
1381 TEST_P(DockedWindowResizerTest, DragToShelf) { | 1393 TEST_P(DockedWindowResizerTest, DragToShelf) { |
1382 if (!SupportsHostWindowResize()) | 1394 if (!SupportsHostWindowResize()) |
1383 return; | 1395 return; |
1384 | 1396 |
1385 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 1397 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
1386 // Work area should cover the whole screen. | 1398 // Work area should cover the whole screen. |
1387 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w1.get()).width(), | 1399 EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w1.get()).width(), |
1388 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).width()); | 1400 ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).width()); |
1389 | 1401 |
1390 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1402 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
1391 // A window should be docked at the right edge. | 1403 // A window should be docked at the right edge. |
1392 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 1404 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
1393 w1->GetBoundsInScreen().right()); | 1405 w1->GetBoundsInScreen().right()); |
1394 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1406 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1395 DockedWindowLayoutManager* manager = | 1407 DockedWindowLayoutManager* manager = |
(...skipping 27 matching lines...) Expand all Loading... |
1423 } | 1435 } |
1424 } | 1436 } |
1425 | 1437 |
1426 // Tests that docking and undocking a |window| with a transient child properly | 1438 // Tests that docking and undocking a |window| with a transient child properly |
1427 // maintains the parent of that transient child to be the same as the |window|. | 1439 // maintains the parent of that transient child to be the same as the |window|. |
1428 TEST_P(DockedWindowResizerTest, DragWindowWithTransientChild) { | 1440 TEST_P(DockedWindowResizerTest, DragWindowWithTransientChild) { |
1429 if (!SupportsHostWindowResize()) | 1441 if (!SupportsHostWindowResize()) |
1430 return; | 1442 return; |
1431 | 1443 |
1432 // Create a window with a transient child. | 1444 // Create a window with a transient child. |
1433 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 1445 std::unique_ptr<aura::Window> window( |
1434 scoped_ptr<aura::Window> child(CreateTestWindowInShellWithDelegateAndType( | 1446 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
1435 NULL, ui::wm::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20))); | 1447 std::unique_ptr<aura::Window> child( |
| 1448 CreateTestWindowInShellWithDelegateAndType( |
| 1449 NULL, ui::wm::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20))); |
1436 ::wm::AddTransientChild(window.get(), child.get()); | 1450 ::wm::AddTransientChild(window.get(), child.get()); |
1437 if (window->parent() != child->parent()) | 1451 if (window->parent() != child->parent()) |
1438 window->parent()->AddChild(child.get()); | 1452 window->parent()->AddChild(child.get()); |
1439 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get())); | 1453 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get())); |
1440 | 1454 |
1441 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20); | 1455 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20); |
1442 | 1456 |
1443 // A window should be docked at the right edge. | 1457 // A window should be docked at the right edge. |
1444 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 1458 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
1445 EXPECT_EQ(kShellWindowId_DockedContainer, child->parent()->id()); | 1459 EXPECT_EQ(kShellWindowId_DockedContainer, child->parent()->id()); |
(...skipping 18 matching lines...) Expand all Loading... |
1464 child->GetBoundsInScreen().origin().ToString()); | 1478 child->GetBoundsInScreen().origin().ToString()); |
1465 } | 1479 } |
1466 | 1480 |
1467 // Tests that reparenting windows during the drag does not affect system modal | 1481 // Tests that reparenting windows during the drag does not affect system modal |
1468 // windows that are transient children of the dragged windows. | 1482 // windows that are transient children of the dragged windows. |
1469 TEST_P(DockedWindowResizerTest, DragWindowWithModalTransientChild) { | 1483 TEST_P(DockedWindowResizerTest, DragWindowWithModalTransientChild) { |
1470 if (!SupportsHostWindowResize()) | 1484 if (!SupportsHostWindowResize()) |
1471 return; | 1485 return; |
1472 | 1486 |
1473 // Create a window. | 1487 // Create a window. |
1474 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 1488 std::unique_ptr<aura::Window> window( |
| 1489 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
1475 gfx::Rect bounds(window->bounds()); | 1490 gfx::Rect bounds(window->bounds()); |
1476 | 1491 |
1477 // Start dragging the window. | 1492 // Start dragging the window. |
1478 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); | 1493 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); |
1479 gfx::Vector2d move_vector(40, test_panels() ? -60 : 60); | 1494 gfx::Vector2d move_vector(40, test_panels() ? -60 : 60); |
1480 DragMove(move_vector.x(), move_vector.y()); | 1495 DragMove(move_vector.x(), move_vector.y()); |
1481 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); | 1496 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); |
1482 | 1497 |
1483 // While still dragging create a modal window and make it a transient child of | 1498 // While still dragging create a modal window and make it a transient child of |
1484 // the |window|. | 1499 // the |window|. |
1485 scoped_ptr<aura::Window> child(CreateModalWindow(gfx::Rect(20, 20, 150, 20))); | 1500 std::unique_ptr<aura::Window> child( |
| 1501 CreateModalWindow(gfx::Rect(20, 20, 150, 20))); |
1486 ::wm::AddTransientChild(window.get(), child.get()); | 1502 ::wm::AddTransientChild(window.get(), child.get()); |
1487 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get())); | 1503 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get())); |
1488 EXPECT_EQ(kShellWindowId_SystemModalContainer, child->parent()->id()); | 1504 EXPECT_EQ(kShellWindowId_SystemModalContainer, child->parent()->id()); |
1489 | 1505 |
1490 // End the drag, the |window| should have moved (if it is a panel it will | 1506 // End the drag, the |window| should have moved (if it is a panel it will |
1491 // no longer be attached to the shelf since we dragged it above). | 1507 // no longer be attached to the shelf since we dragged it above). |
1492 DragEnd(); | 1508 DragEnd(); |
1493 bounds.Offset(move_vector); | 1509 bounds.Offset(move_vector); |
1494 EXPECT_EQ(bounds.ToString(), window->GetBoundsInScreen().ToString()); | 1510 EXPECT_EQ(bounds.ToString(), window->GetBoundsInScreen().ToString()); |
1495 | 1511 |
1496 // The original |window| should be in the default container (not docked or | 1512 // The original |window| should be in the default container (not docked or |
1497 // attached). | 1513 // attached). |
1498 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 1514 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
1499 // The transient |child| should still be in system modal container. | 1515 // The transient |child| should still be in system modal container. |
1500 EXPECT_EQ(kShellWindowId_SystemModalContainer, child->parent()->id()); | 1516 EXPECT_EQ(kShellWindowId_SystemModalContainer, child->parent()->id()); |
1501 // The |child| should not have moved. | 1517 // The |child| should not have moved. |
1502 EXPECT_EQ(gfx::Point(20, 20).ToString(), | 1518 EXPECT_EQ(gfx::Point(20, 20).ToString(), |
1503 child->GetBoundsInScreen().origin().ToString()); | 1519 child->GetBoundsInScreen().origin().ToString()); |
1504 // The |child| should still be a transient child of |window|. | 1520 // The |child| should still be a transient child of |window|. |
1505 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get())); | 1521 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get())); |
1506 } | 1522 } |
1507 | 1523 |
1508 // Tests that side snapping a window undocks it, closes the dock and then snaps. | 1524 // Tests that side snapping a window undocks it, closes the dock and then snaps. |
1509 TEST_P(DockedWindowResizerTest, SideSnapDocked) { | 1525 TEST_P(DockedWindowResizerTest, SideSnapDocked) { |
1510 if (!SupportsHostWindowResize() || test_panels()) | 1526 if (!SupportsHostWindowResize() || test_panels()) |
1511 return; | 1527 return; |
1512 | 1528 |
1513 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 1529 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
1514 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | 1530 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
1515 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1531 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
1516 // A window should be docked at the right edge. | 1532 // A window should be docked at the right edge. |
1517 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 1533 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
1518 w1->GetBoundsInScreen().right()); | 1534 w1->GetBoundsInScreen().right()); |
1519 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 1535 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
1520 DockedWindowLayoutManager* manager = | 1536 DockedWindowLayoutManager* manager = |
1521 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); | 1537 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); |
1522 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1538 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1523 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1539 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 EXPECT_FALSE(window_state->IsDocked()); | 1576 EXPECT_FALSE(window_state->IsDocked()); |
1561 EXPECT_TRUE(window_state->IsSnapped()); | 1577 EXPECT_TRUE(window_state->IsSnapped()); |
1562 } | 1578 } |
1563 | 1579 |
1564 // Tests that a window is undocked if the window is maximized via a keyboard | 1580 // Tests that a window is undocked if the window is maximized via a keyboard |
1565 // accelerator during a drag. | 1581 // accelerator during a drag. |
1566 TEST_P(DockedWindowResizerTest, MaximizedDuringDrag) { | 1582 TEST_P(DockedWindowResizerTest, MaximizedDuringDrag) { |
1567 if (!SupportsHostWindowResize() || test_panels()) | 1583 if (!SupportsHostWindowResize() || test_panels()) |
1568 return; | 1584 return; |
1569 | 1585 |
1570 scoped_ptr<aura::Window> window(CreateTestWindow( | 1586 std::unique_ptr<aura::Window> window( |
1571 gfx::Rect(0, 0, ideal_width(), 201))); | 1587 CreateTestWindow(gfx::Rect(0, 0, ideal_width(), 201))); |
1572 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 1588 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
1573 | 1589 |
1574 // Dock the window to the right edge. | 1590 // Dock the window to the right edge. |
1575 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20); | 1591 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20); |
1576 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 1592 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
1577 window->GetBoundsInScreen().right()); | 1593 window->GetBoundsInScreen().right()); |
1578 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 1594 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
1579 DockedWindowLayoutManager* manager = | 1595 DockedWindowLayoutManager* manager = |
1580 static_cast<DockedWindowLayoutManager*>( | 1596 static_cast<DockedWindowLayoutManager*>( |
1581 window->parent()->layout_manager()); | 1597 window->parent()->layout_manager()); |
(...skipping 21 matching lines...) Expand all Loading... |
1603 EXPECT_TRUE(window_state->IsMaximized()); | 1619 EXPECT_TRUE(window_state->IsMaximized()); |
1604 } | 1620 } |
1605 | 1621 |
1606 // Tests run twice - on both panels and normal windows | 1622 // Tests run twice - on both panels and normal windows |
1607 INSTANTIATE_TEST_CASE_P(NormalOrPanel, | 1623 INSTANTIATE_TEST_CASE_P(NormalOrPanel, |
1608 DockedWindowResizerTest, | 1624 DockedWindowResizerTest, |
1609 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, | 1625 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, |
1610 ui::wm::WINDOW_TYPE_PANEL)); | 1626 ui::wm::WINDOW_TYPE_PANEL)); |
1611 | 1627 |
1612 } // namespace ash | 1628 } // namespace ash |
OLD | NEW |