| 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" |
| 11 #include "ash/common/wm/window_resizer.h" | 11 #include "ash/common/wm/window_resizer.h" |
| 12 #include "ash/common/wm/window_state.h" | 12 #include "ash/common/wm/window_state.h" |
| 13 #include "ash/common/wm_shell.h" |
| 13 #include "ash/common/wm_window.h" | 14 #include "ash/common/wm_window.h" |
| 14 #include "ash/public/cpp/shell_window_ids.h" | 15 #include "ash/public/cpp/shell_window_ids.h" |
| 15 #include "ash/root_window_controller.h" | 16 #include "ash/root_window_controller.h" |
| 16 #include "ash/shell.h" | 17 #include "ash/shell.h" |
| 17 #include "ash/test/ash_test_base.h" | 18 #include "ash/test/ash_test_base.h" |
| 18 #include "ash/test/shelf_view_test_api.h" | 19 #include "ash/test/shelf_view_test_api.h" |
| 19 #include "ash/test/shell_test_api.h" | 20 #include "ash/test/shell_test_api.h" |
| 20 #include "ash/wm/window_state_aura.h" | 21 #include "ash/wm/window_state_aura.h" |
| 21 #include "ash/wm/window_util.h" | 22 #include "ash/wm/window_util.h" |
| 22 #include "base/command_line.h" | 23 #include "base/command_line.h" |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 EXPECT_EQ(base::IntToString(desktop_area.width() - window2->bounds().width() - | 317 EXPECT_EQ(base::IntToString(desktop_area.width() - window2->bounds().width() - |
| 317 docked_width(manager) - min_dock_gap()) + | 318 docked_width(manager) - min_dock_gap()) + |
| 318 ",48 256x512", | 319 ",48 256x512", |
| 319 window2->bounds().ToString()); | 320 window2->bounds().ToString()); |
| 320 } | 321 } |
| 321 | 322 |
| 322 // Tests that with a window docked on the right the auto-placing logic in | 323 // Tests that with a window docked on the right the auto-placing logic in |
| 323 // RearrangeVisibleWindowOnShow places windows flush with work area edges. | 324 // RearrangeVisibleWindowOnShow places windows flush with work area edges. |
| 324 // Test case for the secondary screen. | 325 // Test case for the secondary screen. |
| 325 TEST_P(DockedWindowLayoutManagerTest, AutoPlacingRightSecondScreen) { | 326 TEST_P(DockedWindowLayoutManagerTest, AutoPlacingRightSecondScreen) { |
| 327 // TODO: investigate failure in mash. http://crbug.com/698049. |
| 328 if (WmShell::Get()->IsRunningInMash()) |
| 329 return; |
| 330 |
| 326 // Create a dual screen layout. | 331 // Create a dual screen layout. |
| 327 UpdateDisplay("600x600,600x600"); | 332 UpdateDisplay("600x600,600x600"); |
| 328 | 333 |
| 329 gfx::Rect bounds(600, 0, 201, 201); | 334 gfx::Rect bounds(600, 0, 201, 201); |
| 330 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); | 335 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); |
| 331 // Drag pointer to the right edge of the second screen. | 336 // Drag pointer to the right edge of the second screen. |
| 332 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 337 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
| 333 | 338 |
| 334 // The window should be attached and snapped to the right side of the screen. | 339 // The window should be attached and snapped to the right side of the screen. |
| 335 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 340 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 gap3 = w3->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom(); | 494 gap3 = w3->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom(); |
| 490 gap4 = work_area.bottom() - w3->GetBoundsInScreen().bottom(); | 495 gap4 = work_area.bottom() - w3->GetBoundsInScreen().bottom(); |
| 491 EXPECT_EQ(0, gap1); | 496 EXPECT_EQ(0, gap1); |
| 492 EXPECT_NEAR(gap2, min_dock_gap(), 1); | 497 EXPECT_NEAR(gap2, min_dock_gap(), 1); |
| 493 EXPECT_NEAR(gap3, min_dock_gap(), 1); | 498 EXPECT_NEAR(gap3, min_dock_gap(), 1); |
| 494 EXPECT_EQ(0, gap4); | 499 EXPECT_EQ(0, gap4); |
| 495 } | 500 } |
| 496 | 501 |
| 497 // Adds three windows in bottom display and tests layout after a drag. | 502 // Adds three windows in bottom display and tests layout after a drag. |
| 498 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsDraggingSecondScreen) { | 503 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsDraggingSecondScreen) { |
| 504 // TODO: SetLayoutForCurrentDisplays() needs to ported to mash. |
| 505 // http://crbug.com/698043. |
| 506 if (WmShell::Get()->IsRunningInMash()) |
| 507 return; |
| 508 |
| 499 // Create two screen vertical layout. | 509 // Create two screen vertical layout. |
| 500 UpdateDisplay("600x1000,600x1000"); | 510 UpdateDisplay("600x1000,600x1000"); |
| 501 // Layout the secondary display to the bottom of the primary. | 511 // Layout the secondary display to the bottom of the primary. |
| 502 ASSERT_GT(display::Screen::GetScreen()->GetNumDisplays(), 1); | 512 ASSERT_GT(display::Screen::GetScreen()->GetNumDisplays(), 1); |
| 503 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( | 513 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
| 504 display::test::CreateDisplayLayout(display_manager(), | 514 display::test::CreateDisplayLayout(display_manager(), |
| 505 display::DisplayPlacement::BOTTOM, 0)); | 515 display::DisplayPlacement::BOTTOM, 0)); |
| 506 | 516 |
| 507 std::unique_ptr<aura::Window> w1( | 517 std::unique_ptr<aura::Window> w1( |
| 508 CreateTestWindow(gfx::Rect(0, 1000, 201, 310))); | 518 CreateTestWindow(gfx::Rect(0, 1000, 201, 310))); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 gfx::Rect work_area = display::Screen::GetScreen() | 773 gfx::Rect work_area = display::Screen::GetScreen() |
| 764 ->GetDisplayNearestWindow(w1.get()) | 774 ->GetDisplayNearestWindow(w1.get()) |
| 765 .work_area(); | 775 .work_area(); |
| 766 EXPECT_GT(w1->GetBoundsInScreen().height(), work_area.height() / 2 + 10); | 776 EXPECT_GT(w1->GetBoundsInScreen().height(), work_area.height() / 2 + 10); |
| 767 EXPECT_LT(w2->GetBoundsInScreen().height(), work_area.height() / 2 - 10); | 777 EXPECT_LT(w2->GetBoundsInScreen().height(), work_area.height() / 2 - 10); |
| 768 } | 778 } |
| 769 | 779 |
| 770 // Tests that a docked window is moved to primary display when secondary display | 780 // Tests that a docked window is moved to primary display when secondary display |
| 771 // is disconnected and that it stays docked and properly positioned. | 781 // is disconnected and that it stays docked and properly positioned. |
| 772 TEST_P(DockedWindowLayoutManagerTest, DisplayDisconnectionMovesDocked) { | 782 TEST_P(DockedWindowLayoutManagerTest, DisplayDisconnectionMovesDocked) { |
| 783 // TODO: investigate failure in mash. http://crbug.com/698049. |
| 784 if (WmShell::Get()->IsRunningInMash()) |
| 785 return; |
| 786 |
| 773 // Create a dual screen layout. | 787 // Create a dual screen layout. |
| 774 UpdateDisplay("600x700,800x600"); | 788 UpdateDisplay("600x700,800x600"); |
| 775 | 789 |
| 776 gfx::Rect bounds(600, 0, 201, 201); | 790 gfx::Rect bounds(600, 0, 201, 201); |
| 777 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); | 791 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); |
| 778 // Drag pointer to the right edge of the second screen. | 792 // Drag pointer to the right edge of the second screen. |
| 779 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 793 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
| 780 | 794 |
| 781 // Simulate disconnection of the secondary display. | 795 // Simulate disconnection of the secondary display. |
| 782 UpdateDisplay("600x700"); | 796 UpdateDisplay("600x700"); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 793 EXPECT_EQ(work_area.height(), window->GetBoundsInScreen().height()); | 807 EXPECT_EQ(work_area.height(), window->GetBoundsInScreen().height()); |
| 794 } | 808 } |
| 795 | 809 |
| 796 // Tests run twice - on both panels and normal windows | 810 // Tests run twice - on both panels and normal windows |
| 797 INSTANTIATE_TEST_CASE_P(NormalOrPanel, | 811 INSTANTIATE_TEST_CASE_P(NormalOrPanel, |
| 798 DockedWindowLayoutManagerTest, | 812 DockedWindowLayoutManagerTest, |
| 799 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, | 813 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, |
| 800 ui::wm::WINDOW_TYPE_PANEL)); | 814 ui::wm::WINDOW_TYPE_PANEL)); |
| 801 | 815 |
| 802 } // namespace ash | 816 } // namespace ash |
| OLD | NEW |