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/launcher/launcher.h" | 8 #include "ash/launcher/launcher.h" |
9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
10 #include "ash/screen_ash.h" | 10 #include "ash/screen_ash.h" |
11 #include "ash/shelf/shelf_layout_manager.h" | 11 #include "ash/shelf/shelf_layout_manager.h" |
12 #include "ash/shelf/shelf_model.h" | 12 #include "ash/shelf/shelf_model.h" |
13 #include "ash/shelf/shelf_types.h" | 13 #include "ash/shelf/shelf_types.h" |
14 #include "ash/shelf/shelf_widget.h" | 14 #include "ash/shelf/shelf_widget.h" |
15 #include "ash/shell.h" | 15 #include "ash/shell.h" |
16 #include "ash/shell_window_ids.h" | 16 #include "ash/shell_window_ids.h" |
17 #include "ash/test/ash_test_base.h" | 17 #include "ash/test/ash_test_base.h" |
18 #include "ash/test/cursor_manager_test_api.h" | 18 #include "ash/test/cursor_manager_test_api.h" |
19 #include "ash/test/shell_test_api.h" | 19 #include "ash/test/shell_test_api.h" |
20 #include "ash/test/test_launcher_delegate.h" | 20 #include "ash/test/test_launcher_delegate.h" |
21 #include "ash/wm/coordinate_conversion.h" | 21 #include "ash/wm/coordinate_conversion.h" |
22 #include "ash/wm/dock/docked_window_layout_manager.h" | 22 #include "ash/wm/dock/docked_window_layout_manager.h" |
23 #include "ash/wm/drag_window_resizer.h" | 23 #include "ash/wm/drag_window_resizer.h" |
24 #include "ash/wm/panels/panel_layout_manager.h" | 24 #include "ash/wm/panels/panel_layout_manager.h" |
25 #include "ash/wm/window_state.h" | 25 #include "ash/wm/window_state.h" |
26 #include "ash/wm/window_util.h" | 26 #include "ash/wm/window_util.h" |
27 #include "ash/wm/workspace/snap_sizer.h" | |
27 #include "base/command_line.h" | 28 #include "base/command_line.h" |
28 #include "ui/aura/client/aura_constants.h" | 29 #include "ui/aura/client/aura_constants.h" |
29 #include "ui/aura/root_window.h" | 30 #include "ui/aura/root_window.h" |
30 #include "ui/aura/test/test_window_delegate.h" | 31 #include "ui/aura/test/test_window_delegate.h" |
31 #include "ui/base/hit_test.h" | 32 #include "ui/base/hit_test.h" |
32 #include "ui/base/ui_base_types.h" | 33 #include "ui/base/ui_base_types.h" |
33 #include "ui/views/widget/widget.h" | 34 #include "ui/views/widget/widget.h" |
34 | 35 |
35 namespace ash { | 36 namespace ash { |
36 namespace internal { | 37 namespace internal { |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 }; | 232 }; |
232 | 233 |
233 // Verifies a window can be dragged and attached to the dock. | 234 // Verifies a window can be dragged and attached to the dock. |
234 TEST_P(DockedWindowResizerTest, AttachRightPrecise) { | 235 TEST_P(DockedWindowResizerTest, AttachRightPrecise) { |
235 if (!SupportsHostWindowResize()) | 236 if (!SupportsHostWindowResize()) |
236 return; | 237 return; |
237 | 238 |
238 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 239 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
239 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 240 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
240 | 241 |
241 // The window should be attached and snapped to the right edge. | 242 // The window should be docked at the right edge. |
242 EXPECT_EQ(window->GetRootWindow()->bounds().right(), | 243 EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
243 window->GetBoundsInScreen().right()); | 244 window->GetBoundsInScreen().right()); |
244 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 245 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
245 } | 246 } |
246 | 247 |
247 // Verifies a window can be dragged and attached to the dock | 248 // Verifies a window can be dragged and attached to the dock |
248 // even if pointer overshoots the screen edge by a few pixels (sticky edge) | 249 // even if pointer overshoots the screen edge by a few pixels (sticky edge) |
249 TEST_P(DockedWindowResizerTest, AttachRightOvershoot) { | 250 TEST_P(DockedWindowResizerTest, AttachRightOvershoot) { |
250 if (!SupportsHostWindowResize()) | 251 if (!SupportsHostWindowResize()) |
251 return; | 252 return; |
252 | 253 |
253 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 254 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
254 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), +4); | 255 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), +4); |
255 | 256 |
256 // The window should be attached and snapped to the right edge. | 257 // The window should be docked at the right edge. |
257 EXPECT_EQ(window->GetRootWindow()->bounds().right(), | 258 EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
258 window->GetBoundsInScreen().right()); | 259 window->GetBoundsInScreen().right()); |
259 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 260 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
260 } | 261 } |
261 | 262 |
262 // Verifies a window can be dragged and then if a pointer is not quite reaching | 263 // Verifies a window can be dragged and then if a pointer is not quite reaching |
263 // the screen edge the window does not get docked and stays in the desktop. | 264 // the screen edge the window does not get docked and stays in the desktop. |
264 TEST_P(DockedWindowResizerTest, AttachRightUndershoot) { | 265 TEST_P(DockedWindowResizerTest, AttachRightUndershoot) { |
265 if (!SupportsHostWindowResize()) | 266 if (!SupportsHostWindowResize()) |
266 return; | 267 return; |
(...skipping 20 matching lines...) Expand all Loading... | |
287 } | 288 } |
288 | 289 |
289 // Verifies a window can be dragged and attached to the dock. | 290 // Verifies a window can be dragged and attached to the dock. |
290 TEST_P(DockedWindowResizerTest, AttachLeftPrecise) { | 291 TEST_P(DockedWindowResizerTest, AttachLeftPrecise) { |
291 if (!SupportsHostWindowResize()) | 292 if (!SupportsHostWindowResize()) |
292 return; | 293 return; |
293 | 294 |
294 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 295 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
295 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 0); | 296 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 0); |
296 | 297 |
297 // The window should be attached and snapped to the left dock. | 298 // The window should be docked at the left edge. |
298 EXPECT_EQ(window->GetRootWindow()->bounds().x(), | 299 EXPECT_EQ(window->GetRootWindow()->bounds().x(), |
299 window->GetBoundsInScreen().x()); | 300 window->GetBoundsInScreen().x()); |
300 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 301 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
301 } | 302 } |
302 | 303 |
303 // Verifies a window can be dragged and attached to the dock | 304 // Verifies a window can be dragged and attached to the dock |
304 // even if pointer overshoots the screen edge by a few pixels (sticky edge) | 305 // even if pointer overshoots the screen edge by a few pixels (sticky edge) |
305 TEST_P(DockedWindowResizerTest, AttachLeftOvershoot) { | 306 TEST_P(DockedWindowResizerTest, AttachLeftOvershoot) { |
306 if (!SupportsHostWindowResize()) | 307 if (!SupportsHostWindowResize()) |
307 return; | 308 return; |
308 | 309 |
309 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 310 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
310 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), -4); | 311 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), -4); |
311 | 312 |
312 // The window should be attached and snapped to the left dock. | 313 // The window should be docked at the left edge. |
313 EXPECT_EQ(window->GetRootWindow()->bounds().x(), | 314 EXPECT_EQ(window->GetRootWindow()->bounds().x(), |
314 window->GetBoundsInScreen().x()); | 315 window->GetBoundsInScreen().x()); |
315 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 316 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
316 } | 317 } |
317 | 318 |
318 // Verifies a window can be dragged and then if a pointer is not quite reaching | 319 // Verifies a window can be dragged and then if a pointer is not quite reaching |
319 // the screen edge the window does not get docked and stays in the desktop. | 320 // the screen edge the window does not get docked and stays in the desktop. |
320 TEST_P(DockedWindowResizerTest, AttachLeftUndershoot) { | 321 TEST_P(DockedWindowResizerTest, AttachLeftUndershoot) { |
321 if (!SupportsHostWindowResize()) | 322 if (!SupportsHostWindowResize()) |
322 return; | 323 return; |
(...skipping 11 matching lines...) Expand all Loading... | |
334 | 335 |
335 // Dock on the right side, change shelf alignment, check that windows move to | 336 // Dock on the right side, change shelf alignment, check that windows move to |
336 // the opposite side. | 337 // the opposite side. |
337 TEST_P(DockedWindowResizerTest, AttachRightChangeShelf) { | 338 TEST_P(DockedWindowResizerTest, AttachRightChangeShelf) { |
338 if (!SupportsHostWindowResize()) | 339 if (!SupportsHostWindowResize()) |
339 return; | 340 return; |
340 | 341 |
341 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 342 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
342 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 343 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
343 | 344 |
344 // The window should be attached and snapped to the right edge. | 345 // The window should be docked at the right edge. |
345 EXPECT_EQ(window->GetRootWindow()->bounds().right(), | 346 EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
346 window->GetBoundsInScreen().right()); | 347 window->GetBoundsInScreen().right()); |
347 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 348 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
348 | 349 |
349 // set launcher shelf to be aligned on the right | 350 // set launcher shelf to be aligned on the right |
350 ash::Shell* shell = ash::Shell::GetInstance(); | 351 ash::Shell* shell = ash::Shell::GetInstance(); |
351 shell->SetShelfAlignment(SHELF_ALIGNMENT_RIGHT, | 352 shell->SetShelfAlignment(SHELF_ALIGNMENT_RIGHT, |
352 shell->GetPrimaryRootWindow()); | 353 shell->GetPrimaryRootWindow()); |
353 // The window should have moved and get attached to the left dock. | 354 // The window should have moved and get attached to the left dock. |
354 EXPECT_EQ(window->GetRootWindow()->bounds().x(), | 355 EXPECT_EQ(window->GetRootWindow()->bounds().x(), |
(...skipping 19 matching lines...) Expand all Loading... | |
374 | 375 |
375 // Dock on the right side, try to undock, then drag more to really undock | 376 // Dock on the right side, try to undock, then drag more to really undock |
376 TEST_P(DockedWindowResizerTest, AttachTryDetach) { | 377 TEST_P(DockedWindowResizerTest, AttachTryDetach) { |
377 if (!SupportsHostWindowResize()) | 378 if (!SupportsHostWindowResize()) |
378 return; | 379 return; |
379 | 380 |
380 scoped_ptr<aura::Window> window(CreateTestWindow( | 381 scoped_ptr<aura::Window> window(CreateTestWindow( |
381 gfx::Rect(0, 0, ideal_width() + 10, 201))); | 382 gfx::Rect(0, 0, ideal_width() + 10, 201))); |
382 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 383 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
383 | 384 |
384 // The window should be attached and docked at the right edge. | 385 // The window should be docked at the right edge. |
385 // Its width should shrink to ideal width. | 386 // Its width should shrink to ideal width. |
386 EXPECT_EQ(window->GetRootWindow()->bounds().right(), | 387 EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
387 window->GetBoundsInScreen().right()); | 388 window->GetBoundsInScreen().right()); |
388 EXPECT_EQ(ideal_width(), window->GetBoundsInScreen().width()); | 389 EXPECT_EQ(ideal_width(), window->GetBoundsInScreen().width()); |
389 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 390 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
390 | 391 |
391 // Try to detach by dragging left less than kSnapToDockDistance. | 392 // Try to detach by dragging left less than kSnapToDockDistance. |
392 // The window should stay docked. | 393 // The window should stay docked. |
393 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( | 394 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( |
394 window.get(), 10, 0)); | 395 window.get(), 10, 0)); |
(...skipping 21 matching lines...) Expand all Loading... | |
416 } | 417 } |
417 | 418 |
418 // Minimize a docked window, then restore it and check that it is still docked. | 419 // Minimize a docked window, then restore it and check that it is still docked. |
419 TEST_P(DockedWindowResizerTest, AttachMinimizeRestore) { | 420 TEST_P(DockedWindowResizerTest, AttachMinimizeRestore) { |
420 if (!SupportsHostWindowResize()) | 421 if (!SupportsHostWindowResize()) |
421 return; | 422 return; |
422 | 423 |
423 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 424 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
424 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 425 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
425 | 426 |
426 // The window should be attached and snapped to the right edge. | 427 // The window should be docked at the right edge. |
427 EXPECT_EQ(window->GetRootWindow()->bounds().right(), | 428 EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
428 window->GetBoundsInScreen().right()); | 429 window->GetBoundsInScreen().right()); |
429 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 430 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
430 | 431 |
431 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 432 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
432 // Minimize the window, it should be hidden. | 433 // Minimize the window, it should be hidden. |
433 window_state->Minimize(); | 434 window_state->Minimize(); |
434 RunAllPendingInMessageLoop(); | 435 RunAllPendingInMessageLoop(); |
435 EXPECT_FALSE(window->IsVisible()); | 436 EXPECT_FALSE(window->IsVisible()); |
436 EXPECT_TRUE(window_state->IsMinimized()); | 437 EXPECT_TRUE(window_state->IsMinimized()); |
437 // Restore the window; window should be visible. | 438 // Restore the window; window should be visible. |
438 window_state->Restore(); | 439 window_state->Restore(); |
439 RunAllPendingInMessageLoop(); | 440 RunAllPendingInMessageLoop(); |
440 EXPECT_TRUE(window->IsVisible()); | 441 EXPECT_TRUE(window->IsVisible()); |
441 EXPECT_TRUE(window_state->IsNormalShowState()); | 442 EXPECT_TRUE(window_state->IsNormalShowState()); |
442 } | 443 } |
443 | 444 |
444 // Maximize a docked window and check that it is maximized and no longer docked. | 445 // Maximize a docked window and check that it is maximized and no longer docked. |
445 TEST_P(DockedWindowResizerTest, AttachMaximize) { | 446 TEST_P(DockedWindowResizerTest, AttachMaximize) { |
446 if (!SupportsHostWindowResize()) | 447 if (!SupportsHostWindowResize()) |
447 return; | 448 return; |
448 | 449 |
449 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 450 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
450 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 451 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
451 | 452 |
452 // The window should be attached and snapped to the right edge. | 453 // The window should be docked at the right edge. |
453 EXPECT_EQ(window->GetRootWindow()->bounds().right(), | 454 EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
454 window->GetBoundsInScreen().right()); | 455 window->GetBoundsInScreen().right()); |
455 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 456 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
456 | 457 |
457 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 458 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
458 // Maximize the window, it should get undocked and maximized in a desktop. | 459 // Maximize the window, it should get undocked and maximized in a desktop. |
459 window_state->Maximize(); | 460 window_state->Maximize(); |
460 RunAllPendingInMessageLoop(); | 461 RunAllPendingInMessageLoop(); |
461 EXPECT_TRUE(window->IsVisible()); | 462 EXPECT_TRUE(window->IsVisible()); |
462 EXPECT_TRUE(window_state->IsMaximized()); | 463 EXPECT_TRUE(window_state->IsMaximized()); |
463 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); | 464 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); |
464 } | 465 } |
465 | 466 |
466 // Dock two windows, undock one, check that the other one is still docked. | 467 // Dock two windows, undock one, check that the other one is still docked. |
467 TEST_P(DockedWindowResizerTest, AttachTwoWindows) { | 468 TEST_P(DockedWindowResizerTest, AttachTwoWindows) { |
468 if (!SupportsHostWindowResize()) | 469 if (!SupportsHostWindowResize()) |
469 return; | 470 return; |
470 | 471 |
471 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 472 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
472 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 473 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
473 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 474 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
474 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 50); | 475 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 50); |
475 | 476 |
476 // Both windows should be attached and snapped to the right edge. | 477 // Both windows should be docked at the right edge. |
477 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 478 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
478 w1->GetBoundsInScreen().right()); | 479 w1->GetBoundsInScreen().right()); |
479 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 480 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
480 | 481 |
481 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), | 482 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
482 w2->GetBoundsInScreen().right()); | 483 w2->GetBoundsInScreen().right()); |
483 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); | 484 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); |
484 | 485 |
485 // Detach by dragging left (should get undocked). | 486 // Detach by dragging left (should get undocked). |
486 const int left_edge = w2->bounds().x(); | 487 const int left_edge = w2->bounds().x(); |
(...skipping 15 matching lines...) Expand all Loading... | |
502 } | 503 } |
503 | 504 |
504 // Create two windows, dock one and change shelf to auto-hide. | 505 // Create two windows, dock one and change shelf to auto-hide. |
505 TEST_P(DockedWindowResizerTest, AttachOneAutoHideShelf) { | 506 TEST_P(DockedWindowResizerTest, AttachOneAutoHideShelf) { |
506 if (!SupportsHostWindowResize()) | 507 if (!SupportsHostWindowResize()) |
507 return; | 508 return; |
508 | 509 |
509 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 510 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
510 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 511 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
511 | 512 |
512 // w1 should be attached and snapped to the right edge. | 513 // w1 should be docked at the right edge. |
513 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 514 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
514 w1->GetBoundsInScreen().right()); | 515 w1->GetBoundsInScreen().right()); |
515 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 516 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
516 | 517 |
517 scoped_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegateAndType( | 518 scoped_ptr<aura::Window> w2(CreateTestWindowInShellWithDelegateAndType( |
518 NULL, aura::client::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20))); | 519 NULL, aura::client::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20))); |
519 wm::GetWindowState(w2.get())->Maximize(); | 520 wm::GetWindowState(w2.get())->Maximize(); |
520 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); | 521 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); |
521 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized()); | 522 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized()); |
522 | 523 |
(...skipping 24 matching lines...) Expand all Loading... | |
547 TEST_P(DockedWindowResizerTest, AttachOnTwoSides) { | 548 TEST_P(DockedWindowResizerTest, AttachOnTwoSides) { |
548 if (!SupportsHostWindowResize()) | 549 if (!SupportsHostWindowResize()) |
549 return; | 550 return; |
550 | 551 |
551 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 552 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
552 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 553 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
553 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 554 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
554 gfx::Rect initial_bounds(w2->bounds()); | 555 gfx::Rect initial_bounds(w2->bounds()); |
555 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w2.get(), 50); | 556 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w2.get(), 50); |
556 | 557 |
557 // The first window should be attached and snapped to the right edge. | 558 // The first window should be docked at the right edge. |
558 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 559 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
559 w1->GetBoundsInScreen().right()); | 560 w1->GetBoundsInScreen().right()); |
560 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 561 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
561 | 562 |
562 // The second window should be near the left edge but not snapped. | 563 // The second window should be near the left edge but not snapped. |
563 // Normal window will get side-maximized while panels will not. | 564 // Normal window will get side-maximized while panels will not. |
564 int expected_x = test_panels() ? | 565 int expected_x = test_panels() ? |
565 (initial_bounds.x() - initial_location_in_parent().x()) : 0; | 566 (initial_bounds.x() - initial_location_in_parent().x()) : 0; |
566 EXPECT_EQ(expected_x, w2->GetBoundsInScreen().x()); | 567 EXPECT_EQ(expected_x, w2->GetBoundsInScreen().x()); |
567 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); | 568 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); |
568 } | 569 } |
569 | 570 |
570 // Tests that reverting a drag restores docked state if a window was docked. | 571 // Tests that reverting a drag restores docked state if a window was docked. |
571 TEST_P(DockedWindowResizerTest, RevertDragRestoresAttachment) { | 572 TEST_P(DockedWindowResizerTest, RevertDragRestoresAttachment) { |
572 if (!SupportsHostWindowResize()) | 573 if (!SupportsHostWindowResize()) |
573 return; | 574 return; |
574 | 575 |
575 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 576 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
576 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 577 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
577 | 578 |
578 // The window should be attached and snapped to the right edge. | 579 // The window should be docked at the right edge. |
579 EXPECT_EQ(window->GetRootWindow()->bounds().right(), | 580 EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
580 window->GetBoundsInScreen().right()); | 581 window->GetBoundsInScreen().right()); |
581 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 582 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
582 | 583 |
583 // Drag the window out but revert the drag | 584 // Drag the window out but revert the drag |
584 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); | 585 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); |
585 DragMove(-50, 0); | 586 DragMove(-50, 0); |
586 DragRevert(); | 587 DragRevert(); |
587 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 588 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
588 | 589 |
(...skipping 25 matching lines...) Expand all Loading... | |
614 return; | 615 return; |
615 | 616 |
616 UpdateDisplay("800x800,800x800"); | 617 UpdateDisplay("800x800,800x800"); |
617 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 618 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
618 EXPECT_EQ(2, static_cast<int>(root_windows.size())); | 619 EXPECT_EQ(2, static_cast<int>(root_windows.size())); |
619 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 620 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
620 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 621 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
621 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 622 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
622 | 623 |
623 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 624 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
624 // The window should be attached and snapped to the right edge. | 625 // The window should be docked at the right edge. |
625 EXPECT_EQ(window->GetRootWindow()->bounds().right(), | 626 EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
626 window->GetBoundsInScreen().right()); | 627 window->GetBoundsInScreen().right()); |
627 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 628 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
628 | 629 |
629 // Try dragging to the right - enough to get it peeking at the other screen | 630 // Try dragging to the right - enough to get it peeking at the other screen |
630 // but not enough to land in the other screen. | 631 // but not enough to land in the other screen. |
631 // The window should stay on the left screen. | 632 // The window should stay on the left screen. |
632 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); | 633 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); |
633 DragMove(100, 0); | 634 DragMove(100, 0); |
634 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); | 635 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
679 return; | 680 return; |
680 UpdateDisplay("600x600"); | 681 UpdateDisplay("600x600"); |
681 | 682 |
682 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 683 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
683 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); | 684 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); |
684 // Work area should cover the whole screen. | 685 // Work area should cover the whole screen. |
685 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width(), | 686 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width(), |
686 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 687 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
687 | 688 |
688 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 689 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
689 // A window should be attached and snapped to the right edge. | 690 // A window should be docked at the right edge. |
690 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 691 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
691 w1->GetBoundsInScreen().right()); | 692 w1->GetBoundsInScreen().right()); |
692 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 693 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
693 DockedWindowLayoutManager* manager = | 694 DockedWindowLayoutManager* manager = |
694 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); | 695 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); |
695 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 696 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
696 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 697 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
697 | 698 |
698 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); | 699 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); |
699 // Both windows should now be attached and snapped to the right edge. | 700 // Both windows should now be docked at the right edge. |
700 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), | 701 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
701 w2->GetBoundsInScreen().right()); | 702 w2->GetBoundsInScreen().right()); |
702 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); | 703 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); |
703 // Dock width should be set to a wider window. | 704 // Dock width should be set to a wider window. |
704 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 705 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
705 EXPECT_EQ(std::max(w1->bounds().width(), w2->bounds().width()), | 706 EXPECT_EQ(std::max(w1->bounds().width(), w2->bounds().width()), |
706 docked_width(manager)); | 707 docked_width(manager)); |
707 | 708 |
708 // Try to detach by dragging left a bit (should not get undocked). | 709 // Try to detach by dragging left a bit (should not get undocked). |
709 // This would normally detach a single docked window but since we have another | 710 // This would normally detach a single docked window but since we have another |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
751 if (!SupportsHostWindowResize()) | 752 if (!SupportsHostWindowResize()) |
752 return; | 753 return; |
753 | 754 |
754 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 755 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
755 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); | 756 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); |
756 // Work area should cover the whole screen. | 757 // Work area should cover the whole screen. |
757 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width(), | 758 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width(), |
758 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 759 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
759 | 760 |
760 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 761 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
761 // A window should be attached and snapped to the right edge. | 762 // A window should be docked at the right edge. |
762 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 763 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
763 w1->GetBoundsInScreen().right()); | 764 w1->GetBoundsInScreen().right()); |
764 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 765 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
765 DockedWindowLayoutManager* manager = | 766 DockedWindowLayoutManager* manager = |
766 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); | 767 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); |
767 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 768 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
768 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 769 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
769 | 770 |
770 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(w2.get(), 25, 5)); | 771 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(w2.get(), 25, 5)); |
771 DragMove(w2->GetRootWindow()->bounds().right() | 772 DragMove(w2->GetRootWindow()->bounds().right() |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
850 if (!SupportsHostWindowResize()) | 851 if (!SupportsHostWindowResize()) |
851 return; | 852 return; |
852 | 853 |
853 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 854 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
854 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); | 855 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); |
855 // Work area should cover the whole screen. | 856 // Work area should cover the whole screen. |
856 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width(), | 857 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width(), |
857 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 858 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
858 | 859 |
859 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w1.get(), 20); | 860 DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w1.get(), 20); |
860 // A window should be attached and snapped to the left edge. | 861 // A window should be docked at the left edge. |
861 EXPECT_EQ(w1->GetRootWindow()->bounds().x(), | 862 EXPECT_EQ(w1->GetRootWindow()->bounds().x(), |
862 w1->GetBoundsInScreen().x()); | 863 w1->GetBoundsInScreen().x()); |
863 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 864 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
864 DockedWindowLayoutManager* manager = | 865 DockedWindowLayoutManager* manager = |
865 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); | 866 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); |
866 // The first window should be docked. | 867 // The first window should be docked. |
867 EXPECT_EQ(w1->GetRootWindow()->bounds().x(), | 868 EXPECT_EQ(w1->GetRootWindow()->bounds().x(), |
868 w1->GetBoundsInScreen().x()); | 869 w1->GetBoundsInScreen().x()); |
869 // Dock width should be set to that of a single docked window. | 870 // Dock width should be set to that of a single docked window. |
870 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 871 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
949 | 950 |
950 // Wider display to start since panels are limited to half the display width. | 951 // Wider display to start since panels are limited to half the display width. |
951 UpdateDisplay("1000x600"); | 952 UpdateDisplay("1000x600"); |
952 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 953 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
953 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); | 954 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); |
954 // Work area should cover the whole screen. | 955 // Work area should cover the whole screen. |
955 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width(), | 956 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width(), |
956 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); | 957 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); |
957 | 958 |
958 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 959 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
959 // A window should be attached and snapped to the right edge. | 960 // A window should be docked at the right edge. |
960 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 961 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
961 w1->GetBoundsInScreen().right()); | 962 w1->GetBoundsInScreen().right()); |
962 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 963 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
963 DockedWindowLayoutManager* manager = | 964 DockedWindowLayoutManager* manager = |
964 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); | 965 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); |
965 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 966 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
966 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 967 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
967 | 968 |
968 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); | 969 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 100); |
969 // Both windows should now be attached and snapped to the right edge. | 970 // Both windows should now be docked at the right edge. |
970 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), | 971 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
971 w2->GetBoundsInScreen().right()); | 972 w2->GetBoundsInScreen().right()); |
972 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); | 973 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); |
973 // Dock width should be set to a wider window. | 974 // Dock width should be set to a wider window. |
974 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 975 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
975 EXPECT_EQ(std::max(w1->bounds().width(), w2->bounds().width()), | 976 EXPECT_EQ(std::max(w1->bounds().width(), w2->bounds().width()), |
976 docked_width(manager)); | 977 docked_width(manager)); |
977 | 978 |
978 // Resize the first window left by a bit and test that the dock expands. | 979 // Resize the first window left by a bit and test that the dock expands. |
979 int previous_width = w1->bounds().width(); | 980 int previous_width = w1->bounds().width(); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1090 // Dock a window, resize it and test that undocking it preserves the width. | 1091 // Dock a window, resize it and test that undocking it preserves the width. |
1091 TEST_P(DockedWindowResizerTest, ResizingKeepsWidth) { | 1092 TEST_P(DockedWindowResizerTest, ResizingKeepsWidth) { |
1092 if (!SupportsHostWindowResize()) | 1093 if (!SupportsHostWindowResize()) |
1093 return; | 1094 return; |
1094 | 1095 |
1095 // Wider display to start since panels are limited to half the display width. | 1096 // Wider display to start since panels are limited to half the display width. |
1096 UpdateDisplay("1000x600"); | 1097 UpdateDisplay("1000x600"); |
1097 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 1098 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
1098 | 1099 |
1099 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1100 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
1100 // A window should be attached and snapped to the right edge. | 1101 // A window should be docked at the right edge. |
1101 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), | 1102 EXPECT_EQ(w1->GetRootWindow()->GetBoundsInScreen().right(), |
1102 w1->GetBoundsInScreen().right()); | 1103 w1->GetBoundsInScreen().right()); |
1103 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 1104 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
1104 DockedWindowLayoutManager* manager = | 1105 DockedWindowLayoutManager* manager = |
1105 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); | 1106 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); |
1106 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1107 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1107 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1108 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
1108 | 1109 |
1109 // Resize the window left by a bit and test that the dock expands. | 1110 // Resize the window left by a bit and test that the dock expands. |
1110 int previous_width = w1->bounds().width(); | 1111 int previous_width = w1->bounds().width(); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1219 TEST_P(DockedWindowResizerTest, DragToShelf) { | 1220 TEST_P(DockedWindowResizerTest, DragToShelf) { |
1220 if (!SupportsHostWindowResize()) | 1221 if (!SupportsHostWindowResize()) |
1221 return; | 1222 return; |
1222 | 1223 |
1223 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 1224 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
1224 // Work area should cover the whole screen. | 1225 // Work area should cover the whole screen. |
1225 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w1.get()).width(), | 1226 EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w1.get()).width(), |
1226 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w1.get()).width()); | 1227 ScreenAsh::GetDisplayWorkAreaBoundsInParent(w1.get()).width()); |
1227 | 1228 |
1228 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 1229 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
1229 // A window should be attached and snapped to the right edge. | 1230 // A window should be docked at the right edge. |
1230 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 1231 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
1231 w1->GetBoundsInScreen().right()); | 1232 w1->GetBoundsInScreen().right()); |
1232 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | 1233 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); |
1233 DockedWindowLayoutManager* manager = | 1234 DockedWindowLayoutManager* manager = |
1234 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); | 1235 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); |
1235 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | 1236 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); |
1236 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | 1237 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); |
1237 | 1238 |
1238 // Detach and drag down to shelf. | 1239 // Detach and drag down to shelf. |
1239 ASSERT_NO_FATAL_FAILURE(DragStart(w1.get())); | 1240 ASSERT_NO_FATAL_FAILURE(DragStart(w1.get())); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1271 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 1272 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
1272 scoped_ptr<aura::Window> child(CreateTestWindowInShellWithDelegateAndType( | 1273 scoped_ptr<aura::Window> child(CreateTestWindowInShellWithDelegateAndType( |
1273 NULL, aura::client::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20))); | 1274 NULL, aura::client::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20))); |
1274 window->AddTransientChild(child.get()); | 1275 window->AddTransientChild(child.get()); |
1275 if (window->parent() != child->parent()) | 1276 if (window->parent() != child->parent()) |
1276 window->parent()->AddChild(child.get()); | 1277 window->parent()->AddChild(child.get()); |
1277 EXPECT_EQ(window.get(), child->transient_parent()); | 1278 EXPECT_EQ(window.get(), child->transient_parent()); |
1278 | 1279 |
1279 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20); | 1280 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20); |
1280 | 1281 |
1281 // A window should be attached and snapped to the right edge. | 1282 // A window should be docked at the right edge. |
1282 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); | 1283 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); |
1283 EXPECT_EQ(internal::kShellWindowId_DockedContainer, child->parent()->id()); | 1284 EXPECT_EQ(internal::kShellWindowId_DockedContainer, child->parent()->id()); |
1284 | 1285 |
1285 // Drag the child - it should move freely and stay where it is dragged. | 1286 // Drag the child - it should move freely and stay where it is dragged. |
1286 ASSERT_NO_FATAL_FAILURE(DragStart(child.get())); | 1287 ASSERT_NO_FATAL_FAILURE(DragStart(child.get())); |
1287 DragMove(500, 20); | 1288 DragMove(500, 20); |
1288 DragEnd(); | 1289 DragEnd(); |
1289 EXPECT_EQ(gfx::Point(20 + 500, 20 + 20).ToString(), | 1290 EXPECT_EQ(gfx::Point(20 + 500, 20 + 20).ToString(), |
1290 child->GetBoundsInScreen().origin().ToString()); | 1291 child->GetBoundsInScreen().origin().ToString()); |
1291 | 1292 |
1292 // Undock the window by dragging left. | 1293 // Undock the window by dragging left. |
1293 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); | 1294 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); |
1294 DragMove(-32, -10); | 1295 DragMove(-32, -10); |
1295 DragEnd(); | 1296 DragEnd(); |
1296 | 1297 |
1297 // The window should be undocked and the transient child should be reparented. | 1298 // The window should be undocked and the transient child should be reparented. |
1298 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); | 1299 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); |
1299 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, child->parent()->id()); | 1300 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, child->parent()->id()); |
1300 // The child should not have moved. | 1301 // The child should not have moved. |
1301 EXPECT_EQ(gfx::Point(20 + 500, 20 + 20).ToString(), | 1302 EXPECT_EQ(gfx::Point(20 + 500, 20 + 20).ToString(), |
1302 child->GetBoundsInScreen().origin().ToString()); | 1303 child->GetBoundsInScreen().origin().ToString()); |
1303 } | 1304 } |
1304 | 1305 |
1306 // Tests that side snapping a window undocks it, closes the dock and then snaps. | |
1307 TEST_P(DockedWindowResizerTest, SideSnapDocked) { | |
1308 if (!SupportsHostWindowResize() || test_panels()) | |
1309 return; | |
1310 | |
1311 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | |
1312 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | |
1313 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | |
1314 // A window should be docked at the right edge. | |
1315 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | |
1316 w1->GetBoundsInScreen().right()); | |
1317 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | |
1318 DockedWindowLayoutManager* manager = | |
1319 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); | |
1320 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | |
1321 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | |
1322 EXPECT_TRUE(window_state->IsDocked()); | |
1323 EXPECT_FALSE(window_state->IsSnapped()); | |
1324 | |
1325 // Side snap at right edge. | |
1326 internal::SnapSizer::SnapWindow(window_state, | |
1327 internal::SnapSizer::RIGHT_EDGE); | |
1328 // The window should be snapped at the right edge and the dock should close. | |
1329 EXPECT_EQ(0, docked_width(manager)); | |
1330 EXPECT_EQ(ScreenAsh::GetDisplayWorkAreaBoundsInParent(w1.get()).height(), | |
pkotwicz
2013/11/28 06:15:10
Nit: You could probably cache the work area bounds
varkha
2013/11/28 15:39:40
Done.
| |
1331 w1->bounds().height()); | |
1332 EXPECT_EQ(ScreenAsh::GetDisplayWorkAreaBoundsInParent(w1.get()).right(), | |
1333 w1->bounds().right()); | |
1334 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w1->parent()->id()); | |
1335 EXPECT_FALSE(window_state->IsDocked()); | |
1336 EXPECT_TRUE(window_state->IsSnapped()); | |
1337 | |
1338 // Dock again. | |
1339 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | |
1340 // A window should be docked at the right edge. | |
1341 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | |
1342 w1->GetBoundsInScreen().right()); | |
1343 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | |
1344 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | |
1345 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | |
1346 EXPECT_TRUE(window_state->IsDocked()); | |
1347 EXPECT_FALSE(window_state->IsSnapped()); | |
1348 | |
1349 // Side snap at left edge. | |
1350 internal::SnapSizer::SnapWindow(window_state, | |
1351 internal::SnapSizer::LEFT_EDGE); | |
1352 // The window should be snapped at the right edge and the dock should close. | |
1353 EXPECT_EQ(0, docked_width(manager)); | |
1354 EXPECT_EQ(ScreenAsh::GetDisplayWorkAreaBoundsInParent(w1.get()).height(), | |
1355 w1->bounds().height()); | |
1356 EXPECT_EQ(ScreenAsh::GetDisplayWorkAreaBoundsInParent(w1.get()).x(), | |
1357 w1->bounds().x()); | |
1358 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w1->parent()->id()); | |
1359 EXPECT_FALSE(window_state->IsDocked()); | |
1360 EXPECT_TRUE(window_state->IsSnapped()); | |
1361 } | |
1362 | |
1305 // Tests run twice - on both panels and normal windows | 1363 // Tests run twice - on both panels and normal windows |
1306 INSTANTIATE_TEST_CASE_P(NormalOrPanel, | 1364 INSTANTIATE_TEST_CASE_P(NormalOrPanel, |
1307 DockedWindowResizerTest, | 1365 DockedWindowResizerTest, |
1308 testing::Values(aura::client::WINDOW_TYPE_NORMAL, | 1366 testing::Values(aura::client::WINDOW_TYPE_NORMAL, |
1309 aura::client::WINDOW_TYPE_PANEL)); | 1367 aura::client::WINDOW_TYPE_PANEL)); |
1310 } // namespace internal | 1368 } // namespace internal |
1311 } // namespace ash | 1369 } // namespace ash |
OLD | NEW |