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/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/screen_ash.h" | 9 #include "ash/screen_ash.h" |
10 #include "ash/shelf/shelf.h" | 10 #include "ash/shelf/shelf.h" |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 DragEnd(); | 617 DragEnd(); |
618 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, | 618 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, |
619 window->parent()->id()); | 619 window->parent()->id()); |
620 } | 620 } |
621 | 621 |
622 // Tests that reverting drag restores undocked state if a window was not docked. | 622 // Tests that reverting drag restores undocked state if a window was not docked. |
623 TEST_P(DockedWindowResizerTest, RevertDockedDragRevertsAttachment) { | 623 TEST_P(DockedWindowResizerTest, RevertDockedDragRevertsAttachment) { |
624 if (!SupportsHostWindowResize()) | 624 if (!SupportsHostWindowResize()) |
625 return; | 625 return; |
626 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 626 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
| 627 aura::Window* dock_container = Shell::GetContainer( |
| 628 window->GetRootWindow(), |
| 629 kShellWindowId_DockedContainer); |
| 630 DockedWindowLayoutManager* manager = |
| 631 static_cast<DockedWindowLayoutManager*>(dock_container->layout_manager()); |
627 int previous_container_id = window->parent()->id(); | 632 int previous_container_id = window->parent()->id(); |
628 // Drag the window out but revert the drag | 633 // Drag the window out but revert the drag |
629 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); | 634 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); |
630 DragMove(-50 - window->bounds().x(), 50 - window->bounds().y()); | 635 DragMove(-50 - window->bounds().x(), 50 - window->bounds().y()); |
631 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); | 636 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); |
632 DragRevert(); | 637 DragRevert(); |
633 EXPECT_EQ(previous_container_id, window->parent()->id()); | 638 EXPECT_EQ(previous_container_id, window->parent()->id()); |
| 639 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); |
| 640 |
| 641 // Drag a window to the left so that it overlaps the screen edge. |
| 642 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( |
| 643 window.get(), |
| 644 window->bounds().width()/2 + 10, |
| 645 0)); |
| 646 DragMove(-50 - window->bounds().x(), 50 - window->bounds().y()); |
| 647 DragEnd(); |
| 648 // The window now overlaps the left screen edge but is not docked. |
| 649 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
| 650 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); |
| 651 EXPECT_LT(window->bounds().x(), 0); |
| 652 EXPECT_GT(window->bounds().right(), 0); |
| 653 |
| 654 // Drag the window further left and revert the drag. |
| 655 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin( |
| 656 window.get(), |
| 657 window->bounds().width()/2 + 10, |
| 658 0)); |
| 659 DragMove(-10, 10); |
| 660 DragRevert(); |
| 661 // The window should be in default container and not docked. |
| 662 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
| 663 // Docked area alignment should be cleared. |
| 664 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); |
634 } | 665 } |
635 | 666 |
636 // Move a docked window to the second display | 667 // Move a docked window to the second display |
637 TEST_P(DockedWindowResizerTest, DragAcrossDisplays) { | 668 TEST_P(DockedWindowResizerTest, DragAcrossDisplays) { |
638 if (!SupportsMultipleDisplays()) | 669 if (!SupportsMultipleDisplays()) |
639 return; | 670 return; |
640 | 671 |
641 UpdateDisplay("800x800,800x800"); | 672 UpdateDisplay("800x800,800x800"); |
642 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 673 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
643 EXPECT_EQ(2, static_cast<int>(root_windows.size())); | 674 EXPECT_EQ(2, static_cast<int>(root_windows.size())); |
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1484 EXPECT_TRUE(window_state->IsSnapped()); | 1515 EXPECT_TRUE(window_state->IsSnapped()); |
1485 } | 1516 } |
1486 | 1517 |
1487 // Tests run twice - on both panels and normal windows | 1518 // Tests run twice - on both panels and normal windows |
1488 INSTANTIATE_TEST_CASE_P(NormalOrPanel, | 1519 INSTANTIATE_TEST_CASE_P(NormalOrPanel, |
1489 DockedWindowResizerTest, | 1520 DockedWindowResizerTest, |
1490 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, | 1521 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, |
1491 ui::wm::WINDOW_TYPE_PANEL)); | 1522 ui::wm::WINDOW_TYPE_PANEL)); |
1492 } // namespace internal | 1523 } // namespace internal |
1493 } // namespace ash | 1524 } // namespace ash |
OLD | NEW |