| 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/display/window_tree_host_manager.h" | 5 #include "ash/display/window_tree_host_manager.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "ash/common/ash_switches.h" | 9 #include "ash/common/ash_switches.h" |
| 10 #include "ash/common/material_design/material_design_controller.h" |
| 10 #include "ash/common/wm/window_state.h" | 11 #include "ash/common/wm/window_state.h" |
| 11 #include "ash/common/wm/wm_event.h" | 12 #include "ash/common/wm/wm_event.h" |
| 12 #include "ash/display/display_info.h" | 13 #include "ash/display/display_info.h" |
| 13 #include "ash/display/display_layout_store.h" | 14 #include "ash/display/display_layout_store.h" |
| 14 #include "ash/display/display_manager.h" | 15 #include "ash/display/display_manager.h" |
| 15 #include "ash/display/display_util.h" | 16 #include "ash/display/display_util.h" |
| 16 #include "ash/screen_util.h" | 17 #include "ash/screen_util.h" |
| 17 #include "ash/shelf/shelf.h" | 18 #include "ash/shelf/shelf.h" |
| 18 #include "ash/shelf/shelf_widget.h" | 19 #include "ash/shelf/shelf_widget.h" |
| 19 #include "ash/shell.h" | 20 #include "ash/shell.h" |
| 21 #include "ash/test/ash_md_test_base.h" |
| 20 #include "ash/test/ash_test_base.h" | 22 #include "ash/test/ash_test_base.h" |
| 21 #include "ash/test/ash_test_helper.h" | 23 #include "ash/test/ash_test_helper.h" |
| 22 #include "ash/test/cursor_manager_test_api.h" | 24 #include "ash/test/cursor_manager_test_api.h" |
| 23 #include "ash/test/display_manager_test_api.h" | 25 #include "ash/test/display_manager_test_api.h" |
| 24 #include "ash/test/test_shell_delegate.h" | 26 #include "ash/test/test_shell_delegate.h" |
| 25 #include "ash/wm/window_state_aura.h" | 27 #include "ash/wm/window_state_aura.h" |
| 26 #include "base/command_line.h" | 28 #include "base/command_line.h" |
| 27 #include "ui/aura/client/focus_change_observer.h" | 29 #include "ui/aura/client/focus_change_observer.h" |
| 28 #include "ui/aura/client/focus_client.h" | 30 #include "ui/aura/client/focus_client.h" |
| 29 #include "ui/aura/env.h" | 31 #include "ui/aura/env.h" |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 | 375 |
| 374 private: | 376 private: |
| 375 // views::MouseWatcherListener: | 377 // views::MouseWatcherListener: |
| 376 void MouseMovedOutOfHost() override {} | 378 void MouseMovedOutOfHost() override {} |
| 377 | 379 |
| 378 DISALLOW_COPY_AND_ASSIGN(TestMouseWatcherListener); | 380 DISALLOW_COPY_AND_ASSIGN(TestMouseWatcherListener); |
| 379 }; | 381 }; |
| 380 | 382 |
| 381 } // namespace | 383 } // namespace |
| 382 | 384 |
| 383 typedef test::AshTestBase WindowTreeHostManagerTest; | 385 using WindowTreeHostManagerTest = test::AshMDTestBase; |
| 386 |
| 387 INSTANTIATE_TEST_CASE_P( |
| 388 /* prefix intentionally left blank due to only one parameterization */, |
| 389 WindowTreeHostManagerTest, |
| 390 testing::Values(MaterialDesignController::NON_MATERIAL, |
| 391 MaterialDesignController::MATERIAL_NORMAL, |
| 392 MaterialDesignController::MATERIAL_EXPERIMENTAL)); |
| 384 | 393 |
| 385 TEST_F(WindowTreeHostManagerShutdownTest, Shutdown) { | 394 TEST_F(WindowTreeHostManagerShutdownTest, Shutdown) { |
| 386 if (!SupportsMultipleDisplays()) | 395 if (!SupportsMultipleDisplays()) |
| 387 return; | 396 return; |
| 388 | 397 |
| 389 UpdateDisplay("444x333, 200x200"); | 398 UpdateDisplay("444x333, 200x200"); |
| 390 } | 399 } |
| 391 | 400 |
| 392 TEST_F(WindowTreeHostManagerStartupTest, Startup) { | 401 TEST_F(WindowTreeHostManagerStartupTest, Startup) { |
| 393 if (!SupportsMultipleDisplays()) | 402 if (!SupportsMultipleDisplays()) |
| 394 return; | 403 return; |
| 395 | 404 |
| 396 EXPECT_TRUE(startup_helper()->displays_initialized()); | 405 EXPECT_TRUE(startup_helper()->displays_initialized()); |
| 397 } | 406 } |
| 398 | 407 |
| 399 TEST_F(WindowTreeHostManagerTest, SecondaryDisplayLayout) { | 408 TEST_P(WindowTreeHostManagerTest, SecondaryDisplayLayout) { |
| 400 if (!SupportsMultipleDisplays()) | 409 if (!SupportsMultipleDisplays()) |
| 401 return; | 410 return; |
| 402 | 411 |
| 403 // Creates windows to catch activation change event. | 412 // Creates windows to catch activation change event. |
| 404 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); | 413 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); |
| 405 w1->Focus(); | 414 w1->Focus(); |
| 406 | 415 |
| 407 TestObserver observer; | 416 TestObserver observer; |
| 408 UpdateDisplay("500x500,400x400"); | 417 UpdateDisplay("500x500,400x400"); |
| 409 EXPECT_EQ(1, observer.CountAndReset()); // resize and add | 418 EXPECT_EQ(1, observer.CountAndReset()); // resize and add |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 } | 560 } |
| 552 | 561 |
| 553 DisplayInfo CreateMirroredDisplayInfo(int64_t id, float device_scale_factor) { | 562 DisplayInfo CreateMirroredDisplayInfo(int64_t id, float device_scale_factor) { |
| 554 DisplayInfo info = CreateDisplayInfo(id, 0, display::Display::ROTATE_0); | 563 DisplayInfo info = CreateDisplayInfo(id, 0, display::Display::ROTATE_0); |
| 555 info.set_device_scale_factor(device_scale_factor); | 564 info.set_device_scale_factor(device_scale_factor); |
| 556 return info; | 565 return info; |
| 557 } | 566 } |
| 558 | 567 |
| 559 } // namespace | 568 } // namespace |
| 560 | 569 |
| 561 TEST_F(WindowTreeHostManagerTest, MirrorToDockedWithFullscreen) { | 570 TEST_P(WindowTreeHostManagerTest, MirrorToDockedWithFullscreen) { |
| 562 if (!SupportsMultipleDisplays()) | 571 if (!SupportsMultipleDisplays()) |
| 563 return; | 572 return; |
| 564 | 573 |
| 565 // Creates windows to catch activation change event. | 574 // Creates windows to catch activation change event. |
| 566 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); | 575 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); |
| 567 w1->Focus(); | 576 w1->Focus(); |
| 568 | 577 |
| 569 // Docked mode. | 578 // Docked mode. |
| 570 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 579 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 571 | 580 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 601 EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset()); | 610 EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset()); |
| 602 EXPECT_EQ(1, observer.GetPrimaryChangedCountAndReset()); | 611 EXPECT_EQ(1, observer.GetPrimaryChangedCountAndReset()); |
| 603 EXPECT_EQ(1, observer.CountAndReset()); | 612 EXPECT_EQ(1, observer.CountAndReset()); |
| 604 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 613 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
| 605 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 614 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
| 606 | 615 |
| 607 EXPECT_TRUE(window_state->IsFullscreen()); | 616 EXPECT_TRUE(window_state->IsFullscreen()); |
| 608 EXPECT_EQ("0,0 500x500", w1->bounds().ToString()); | 617 EXPECT_EQ("0,0 500x500", w1->bounds().ToString()); |
| 609 } | 618 } |
| 610 | 619 |
| 611 TEST_F(WindowTreeHostManagerTest, BoundsUpdated) { | 620 TEST_P(WindowTreeHostManagerTest, BoundsUpdated) { |
| 612 if (!SupportsMultipleDisplays()) | 621 if (!SupportsMultipleDisplays()) |
| 613 return; | 622 return; |
| 614 | 623 |
| 615 // Creates windows to catch activation change event. | 624 // Creates windows to catch activation change event. |
| 616 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); | 625 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); |
| 617 w1->Focus(); | 626 w1->Focus(); |
| 618 | 627 |
| 619 TestObserver observer; | 628 TestObserver observer; |
| 620 SetDefaultDisplayLayout(display::DisplayPlacement::BOTTOM); | 629 SetDefaultDisplayLayout(display::DisplayPlacement::BOTTOM); |
| 621 UpdateDisplay("200x200,300x300"); // layout, resize and add. | 630 UpdateDisplay("200x200,300x300"); // layout, resize and add. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 SetDisplayUIScale(primary_id, 1.125f); | 717 SetDisplayUIScale(primary_id, 1.125f); |
| 709 EXPECT_EQ(0, observer.CountAndReset()); | 718 EXPECT_EQ(0, observer.CountAndReset()); |
| 710 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 719 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
| 711 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 720 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
| 712 SetDisplayUIScale(primary_id, 1.125f); | 721 SetDisplayUIScale(primary_id, 1.125f); |
| 713 EXPECT_EQ(0, observer.CountAndReset()); | 722 EXPECT_EQ(0, observer.CountAndReset()); |
| 714 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 723 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
| 715 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 724 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
| 716 } | 725 } |
| 717 | 726 |
| 718 TEST_F(WindowTreeHostManagerTest, FindNearestDisplay) { | 727 TEST_P(WindowTreeHostManagerTest, FindNearestDisplay) { |
| 719 if (!SupportsMultipleDisplays()) | 728 if (!SupportsMultipleDisplays()) |
| 720 return; | 729 return; |
| 721 | 730 |
| 722 WindowTreeHostManager* window_tree_host_manager = | 731 WindowTreeHostManager* window_tree_host_manager = |
| 723 Shell::GetInstance()->window_tree_host_manager(); | 732 Shell::GetInstance()->window_tree_host_manager(); |
| 724 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 733 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 725 | 734 |
| 726 UpdateDisplay("200x200,300x300"); | 735 UpdateDisplay("200x200,300x300"); |
| 727 display_manager->SetLayoutForCurrentDisplays( | 736 display_manager->SetLayoutForCurrentDisplays( |
| 728 test::CreateDisplayLayout(display::DisplayPlacement::RIGHT, 50)); | 737 test::CreateDisplayLayout(display::DisplayPlacement::RIGHT, 50)); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 EXPECT_EQ(secondary_display.id(), | 779 EXPECT_EQ(secondary_display.id(), |
| 771 display::Screen::GetScreen() | 780 display::Screen::GetScreen() |
| 772 ->GetDisplayNearestPoint(gfx::Point(176, 225)) | 781 ->GetDisplayNearestPoint(gfx::Point(176, 225)) |
| 773 .id()); | 782 .id()); |
| 774 EXPECT_EQ(secondary_display.id(), | 783 EXPECT_EQ(secondary_display.id(), |
| 775 display::Screen::GetScreen() | 784 display::Screen::GetScreen() |
| 776 ->GetDisplayNearestPoint(gfx::Point(300, 400)) | 785 ->GetDisplayNearestPoint(gfx::Point(300, 400)) |
| 777 .id()); | 786 .id()); |
| 778 } | 787 } |
| 779 | 788 |
| 780 TEST_F(WindowTreeHostManagerTest, SwapPrimaryById) { | 789 TEST_P(WindowTreeHostManagerTest, SwapPrimaryById) { |
| 781 if (!SupportsMultipleDisplays()) | 790 if (!SupportsMultipleDisplays()) |
| 782 return; | 791 return; |
| 792 const int height_offset = GetMdMaximizedWindowHeightOffset(); |
| 783 | 793 |
| 784 WindowTreeHostManager* window_tree_host_manager = | 794 WindowTreeHostManager* window_tree_host_manager = |
| 785 Shell::GetInstance()->window_tree_host_manager(); | 795 Shell::GetInstance()->window_tree_host_manager(); |
| 786 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 796 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 787 | 797 |
| 788 UpdateDisplay("200x200,300x300"); | 798 UpdateDisplay("200x200,300x300"); |
| 789 display::Display primary_display = | 799 display::Display primary_display = |
| 790 display::Screen::GetScreen()->GetPrimaryDisplay(); | 800 display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 791 display::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); | 801 display::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); |
| 792 | 802 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 806 EXPECT_NE(primary_root, secondary_root); | 816 EXPECT_NE(primary_root, secondary_root); |
| 807 EXPECT_EQ(primary_display.id(), | 817 EXPECT_EQ(primary_display.id(), |
| 808 display::Screen::GetScreen() | 818 display::Screen::GetScreen() |
| 809 ->GetDisplayNearestPoint(gfx::Point(-100, -100)) | 819 ->GetDisplayNearestPoint(gfx::Point(-100, -100)) |
| 810 .id()); | 820 .id()); |
| 811 EXPECT_EQ( | 821 EXPECT_EQ( |
| 812 primary_display.id(), | 822 primary_display.id(), |
| 813 display::Screen::GetScreen()->GetDisplayNearestWindow(nullptr).id()); | 823 display::Screen::GetScreen()->GetDisplayNearestWindow(nullptr).id()); |
| 814 | 824 |
| 815 EXPECT_EQ("0,0 200x200", primary_display.bounds().ToString()); | 825 EXPECT_EQ("0,0 200x200", primary_display.bounds().ToString()); |
| 816 EXPECT_EQ("0,0 200x153", primary_display.work_area().ToString()); | 826 EXPECT_EQ(gfx::Rect(0, 0, 200, 153 + height_offset).ToString(), |
| 827 primary_display.work_area().ToString()); |
| 817 EXPECT_EQ("200,0 300x300", secondary_display.bounds().ToString()); | 828 EXPECT_EQ("200,0 300x300", secondary_display.bounds().ToString()); |
| 818 EXPECT_EQ("200,0 300x253", secondary_display.work_area().ToString()); | 829 EXPECT_EQ(gfx::Rect(200, 0, 300, 253 + height_offset).ToString(), |
| 830 secondary_display.work_area().ToString()); |
| 819 EXPECT_EQ( | 831 EXPECT_EQ( |
| 820 "id=2200000001, parent=2200000000, right, 50", | 832 "id=2200000001, parent=2200000000, right, 50", |
| 821 display_manager->GetCurrentDisplayLayout().placement_list[0].ToString()); | 833 display_manager->GetCurrentDisplayLayout().placement_list[0].ToString()); |
| 822 | 834 |
| 823 // Switch primary and secondary by display ID. | 835 // Switch primary and secondary by display ID. |
| 824 TestObserver observer; | 836 TestObserver observer; |
| 825 window_tree_host_manager->SetPrimaryDisplayId(secondary_display.id()); | 837 window_tree_host_manager->SetPrimaryDisplayId(secondary_display.id()); |
| 826 EXPECT_EQ(secondary_display.id(), | 838 EXPECT_EQ(secondary_display.id(), |
| 827 display::Screen::GetScreen()->GetPrimaryDisplay().id()); | 839 display::Screen::GetScreen()->GetPrimaryDisplay().id()); |
| 828 EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id()); | 840 EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id()); |
| 829 EXPECT_LT(0, observer.CountAndReset()); | 841 EXPECT_LT(0, observer.CountAndReset()); |
| 830 | 842 |
| 831 EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( | 843 EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( |
| 832 secondary_display.id())); | 844 secondary_display.id())); |
| 833 EXPECT_EQ(secondary_root, window_tree_host_manager->GetRootWindowForDisplayId( | 845 EXPECT_EQ(secondary_root, window_tree_host_manager->GetRootWindowForDisplayId( |
| 834 primary_display.id())); | 846 primary_display.id())); |
| 835 EXPECT_TRUE(primary_root->Contains(shelf_window)); | 847 EXPECT_TRUE(primary_root->Contains(shelf_window)); |
| 836 EXPECT_FALSE(secondary_root->Contains(shelf_window)); | 848 EXPECT_FALSE(secondary_root->Contains(shelf_window)); |
| 837 | 849 |
| 838 const display::DisplayLayout& inverted_layout = | 850 const display::DisplayLayout& inverted_layout = |
| 839 display_manager->GetCurrentDisplayLayout(); | 851 display_manager->GetCurrentDisplayLayout(); |
| 840 | 852 |
| 841 EXPECT_EQ("id=2200000000, parent=2200000001, left, -50", | 853 EXPECT_EQ("id=2200000000, parent=2200000001, left, -50", |
| 842 inverted_layout.placement_list[0].ToString()); | 854 inverted_layout.placement_list[0].ToString()); |
| 843 // Test if the bounds are correctly swapped. | 855 // Test if the bounds are correctly swapped. |
| 844 display::Display swapped_primary = | 856 display::Display swapped_primary = |
| 845 display::Screen::GetScreen()->GetPrimaryDisplay(); | 857 display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 846 display::Display swapped_secondary = ScreenUtil::GetSecondaryDisplay(); | 858 display::Display swapped_secondary = ScreenUtil::GetSecondaryDisplay(); |
| 847 EXPECT_EQ("0,0 300x300", swapped_primary.bounds().ToString()); | 859 EXPECT_EQ("0,0 300x300", swapped_primary.bounds().ToString()); |
| 848 EXPECT_EQ("0,0 300x253", swapped_primary.work_area().ToString()); | 860 EXPECT_EQ(gfx::Rect(0, 0, 300, 253 + height_offset).ToString(), |
| 861 swapped_primary.work_area().ToString()); |
| 849 EXPECT_EQ("-200,-50 200x200", swapped_secondary.bounds().ToString()); | 862 EXPECT_EQ("-200,-50 200x200", swapped_secondary.bounds().ToString()); |
| 850 EXPECT_EQ("-200,-50 200x153", swapped_secondary.work_area().ToString()); | 863 EXPECT_EQ(gfx::Rect(-200, -50, 200, 153 + height_offset).ToString(), |
| 864 swapped_secondary.work_area().ToString()); |
| 851 | 865 |
| 852 // Calling the same ID don't do anything. | 866 // Calling the same ID don't do anything. |
| 853 window_tree_host_manager->SetPrimaryDisplayId(secondary_display.id()); | 867 window_tree_host_manager->SetPrimaryDisplayId(secondary_display.id()); |
| 854 EXPECT_EQ(0, observer.CountAndReset()); | 868 EXPECT_EQ(0, observer.CountAndReset()); |
| 855 | 869 |
| 856 aura::WindowTracker tracker; | 870 aura::WindowTracker tracker; |
| 857 tracker.Add(primary_root); | 871 tracker.Add(primary_root); |
| 858 tracker.Add(secondary_root); | 872 tracker.Add(secondary_root); |
| 859 | 873 |
| 860 // Deleting 2nd display should move the primary to original primary display. | 874 // Deleting 2nd display should move the primary to original primary display. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 EXPECT_EQ(primary_display.id(), | 926 EXPECT_EQ(primary_display.id(), |
| 913 display::Screen::GetScreen()->GetPrimaryDisplay().id()); | 927 display::Screen::GetScreen()->GetPrimaryDisplay().id()); |
| 914 EXPECT_EQ(third_display_info.id(), ScreenUtil::GetSecondaryDisplay().id()); | 928 EXPECT_EQ(third_display_info.id(), ScreenUtil::GetSecondaryDisplay().id()); |
| 915 EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( | 929 EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( |
| 916 primary_display.id())); | 930 primary_display.id())); |
| 917 EXPECT_NE(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( | 931 EXPECT_NE(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( |
| 918 third_display_info.id())); | 932 third_display_info.id())); |
| 919 EXPECT_TRUE(primary_root->Contains(shelf_window)); | 933 EXPECT_TRUE(primary_root->Contains(shelf_window)); |
| 920 } | 934 } |
| 921 | 935 |
| 922 TEST_F(WindowTreeHostManagerTest, NoSwapPrimaryWithThreeDisplays) { | 936 TEST_P(WindowTreeHostManagerTest, NoSwapPrimaryWithThreeDisplays) { |
| 923 if (!SupportsMultipleDisplays()) | 937 if (!SupportsMultipleDisplays()) |
| 924 return; | 938 return; |
| 925 int64_t primary = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 939 int64_t primary = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 926 UpdateDisplay("500x400,400x300,300x200"); | 940 UpdateDisplay("500x400,400x300,300x200"); |
| 927 EXPECT_EQ(primary, display::Screen::GetScreen()->GetPrimaryDisplay().id()); | 941 EXPECT_EQ(primary, display::Screen::GetScreen()->GetPrimaryDisplay().id()); |
| 928 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( | 942 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( |
| 929 ScreenUtil::GetSecondaryDisplay().id()); | 943 ScreenUtil::GetSecondaryDisplay().id()); |
| 930 EXPECT_EQ(primary, display::Screen::GetScreen()->GetPrimaryDisplay().id()); | 944 EXPECT_EQ(primary, display::Screen::GetScreen()->GetPrimaryDisplay().id()); |
| 931 } | 945 } |
| 932 | 946 |
| 933 TEST_F(WindowTreeHostManagerTest, OverscanInsets) { | 947 TEST_P(WindowTreeHostManagerTest, OverscanInsets) { |
| 934 if (!SupportsMultipleDisplays()) | 948 if (!SupportsMultipleDisplays()) |
| 935 return; | 949 return; |
| 936 | 950 |
| 937 WindowTreeHostManager* window_tree_host_manager = | 951 WindowTreeHostManager* window_tree_host_manager = |
| 938 Shell::GetInstance()->window_tree_host_manager(); | 952 Shell::GetInstance()->window_tree_host_manager(); |
| 939 TestEventHandler event_handler; | 953 TestEventHandler event_handler; |
| 940 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 954 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
| 941 | 955 |
| 942 UpdateDisplay("120x200,300x400*2"); | 956 UpdateDisplay("120x200,300x400*2"); |
| 943 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); | 957 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 973 | 987 |
| 974 test::SwapPrimaryDisplay(); | 988 test::SwapPrimaryDisplay(); |
| 975 point.SetPoint(0, 0); | 989 point.SetPoint(0, 0); |
| 976 Shell::GetAllRootWindows()[1]->GetHost()->GetRootTransform().TransformPoint( | 990 Shell::GetAllRootWindows()[1]->GetHost()->GetRootTransform().TransformPoint( |
| 977 &point); | 991 &point); |
| 978 EXPECT_EQ("15,10", point.ToString()); | 992 EXPECT_EQ("15,10", point.ToString()); |
| 979 | 993 |
| 980 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 994 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
| 981 } | 995 } |
| 982 | 996 |
| 983 TEST_F(WindowTreeHostManagerTest, Rotate) { | 997 TEST_P(WindowTreeHostManagerTest, Rotate) { |
| 984 if (!SupportsMultipleDisplays()) | 998 if (!SupportsMultipleDisplays()) |
| 985 return; | 999 return; |
| 986 | 1000 |
| 987 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 1001 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 988 TestEventHandler event_handler; | 1002 TestEventHandler event_handler; |
| 989 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 1003 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
| 990 | 1004 |
| 991 UpdateDisplay("120x200,300x400*2"); | 1005 UpdateDisplay("120x200,300x400*2"); |
| 992 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); | 1006 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 993 int64_t display2_id = ScreenUtil::GetSecondaryDisplay().id(); | 1007 int64_t display2_id = ScreenUtil::GetSecondaryDisplay().id(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 GetActiveDisplayRotation(display2_id)); | 1070 GetActiveDisplayRotation(display2_id)); |
| 1057 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); | 1071 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); |
| 1058 | 1072 |
| 1059 generator1.MoveMouseToInHost(50, 40); | 1073 generator1.MoveMouseToInHost(50, 40); |
| 1060 EXPECT_EQ("69,159", event_handler.GetLocationAndReset()); | 1074 EXPECT_EQ("69,159", event_handler.GetLocationAndReset()); |
| 1061 #endif | 1075 #endif |
| 1062 | 1076 |
| 1063 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 1077 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
| 1064 } | 1078 } |
| 1065 | 1079 |
| 1066 TEST_F(WindowTreeHostManagerTest, ScaleRootWindow) { | 1080 TEST_P(WindowTreeHostManagerTest, ScaleRootWindow) { |
| 1067 if (!SupportsMultipleDisplays()) | 1081 if (!SupportsMultipleDisplays()) |
| 1068 return; | 1082 return; |
| 1069 | 1083 |
| 1070 TestEventHandler event_handler; | 1084 TestEventHandler event_handler; |
| 1071 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 1085 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
| 1072 | 1086 |
| 1073 UpdateDisplay("600x400*2@1.5,500x300"); | 1087 UpdateDisplay("600x400*2@1.5,500x300"); |
| 1074 | 1088 |
| 1075 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); | 1089 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 1076 test::ScopedSetInternalDisplayId set_internal(display1.id()); | 1090 test::ScopedSetInternalDisplayId set_internal(display1.id()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1092 display2 = ScreenUtil::GetSecondaryDisplay(); | 1106 display2 = ScreenUtil::GetSecondaryDisplay(); |
| 1093 EXPECT_EQ("0,0 375x250", display1.bounds().ToString()); | 1107 EXPECT_EQ("0,0 375x250", display1.bounds().ToString()); |
| 1094 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString()); | 1108 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString()); |
| 1095 EXPECT_EQ("375,0 500x300", display2.bounds().ToString()); | 1109 EXPECT_EQ("375,0 500x300", display2.bounds().ToString()); |
| 1096 EXPECT_EQ(1.25f, GetStoredUIScale(display1.id())); | 1110 EXPECT_EQ(1.25f, GetStoredUIScale(display1.id())); |
| 1097 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); | 1111 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); |
| 1098 | 1112 |
| 1099 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 1113 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
| 1100 } | 1114 } |
| 1101 | 1115 |
| 1102 TEST_F(WindowTreeHostManagerTest, TouchScale) { | 1116 TEST_P(WindowTreeHostManagerTest, TouchScale) { |
| 1103 if (!SupportsMultipleDisplays()) | 1117 if (!SupportsMultipleDisplays()) |
| 1104 return; | 1118 return; |
| 1105 | 1119 |
| 1106 TestEventHandler event_handler; | 1120 TestEventHandler event_handler; |
| 1107 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 1121 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
| 1108 | 1122 |
| 1109 UpdateDisplay("200x200*2"); | 1123 UpdateDisplay("200x200*2"); |
| 1110 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); | 1124 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 1111 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1125 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1112 aura::Window* root_window = root_windows[0]; | 1126 aura::Window* root_window = root_windows[0]; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1124 | 1138 |
| 1125 // ordinal_offset is invariant to the device scale factor. | 1139 // ordinal_offset is invariant to the device scale factor. |
| 1126 EXPECT_EQ(event_handler.scroll_x_offset(), | 1140 EXPECT_EQ(event_handler.scroll_x_offset(), |
| 1127 event_handler.scroll_x_offset_ordinal()); | 1141 event_handler.scroll_x_offset_ordinal()); |
| 1128 EXPECT_EQ(event_handler.scroll_y_offset(), | 1142 EXPECT_EQ(event_handler.scroll_y_offset(), |
| 1129 event_handler.scroll_y_offset_ordinal()); | 1143 event_handler.scroll_y_offset_ordinal()); |
| 1130 | 1144 |
| 1131 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 1145 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
| 1132 } | 1146 } |
| 1133 | 1147 |
| 1134 TEST_F(WindowTreeHostManagerTest, ConvertHostToRootCoords) { | 1148 TEST_P(WindowTreeHostManagerTest, ConvertHostToRootCoords) { |
| 1135 if (!SupportsMultipleDisplays()) | 1149 if (!SupportsMultipleDisplays()) |
| 1136 return; | 1150 return; |
| 1137 | 1151 |
| 1138 TestEventHandler event_handler; | 1152 TestEventHandler event_handler; |
| 1139 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 1153 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
| 1140 | 1154 |
| 1141 UpdateDisplay("600x400*2/r@1.5"); | 1155 UpdateDisplay("600x400*2/r@1.5"); |
| 1142 | 1156 |
| 1143 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); | 1157 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 1144 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1158 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1186 generator.MoveMouseToInHost(599, 399); | 1200 generator.MoveMouseToInHost(599, 399); |
| 1187 EXPECT_EQ("0,449", event_handler.GetLocationAndReset()); | 1201 EXPECT_EQ("0,449", event_handler.GetLocationAndReset()); |
| 1188 generator.MoveMouseToInHost(0, 399); | 1202 generator.MoveMouseToInHost(0, 399); |
| 1189 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); | 1203 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); |
| 1190 | 1204 |
| 1191 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 1205 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
| 1192 } | 1206 } |
| 1193 | 1207 |
| 1194 // Make sure that the compositor based mirroring can switch | 1208 // Make sure that the compositor based mirroring can switch |
| 1195 // from/to dock mode. | 1209 // from/to dock mode. |
| 1196 TEST_F(WindowTreeHostManagerTest, DockToSingle) { | 1210 TEST_P(WindowTreeHostManagerTest, DockToSingle) { |
| 1197 if (!SupportsMultipleDisplays()) | 1211 if (!SupportsMultipleDisplays()) |
| 1198 return; | 1212 return; |
| 1199 | 1213 |
| 1200 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 1214 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 1201 | 1215 |
| 1202 const int64_t internal_id = 1; | 1216 const int64_t internal_id = 1; |
| 1203 | 1217 |
| 1204 const DisplayInfo internal_display_info = | 1218 const DisplayInfo internal_display_info = |
| 1205 CreateDisplayInfo(internal_id, 0, display::Display::ROTATE_0); | 1219 CreateDisplayInfo(internal_id, 0, display::Display::ROTATE_0); |
| 1206 const DisplayInfo external_display_info = | 1220 const DisplayInfo external_display_info = |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1232 display_info_list.push_back(internal_display_info); | 1246 display_info_list.push_back(internal_display_info); |
| 1233 display_manager->OnNativeDisplaysChanged(display_info_list); | 1247 display_manager->OnNativeDisplaysChanged(display_info_list); |
| 1234 EXPECT_TRUE(Shell::GetPrimaryRootWindow() | 1248 EXPECT_TRUE(Shell::GetPrimaryRootWindow() |
| 1235 ->GetHost() | 1249 ->GetHost() |
| 1236 ->GetRootTransform() | 1250 ->GetRootTransform() |
| 1237 .IsIdentityOrIntegerTranslation()); | 1251 .IsIdentityOrIntegerTranslation()); |
| 1238 } | 1252 } |
| 1239 | 1253 |
| 1240 // Tests if switching two displays at the same time while the primary display | 1254 // Tests if switching two displays at the same time while the primary display |
| 1241 // is swapped should not cause a crash. (crbug.com/426292) | 1255 // is swapped should not cause a crash. (crbug.com/426292) |
| 1242 TEST_F(WindowTreeHostManagerTest, ReplaceSwappedPrimary) { | 1256 TEST_P(WindowTreeHostManagerTest, ReplaceSwappedPrimary) { |
| 1243 if (!SupportsMultipleDisplays()) | 1257 if (!SupportsMultipleDisplays()) |
| 1244 return; | 1258 return; |
| 1245 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 1259 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 1246 | 1260 |
| 1247 const DisplayInfo first_display_info = | 1261 const DisplayInfo first_display_info = |
| 1248 CreateDisplayInfo(10, 0, display::Display::ROTATE_0); | 1262 CreateDisplayInfo(10, 0, display::Display::ROTATE_0); |
| 1249 const DisplayInfo second_display_info = | 1263 const DisplayInfo second_display_info = |
| 1250 CreateDisplayInfo(11, 1, display::Display::ROTATE_0); | 1264 CreateDisplayInfo(11, 1, display::Display::ROTATE_0); |
| 1251 | 1265 |
| 1252 std::vector<DisplayInfo> display_info_list; | 1266 std::vector<DisplayInfo> display_info_list; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1295 }; | 1309 }; |
| 1296 | 1310 |
| 1297 } // names | 1311 } // names |
| 1298 | 1312 |
| 1299 // Make sure that GetShelfDisplayBoundsInRoot returns the correct bounds | 1313 // Make sure that GetShelfDisplayBoundsInRoot returns the correct bounds |
| 1300 // when primary display gets replaced in a following scenario. | 1314 // when primary display gets replaced in a following scenario. |
| 1301 // 1) Two displays connected: a) b) | 1315 // 1) Two displays connected: a) b) |
| 1302 // 2) both are disconnected and new one with the same size as b) is connected | 1316 // 2) both are disconnected and new one with the same size as b) is connected |
| 1303 // in one configuration event. | 1317 // in one configuration event. |
| 1304 // See crbug.com/547280. | 1318 // See crbug.com/547280. |
| 1305 TEST_F(WindowTreeHostManagerTest, ReplacePrimary) { | 1319 TEST_P(WindowTreeHostManagerTest, ReplacePrimary) { |
| 1306 if (!SupportsMultipleDisplays()) | 1320 if (!SupportsMultipleDisplays()) |
| 1307 return; | 1321 return; |
| 1308 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 1322 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 1309 | 1323 |
| 1310 DisplayInfo first_display_info = | 1324 DisplayInfo first_display_info = |
| 1311 CreateDisplayInfo(10, 0, display::Display::ROTATE_0); | 1325 CreateDisplayInfo(10, 0, display::Display::ROTATE_0); |
| 1312 first_display_info.SetBounds(gfx::Rect(0, 0, 400, 400)); | 1326 first_display_info.SetBounds(gfx::Rect(0, 0, 400, 400)); |
| 1313 const DisplayInfo second_display_info = | 1327 const DisplayInfo second_display_info = |
| 1314 CreateDisplayInfo(11, 500, display::Display::ROTATE_0); | 1328 CreateDisplayInfo(11, 500, display::Display::ROTATE_0); |
| 1315 | 1329 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1327 display_info_list.clear(); | 1341 display_info_list.clear(); |
| 1328 const DisplayInfo new_first_display_info = | 1342 const DisplayInfo new_first_display_info = |
| 1329 CreateDisplayInfo(new_display_id, 0, display::Display::ROTATE_0); | 1343 CreateDisplayInfo(new_display_id, 0, display::Display::ROTATE_0); |
| 1330 | 1344 |
| 1331 display_info_list.push_back(new_first_display_info); | 1345 display_info_list.push_back(new_first_display_info); |
| 1332 display_manager->OnNativeDisplaysChanged(display_info_list); | 1346 display_manager->OnNativeDisplaysChanged(display_info_list); |
| 1333 EXPECT_EQ("0,0 500x500", test_observer.shelf_display_bounds().ToString()); | 1347 EXPECT_EQ("0,0 500x500", test_observer.shelf_display_bounds().ToString()); |
| 1334 primary_root->RemoveObserver(&test_observer); | 1348 primary_root->RemoveObserver(&test_observer); |
| 1335 } | 1349 } |
| 1336 | 1350 |
| 1337 TEST_F(WindowTreeHostManagerTest, UpdateMouseLocationAfterDisplayChange) { | 1351 TEST_P(WindowTreeHostManagerTest, UpdateMouseLocationAfterDisplayChange) { |
| 1338 if (!SupportsMultipleDisplays()) | 1352 if (!SupportsMultipleDisplays()) |
| 1339 return; | 1353 return; |
| 1340 | 1354 |
| 1341 UpdateDisplay("200x200,300x300"); | 1355 UpdateDisplay("200x200,300x300"); |
| 1342 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1356 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1343 | 1357 |
| 1344 aura::Env* env = aura::Env::GetInstance(); | 1358 aura::Env* env = aura::Env::GetInstance(); |
| 1345 | 1359 |
| 1346 ui::test::EventGenerator generator(root_windows[0]); | 1360 ui::test::EventGenerator generator(root_windows[0]); |
| 1347 | 1361 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1370 | 1384 |
| 1371 // Move the mouse pointer to the bottom of 1st display. | 1385 // Move the mouse pointer to the bottom of 1st display. |
| 1372 generator.MoveMouseToInHost(150, 290); | 1386 generator.MoveMouseToInHost(150, 290); |
| 1373 EXPECT_EQ("150,290", env->last_mouse_location().ToString()); | 1387 EXPECT_EQ("150,290", env->last_mouse_location().ToString()); |
| 1374 | 1388 |
| 1375 // The mouse pointer is now on 2nd display. | 1389 // The mouse pointer is now on 2nd display. |
| 1376 UpdateDisplay("300x280,200x200"); | 1390 UpdateDisplay("300x280,200x200"); |
| 1377 EXPECT_EQ("450,10", env->last_mouse_location().ToString()); | 1391 EXPECT_EQ("450,10", env->last_mouse_location().ToString()); |
| 1378 } | 1392 } |
| 1379 | 1393 |
| 1380 TEST_F(WindowTreeHostManagerTest, | 1394 TEST_P(WindowTreeHostManagerTest, |
| 1381 UpdateMouseLocationAfterDisplayChange_2ndOnLeft) { | 1395 UpdateMouseLocationAfterDisplayChange_2ndOnLeft) { |
| 1382 if (!SupportsMultipleDisplays()) | 1396 if (!SupportsMultipleDisplays()) |
| 1383 return; | 1397 return; |
| 1384 | 1398 |
| 1385 // Set the 2nd display on the left. | 1399 // Set the 2nd display on the left. |
| 1386 DisplayLayoutStore* layout_store = | 1400 DisplayLayoutStore* layout_store = |
| 1387 Shell::GetInstance()->display_manager()->layout_store(); | 1401 Shell::GetInstance()->display_manager()->layout_store(); |
| 1388 display::DisplayPlacement new_default(display::DisplayPlacement::LEFT, 0); | 1402 display::DisplayPlacement new_default(display::DisplayPlacement::LEFT, 0); |
| 1389 layout_store->SetDefaultDisplayPlacement(new_default); | 1403 layout_store->SetDefaultDisplayPlacement(new_default); |
| 1390 | 1404 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1410 EXPECT_EQ("-100,50", env->last_mouse_location().ToString()); | 1424 EXPECT_EQ("-100,50", env->last_mouse_location().ToString()); |
| 1411 | 1425 |
| 1412 // 2nd display was disconnected. Mouse pointer should move to | 1426 // 2nd display was disconnected. Mouse pointer should move to |
| 1413 // 1st display. | 1427 // 1st display. |
| 1414 UpdateDisplay("300x300"); | 1428 UpdateDisplay("300x300"); |
| 1415 EXPECT_EQ("150,150", env->last_mouse_location().ToString()); | 1429 EXPECT_EQ("150,150", env->last_mouse_location().ToString()); |
| 1416 } | 1430 } |
| 1417 | 1431 |
| 1418 // Test that the cursor swaps displays and that its scale factor and rotation | 1432 // Test that the cursor swaps displays and that its scale factor and rotation |
| 1419 // are updated when the primary display is swapped. | 1433 // are updated when the primary display is swapped. |
| 1420 TEST_F(WindowTreeHostManagerTest, | 1434 TEST_P(WindowTreeHostManagerTest, |
| 1421 UpdateMouseLocationAfterDisplayChange_SwapPrimary) { | 1435 UpdateMouseLocationAfterDisplayChange_SwapPrimary) { |
| 1422 if (!SupportsMultipleDisplays()) | 1436 if (!SupportsMultipleDisplays()) |
| 1423 return; | 1437 return; |
| 1424 | 1438 |
| 1425 UpdateDisplay("200x200,200x200*2/r"); | 1439 UpdateDisplay("200x200,200x200*2/r"); |
| 1426 | 1440 |
| 1427 aura::Env* env = aura::Env::GetInstance(); | 1441 aura::Env* env = aura::Env::GetInstance(); |
| 1428 Shell* shell = Shell::GetInstance(); | 1442 Shell* shell = Shell::GetInstance(); |
| 1429 WindowTreeHostManager* window_tree_host_manager = | 1443 WindowTreeHostManager* window_tree_host_manager = |
| 1430 shell->window_tree_host_manager(); | 1444 shell->window_tree_host_manager(); |
| 1431 test::CursorManagerTestApi test_api(shell->cursor_manager()); | 1445 test::CursorManagerTestApi test_api(shell->cursor_manager()); |
| 1432 | 1446 |
| 1433 window_tree_host_manager->GetPrimaryRootWindow()->MoveCursorTo( | 1447 window_tree_host_manager->GetPrimaryRootWindow()->MoveCursorTo( |
| 1434 gfx::Point(20, 50)); | 1448 gfx::Point(20, 50)); |
| 1435 | 1449 |
| 1436 EXPECT_EQ("20,50", env->last_mouse_location().ToString()); | 1450 EXPECT_EQ("20,50", env->last_mouse_location().ToString()); |
| 1437 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); | 1451 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); |
| 1438 EXPECT_EQ(display::Display::ROTATE_0, test_api.GetCurrentCursorRotation()); | 1452 EXPECT_EQ(display::Display::ROTATE_0, test_api.GetCurrentCursorRotation()); |
| 1439 | 1453 |
| 1440 test::SwapPrimaryDisplay(); | 1454 test::SwapPrimaryDisplay(); |
| 1441 | 1455 |
| 1442 EXPECT_EQ("20,50", env->last_mouse_location().ToString()); | 1456 EXPECT_EQ("20,50", env->last_mouse_location().ToString()); |
| 1443 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); | 1457 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); |
| 1444 EXPECT_EQ(display::Display::ROTATE_90, test_api.GetCurrentCursorRotation()); | 1458 EXPECT_EQ(display::Display::ROTATE_90, test_api.GetCurrentCursorRotation()); |
| 1445 } | 1459 } |
| 1446 | 1460 |
| 1447 // Test that the cursor moves to the other display and that its scale factor | 1461 // Test that the cursor moves to the other display and that its scale factor |
| 1448 // and rotation are updated when the primary display is disconnected. | 1462 // and rotation are updated when the primary display is disconnected. |
| 1449 TEST_F(WindowTreeHostManagerTest, | 1463 TEST_P(WindowTreeHostManagerTest, |
| 1450 UpdateMouseLocationAfterDisplayChange_PrimaryDisconnected) { | 1464 UpdateMouseLocationAfterDisplayChange_PrimaryDisconnected) { |
| 1451 if (!SupportsMultipleDisplays()) | 1465 if (!SupportsMultipleDisplays()) |
| 1452 return; | 1466 return; |
| 1453 | 1467 |
| 1454 aura::Env* env = aura::Env::GetInstance(); | 1468 aura::Env* env = aura::Env::GetInstance(); |
| 1455 Shell* shell = Shell::GetInstance(); | 1469 Shell* shell = Shell::GetInstance(); |
| 1456 WindowTreeHostManager* window_tree_host_manager = | 1470 WindowTreeHostManager* window_tree_host_manager = |
| 1457 shell->window_tree_host_manager(); | 1471 shell->window_tree_host_manager(); |
| 1458 test::CursorManagerTestApi test_api(shell->cursor_manager()); | 1472 test::CursorManagerTestApi test_api(shell->cursor_manager()); |
| 1459 | 1473 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1475 window_tree_host_manager->GetPrimaryDisplayId()); | 1489 window_tree_host_manager->GetPrimaryDisplayId()); |
| 1476 | 1490 |
| 1477 // Cursor should be centered on the remaining display. | 1491 // Cursor should be centered on the remaining display. |
| 1478 EXPECT_EQ("75,75", env->last_mouse_location().ToString()); | 1492 EXPECT_EQ("75,75", env->last_mouse_location().ToString()); |
| 1479 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); | 1493 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); |
| 1480 EXPECT_EQ(display::Display::ROTATE_90, test_api.GetCurrentCursorRotation()); | 1494 EXPECT_EQ(display::Display::ROTATE_90, test_api.GetCurrentCursorRotation()); |
| 1481 } | 1495 } |
| 1482 | 1496 |
| 1483 // GetRootWindowForDisplayId() for removed display::Display during | 1497 // GetRootWindowForDisplayId() for removed display::Display during |
| 1484 // OnDisplayRemoved() should not cause crash. See http://crbug.com/415222 | 1498 // OnDisplayRemoved() should not cause crash. See http://crbug.com/415222 |
| 1485 TEST_F(WindowTreeHostManagerTest, | 1499 TEST_P(WindowTreeHostManagerTest, |
| 1486 GetRootWindowForDisplayIdDuringDisplayDisconnection) { | 1500 GetRootWindowForDisplayIdDuringDisplayDisconnection) { |
| 1487 if (!SupportsMultipleDisplays()) | 1501 if (!SupportsMultipleDisplays()) |
| 1488 return; | 1502 return; |
| 1489 | 1503 |
| 1490 UpdateDisplay("300x300,200x200"); | 1504 UpdateDisplay("300x300,200x200"); |
| 1491 aura::Window* root2 = | 1505 aura::Window* root2 = |
| 1492 Shell::GetInstance() | 1506 Shell::GetInstance() |
| 1493 ->window_tree_host_manager() | 1507 ->window_tree_host_manager() |
| 1494 ->GetRootWindowForDisplayId(ScreenUtil::GetSecondaryDisplay().id()); | 1508 ->GetRootWindowForDisplayId(ScreenUtil::GetSecondaryDisplay().id()); |
| 1495 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( | 1509 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1508 widget->GetNativeWindow()->GetRootWindow()); | 1522 widget->GetNativeWindow()->GetRootWindow()); |
| 1509 event_generator.MoveMouseToCenterOf(widget->GetNativeWindow()); | 1523 event_generator.MoveMouseToCenterOf(widget->GetNativeWindow()); |
| 1510 | 1524 |
| 1511 UpdateDisplay("300x300"); | 1525 UpdateDisplay("300x300"); |
| 1512 watcher.Stop(); | 1526 watcher.Stop(); |
| 1513 | 1527 |
| 1514 widget->CloseNow(); | 1528 widget->CloseNow(); |
| 1515 } | 1529 } |
| 1516 | 1530 |
| 1517 } // namespace ash | 1531 } // namespace ash |
| OLD | NEW |