| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/panels/panel_layout_manager.h" | 5 #include "ash/common/wm/panels/panel_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/common/shelf/shelf_button.h" | 7 #include "ash/common/shelf/shelf_button.h" |
| 8 #include "ash/common/shelf/shelf_layout_manager.h" | 8 #include "ash/common/shelf/shelf_layout_manager.h" |
| 9 #include "ash/common/shelf/shelf_model.h" | 9 #include "ash/common/shelf/shelf_model.h" |
| 10 #include "ash/common/shelf/shelf_view.h" | 10 #include "ash/common/shelf/shelf_view.h" |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 gfx::Rect bounds(0, 0, 201, 201); | 379 gfx::Rect bounds(0, 0, 201, 201); |
| 380 SetShelfAutoHideBehavior(Shell::GetPrimaryRootWindow(), | 380 SetShelfAutoHideBehavior(Shell::GetPrimaryRootWindow(), |
| 381 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 381 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 382 std::unique_ptr<aura::Window> normal_window(CreateNormalWindow(bounds)); | 382 std::unique_ptr<aura::Window> normal_window(CreateNormalWindow(bounds)); |
| 383 std::unique_ptr<aura::Window> window(CreatePanelWindow(bounds)); | 383 std::unique_ptr<aura::Window> window(CreatePanelWindow(bounds)); |
| 384 EXPECT_EQ(GetPanelContainer(window.get()), window->parent()); | 384 EXPECT_EQ(GetPanelContainer(window.get()), window->parent()); |
| 385 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); | 385 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); |
| 386 } | 386 } |
| 387 | 387 |
| 388 TEST_F(PanelLayoutManagerTest, PanelAlignsToHiddenLauncherIconSecondDisplay) { | 388 TEST_F(PanelLayoutManagerTest, PanelAlignsToHiddenLauncherIconSecondDisplay) { |
| 389 if (!SupportsMultipleDisplays()) | |
| 390 return; | |
| 391 | |
| 392 // Keep the displays wide so that shelves have enough space for shelves | 389 // Keep the displays wide so that shelves have enough space for shelves |
| 393 // buttons. | 390 // buttons. |
| 394 UpdateDisplay("400x400,600x400"); | 391 UpdateDisplay("400x400,600x400"); |
| 395 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 392 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 396 | 393 |
| 397 std::unique_ptr<aura::Window> normal_window( | 394 std::unique_ptr<aura::Window> normal_window( |
| 398 CreateNormalWindow(gfx::Rect(450, 0, 100, 100))); | 395 CreateNormalWindow(gfx::Rect(450, 0, 100, 100))); |
| 399 std::unique_ptr<aura::Window> panel( | 396 std::unique_ptr<aura::Window> panel( |
| 400 CreatePanelWindow(gfx::Rect(400, 0, 50, 50))); | 397 CreatePanelWindow(gfx::Rect(400, 0, 50, 50))); |
| 401 EXPECT_EQ(root_windows[1], panel->GetRootWindow()); | 398 EXPECT_EQ(root_windows[1], panel->GetRootWindow()); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 wm::GetWindowState(window.get())->Unminimize(); | 641 wm::GetWindowState(window.get())->Unminimize(); |
| 645 RunAllPendingInMessageLoop(); | 642 RunAllPendingInMessageLoop(); |
| 646 EXPECT_TRUE(IsPanelCalloutVisible(window.get())); | 643 EXPECT_TRUE(IsPanelCalloutVisible(window.get())); |
| 647 // Activate the window, ensure callout is visible. | 644 // Activate the window, ensure callout is visible. |
| 648 wm::ActivateWindow(window.get()); | 645 wm::ActivateWindow(window.get()); |
| 649 RunAllPendingInMessageLoop(); | 646 RunAllPendingInMessageLoop(); |
| 650 EXPECT_TRUE(IsPanelCalloutVisible(window.get())); | 647 EXPECT_TRUE(IsPanelCalloutVisible(window.get())); |
| 651 } | 648 } |
| 652 | 649 |
| 653 TEST_F(PanelLayoutManagerTest, PanelMoveBetweenMultipleDisplays) { | 650 TEST_F(PanelLayoutManagerTest, PanelMoveBetweenMultipleDisplays) { |
| 654 if (!SupportsMultipleDisplays()) | |
| 655 return; | |
| 656 | |
| 657 // Keep the displays wide so that shelves have enough space for launcher | 651 // Keep the displays wide so that shelves have enough space for launcher |
| 658 // buttons. | 652 // buttons. |
| 659 UpdateDisplay("600x400,600x400"); | 653 UpdateDisplay("600x400,600x400"); |
| 660 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 654 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 661 | 655 |
| 662 std::unique_ptr<aura::Window> p1_d1( | 656 std::unique_ptr<aura::Window> p1_d1( |
| 663 CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); | 657 CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); |
| 664 std::unique_ptr<aura::Window> p2_d1( | 658 std::unique_ptr<aura::Window> p2_d1( |
| 665 CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); | 659 CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); |
| 666 std::unique_ptr<aura::Window> p1_d2( | 660 std::unique_ptr<aura::Window> p1_d2( |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 ClickShelfItemForWindow(shelf_view_1st, p1_d1.get()); | 721 ClickShelfItemForWindow(shelf_view_1st, p1_d1.get()); |
| 728 EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); | 722 EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); |
| 729 EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); | 723 EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); |
| 730 EXPECT_EQ(root_windows[0], p1_d2->GetRootWindow()); | 724 EXPECT_EQ(root_windows[0], p1_d2->GetRootWindow()); |
| 731 EXPECT_EQ(root_windows[1], p2_d2->GetRootWindow()); | 725 EXPECT_EQ(root_windows[1], p2_d2->GetRootWindow()); |
| 732 EXPECT_TRUE(root_windows[0]->GetBoundsInScreen().Contains( | 726 EXPECT_TRUE(root_windows[0]->GetBoundsInScreen().Contains( |
| 733 p1_d1->GetBoundsInScreen())); | 727 p1_d1->GetBoundsInScreen())); |
| 734 } | 728 } |
| 735 | 729 |
| 736 TEST_F(PanelLayoutManagerTest, PanelAttachPositionMultipleDisplays) { | 730 TEST_F(PanelLayoutManagerTest, PanelAttachPositionMultipleDisplays) { |
| 737 if (!SupportsMultipleDisplays()) | |
| 738 return; | |
| 739 | |
| 740 // Keep the displays wide so that shelves have enough space for shelf buttons. | 731 // Keep the displays wide so that shelves have enough space for shelf buttons. |
| 741 // Use differently sized displays so the shelf is in a different | 732 // Use differently sized displays so the shelf is in a different |
| 742 // position on second display. | 733 // position on second display. |
| 743 UpdateDisplay("600x400,600x600"); | 734 UpdateDisplay("600x400,600x600"); |
| 744 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 735 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 745 | 736 |
| 746 std::unique_ptr<aura::Window> p1_d1( | 737 std::unique_ptr<aura::Window> p1_d1( |
| 747 CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); | 738 CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); |
| 748 std::unique_ptr<aura::Window> p1_d2( | 739 std::unique_ptr<aura::Window> p1_d2( |
| 749 CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); | 740 CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); |
| 750 | 741 |
| 751 EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); | 742 EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); |
| 752 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); | 743 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); |
| 753 | 744 |
| 754 IsPanelAboveLauncherIcon(p1_d1.get()); | 745 IsPanelAboveLauncherIcon(p1_d1.get()); |
| 755 IsCalloutAboveLauncherIcon(p1_d1.get()); | 746 IsCalloutAboveLauncherIcon(p1_d1.get()); |
| 756 IsPanelAboveLauncherIcon(p1_d2.get()); | 747 IsPanelAboveLauncherIcon(p1_d2.get()); |
| 757 IsCalloutAboveLauncherIcon(p1_d2.get()); | 748 IsCalloutAboveLauncherIcon(p1_d2.get()); |
| 758 } | 749 } |
| 759 | 750 |
| 760 TEST_F(PanelLayoutManagerTest, PanelAlignmentSecondDisplay) { | 751 TEST_F(PanelLayoutManagerTest, PanelAlignmentSecondDisplay) { |
| 761 if (!SupportsMultipleDisplays()) | |
| 762 return; | |
| 763 | |
| 764 UpdateDisplay("600x400,600x400"); | 752 UpdateDisplay("600x400,600x400"); |
| 765 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 753 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 766 | 754 |
| 767 std::unique_ptr<aura::Window> p1_d2( | 755 std::unique_ptr<aura::Window> p1_d2( |
| 768 CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); | 756 CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); |
| 769 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); | 757 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); |
| 770 | 758 |
| 771 IsPanelAboveLauncherIcon(p1_d2.get()); | 759 IsPanelAboveLauncherIcon(p1_d2.get()); |
| 772 IsCalloutAboveLauncherIcon(p1_d2.get()); | 760 IsCalloutAboveLauncherIcon(p1_d2.get()); |
| 773 | 761 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); | 886 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); |
| 899 target = targeter->FindTargetForEvent(root, &touch); | 887 target = targeter->FindTargetForEvent(root, &touch); |
| 900 EXPECT_NE(w.get(), target); | 888 EXPECT_NE(w.get(), target); |
| 901 } | 889 } |
| 902 | 890 |
| 903 INSTANTIATE_TEST_CASE_P(LtrRtl, | 891 INSTANTIATE_TEST_CASE_P(LtrRtl, |
| 904 PanelLayoutManagerTextDirectionTest, | 892 PanelLayoutManagerTextDirectionTest, |
| 905 testing::Bool()); | 893 testing::Bool()); |
| 906 | 894 |
| 907 } // namespace ash | 895 } // namespace ash |
| OLD | NEW |