| 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/material_design/material_design_controller.h" | 9 #include "ash/common/material_design/material_design_controller.h" |
| 10 #include "ash/common/shelf/shelf_widget.h" | 10 #include "ash/common/shelf/shelf_widget.h" |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 } | 242 } |
| 243 | 243 |
| 244 class WindowTreeHostManagerShutdownTest : public test::AshTestBase, | 244 class WindowTreeHostManagerShutdownTest : public test::AshTestBase, |
| 245 public TestHelper { | 245 public TestHelper { |
| 246 public: | 246 public: |
| 247 WindowTreeHostManagerShutdownTest() : TestHelper(this) {} | 247 WindowTreeHostManagerShutdownTest() : TestHelper(this) {} |
| 248 ~WindowTreeHostManagerShutdownTest() override {} | 248 ~WindowTreeHostManagerShutdownTest() override {} |
| 249 | 249 |
| 250 void TearDown() override { | 250 void TearDown() override { |
| 251 test::AshTestBase::TearDown(); | 251 test::AshTestBase::TearDown(); |
| 252 if (!SupportsMultipleDisplays()) | |
| 253 return; | |
| 254 | 252 |
| 255 // Make sure that primary display is accessible after shutdown. | 253 // Make sure that primary display is accessible after shutdown. |
| 256 display::Display primary = | 254 display::Display primary = |
| 257 display::Screen::GetScreen()->GetPrimaryDisplay(); | 255 display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 258 EXPECT_EQ("0,0 444x333", primary.bounds().ToString()); | 256 EXPECT_EQ("0,0 444x333", primary.bounds().ToString()); |
| 259 EXPECT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); | 257 EXPECT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); |
| 260 } | 258 } |
| 261 | 259 |
| 262 private: | 260 private: |
| 263 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostManagerShutdownTest); | 261 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostManagerShutdownTest); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 }; | 416 }; |
| 419 | 417 |
| 420 INSTANTIATE_TEST_CASE_P( | 418 INSTANTIATE_TEST_CASE_P( |
| 421 /* prefix intentionally left blank due to only one parameterization */, | 419 /* prefix intentionally left blank due to only one parameterization */, |
| 422 WindowTreeHostManagerTest, | 420 WindowTreeHostManagerTest, |
| 423 testing::Values(MaterialDesignController::NON_MATERIAL, | 421 testing::Values(MaterialDesignController::NON_MATERIAL, |
| 424 MaterialDesignController::MATERIAL_NORMAL, | 422 MaterialDesignController::MATERIAL_NORMAL, |
| 425 MaterialDesignController::MATERIAL_EXPERIMENTAL)); | 423 MaterialDesignController::MATERIAL_EXPERIMENTAL)); |
| 426 | 424 |
| 427 TEST_F(WindowTreeHostManagerShutdownTest, Shutdown) { | 425 TEST_F(WindowTreeHostManagerShutdownTest, Shutdown) { |
| 428 if (!SupportsMultipleDisplays()) | |
| 429 return; | |
| 430 | |
| 431 UpdateDisplay("444x333, 200x200"); | 426 UpdateDisplay("444x333, 200x200"); |
| 432 } | 427 } |
| 433 | 428 |
| 434 TEST_F(WindowTreeHostManagerStartupTest, Startup) { | 429 TEST_F(WindowTreeHostManagerStartupTest, Startup) { |
| 435 if (!SupportsMultipleDisplays()) | |
| 436 return; | |
| 437 | |
| 438 EXPECT_TRUE(startup_helper()->displays_initialized()); | 430 EXPECT_TRUE(startup_helper()->displays_initialized()); |
| 439 } | 431 } |
| 440 | 432 |
| 441 TEST_P(WindowTreeHostManagerTest, SecondaryDisplayLayout) { | 433 TEST_P(WindowTreeHostManagerTest, SecondaryDisplayLayout) { |
| 442 if (!SupportsMultipleDisplays()) | |
| 443 return; | |
| 444 | |
| 445 // Creates windows to catch activation change event. | 434 // Creates windows to catch activation change event. |
| 446 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); | 435 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); |
| 447 w1->Focus(); | 436 w1->Focus(); |
| 448 | 437 |
| 449 TestObserver observer; | 438 TestObserver observer; |
| 450 UpdateDisplay("500x500,400x400"); | 439 UpdateDisplay("500x500,400x400"); |
| 451 EXPECT_EQ(1, observer.CountAndReset()); // resize and add | 440 EXPECT_EQ(1, observer.CountAndReset()); // resize and add |
| 452 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); | 441 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); |
| 453 EXPECT_EQ(2, observer.GetWorkareaChangedCountAndReset()); | 442 EXPECT_EQ(2, observer.GetWorkareaChangedCountAndReset()); |
| 454 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 443 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 float device_scale_factor) { | 586 float device_scale_factor) { |
| 598 display::ManagedDisplayInfo info = | 587 display::ManagedDisplayInfo info = |
| 599 CreateDisplayInfo(id, 0, display::Display::ROTATE_0); | 588 CreateDisplayInfo(id, 0, display::Display::ROTATE_0); |
| 600 info.set_device_scale_factor(device_scale_factor); | 589 info.set_device_scale_factor(device_scale_factor); |
| 601 return info; | 590 return info; |
| 602 } | 591 } |
| 603 | 592 |
| 604 } // namespace | 593 } // namespace |
| 605 | 594 |
| 606 TEST_P(WindowTreeHostManagerTest, MirrorToDockedWithFullscreen) { | 595 TEST_P(WindowTreeHostManagerTest, MirrorToDockedWithFullscreen) { |
| 607 if (!SupportsMultipleDisplays()) | |
| 608 return; | |
| 609 | |
| 610 // Creates windows to catch activation change event. | 596 // Creates windows to catch activation change event. |
| 611 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); | 597 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); |
| 612 w1->Focus(); | 598 w1->Focus(); |
| 613 | 599 |
| 614 // Docked mode. | 600 // Docked mode. |
| 615 | 601 |
| 616 const display::ManagedDisplayInfo internal_display_info = | 602 const display::ManagedDisplayInfo internal_display_info = |
| 617 CreateMirroredDisplayInfo(1, 2.0f); | 603 CreateMirroredDisplayInfo(1, 2.0f); |
| 618 const display::ManagedDisplayInfo external_display_info = | 604 const display::ManagedDisplayInfo external_display_info = |
| 619 CreateMirroredDisplayInfo(2, 1.0f); | 605 CreateMirroredDisplayInfo(2, 1.0f); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 649 EXPECT_EQ(1, observer.GetPrimaryChangedCountAndReset()); | 635 EXPECT_EQ(1, observer.GetPrimaryChangedCountAndReset()); |
| 650 EXPECT_EQ(1, observer.CountAndReset()); | 636 EXPECT_EQ(1, observer.CountAndReset()); |
| 651 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 637 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
| 652 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 638 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
| 653 | 639 |
| 654 EXPECT_TRUE(window_state->IsFullscreen()); | 640 EXPECT_TRUE(window_state->IsFullscreen()); |
| 655 EXPECT_EQ("0,0 500x500", w1->bounds().ToString()); | 641 EXPECT_EQ("0,0 500x500", w1->bounds().ToString()); |
| 656 } | 642 } |
| 657 | 643 |
| 658 TEST_P(WindowTreeHostManagerTest, BoundsUpdated) { | 644 TEST_P(WindowTreeHostManagerTest, BoundsUpdated) { |
| 659 if (!SupportsMultipleDisplays()) | |
| 660 return; | |
| 661 | |
| 662 // Creates windows to catch activation change event. | 645 // Creates windows to catch activation change event. |
| 663 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); | 646 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); |
| 664 w1->Focus(); | 647 w1->Focus(); |
| 665 | 648 |
| 666 TestObserver observer; | 649 TestObserver observer; |
| 667 SetDefaultDisplayLayout(display::DisplayPlacement::BOTTOM); | 650 SetDefaultDisplayLayout(display::DisplayPlacement::BOTTOM); |
| 668 UpdateDisplay("200x200,300x300"); // layout, resize and add. | 651 UpdateDisplay("200x200,300x300"); // layout, resize and add. |
| 669 EXPECT_EQ(1, observer.CountAndReset()); | 652 EXPECT_EQ(1, observer.CountAndReset()); |
| 670 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 653 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
| 671 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 654 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 745 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
| 763 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 746 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
| 764 display::test::DisplayManagerTestApi(display_manager()) | 747 display::test::DisplayManagerTestApi(display_manager()) |
| 765 .SetDisplayUIScale(primary_id, 1.125f); | 748 .SetDisplayUIScale(primary_id, 1.125f); |
| 766 EXPECT_EQ(0, observer.CountAndReset()); | 749 EXPECT_EQ(0, observer.CountAndReset()); |
| 767 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 750 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
| 768 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 751 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
| 769 } | 752 } |
| 770 | 753 |
| 771 TEST_P(WindowTreeHostManagerTest, FindNearestDisplay) { | 754 TEST_P(WindowTreeHostManagerTest, FindNearestDisplay) { |
| 772 if (!SupportsMultipleDisplays()) | |
| 773 return; | |
| 774 | |
| 775 WindowTreeHostManager* window_tree_host_manager = | 755 WindowTreeHostManager* window_tree_host_manager = |
| 776 Shell::GetInstance()->window_tree_host_manager(); | 756 Shell::GetInstance()->window_tree_host_manager(); |
| 777 | 757 |
| 778 UpdateDisplay("200x200,300x300"); | 758 UpdateDisplay("200x200,300x300"); |
| 779 display_manager()->SetLayoutForCurrentDisplays( | 759 display_manager()->SetLayoutForCurrentDisplays( |
| 780 display::test::CreateDisplayLayout(display_manager(), | 760 display::test::CreateDisplayLayout(display_manager(), |
| 781 display::DisplayPlacement::RIGHT, 50)); | 761 display::DisplayPlacement::RIGHT, 50)); |
| 782 | 762 |
| 783 display::Display primary_display = | 763 display::Display primary_display = |
| 784 display::Screen::GetScreen()->GetPrimaryDisplay(); | 764 display::Screen::GetScreen()->GetPrimaryDisplay(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 display::Screen::GetScreen() | 804 display::Screen::GetScreen() |
| 825 ->GetDisplayNearestPoint(gfx::Point(176, 225)) | 805 ->GetDisplayNearestPoint(gfx::Point(176, 225)) |
| 826 .id()); | 806 .id()); |
| 827 EXPECT_EQ(secondary_display.id(), | 807 EXPECT_EQ(secondary_display.id(), |
| 828 display::Screen::GetScreen() | 808 display::Screen::GetScreen() |
| 829 ->GetDisplayNearestPoint(gfx::Point(300, 400)) | 809 ->GetDisplayNearestPoint(gfx::Point(300, 400)) |
| 830 .id()); | 810 .id()); |
| 831 } | 811 } |
| 832 | 812 |
| 833 TEST_P(WindowTreeHostManagerTest, SwapPrimaryById) { | 813 TEST_P(WindowTreeHostManagerTest, SwapPrimaryById) { |
| 834 if (!SupportsMultipleDisplays()) | |
| 835 return; | |
| 836 const int height_offset = GetMdMaximizedWindowHeightOffset(); | 814 const int height_offset = GetMdMaximizedWindowHeightOffset(); |
| 837 | 815 |
| 838 WindowTreeHostManager* window_tree_host_manager = | 816 WindowTreeHostManager* window_tree_host_manager = |
| 839 Shell::GetInstance()->window_tree_host_manager(); | 817 Shell::GetInstance()->window_tree_host_manager(); |
| 840 | 818 |
| 841 UpdateDisplay("200x200,300x300"); | 819 UpdateDisplay("200x200,300x300"); |
| 842 display::Display primary_display = | 820 display::Display primary_display = |
| 843 display::Screen::GetScreen()->GetPrimaryDisplay(); | 821 display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 844 display::Display secondary_display = display_manager()->GetSecondaryDisplay(); | 822 display::Display secondary_display = display_manager()->GetSecondaryDisplay(); |
| 845 | 823 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 EXPECT_EQ(third_display_info.id(), | 954 EXPECT_EQ(third_display_info.id(), |
| 977 display_manager()->GetSecondaryDisplay().id()); | 955 display_manager()->GetSecondaryDisplay().id()); |
| 978 EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( | 956 EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( |
| 979 primary_display.id())); | 957 primary_display.id())); |
| 980 EXPECT_NE(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( | 958 EXPECT_NE(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( |
| 981 third_display_info.id())); | 959 third_display_info.id())); |
| 982 EXPECT_TRUE(primary_root->Contains(shelf_window)); | 960 EXPECT_TRUE(primary_root->Contains(shelf_window)); |
| 983 } | 961 } |
| 984 | 962 |
| 985 TEST_P(WindowTreeHostManagerTest, SetPrimaryWithThreeDisplays) { | 963 TEST_P(WindowTreeHostManagerTest, SetPrimaryWithThreeDisplays) { |
| 986 if (!SupportsMultipleDisplays()) | |
| 987 return; | |
| 988 UpdateDisplay("500x400,400x300,300x200"); | 964 UpdateDisplay("500x400,400x300,300x200"); |
| 989 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 965 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 990 display::DisplayIdList non_primary_ids = | 966 display::DisplayIdList non_primary_ids = |
| 991 display_manager()->GetCurrentDisplayIdList(); | 967 display_manager()->GetCurrentDisplayIdList(); |
| 992 auto itr = | 968 auto itr = |
| 993 std::remove(non_primary_ids.begin(), non_primary_ids.end(), primary_id); | 969 std::remove(non_primary_ids.begin(), non_primary_ids.end(), primary_id); |
| 994 ASSERT_TRUE(itr != non_primary_ids.end()); | 970 ASSERT_TRUE(itr != non_primary_ids.end()); |
| 995 non_primary_ids.erase(itr, non_primary_ids.end()); | 971 non_primary_ids.erase(itr, non_primary_ids.end()); |
| 996 ASSERT_EQ(2u, non_primary_ids.size()); | 972 ASSERT_EQ(2u, non_primary_ids.size()); |
| 997 | 973 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 EXPECT_EQ(display::DisplayPlacement::TOP, | 1074 EXPECT_EQ(display::DisplayPlacement::TOP, |
| 1099 current_layout.placement_list[0].position); | 1075 current_layout.placement_list[0].position); |
| 1100 EXPECT_EQ(non_primary_ids[0], current_layout.placement_list[1].display_id); | 1076 EXPECT_EQ(non_primary_ids[0], current_layout.placement_list[1].display_id); |
| 1101 EXPECT_EQ(primary_id, current_layout.placement_list[1].parent_display_id); | 1077 EXPECT_EQ(primary_id, current_layout.placement_list[1].parent_display_id); |
| 1102 EXPECT_EQ(display::DisplayPlacement::RIGHT, | 1078 EXPECT_EQ(display::DisplayPlacement::RIGHT, |
| 1103 current_layout.placement_list[1].position); | 1079 current_layout.placement_list[1].position); |
| 1104 } | 1080 } |
| 1105 } | 1081 } |
| 1106 | 1082 |
| 1107 TEST_P(WindowTreeHostManagerTest, SetPrimaryWithFourDisplays) { | 1083 TEST_P(WindowTreeHostManagerTest, SetPrimaryWithFourDisplays) { |
| 1108 if (!SupportsMultipleDisplays()) | |
| 1109 return; | |
| 1110 UpdateDisplay("600x500,500x400,400x300,300x200"); | 1084 UpdateDisplay("600x500,500x400,400x300,300x200"); |
| 1111 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 1085 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 1112 display::DisplayIdList non_primary_ids = | 1086 display::DisplayIdList non_primary_ids = |
| 1113 display_manager()->GetCurrentDisplayIdList(); | 1087 display_manager()->GetCurrentDisplayIdList(); |
| 1114 auto itr = | 1088 auto itr = |
| 1115 std::remove(non_primary_ids.begin(), non_primary_ids.end(), primary_id); | 1089 std::remove(non_primary_ids.begin(), non_primary_ids.end(), primary_id); |
| 1116 ASSERT_TRUE(itr != non_primary_ids.end()); | 1090 ASSERT_TRUE(itr != non_primary_ids.end()); |
| 1117 non_primary_ids.erase(itr, non_primary_ids.end()); | 1091 non_primary_ids.erase(itr, non_primary_ids.end()); |
| 1118 ASSERT_EQ(3u, non_primary_ids.size()); | 1092 ASSERT_EQ(3u, non_primary_ids.size()); |
| 1119 | 1093 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 current_layout.placement_list[1].position); | 1183 current_layout.placement_list[1].position); |
| 1210 EXPECT_EQ(non_primary_ids[2], current_layout.placement_list[2].display_id); | 1184 EXPECT_EQ(non_primary_ids[2], current_layout.placement_list[2].display_id); |
| 1211 EXPECT_EQ(non_primary_ids[0], | 1185 EXPECT_EQ(non_primary_ids[0], |
| 1212 current_layout.placement_list[2].parent_display_id); | 1186 current_layout.placement_list[2].parent_display_id); |
| 1213 EXPECT_EQ(display::DisplayPlacement::RIGHT, | 1187 EXPECT_EQ(display::DisplayPlacement::RIGHT, |
| 1214 current_layout.placement_list[2].position); | 1188 current_layout.placement_list[2].position); |
| 1215 } | 1189 } |
| 1216 } | 1190 } |
| 1217 | 1191 |
| 1218 TEST_P(WindowTreeHostManagerTest, OverscanInsets) { | 1192 TEST_P(WindowTreeHostManagerTest, OverscanInsets) { |
| 1219 if (!SupportsMultipleDisplays()) | |
| 1220 return; | |
| 1221 | |
| 1222 WindowTreeHostManager* window_tree_host_manager = | 1193 WindowTreeHostManager* window_tree_host_manager = |
| 1223 Shell::GetInstance()->window_tree_host_manager(); | 1194 Shell::GetInstance()->window_tree_host_manager(); |
| 1224 TestEventHandler event_handler; | 1195 TestEventHandler event_handler; |
| 1225 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 1196 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
| 1226 | 1197 |
| 1227 UpdateDisplay("120x200,300x400*2"); | 1198 UpdateDisplay("120x200,300x400*2"); |
| 1228 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); | 1199 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 1229 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1200 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1230 | 1201 |
| 1231 window_tree_host_manager->SetOverscanInsets(display1.id(), | 1202 window_tree_host_manager->SetOverscanInsets(display1.id(), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1259 SwapPrimaryDisplay(); | 1230 SwapPrimaryDisplay(); |
| 1260 point.SetPoint(0, 0); | 1231 point.SetPoint(0, 0); |
| 1261 Shell::GetAllRootWindows()[1]->GetHost()->GetRootTransform().TransformPoint( | 1232 Shell::GetAllRootWindows()[1]->GetHost()->GetRootTransform().TransformPoint( |
| 1262 &point); | 1233 &point); |
| 1263 EXPECT_EQ("15,10", point.ToString()); | 1234 EXPECT_EQ("15,10", point.ToString()); |
| 1264 | 1235 |
| 1265 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 1236 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
| 1266 } | 1237 } |
| 1267 | 1238 |
| 1268 TEST_P(WindowTreeHostManagerTest, Rotate) { | 1239 TEST_P(WindowTreeHostManagerTest, Rotate) { |
| 1269 if (!SupportsMultipleDisplays()) | |
| 1270 return; | |
| 1271 | |
| 1272 TestEventHandler event_handler; | 1240 TestEventHandler event_handler; |
| 1273 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 1241 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
| 1274 | 1242 |
| 1275 UpdateDisplay("120x200,300x400*2"); | 1243 UpdateDisplay("120x200,300x400*2"); |
| 1276 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); | 1244 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 1277 int64_t display2_id = display_manager()->GetSecondaryDisplay().id(); | 1245 int64_t display2_id = display_manager()->GetSecondaryDisplay().id(); |
| 1278 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1246 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1279 ui::test::EventGenerator generator1(root_windows[0]); | 1247 ui::test::EventGenerator generator1(root_windows[0]); |
| 1280 | 1248 |
| 1281 TestObserver observer; | 1249 TestObserver observer; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1316 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); | 1284 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); |
| 1317 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); | 1285 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); |
| 1318 EXPECT_EQ("50,120 200x150", | 1286 EXPECT_EQ("50,120 200x150", |
| 1319 display_manager()->GetSecondaryDisplay().bounds().ToString()); | 1287 display_manager()->GetSecondaryDisplay().bounds().ToString()); |
| 1320 EXPECT_EQ(display::Display::ROTATE_90, | 1288 EXPECT_EQ(display::Display::ROTATE_90, |
| 1321 GetActiveDisplayRotation(display1.id())); | 1289 GetActiveDisplayRotation(display1.id())); |
| 1322 EXPECT_EQ(display::Display::ROTATE_270, | 1290 EXPECT_EQ(display::Display::ROTATE_270, |
| 1323 GetActiveDisplayRotation(display2_id)); | 1291 GetActiveDisplayRotation(display2_id)); |
| 1324 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); | 1292 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); |
| 1325 | 1293 |
| 1326 #if !defined(OS_WIN) | |
| 1327 ui::test::EventGenerator generator2(root_windows[1]); | 1294 ui::test::EventGenerator generator2(root_windows[1]); |
| 1328 generator2.MoveMouseToInHost(50, 40); | 1295 generator2.MoveMouseToInHost(50, 40); |
| 1329 EXPECT_EQ("179,25", event_handler.GetLocationAndReset()); | 1296 EXPECT_EQ("179,25", event_handler.GetLocationAndReset()); |
| 1330 display_manager()->SetDisplayRotation( | 1297 display_manager()->SetDisplayRotation( |
| 1331 display1.id(), display::Display::ROTATE_180, | 1298 display1.id(), display::Display::ROTATE_180, |
| 1332 display::Display::ROTATION_SOURCE_ACTIVE); | 1299 display::Display::ROTATION_SOURCE_ACTIVE); |
| 1333 | 1300 |
| 1334 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); | 1301 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); |
| 1335 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); | 1302 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); |
| 1336 // Dislay must share at least 100, so the x's offset becomes 20. | 1303 // Dislay must share at least 100, so the x's offset becomes 20. |
| 1337 EXPECT_EQ("20,200 200x150", | 1304 EXPECT_EQ("20,200 200x150", |
| 1338 display_manager()->GetSecondaryDisplay().bounds().ToString()); | 1305 display_manager()->GetSecondaryDisplay().bounds().ToString()); |
| 1339 EXPECT_EQ(display::Display::ROTATE_180, | 1306 EXPECT_EQ(display::Display::ROTATE_180, |
| 1340 GetActiveDisplayRotation(display1.id())); | 1307 GetActiveDisplayRotation(display1.id())); |
| 1341 EXPECT_EQ(display::Display::ROTATE_270, | 1308 EXPECT_EQ(display::Display::ROTATE_270, |
| 1342 GetActiveDisplayRotation(display2_id)); | 1309 GetActiveDisplayRotation(display2_id)); |
| 1343 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); | 1310 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); |
| 1344 | 1311 |
| 1345 generator1.MoveMouseToInHost(50, 40); | 1312 generator1.MoveMouseToInHost(50, 40); |
| 1346 EXPECT_EQ("69,159", event_handler.GetLocationAndReset()); | 1313 EXPECT_EQ("69,159", event_handler.GetLocationAndReset()); |
| 1347 #endif | |
| 1348 | 1314 |
| 1349 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 1315 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
| 1350 } | 1316 } |
| 1351 | 1317 |
| 1352 TEST_P(WindowTreeHostManagerTest, ScaleRootWindow) { | 1318 TEST_P(WindowTreeHostManagerTest, ScaleRootWindow) { |
| 1353 if (!SupportsMultipleDisplays()) | |
| 1354 return; | |
| 1355 | |
| 1356 TestEventHandler event_handler; | 1319 TestEventHandler event_handler; |
| 1357 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 1320 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
| 1358 | 1321 |
| 1359 UpdateDisplay("600x400*2@1.5,500x300"); | 1322 UpdateDisplay("600x400*2@1.5,500x300"); |
| 1360 | 1323 |
| 1361 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); | 1324 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 1362 display::test::ScopedSetInternalDisplayId set_internal(display_manager(), | 1325 display::test::ScopedSetInternalDisplayId set_internal(display_manager(), |
| 1363 display1.id()); | 1326 display1.id()); |
| 1364 | 1327 |
| 1365 display::Display display2 = display_manager()->GetSecondaryDisplay(); | 1328 display::Display display2 = display_manager()->GetSecondaryDisplay(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1381 EXPECT_EQ("0,0 375x250", display1.bounds().ToString()); | 1344 EXPECT_EQ("0,0 375x250", display1.bounds().ToString()); |
| 1382 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString()); | 1345 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString()); |
| 1383 EXPECT_EQ("375,0 500x300", display2.bounds().ToString()); | 1346 EXPECT_EQ("375,0 500x300", display2.bounds().ToString()); |
| 1384 EXPECT_EQ(1.25f, GetStoredUIScale(display1.id())); | 1347 EXPECT_EQ(1.25f, GetStoredUIScale(display1.id())); |
| 1385 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); | 1348 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); |
| 1386 | 1349 |
| 1387 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 1350 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
| 1388 } | 1351 } |
| 1389 | 1352 |
| 1390 TEST_P(WindowTreeHostManagerTest, TouchScale) { | 1353 TEST_P(WindowTreeHostManagerTest, TouchScale) { |
| 1391 if (!SupportsMultipleDisplays()) | |
| 1392 return; | |
| 1393 | |
| 1394 TestEventHandler event_handler; | 1354 TestEventHandler event_handler; |
| 1395 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 1355 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
| 1396 | 1356 |
| 1397 UpdateDisplay("200x200*2"); | 1357 UpdateDisplay("200x200*2"); |
| 1398 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); | 1358 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 1399 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1359 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1400 aura::Window* root_window = root_windows[0]; | 1360 aura::Window* root_window = root_windows[0]; |
| 1401 ui::test::EventGenerator generator(root_window); | 1361 ui::test::EventGenerator generator(root_window); |
| 1402 | 1362 |
| 1403 generator.PressMoveAndReleaseTouchTo(50, 50); | 1363 generator.PressMoveAndReleaseTouchTo(50, 50); |
| 1404 // Default test touches have radius_x/y = 1.0, with device scale | 1364 // Default test touches have radius_x/y = 1.0, with device scale |
| 1405 // factor = 2, the scaled radius_x/y should be 0.5. | 1365 // factor = 2, the scaled radius_x/y should be 0.5. |
| 1406 EXPECT_EQ(0.5, event_handler.touch_radius_x()); | 1366 EXPECT_EQ(0.5, event_handler.touch_radius_x()); |
| 1407 EXPECT_EQ(0.5, event_handler.touch_radius_y()); | 1367 EXPECT_EQ(0.5, event_handler.touch_radius_y()); |
| 1408 | 1368 |
| 1409 generator.ScrollSequence(gfx::Point(0, 0), | 1369 generator.ScrollSequence(gfx::Point(0, 0), |
| 1410 base::TimeDelta::FromMilliseconds(100), 10.0, 1.0, 5, | 1370 base::TimeDelta::FromMilliseconds(100), 10.0, 1.0, 5, |
| 1411 1); | 1371 1); |
| 1412 | 1372 |
| 1413 // ordinal_offset is invariant to the device scale factor. | 1373 // ordinal_offset is invariant to the device scale factor. |
| 1414 EXPECT_EQ(event_handler.scroll_x_offset(), | 1374 EXPECT_EQ(event_handler.scroll_x_offset(), |
| 1415 event_handler.scroll_x_offset_ordinal()); | 1375 event_handler.scroll_x_offset_ordinal()); |
| 1416 EXPECT_EQ(event_handler.scroll_y_offset(), | 1376 EXPECT_EQ(event_handler.scroll_y_offset(), |
| 1417 event_handler.scroll_y_offset_ordinal()); | 1377 event_handler.scroll_y_offset_ordinal()); |
| 1418 | 1378 |
| 1419 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 1379 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
| 1420 } | 1380 } |
| 1421 | 1381 |
| 1422 TEST_P(WindowTreeHostManagerTest, ConvertHostToRootCoords) { | 1382 TEST_P(WindowTreeHostManagerTest, ConvertHostToRootCoords) { |
| 1423 if (!SupportsMultipleDisplays()) | |
| 1424 return; | |
| 1425 | |
| 1426 TestEventHandler event_handler; | 1383 TestEventHandler event_handler; |
| 1427 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 1384 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
| 1428 | 1385 |
| 1429 UpdateDisplay("600x400*2/r@1.5"); | 1386 UpdateDisplay("600x400*2/r@1.5"); |
| 1430 | 1387 |
| 1431 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); | 1388 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 1432 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1389 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1433 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); | 1390 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); |
| 1434 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); | 1391 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); |
| 1435 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); | 1392 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1475 EXPECT_EQ("0,449", event_handler.GetLocationAndReset()); | 1432 EXPECT_EQ("0,449", event_handler.GetLocationAndReset()); |
| 1476 generator.MoveMouseToInHost(0, 399); | 1433 generator.MoveMouseToInHost(0, 399); |
| 1477 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); | 1434 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); |
| 1478 | 1435 |
| 1479 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 1436 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
| 1480 } | 1437 } |
| 1481 | 1438 |
| 1482 // Make sure that the compositor based mirroring can switch | 1439 // Make sure that the compositor based mirroring can switch |
| 1483 // from/to dock mode. | 1440 // from/to dock mode. |
| 1484 TEST_P(WindowTreeHostManagerTest, DockToSingle) { | 1441 TEST_P(WindowTreeHostManagerTest, DockToSingle) { |
| 1485 if (!SupportsMultipleDisplays()) | |
| 1486 return; | |
| 1487 | |
| 1488 const int64_t internal_id = 1; | 1442 const int64_t internal_id = 1; |
| 1489 | 1443 |
| 1490 const display::ManagedDisplayInfo internal_display_info = | 1444 const display::ManagedDisplayInfo internal_display_info = |
| 1491 CreateDisplayInfo(internal_id, 0, display::Display::ROTATE_0); | 1445 CreateDisplayInfo(internal_id, 0, display::Display::ROTATE_0); |
| 1492 const display::ManagedDisplayInfo external_display_info = | 1446 const display::ManagedDisplayInfo external_display_info = |
| 1493 CreateDisplayInfo(2, 1, display::Display::ROTATE_90); | 1447 CreateDisplayInfo(2, 1, display::Display::ROTATE_90); |
| 1494 | 1448 |
| 1495 std::vector<display::ManagedDisplayInfo> display_info_list; | 1449 std::vector<display::ManagedDisplayInfo> display_info_list; |
| 1496 // Extended | 1450 // Extended |
| 1497 display_info_list.push_back(internal_display_info); | 1451 display_info_list.push_back(internal_display_info); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1520 display_manager()->OnNativeDisplaysChanged(display_info_list); | 1474 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 1521 EXPECT_TRUE(Shell::GetPrimaryRootWindow() | 1475 EXPECT_TRUE(Shell::GetPrimaryRootWindow() |
| 1522 ->GetHost() | 1476 ->GetHost() |
| 1523 ->GetRootTransform() | 1477 ->GetRootTransform() |
| 1524 .IsIdentityOrIntegerTranslation()); | 1478 .IsIdentityOrIntegerTranslation()); |
| 1525 } | 1479 } |
| 1526 | 1480 |
| 1527 // Tests if switching two displays at the same time while the primary display | 1481 // Tests if switching two displays at the same time while the primary display |
| 1528 // is swapped should not cause a crash. (crbug.com/426292) | 1482 // is swapped should not cause a crash. (crbug.com/426292) |
| 1529 TEST_P(WindowTreeHostManagerTest, ReplaceSwappedPrimary) { | 1483 TEST_P(WindowTreeHostManagerTest, ReplaceSwappedPrimary) { |
| 1530 if (!SupportsMultipleDisplays()) | |
| 1531 return; | |
| 1532 | |
| 1533 const display::ManagedDisplayInfo first_display_info = | 1484 const display::ManagedDisplayInfo first_display_info = |
| 1534 CreateDisplayInfo(10, 0, display::Display::ROTATE_0); | 1485 CreateDisplayInfo(10, 0, display::Display::ROTATE_0); |
| 1535 const display::ManagedDisplayInfo second_display_info = | 1486 const display::ManagedDisplayInfo second_display_info = |
| 1536 CreateDisplayInfo(11, 1, display::Display::ROTATE_0); | 1487 CreateDisplayInfo(11, 1, display::Display::ROTATE_0); |
| 1537 | 1488 |
| 1538 std::vector<display::ManagedDisplayInfo> display_info_list; | 1489 std::vector<display::ManagedDisplayInfo> display_info_list; |
| 1539 // Extended | 1490 // Extended |
| 1540 display_info_list.push_back(first_display_info); | 1491 display_info_list.push_back(first_display_info); |
| 1541 display_info_list.push_back(second_display_info); | 1492 display_info_list.push_back(second_display_info); |
| 1542 display_manager()->OnNativeDisplaysChanged(display_info_list); | 1493 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1583 | 1534 |
| 1584 } // names | 1535 } // names |
| 1585 | 1536 |
| 1586 // Make sure that GetDisplayBoundsWithShelf returns the correct bounds | 1537 // Make sure that GetDisplayBoundsWithShelf returns the correct bounds |
| 1587 // when the primary display gets replaced in one of the following scenarios: | 1538 // when the primary display gets replaced in one of the following scenarios: |
| 1588 // 1) Two displays connected: a) b) | 1539 // 1) Two displays connected: a) b) |
| 1589 // 2) both are disconnected and new one with the same size as b) is connected | 1540 // 2) both are disconnected and new one with the same size as b) is connected |
| 1590 // in one configuration event. | 1541 // in one configuration event. |
| 1591 // See crbug.com/547280. | 1542 // See crbug.com/547280. |
| 1592 TEST_P(WindowTreeHostManagerTest, ReplacePrimary) { | 1543 TEST_P(WindowTreeHostManagerTest, ReplacePrimary) { |
| 1593 if (!SupportsMultipleDisplays()) | |
| 1594 return; | |
| 1595 | |
| 1596 display::ManagedDisplayInfo first_display_info = | 1544 display::ManagedDisplayInfo first_display_info = |
| 1597 CreateDisplayInfo(10, 0, display::Display::ROTATE_0); | 1545 CreateDisplayInfo(10, 0, display::Display::ROTATE_0); |
| 1598 first_display_info.SetBounds(gfx::Rect(0, 0, 400, 400)); | 1546 first_display_info.SetBounds(gfx::Rect(0, 0, 400, 400)); |
| 1599 const display::ManagedDisplayInfo second_display_info = | 1547 const display::ManagedDisplayInfo second_display_info = |
| 1600 CreateDisplayInfo(11, 500, display::Display::ROTATE_0); | 1548 CreateDisplayInfo(11, 500, display::Display::ROTATE_0); |
| 1601 | 1549 |
| 1602 std::vector<display::ManagedDisplayInfo> display_info_list; | 1550 std::vector<display::ManagedDisplayInfo> display_info_list; |
| 1603 // Extended | 1551 // Extended |
| 1604 display_info_list.push_back(first_display_info); | 1552 display_info_list.push_back(first_display_info); |
| 1605 display_info_list.push_back(second_display_info); | 1553 display_info_list.push_back(second_display_info); |
| 1606 display_manager()->OnNativeDisplaysChanged(display_info_list); | 1554 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 1607 aura::Window* primary_root = Shell::GetAllRootWindows()[0]; | 1555 aura::Window* primary_root = Shell::GetAllRootWindows()[0]; |
| 1608 | 1556 |
| 1609 int64_t new_display_id = 20; | 1557 int64_t new_display_id = 20; |
| 1610 RootWindowTestObserver test_observer; | 1558 RootWindowTestObserver test_observer; |
| 1611 primary_root->AddObserver(&test_observer); | 1559 primary_root->AddObserver(&test_observer); |
| 1612 | 1560 |
| 1613 display_info_list.clear(); | 1561 display_info_list.clear(); |
| 1614 const display::ManagedDisplayInfo new_first_display_info = | 1562 const display::ManagedDisplayInfo new_first_display_info = |
| 1615 CreateDisplayInfo(new_display_id, 0, display::Display::ROTATE_0); | 1563 CreateDisplayInfo(new_display_id, 0, display::Display::ROTATE_0); |
| 1616 | 1564 |
| 1617 display_info_list.push_back(new_first_display_info); | 1565 display_info_list.push_back(new_first_display_info); |
| 1618 display_manager()->OnNativeDisplaysChanged(display_info_list); | 1566 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 1619 EXPECT_EQ("0,0 500x500", test_observer.shelf_display_bounds().ToString()); | 1567 EXPECT_EQ("0,0 500x500", test_observer.shelf_display_bounds().ToString()); |
| 1620 primary_root->RemoveObserver(&test_observer); | 1568 primary_root->RemoveObserver(&test_observer); |
| 1621 } | 1569 } |
| 1622 | 1570 |
| 1623 TEST_P(WindowTreeHostManagerTest, UpdateMouseLocationAfterDisplayChange) { | 1571 TEST_P(WindowTreeHostManagerTest, UpdateMouseLocationAfterDisplayChange) { |
| 1624 if (!SupportsMultipleDisplays()) | |
| 1625 return; | |
| 1626 | |
| 1627 UpdateDisplay("200x200,300x300"); | 1572 UpdateDisplay("200x200,300x300"); |
| 1628 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1573 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1629 | 1574 |
| 1630 aura::Env* env = aura::Env::GetInstance(); | 1575 aura::Env* env = aura::Env::GetInstance(); |
| 1631 | 1576 |
| 1632 ui::test::EventGenerator generator(root_windows[0]); | 1577 ui::test::EventGenerator generator(root_windows[0]); |
| 1633 | 1578 |
| 1634 // Set the initial position. | 1579 // Set the initial position. |
| 1635 generator.MoveMouseToInHost(350, 150); | 1580 generator.MoveMouseToInHost(350, 150); |
| 1636 EXPECT_EQ("350,150", env->last_mouse_location().ToString()); | 1581 EXPECT_EQ("350,150", env->last_mouse_location().ToString()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1658 generator.MoveMouseToInHost(150, 290); | 1603 generator.MoveMouseToInHost(150, 290); |
| 1659 EXPECT_EQ("150,290", env->last_mouse_location().ToString()); | 1604 EXPECT_EQ("150,290", env->last_mouse_location().ToString()); |
| 1660 | 1605 |
| 1661 // The mouse pointer is now on 2nd display. | 1606 // The mouse pointer is now on 2nd display. |
| 1662 UpdateDisplay("300x280,200x200"); | 1607 UpdateDisplay("300x280,200x200"); |
| 1663 EXPECT_EQ("450,10", env->last_mouse_location().ToString()); | 1608 EXPECT_EQ("450,10", env->last_mouse_location().ToString()); |
| 1664 } | 1609 } |
| 1665 | 1610 |
| 1666 TEST_P(WindowTreeHostManagerTest, | 1611 TEST_P(WindowTreeHostManagerTest, |
| 1667 UpdateMouseLocationAfterDisplayChange_2ndOnLeft) { | 1612 UpdateMouseLocationAfterDisplayChange_2ndOnLeft) { |
| 1668 if (!SupportsMultipleDisplays()) | |
| 1669 return; | |
| 1670 | |
| 1671 // Set the 2nd display on the left. | 1613 // Set the 2nd display on the left. |
| 1672 display::DisplayLayoutStore* layout_store = display_manager()->layout_store(); | 1614 display::DisplayLayoutStore* layout_store = display_manager()->layout_store(); |
| 1673 display::DisplayPlacement new_default(display::DisplayPlacement::LEFT, 0); | 1615 display::DisplayPlacement new_default(display::DisplayPlacement::LEFT, 0); |
| 1674 layout_store->SetDefaultDisplayPlacement(new_default); | 1616 layout_store->SetDefaultDisplayPlacement(new_default); |
| 1675 | 1617 |
| 1676 UpdateDisplay("200x200,300x300"); | 1618 UpdateDisplay("200x200,300x300"); |
| 1677 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1619 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1678 | 1620 |
| 1679 EXPECT_EQ("-300,0 300x300", | 1621 EXPECT_EQ("-300,0 300x300", |
| 1680 display_manager()->GetSecondaryDisplay().bounds().ToString()); | 1622 display_manager()->GetSecondaryDisplay().bounds().ToString()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1697 // 2nd display was disconnected. Mouse pointer should move to | 1639 // 2nd display was disconnected. Mouse pointer should move to |
| 1698 // 1st display. | 1640 // 1st display. |
| 1699 UpdateDisplay("300x300"); | 1641 UpdateDisplay("300x300"); |
| 1700 EXPECT_EQ("150,150", env->last_mouse_location().ToString()); | 1642 EXPECT_EQ("150,150", env->last_mouse_location().ToString()); |
| 1701 } | 1643 } |
| 1702 | 1644 |
| 1703 // Test that the cursor swaps displays and that its scale factor and rotation | 1645 // Test that the cursor swaps displays and that its scale factor and rotation |
| 1704 // are updated when the primary display is swapped. | 1646 // are updated when the primary display is swapped. |
| 1705 TEST_P(WindowTreeHostManagerTest, | 1647 TEST_P(WindowTreeHostManagerTest, |
| 1706 UpdateMouseLocationAfterDisplayChange_SwapPrimary) { | 1648 UpdateMouseLocationAfterDisplayChange_SwapPrimary) { |
| 1707 if (!SupportsMultipleDisplays()) | |
| 1708 return; | |
| 1709 | |
| 1710 UpdateDisplay("200x200,200x200*2/r"); | 1649 UpdateDisplay("200x200,200x200*2/r"); |
| 1711 | 1650 |
| 1712 aura::Env* env = aura::Env::GetInstance(); | 1651 aura::Env* env = aura::Env::GetInstance(); |
| 1713 Shell* shell = Shell::GetInstance(); | 1652 Shell* shell = Shell::GetInstance(); |
| 1714 WindowTreeHostManager* window_tree_host_manager = | 1653 WindowTreeHostManager* window_tree_host_manager = |
| 1715 shell->window_tree_host_manager(); | 1654 shell->window_tree_host_manager(); |
| 1716 test::CursorManagerTestApi test_api(shell->cursor_manager()); | 1655 test::CursorManagerTestApi test_api(shell->cursor_manager()); |
| 1717 | 1656 |
| 1718 window_tree_host_manager->GetPrimaryRootWindow()->MoveCursorTo( | 1657 window_tree_host_manager->GetPrimaryRootWindow()->MoveCursorTo( |
| 1719 gfx::Point(20, 50)); | 1658 gfx::Point(20, 50)); |
| 1720 | 1659 |
| 1721 EXPECT_EQ("20,50", env->last_mouse_location().ToString()); | 1660 EXPECT_EQ("20,50", env->last_mouse_location().ToString()); |
| 1722 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); | 1661 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); |
| 1723 EXPECT_EQ(display::Display::ROTATE_0, test_api.GetCurrentCursorRotation()); | 1662 EXPECT_EQ(display::Display::ROTATE_0, test_api.GetCurrentCursorRotation()); |
| 1724 | 1663 |
| 1725 SwapPrimaryDisplay(); | 1664 SwapPrimaryDisplay(); |
| 1726 | 1665 |
| 1727 EXPECT_EQ("20,50", env->last_mouse_location().ToString()); | 1666 EXPECT_EQ("20,50", env->last_mouse_location().ToString()); |
| 1728 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); | 1667 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); |
| 1729 EXPECT_EQ(display::Display::ROTATE_90, test_api.GetCurrentCursorRotation()); | 1668 EXPECT_EQ(display::Display::ROTATE_90, test_api.GetCurrentCursorRotation()); |
| 1730 } | 1669 } |
| 1731 | 1670 |
| 1732 // Test that the cursor moves to the other display and that its scale factor | 1671 // Test that the cursor moves to the other display and that its scale factor |
| 1733 // and rotation are updated when the primary display is disconnected. | 1672 // and rotation are updated when the primary display is disconnected. |
| 1734 TEST_P(WindowTreeHostManagerTest, | 1673 TEST_P(WindowTreeHostManagerTest, |
| 1735 UpdateMouseLocationAfterDisplayChange_PrimaryDisconnected) { | 1674 UpdateMouseLocationAfterDisplayChange_PrimaryDisconnected) { |
| 1736 if (!SupportsMultipleDisplays()) | |
| 1737 return; | |
| 1738 | |
| 1739 aura::Env* env = aura::Env::GetInstance(); | 1675 aura::Env* env = aura::Env::GetInstance(); |
| 1740 Shell* shell = Shell::GetInstance(); | 1676 Shell* shell = Shell::GetInstance(); |
| 1741 WindowTreeHostManager* window_tree_host_manager = | 1677 WindowTreeHostManager* window_tree_host_manager = |
| 1742 shell->window_tree_host_manager(); | 1678 shell->window_tree_host_manager(); |
| 1743 test::CursorManagerTestApi test_api(shell->cursor_manager()); | 1679 test::CursorManagerTestApi test_api(shell->cursor_manager()); |
| 1744 | 1680 |
| 1745 UpdateDisplay("300x300*2/r,200x200"); | 1681 UpdateDisplay("300x300*2/r,200x200"); |
| 1746 // Swap the primary display to make it possible to remove the primary display | 1682 // Swap the primary display to make it possible to remove the primary display |
| 1747 // via UpdateDisplay(). | 1683 // via UpdateDisplay(). |
| 1748 SwapPrimaryDisplay(); | 1684 SwapPrimaryDisplay(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1762 // Cursor should be centered on the remaining display. | 1698 // Cursor should be centered on the remaining display. |
| 1763 EXPECT_EQ("75,75", env->last_mouse_location().ToString()); | 1699 EXPECT_EQ("75,75", env->last_mouse_location().ToString()); |
| 1764 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); | 1700 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); |
| 1765 EXPECT_EQ(display::Display::ROTATE_90, test_api.GetCurrentCursorRotation()); | 1701 EXPECT_EQ(display::Display::ROTATE_90, test_api.GetCurrentCursorRotation()); |
| 1766 } | 1702 } |
| 1767 | 1703 |
| 1768 // GetRootWindowForDisplayId() for removed display::Display during | 1704 // GetRootWindowForDisplayId() for removed display::Display during |
| 1769 // OnDisplayRemoved() should not cause crash. See http://crbug.com/415222 | 1705 // OnDisplayRemoved() should not cause crash. See http://crbug.com/415222 |
| 1770 TEST_P(WindowTreeHostManagerTest, | 1706 TEST_P(WindowTreeHostManagerTest, |
| 1771 GetRootWindowForDisplayIdDuringDisplayDisconnection) { | 1707 GetRootWindowForDisplayIdDuringDisplayDisconnection) { |
| 1772 if (!SupportsMultipleDisplays()) | |
| 1773 return; | |
| 1774 | |
| 1775 UpdateDisplay("300x300,200x200"); | 1708 UpdateDisplay("300x300,200x200"); |
| 1776 aura::Window* root2 = Shell::GetInstance() | 1709 aura::Window* root2 = Shell::GetInstance() |
| 1777 ->window_tree_host_manager() | 1710 ->window_tree_host_manager() |
| 1778 ->GetRootWindowForDisplayId( | 1711 ->GetRootWindowForDisplayId( |
| 1779 display_manager()->GetSecondaryDisplay().id()); | 1712 display_manager()->GetSecondaryDisplay().id()); |
| 1780 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( | 1713 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( |
| 1781 nullptr, root2, gfx::Rect(350, 0, 100, 100)); | 1714 nullptr, root2, gfx::Rect(350, 0, 100, 100)); |
| 1782 views::View* view = new views::View(); | 1715 views::View* view = new views::View(); |
| 1783 widget->GetContentsView()->AddChildView(view); | 1716 widget->GetContentsView()->AddChildView(view); |
| 1784 view->SetBounds(0, 0, 100, 100); | 1717 view->SetBounds(0, 0, 100, 100); |
| 1785 widget->Show(); | 1718 widget->Show(); |
| 1786 | 1719 |
| 1787 TestMouseWatcherListener listener; | 1720 TestMouseWatcherListener listener; |
| 1788 views::MouseWatcher watcher( | 1721 views::MouseWatcher watcher( |
| 1789 new views::MouseWatcherViewHost(view, gfx::Insets()), &listener); | 1722 new views::MouseWatcherViewHost(view, gfx::Insets()), &listener); |
| 1790 watcher.Start(); | 1723 watcher.Start(); |
| 1791 | 1724 |
| 1792 ui::test::EventGenerator event_generator( | 1725 ui::test::EventGenerator event_generator( |
| 1793 widget->GetNativeWindow()->GetRootWindow()); | 1726 widget->GetNativeWindow()->GetRootWindow()); |
| 1794 event_generator.MoveMouseToCenterOf(widget->GetNativeWindow()); | 1727 event_generator.MoveMouseToCenterOf(widget->GetNativeWindow()); |
| 1795 | 1728 |
| 1796 UpdateDisplay("300x300"); | 1729 UpdateDisplay("300x300"); |
| 1797 watcher.Stop(); | 1730 watcher.Stop(); |
| 1798 | 1731 |
| 1799 widget->CloseNow(); | 1732 widget->CloseNow(); |
| 1800 } | 1733 } |
| 1801 | 1734 |
| 1802 } // namespace ash | 1735 } // namespace ash |
| OLD | NEW |