| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/common/wm/dock/docked_window_layout_manager.h" | 5 #include "ash/common/wm/dock/docked_window_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/common/ash_switches.h" | 7 #include "ash/common/ash_switches.h" |
| 8 #include "ash/common/shelf/wm_shelf.h" | 8 #include "ash/common/shelf/wm_shelf.h" |
| 9 #include "ash/common/test/test_shelf_delegate.h" | 9 #include "ash/common/test/test_shelf_delegate.h" |
| 10 #include "ash/common/wm/panels/panel_layout_manager.h" | 10 #include "ash/common/wm/panels/panel_layout_manager.h" |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 EXPECT_EQ(base::IntToString(desktop_area.width() - window2->bounds().width() - | 316 EXPECT_EQ(base::IntToString(desktop_area.width() - window2->bounds().width() - |
| 317 docked_width(manager) - min_dock_gap()) + | 317 docked_width(manager) - min_dock_gap()) + |
| 318 ",48 256x512", | 318 ",48 256x512", |
| 319 window2->bounds().ToString()); | 319 window2->bounds().ToString()); |
| 320 } | 320 } |
| 321 | 321 |
| 322 // Tests that with a window docked on the right the auto-placing logic in | 322 // Tests that with a window docked on the right the auto-placing logic in |
| 323 // RearrangeVisibleWindowOnShow places windows flush with work area edges. | 323 // RearrangeVisibleWindowOnShow places windows flush with work area edges. |
| 324 // Test case for the secondary screen. | 324 // Test case for the secondary screen. |
| 325 TEST_P(DockedWindowLayoutManagerTest, AutoPlacingRightSecondScreen) { | 325 TEST_P(DockedWindowLayoutManagerTest, AutoPlacingRightSecondScreen) { |
| 326 if (!SupportsMultipleDisplays()) | |
| 327 return; | |
| 328 | |
| 329 // Create a dual screen layout. | 326 // Create a dual screen layout. |
| 330 UpdateDisplay("600x600,600x600"); | 327 UpdateDisplay("600x600,600x600"); |
| 331 | 328 |
| 332 gfx::Rect bounds(600, 0, 201, 201); | 329 gfx::Rect bounds(600, 0, 201, 201); |
| 333 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); | 330 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); |
| 334 // Drag pointer to the right edge of the second screen. | 331 // Drag pointer to the right edge of the second screen. |
| 335 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 332 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
| 336 | 333 |
| 337 // The window should be attached and snapped to the right side of the screen. | 334 // The window should be attached and snapped to the right side of the screen. |
| 338 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 335 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 gap3 = w3->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom(); | 489 gap3 = w3->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom(); |
| 493 gap4 = work_area.bottom() - w3->GetBoundsInScreen().bottom(); | 490 gap4 = work_area.bottom() - w3->GetBoundsInScreen().bottom(); |
| 494 EXPECT_EQ(0, gap1); | 491 EXPECT_EQ(0, gap1); |
| 495 EXPECT_NEAR(gap2, min_dock_gap(), 1); | 492 EXPECT_NEAR(gap2, min_dock_gap(), 1); |
| 496 EXPECT_NEAR(gap3, min_dock_gap(), 1); | 493 EXPECT_NEAR(gap3, min_dock_gap(), 1); |
| 497 EXPECT_EQ(0, gap4); | 494 EXPECT_EQ(0, gap4); |
| 498 } | 495 } |
| 499 | 496 |
| 500 // Adds three windows in bottom display and tests layout after a drag. | 497 // Adds three windows in bottom display and tests layout after a drag. |
| 501 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsDraggingSecondScreen) { | 498 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsDraggingSecondScreen) { |
| 502 if (!SupportsMultipleDisplays()) | |
| 503 return; | |
| 504 | |
| 505 // Create two screen vertical layout. | 499 // Create two screen vertical layout. |
| 506 UpdateDisplay("600x1000,600x1000"); | 500 UpdateDisplay("600x1000,600x1000"); |
| 507 // Layout the secondary display to the bottom of the primary. | 501 // Layout the secondary display to the bottom of the primary. |
| 508 ASSERT_GT(display::Screen::GetScreen()->GetNumDisplays(), 1); | 502 ASSERT_GT(display::Screen::GetScreen()->GetNumDisplays(), 1); |
| 509 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( | 503 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
| 510 display::test::CreateDisplayLayout(display_manager(), | 504 display::test::CreateDisplayLayout(display_manager(), |
| 511 display::DisplayPlacement::BOTTOM, 0)); | 505 display::DisplayPlacement::BOTTOM, 0)); |
| 512 | 506 |
| 513 std::unique_ptr<aura::Window> w1( | 507 std::unique_ptr<aura::Window> w1( |
| 514 CreateTestWindow(gfx::Rect(0, 1000, 201, 310))); | 508 CreateTestWindow(gfx::Rect(0, 1000, 201, 310))); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 gfx::Rect work_area = display::Screen::GetScreen() | 763 gfx::Rect work_area = display::Screen::GetScreen() |
| 770 ->GetDisplayNearestWindow(w1.get()) | 764 ->GetDisplayNearestWindow(w1.get()) |
| 771 .work_area(); | 765 .work_area(); |
| 772 EXPECT_GT(w1->GetBoundsInScreen().height(), work_area.height() / 2 + 10); | 766 EXPECT_GT(w1->GetBoundsInScreen().height(), work_area.height() / 2 + 10); |
| 773 EXPECT_LT(w2->GetBoundsInScreen().height(), work_area.height() / 2 - 10); | 767 EXPECT_LT(w2->GetBoundsInScreen().height(), work_area.height() / 2 - 10); |
| 774 } | 768 } |
| 775 | 769 |
| 776 // Tests that a docked window is moved to primary display when secondary display | 770 // Tests that a docked window is moved to primary display when secondary display |
| 777 // is disconnected and that it stays docked and properly positioned. | 771 // is disconnected and that it stays docked and properly positioned. |
| 778 TEST_P(DockedWindowLayoutManagerTest, DisplayDisconnectionMovesDocked) { | 772 TEST_P(DockedWindowLayoutManagerTest, DisplayDisconnectionMovesDocked) { |
| 779 if (!SupportsMultipleDisplays()) | |
| 780 return; | |
| 781 | |
| 782 // Create a dual screen layout. | 773 // Create a dual screen layout. |
| 783 UpdateDisplay("600x700,800x600"); | 774 UpdateDisplay("600x700,800x600"); |
| 784 | 775 |
| 785 gfx::Rect bounds(600, 0, 201, 201); | 776 gfx::Rect bounds(600, 0, 201, 201); |
| 786 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); | 777 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); |
| 787 // Drag pointer to the right edge of the second screen. | 778 // Drag pointer to the right edge of the second screen. |
| 788 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 779 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
| 789 | 780 |
| 790 // Simulate disconnection of the secondary display. | 781 // Simulate disconnection of the secondary display. |
| 791 UpdateDisplay("600x700"); | 782 UpdateDisplay("600x700"); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 802 EXPECT_EQ(work_area.height(), window->GetBoundsInScreen().height()); | 793 EXPECT_EQ(work_area.height(), window->GetBoundsInScreen().height()); |
| 803 } | 794 } |
| 804 | 795 |
| 805 // Tests run twice - on both panels and normal windows | 796 // Tests run twice - on both panels and normal windows |
| 806 INSTANTIATE_TEST_CASE_P(NormalOrPanel, | 797 INSTANTIATE_TEST_CASE_P(NormalOrPanel, |
| 807 DockedWindowLayoutManagerTest, | 798 DockedWindowLayoutManagerTest, |
| 808 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, | 799 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, |
| 809 ui::wm::WINDOW_TYPE_PANEL)); | 800 ui::wm::WINDOW_TYPE_PANEL)); |
| 810 | 801 |
| 811 } // namespace ash | 802 } // namespace ash |
| OLD | NEW |