Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: ash/display/window_tree_host_manager_unittest.cc

Issue 2692663002: Gut ash::MaterialDesignController, and remove the about:flags entry. (Closed)
Patch Set: yet another rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/display/display_manager_unittest.cc ('k') | ash/mus/test/wm_test_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
10 #include "ash/common/shelf/shelf_widget.h" 9 #include "ash/common/shelf/shelf_widget.h"
11 #include "ash/common/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
12 #include "ash/common/wm/window_state.h" 11 #include "ash/common/wm/window_state.h"
13 #include "ash/common/wm/wm_event.h" 12 #include "ash/common/wm/wm_event.h"
14 #include "ash/common/wm/wm_screen_util.h" 13 #include "ash/common/wm/wm_screen_util.h"
15 #include "ash/common/wm_window.h" 14 #include "ash/common/wm_window.h"
16 #include "ash/display/display_util.h" 15 #include "ash/display/display_util.h"
17 #include "ash/screen_util.h" 16 #include "ash/screen_util.h"
18 #include "ash/shell.h" 17 #include "ash/shell.h"
19 #include "ash/test/ash_md_test_base.h"
20 #include "ash/test/ash_test_base.h" 18 #include "ash/test/ash_test_base.h"
21 #include "ash/test/ash_test_helper.h" 19 #include "ash/test/ash_test_helper.h"
22 #include "ash/test/cursor_manager_test_api.h" 20 #include "ash/test/cursor_manager_test_api.h"
23 #include "ash/test/test_shell_delegate.h" 21 #include "ash/test/test_shell_delegate.h"
24 #include "ash/wm/window_state_aura.h" 22 #include "ash/wm/window_state_aura.h"
25 #include "base/command_line.h" 23 #include "base/command_line.h"
26 #include "ui/aura/client/focus_change_observer.h" 24 #include "ui/aura/client/focus_change_observer.h"
27 #include "ui/aura/client/focus_client.h" 25 #include "ui/aura/client/focus_client.h"
28 #include "ui/aura/env.h" 26 #include "ui/aura/env.h"
29 #include "ui/aura/window_observer.h" 27 #include "ui/aura/window_observer.h"
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 396
399 private: 397 private:
400 // views::MouseWatcherListener: 398 // views::MouseWatcherListener:
401 void MouseMovedOutOfHost() override {} 399 void MouseMovedOutOfHost() override {}
402 400
403 DISALLOW_COPY_AND_ASSIGN(TestMouseWatcherListener); 401 DISALLOW_COPY_AND_ASSIGN(TestMouseWatcherListener);
404 }; 402 };
405 403
406 } // namespace 404 } // namespace
407 405
408 class WindowTreeHostManagerTest : public test::AshMDTestBase, 406 class WindowTreeHostManagerTest : public test::AshTestBase, public TestHelper {
409 public TestHelper {
410 public: 407 public:
411 WindowTreeHostManagerTest() : TestHelper(this){}; 408 WindowTreeHostManagerTest() : TestHelper(this){};
412 ~WindowTreeHostManagerTest() override{}; 409 ~WindowTreeHostManagerTest() override{};
413 410
414 private: 411 private:
415 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostManagerTest); 412 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostManagerTest);
416 }; 413 };
417 414
418 INSTANTIATE_TEST_CASE_P(
419 /* prefix intentionally left blank due to only one parameterization */,
420 WindowTreeHostManagerTest,
421 testing::Values(MaterialDesignController::NON_MATERIAL,
422 MaterialDesignController::MATERIAL_NORMAL,
423 MaterialDesignController::MATERIAL_EXPERIMENTAL));
424
425 TEST_F(WindowTreeHostManagerShutdownTest, Shutdown) { 415 TEST_F(WindowTreeHostManagerShutdownTest, Shutdown) {
426 UpdateDisplay("444x333, 200x200"); 416 UpdateDisplay("444x333, 200x200");
427 } 417 }
428 418
429 TEST_F(WindowTreeHostManagerStartupTest, Startup) { 419 TEST_F(WindowTreeHostManagerStartupTest, Startup) {
430 EXPECT_TRUE(startup_helper()->displays_initialized()); 420 EXPECT_TRUE(startup_helper()->displays_initialized());
431 } 421 }
432 422
433 TEST_P(WindowTreeHostManagerTest, SecondaryDisplayLayout) { 423 TEST_F(WindowTreeHostManagerTest, SecondaryDisplayLayout) {
434 // Creates windows to catch activation change event. 424 // Creates windows to catch activation change event.
435 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); 425 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1));
436 w1->Focus(); 426 w1->Focus();
437 427
438 TestObserver observer; 428 TestObserver observer;
439 UpdateDisplay("500x500,400x400"); 429 UpdateDisplay("500x500,400x400");
440 EXPECT_EQ(1, observer.CountAndReset()); // resize and add 430 EXPECT_EQ(1, observer.CountAndReset()); // resize and add
441 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset()); 431 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset());
442 EXPECT_EQ(2, observer.GetWorkareaChangedCountAndReset()); 432 EXPECT_EQ(2, observer.GetWorkareaChangedCountAndReset());
443 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); 433 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 int64_t id, 575 int64_t id,
586 float device_scale_factor) { 576 float device_scale_factor) {
587 display::ManagedDisplayInfo info = 577 display::ManagedDisplayInfo info =
588 CreateDisplayInfo(id, 0, display::Display::ROTATE_0); 578 CreateDisplayInfo(id, 0, display::Display::ROTATE_0);
589 info.set_device_scale_factor(device_scale_factor); 579 info.set_device_scale_factor(device_scale_factor);
590 return info; 580 return info;
591 } 581 }
592 582
593 } // namespace 583 } // namespace
594 584
595 TEST_P(WindowTreeHostManagerTest, MirrorToDockedWithFullscreen) { 585 TEST_F(WindowTreeHostManagerTest, MirrorToDockedWithFullscreen) {
596 // Creates windows to catch activation change event. 586 // Creates windows to catch activation change event.
597 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); 587 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1));
598 w1->Focus(); 588 w1->Focus();
599 589
600 // Docked mode. 590 // Docked mode.
601 591
602 const display::ManagedDisplayInfo internal_display_info = 592 const display::ManagedDisplayInfo internal_display_info =
603 CreateMirroredDisplayInfo(1, 2.0f); 593 CreateMirroredDisplayInfo(1, 2.0f);
604 const display::ManagedDisplayInfo external_display_info = 594 const display::ManagedDisplayInfo external_display_info =
605 CreateMirroredDisplayInfo(2, 1.0f); 595 CreateMirroredDisplayInfo(2, 1.0f);
(...skipping 28 matching lines...) Expand all
634 EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset()); 624 EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset());
635 EXPECT_EQ(1, observer.GetPrimaryChangedCountAndReset()); 625 EXPECT_EQ(1, observer.GetPrimaryChangedCountAndReset());
636 EXPECT_EQ(1, observer.CountAndReset()); 626 EXPECT_EQ(1, observer.CountAndReset());
637 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); 627 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
638 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); 628 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
639 629
640 EXPECT_TRUE(window_state->IsFullscreen()); 630 EXPECT_TRUE(window_state->IsFullscreen());
641 EXPECT_EQ("0,0 500x500", w1->bounds().ToString()); 631 EXPECT_EQ("0,0 500x500", w1->bounds().ToString());
642 } 632 }
643 633
644 TEST_P(WindowTreeHostManagerTest, BoundsUpdated) { 634 TEST_F(WindowTreeHostManagerTest, BoundsUpdated) {
645 // Creates windows to catch activation change event. 635 // Creates windows to catch activation change event.
646 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); 636 std::unique_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1));
647 w1->Focus(); 637 w1->Focus();
648 638
649 TestObserver observer; 639 TestObserver observer;
650 SetDefaultDisplayLayout(display::DisplayPlacement::BOTTOM); 640 SetDefaultDisplayLayout(display::DisplayPlacement::BOTTOM);
651 UpdateDisplay("200x200,300x300"); // layout, resize and add. 641 UpdateDisplay("200x200,300x300"); // layout, resize and add.
652 EXPECT_EQ(1, observer.CountAndReset()); 642 EXPECT_EQ(1, observer.CountAndReset());
653 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); 643 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
654 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); 644 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 EXPECT_EQ(0, observer.CountAndReset()); 734 EXPECT_EQ(0, observer.CountAndReset());
745 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); 735 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
746 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); 736 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
747 display::test::DisplayManagerTestApi(display_manager()) 737 display::test::DisplayManagerTestApi(display_manager())
748 .SetDisplayUIScale(primary_id, 1.125f); 738 .SetDisplayUIScale(primary_id, 1.125f);
749 EXPECT_EQ(0, observer.CountAndReset()); 739 EXPECT_EQ(0, observer.CountAndReset());
750 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); 740 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
751 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); 741 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
752 } 742 }
753 743
754 TEST_P(WindowTreeHostManagerTest, FindNearestDisplay) { 744 TEST_F(WindowTreeHostManagerTest, FindNearestDisplay) {
755 WindowTreeHostManager* window_tree_host_manager = 745 WindowTreeHostManager* window_tree_host_manager =
756 Shell::GetInstance()->window_tree_host_manager(); 746 Shell::GetInstance()->window_tree_host_manager();
757 747
758 UpdateDisplay("200x200,300x300"); 748 UpdateDisplay("200x200,300x300");
759 display_manager()->SetLayoutForCurrentDisplays( 749 display_manager()->SetLayoutForCurrentDisplays(
760 display::test::CreateDisplayLayout(display_manager(), 750 display::test::CreateDisplayLayout(display_manager(),
761 display::DisplayPlacement::RIGHT, 50)); 751 display::DisplayPlacement::RIGHT, 50));
762 752
763 display::Display primary_display = 753 display::Display primary_display =
764 display::Screen::GetScreen()->GetPrimaryDisplay(); 754 display::Screen::GetScreen()->GetPrimaryDisplay();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 EXPECT_EQ(secondary_display.id(), 793 EXPECT_EQ(secondary_display.id(),
804 display::Screen::GetScreen() 794 display::Screen::GetScreen()
805 ->GetDisplayNearestPoint(gfx::Point(176, 225)) 795 ->GetDisplayNearestPoint(gfx::Point(176, 225))
806 .id()); 796 .id());
807 EXPECT_EQ(secondary_display.id(), 797 EXPECT_EQ(secondary_display.id(),
808 display::Screen::GetScreen() 798 display::Screen::GetScreen()
809 ->GetDisplayNearestPoint(gfx::Point(300, 400)) 799 ->GetDisplayNearestPoint(gfx::Point(300, 400))
810 .id()); 800 .id());
811 } 801 }
812 802
813 TEST_P(WindowTreeHostManagerTest, SwapPrimaryById) { 803 TEST_F(WindowTreeHostManagerTest, SwapPrimaryById) {
814 const int height_offset = GetMdMaximizedWindowHeightOffset();
815
816 WindowTreeHostManager* window_tree_host_manager = 804 WindowTreeHostManager* window_tree_host_manager =
817 Shell::GetInstance()->window_tree_host_manager(); 805 Shell::GetInstance()->window_tree_host_manager();
818 806
819 UpdateDisplay("200x200,300x300"); 807 UpdateDisplay("200x200,300x300");
820 display::Display primary_display = 808 display::Display primary_display =
821 display::Screen::GetScreen()->GetPrimaryDisplay(); 809 display::Screen::GetScreen()->GetPrimaryDisplay();
822 display::Display secondary_display = display_manager()->GetSecondaryDisplay(); 810 display::Display secondary_display = display_manager()->GetSecondaryDisplay();
823 811
824 display_manager()->SetLayoutForCurrentDisplays( 812 display_manager()->SetLayoutForCurrentDisplays(
825 display::test::CreateDisplayLayout(display_manager(), 813 display::test::CreateDisplayLayout(display_manager(),
(...skipping 12 matching lines...) Expand all
838 EXPECT_NE(primary_root, secondary_root); 826 EXPECT_NE(primary_root, secondary_root);
839 EXPECT_EQ(primary_display.id(), 827 EXPECT_EQ(primary_display.id(),
840 display::Screen::GetScreen() 828 display::Screen::GetScreen()
841 ->GetDisplayNearestPoint(gfx::Point(-100, -100)) 829 ->GetDisplayNearestPoint(gfx::Point(-100, -100))
842 .id()); 830 .id());
843 EXPECT_EQ( 831 EXPECT_EQ(
844 primary_display.id(), 832 primary_display.id(),
845 display::Screen::GetScreen()->GetDisplayNearestWindow(nullptr).id()); 833 display::Screen::GetScreen()->GetDisplayNearestWindow(nullptr).id());
846 834
847 EXPECT_EQ("0,0 200x200", primary_display.bounds().ToString()); 835 EXPECT_EQ("0,0 200x200", primary_display.bounds().ToString());
848 EXPECT_EQ(gfx::Rect(0, 0, 200, 153 + height_offset).ToString(), 836 EXPECT_EQ(gfx::Rect(0, 0, 200, 152).ToString(),
849 primary_display.work_area().ToString()); 837 primary_display.work_area().ToString());
850 EXPECT_EQ("200,0 300x300", secondary_display.bounds().ToString()); 838 EXPECT_EQ("200,0 300x300", secondary_display.bounds().ToString());
851 EXPECT_EQ(gfx::Rect(200, 0, 300, 253 + height_offset).ToString(), 839 EXPECT_EQ(gfx::Rect(200, 0, 300, 252).ToString(),
852 secondary_display.work_area().ToString()); 840 secondary_display.work_area().ToString());
853 EXPECT_EQ("id=2200000001, parent=2200000000, right, 50", 841 EXPECT_EQ("id=2200000001, parent=2200000000, right, 50",
854 display_manager() 842 display_manager()
855 ->GetCurrentDisplayLayout() 843 ->GetCurrentDisplayLayout()
856 .placement_list[0] 844 .placement_list[0]
857 .ToString()); 845 .ToString());
858 846
859 // Switch primary and secondary by display ID. 847 // Switch primary and secondary by display ID.
860 TestObserver observer; 848 TestObserver observer;
861 window_tree_host_manager->SetPrimaryDisplayId(secondary_display.id()); 849 window_tree_host_manager->SetPrimaryDisplayId(secondary_display.id());
(...skipping 13 matching lines...) Expand all
875 const display::DisplayLayout& inverted_layout = 863 const display::DisplayLayout& inverted_layout =
876 display_manager()->GetCurrentDisplayLayout(); 864 display_manager()->GetCurrentDisplayLayout();
877 865
878 EXPECT_EQ("id=2200000000, parent=2200000001, left, -50", 866 EXPECT_EQ("id=2200000000, parent=2200000001, left, -50",
879 inverted_layout.placement_list[0].ToString()); 867 inverted_layout.placement_list[0].ToString());
880 // Test if the bounds are correctly swapped. 868 // Test if the bounds are correctly swapped.
881 display::Display swapped_primary = 869 display::Display swapped_primary =
882 display::Screen::GetScreen()->GetPrimaryDisplay(); 870 display::Screen::GetScreen()->GetPrimaryDisplay();
883 display::Display swapped_secondary = display_manager()->GetSecondaryDisplay(); 871 display::Display swapped_secondary = display_manager()->GetSecondaryDisplay();
884 EXPECT_EQ("0,0 300x300", swapped_primary.bounds().ToString()); 872 EXPECT_EQ("0,0 300x300", swapped_primary.bounds().ToString());
885 EXPECT_EQ(gfx::Rect(0, 0, 300, 253 + height_offset).ToString(), 873 EXPECT_EQ(gfx::Rect(0, 0, 300, 252).ToString(),
886 swapped_primary.work_area().ToString()); 874 swapped_primary.work_area().ToString());
887 EXPECT_EQ("-200,-50 200x200", swapped_secondary.bounds().ToString()); 875 EXPECT_EQ("-200,-50 200x200", swapped_secondary.bounds().ToString());
888 EXPECT_EQ(gfx::Rect(-200, -50, 200, 153 + height_offset).ToString(), 876 EXPECT_EQ(gfx::Rect(-200, -50, 200, 152).ToString(),
889 swapped_secondary.work_area().ToString()); 877 swapped_secondary.work_area().ToString());
890 878
891 // Calling the same ID don't do anything. 879 // Calling the same ID don't do anything.
892 window_tree_host_manager->SetPrimaryDisplayId(secondary_display.id()); 880 window_tree_host_manager->SetPrimaryDisplayId(secondary_display.id());
893 EXPECT_EQ(0, observer.CountAndReset()); 881 EXPECT_EQ(0, observer.CountAndReset());
894 882
895 aura::WindowTracker tracker; 883 aura::WindowTracker tracker;
896 tracker.Add(primary_root); 884 tracker.Add(primary_root);
897 tracker.Add(secondary_root); 885 tracker.Add(secondary_root);
898 886
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 display::Screen::GetScreen()->GetPrimaryDisplay().id()); 941 display::Screen::GetScreen()->GetPrimaryDisplay().id());
954 EXPECT_EQ(third_display_info.id(), 942 EXPECT_EQ(third_display_info.id(),
955 display_manager()->GetSecondaryDisplay().id()); 943 display_manager()->GetSecondaryDisplay().id());
956 EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( 944 EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId(
957 primary_display.id())); 945 primary_display.id()));
958 EXPECT_NE(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( 946 EXPECT_NE(primary_root, window_tree_host_manager->GetRootWindowForDisplayId(
959 third_display_info.id())); 947 third_display_info.id()));
960 EXPECT_TRUE(primary_root->Contains(shelf_window)); 948 EXPECT_TRUE(primary_root->Contains(shelf_window));
961 } 949 }
962 950
963 TEST_P(WindowTreeHostManagerTest, SetPrimaryWithThreeDisplays) { 951 TEST_F(WindowTreeHostManagerTest, SetPrimaryWithThreeDisplays) {
964 UpdateDisplay("500x400,400x300,300x200"); 952 UpdateDisplay("500x400,400x300,300x200");
965 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 953 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
966 display::DisplayIdList non_primary_ids = 954 display::DisplayIdList non_primary_ids =
967 display_manager()->GetCurrentDisplayIdList(); 955 display_manager()->GetCurrentDisplayIdList();
968 auto itr = 956 auto itr =
969 std::remove(non_primary_ids.begin(), non_primary_ids.end(), primary_id); 957 std::remove(non_primary_ids.begin(), non_primary_ids.end(), primary_id);
970 ASSERT_TRUE(itr != non_primary_ids.end()); 958 ASSERT_TRUE(itr != non_primary_ids.end());
971 non_primary_ids.erase(itr, non_primary_ids.end()); 959 non_primary_ids.erase(itr, non_primary_ids.end());
972 ASSERT_EQ(2u, non_primary_ids.size()); 960 ASSERT_EQ(2u, non_primary_ids.size());
973 961
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 current_layout.placement_list[0].parent_display_id); 1061 current_layout.placement_list[0].parent_display_id);
1074 EXPECT_EQ(display::DisplayPlacement::TOP, 1062 EXPECT_EQ(display::DisplayPlacement::TOP,
1075 current_layout.placement_list[0].position); 1063 current_layout.placement_list[0].position);
1076 EXPECT_EQ(non_primary_ids[0], current_layout.placement_list[1].display_id); 1064 EXPECT_EQ(non_primary_ids[0], current_layout.placement_list[1].display_id);
1077 EXPECT_EQ(primary_id, current_layout.placement_list[1].parent_display_id); 1065 EXPECT_EQ(primary_id, current_layout.placement_list[1].parent_display_id);
1078 EXPECT_EQ(display::DisplayPlacement::RIGHT, 1066 EXPECT_EQ(display::DisplayPlacement::RIGHT,
1079 current_layout.placement_list[1].position); 1067 current_layout.placement_list[1].position);
1080 } 1068 }
1081 } 1069 }
1082 1070
1083 TEST_P(WindowTreeHostManagerTest, SetPrimaryWithFourDisplays) { 1071 TEST_F(WindowTreeHostManagerTest, SetPrimaryWithFourDisplays) {
1084 UpdateDisplay("600x500,500x400,400x300,300x200"); 1072 UpdateDisplay("600x500,500x400,400x300,300x200");
1085 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1073 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1086 display::DisplayIdList non_primary_ids = 1074 display::DisplayIdList non_primary_ids =
1087 display_manager()->GetCurrentDisplayIdList(); 1075 display_manager()->GetCurrentDisplayIdList();
1088 auto itr = 1076 auto itr =
1089 std::remove(non_primary_ids.begin(), non_primary_ids.end(), primary_id); 1077 std::remove(non_primary_ids.begin(), non_primary_ids.end(), primary_id);
1090 ASSERT_TRUE(itr != non_primary_ids.end()); 1078 ASSERT_TRUE(itr != non_primary_ids.end());
1091 non_primary_ids.erase(itr, non_primary_ids.end()); 1079 non_primary_ids.erase(itr, non_primary_ids.end());
1092 ASSERT_EQ(3u, non_primary_ids.size()); 1080 ASSERT_EQ(3u, non_primary_ids.size());
1093 1081
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 EXPECT_EQ(display::DisplayPlacement::RIGHT, 1170 EXPECT_EQ(display::DisplayPlacement::RIGHT,
1183 current_layout.placement_list[1].position); 1171 current_layout.placement_list[1].position);
1184 EXPECT_EQ(non_primary_ids[2], current_layout.placement_list[2].display_id); 1172 EXPECT_EQ(non_primary_ids[2], current_layout.placement_list[2].display_id);
1185 EXPECT_EQ(non_primary_ids[0], 1173 EXPECT_EQ(non_primary_ids[0],
1186 current_layout.placement_list[2].parent_display_id); 1174 current_layout.placement_list[2].parent_display_id);
1187 EXPECT_EQ(display::DisplayPlacement::RIGHT, 1175 EXPECT_EQ(display::DisplayPlacement::RIGHT,
1188 current_layout.placement_list[2].position); 1176 current_layout.placement_list[2].position);
1189 } 1177 }
1190 } 1178 }
1191 1179
1192 TEST_P(WindowTreeHostManagerTest, OverscanInsets) { 1180 TEST_F(WindowTreeHostManagerTest, OverscanInsets) {
1193 WindowTreeHostManager* window_tree_host_manager = 1181 WindowTreeHostManager* window_tree_host_manager =
1194 Shell::GetInstance()->window_tree_host_manager(); 1182 Shell::GetInstance()->window_tree_host_manager();
1195 TestEventHandler event_handler; 1183 TestEventHandler event_handler;
1196 Shell::GetInstance()->AddPreTargetHandler(&event_handler); 1184 Shell::GetInstance()->AddPreTargetHandler(&event_handler);
1197 1185
1198 UpdateDisplay("120x200,300x400*2"); 1186 UpdateDisplay("120x200,300x400*2");
1199 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); 1187 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay();
1200 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1188 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1201 1189
1202 window_tree_host_manager->SetOverscanInsets(display1.id(), 1190 window_tree_host_manager->SetOverscanInsets(display1.id(),
(...skipping 26 matching lines...) Expand all
1229 1217
1230 SwapPrimaryDisplay(); 1218 SwapPrimaryDisplay();
1231 point.SetPoint(0, 0); 1219 point.SetPoint(0, 0);
1232 Shell::GetAllRootWindows()[1]->GetHost()->GetRootTransform().TransformPoint( 1220 Shell::GetAllRootWindows()[1]->GetHost()->GetRootTransform().TransformPoint(
1233 &point); 1221 &point);
1234 EXPECT_EQ("15,10", point.ToString()); 1222 EXPECT_EQ("15,10", point.ToString());
1235 1223
1236 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 1224 Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
1237 } 1225 }
1238 1226
1239 TEST_P(WindowTreeHostManagerTest, Rotate) { 1227 TEST_F(WindowTreeHostManagerTest, Rotate) {
1240 TestEventHandler event_handler; 1228 TestEventHandler event_handler;
1241 Shell::GetInstance()->AddPreTargetHandler(&event_handler); 1229 Shell::GetInstance()->AddPreTargetHandler(&event_handler);
1242 1230
1243 UpdateDisplay("120x200,300x400*2"); 1231 UpdateDisplay("120x200,300x400*2");
1244 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); 1232 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay();
1245 int64_t display2_id = display_manager()->GetSecondaryDisplay().id(); 1233 int64_t display2_id = display_manager()->GetSecondaryDisplay().id();
1246 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1234 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1247 ui::test::EventGenerator generator1(root_windows[0]); 1235 ui::test::EventGenerator generator1(root_windows[0]);
1248 1236
1249 TestObserver observer; 1237 TestObserver observer;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 EXPECT_EQ(display::Display::ROTATE_270, 1296 EXPECT_EQ(display::Display::ROTATE_270,
1309 GetActiveDisplayRotation(display2_id)); 1297 GetActiveDisplayRotation(display2_id));
1310 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); 1298 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset());
1311 1299
1312 generator1.MoveMouseToInHost(50, 40); 1300 generator1.MoveMouseToInHost(50, 40);
1313 EXPECT_EQ("69,159", event_handler.GetLocationAndReset()); 1301 EXPECT_EQ("69,159", event_handler.GetLocationAndReset());
1314 1302
1315 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 1303 Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
1316 } 1304 }
1317 1305
1318 TEST_P(WindowTreeHostManagerTest, ScaleRootWindow) { 1306 TEST_F(WindowTreeHostManagerTest, ScaleRootWindow) {
1319 TestEventHandler event_handler; 1307 TestEventHandler event_handler;
1320 Shell::GetInstance()->AddPreTargetHandler(&event_handler); 1308 Shell::GetInstance()->AddPreTargetHandler(&event_handler);
1321 1309
1322 UpdateDisplay("600x400*2@1.5,500x300"); 1310 UpdateDisplay("600x400*2@1.5,500x300");
1323 1311
1324 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); 1312 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay();
1325 display::test::ScopedSetInternalDisplayId set_internal(display_manager(), 1313 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
1326 display1.id()); 1314 display1.id());
1327 1315
1328 display::Display display2 = display_manager()->GetSecondaryDisplay(); 1316 display::Display display2 = display_manager()->GetSecondaryDisplay();
(...skipping 14 matching lines...) Expand all
1343 display2 = display_manager()->GetSecondaryDisplay(); 1331 display2 = display_manager()->GetSecondaryDisplay();
1344 EXPECT_EQ("0,0 375x250", display1.bounds().ToString()); 1332 EXPECT_EQ("0,0 375x250", display1.bounds().ToString());
1345 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString()); 1333 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString());
1346 EXPECT_EQ("375,0 500x300", display2.bounds().ToString()); 1334 EXPECT_EQ("375,0 500x300", display2.bounds().ToString());
1347 EXPECT_EQ(1.25f, GetStoredUIScale(display1.id())); 1335 EXPECT_EQ(1.25f, GetStoredUIScale(display1.id()));
1348 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); 1336 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id()));
1349 1337
1350 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 1338 Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
1351 } 1339 }
1352 1340
1353 TEST_P(WindowTreeHostManagerTest, TouchScale) { 1341 TEST_F(WindowTreeHostManagerTest, TouchScale) {
1354 TestEventHandler event_handler; 1342 TestEventHandler event_handler;
1355 Shell::GetInstance()->AddPreTargetHandler(&event_handler); 1343 Shell::GetInstance()->AddPreTargetHandler(&event_handler);
1356 1344
1357 UpdateDisplay("200x200*2"); 1345 UpdateDisplay("200x200*2");
1358 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); 1346 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay();
1359 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1347 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1360 aura::Window* root_window = root_windows[0]; 1348 aura::Window* root_window = root_windows[0];
1361 ui::test::EventGenerator generator(root_window); 1349 ui::test::EventGenerator generator(root_window);
1362 1350
1363 generator.PressMoveAndReleaseTouchTo(50, 50); 1351 generator.PressMoveAndReleaseTouchTo(50, 50);
1364 // Default test touches have radius_x/y = 1.0, with device scale 1352 // Default test touches have radius_x/y = 1.0, with device scale
1365 // factor = 2, the scaled radius_x/y should be 0.5. 1353 // factor = 2, the scaled radius_x/y should be 0.5.
1366 EXPECT_EQ(0.5, event_handler.touch_radius_x()); 1354 EXPECT_EQ(0.5, event_handler.touch_radius_x());
1367 EXPECT_EQ(0.5, event_handler.touch_radius_y()); 1355 EXPECT_EQ(0.5, event_handler.touch_radius_y());
1368 1356
1369 generator.ScrollSequence(gfx::Point(0, 0), 1357 generator.ScrollSequence(gfx::Point(0, 0),
1370 base::TimeDelta::FromMilliseconds(100), 10.0, 1.0, 5, 1358 base::TimeDelta::FromMilliseconds(100), 10.0, 1.0, 5,
1371 1); 1359 1);
1372 1360
1373 // ordinal_offset is invariant to the device scale factor. 1361 // ordinal_offset is invariant to the device scale factor.
1374 EXPECT_EQ(event_handler.scroll_x_offset(), 1362 EXPECT_EQ(event_handler.scroll_x_offset(),
1375 event_handler.scroll_x_offset_ordinal()); 1363 event_handler.scroll_x_offset_ordinal());
1376 EXPECT_EQ(event_handler.scroll_y_offset(), 1364 EXPECT_EQ(event_handler.scroll_y_offset(),
1377 event_handler.scroll_y_offset_ordinal()); 1365 event_handler.scroll_y_offset_ordinal());
1378 1366
1379 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 1367 Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
1380 } 1368 }
1381 1369
1382 TEST_P(WindowTreeHostManagerTest, ConvertHostToRootCoords) { 1370 TEST_F(WindowTreeHostManagerTest, ConvertHostToRootCoords) {
1383 TestEventHandler event_handler; 1371 TestEventHandler event_handler;
1384 Shell::GetInstance()->AddPreTargetHandler(&event_handler); 1372 Shell::GetInstance()->AddPreTargetHandler(&event_handler);
1385 1373
1386 UpdateDisplay("600x400*2/r@1.5"); 1374 UpdateDisplay("600x400*2/r@1.5");
1387 1375
1388 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay(); 1376 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay();
1389 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1377 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1390 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); 1378 EXPECT_EQ("0,0 300x450", display1.bounds().ToString());
1391 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); 1379 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString());
1392 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); 1380 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id()));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 generator.MoveMouseToInHost(599, 399); 1419 generator.MoveMouseToInHost(599, 399);
1432 EXPECT_EQ("0,449", event_handler.GetLocationAndReset()); 1420 EXPECT_EQ("0,449", event_handler.GetLocationAndReset());
1433 generator.MoveMouseToInHost(0, 399); 1421 generator.MoveMouseToInHost(0, 399);
1434 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); 1422 EXPECT_EQ("0,0", event_handler.GetLocationAndReset());
1435 1423
1436 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 1424 Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
1437 } 1425 }
1438 1426
1439 // Make sure that the compositor based mirroring can switch 1427 // Make sure that the compositor based mirroring can switch
1440 // from/to dock mode. 1428 // from/to dock mode.
1441 TEST_P(WindowTreeHostManagerTest, DockToSingle) { 1429 TEST_F(WindowTreeHostManagerTest, DockToSingle) {
1442 const int64_t internal_id = 1; 1430 const int64_t internal_id = 1;
1443 1431
1444 const display::ManagedDisplayInfo internal_display_info = 1432 const display::ManagedDisplayInfo internal_display_info =
1445 CreateDisplayInfo(internal_id, 0, display::Display::ROTATE_0); 1433 CreateDisplayInfo(internal_id, 0, display::Display::ROTATE_0);
1446 const display::ManagedDisplayInfo external_display_info = 1434 const display::ManagedDisplayInfo external_display_info =
1447 CreateDisplayInfo(2, 1, display::Display::ROTATE_90); 1435 CreateDisplayInfo(2, 1, display::Display::ROTATE_90);
1448 1436
1449 std::vector<display::ManagedDisplayInfo> display_info_list; 1437 std::vector<display::ManagedDisplayInfo> display_info_list;
1450 // Extended 1438 // Extended
1451 display_info_list.push_back(internal_display_info); 1439 display_info_list.push_back(internal_display_info);
(...skipping 21 matching lines...) Expand all
1473 display_info_list.push_back(internal_display_info); 1461 display_info_list.push_back(internal_display_info);
1474 display_manager()->OnNativeDisplaysChanged(display_info_list); 1462 display_manager()->OnNativeDisplaysChanged(display_info_list);
1475 EXPECT_TRUE(Shell::GetPrimaryRootWindow() 1463 EXPECT_TRUE(Shell::GetPrimaryRootWindow()
1476 ->GetHost() 1464 ->GetHost()
1477 ->GetRootTransform() 1465 ->GetRootTransform()
1478 .IsIdentityOrIntegerTranslation()); 1466 .IsIdentityOrIntegerTranslation());
1479 } 1467 }
1480 1468
1481 // Tests if switching two displays at the same time while the primary display 1469 // Tests if switching two displays at the same time while the primary display
1482 // is swapped should not cause a crash. (crbug.com/426292) 1470 // is swapped should not cause a crash. (crbug.com/426292)
1483 TEST_P(WindowTreeHostManagerTest, ReplaceSwappedPrimary) { 1471 TEST_F(WindowTreeHostManagerTest, ReplaceSwappedPrimary) {
1484 const display::ManagedDisplayInfo first_display_info = 1472 const display::ManagedDisplayInfo first_display_info =
1485 CreateDisplayInfo(10, 0, display::Display::ROTATE_0); 1473 CreateDisplayInfo(10, 0, display::Display::ROTATE_0);
1486 const display::ManagedDisplayInfo second_display_info = 1474 const display::ManagedDisplayInfo second_display_info =
1487 CreateDisplayInfo(11, 1, display::Display::ROTATE_0); 1475 CreateDisplayInfo(11, 1, display::Display::ROTATE_0);
1488 1476
1489 std::vector<display::ManagedDisplayInfo> display_info_list; 1477 std::vector<display::ManagedDisplayInfo> display_info_list;
1490 // Extended 1478 // Extended
1491 display_info_list.push_back(first_display_info); 1479 display_info_list.push_back(first_display_info);
1492 display_info_list.push_back(second_display_info); 1480 display_info_list.push_back(second_display_info);
1493 display_manager()->OnNativeDisplaysChanged(display_info_list); 1481 display_manager()->OnNativeDisplaysChanged(display_info_list);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 }; 1521 };
1534 1522
1535 } // names 1523 } // names
1536 1524
1537 // Make sure that GetDisplayBoundsWithShelf returns the correct bounds 1525 // Make sure that GetDisplayBoundsWithShelf returns the correct bounds
1538 // when the primary display gets replaced in one of the following scenarios: 1526 // when the primary display gets replaced in one of the following scenarios:
1539 // 1) Two displays connected: a) b) 1527 // 1) Two displays connected: a) b)
1540 // 2) both are disconnected and new one with the same size as b) is connected 1528 // 2) both are disconnected and new one with the same size as b) is connected
1541 // in one configuration event. 1529 // in one configuration event.
1542 // See crbug.com/547280. 1530 // See crbug.com/547280.
1543 TEST_P(WindowTreeHostManagerTest, ReplacePrimary) { 1531 TEST_F(WindowTreeHostManagerTest, ReplacePrimary) {
1544 display::ManagedDisplayInfo first_display_info = 1532 display::ManagedDisplayInfo first_display_info =
1545 CreateDisplayInfo(10, 0, display::Display::ROTATE_0); 1533 CreateDisplayInfo(10, 0, display::Display::ROTATE_0);
1546 first_display_info.SetBounds(gfx::Rect(0, 0, 400, 400)); 1534 first_display_info.SetBounds(gfx::Rect(0, 0, 400, 400));
1547 const display::ManagedDisplayInfo second_display_info = 1535 const display::ManagedDisplayInfo second_display_info =
1548 CreateDisplayInfo(11, 500, display::Display::ROTATE_0); 1536 CreateDisplayInfo(11, 500, display::Display::ROTATE_0);
1549 1537
1550 std::vector<display::ManagedDisplayInfo> display_info_list; 1538 std::vector<display::ManagedDisplayInfo> display_info_list;
1551 // Extended 1539 // Extended
1552 display_info_list.push_back(first_display_info); 1540 display_info_list.push_back(first_display_info);
1553 display_info_list.push_back(second_display_info); 1541 display_info_list.push_back(second_display_info);
1554 display_manager()->OnNativeDisplaysChanged(display_info_list); 1542 display_manager()->OnNativeDisplaysChanged(display_info_list);
1555 aura::Window* primary_root = Shell::GetAllRootWindows()[0]; 1543 aura::Window* primary_root = Shell::GetAllRootWindows()[0];
1556 1544
1557 int64_t new_display_id = 20; 1545 int64_t new_display_id = 20;
1558 RootWindowTestObserver test_observer; 1546 RootWindowTestObserver test_observer;
1559 primary_root->AddObserver(&test_observer); 1547 primary_root->AddObserver(&test_observer);
1560 1548
1561 display_info_list.clear(); 1549 display_info_list.clear();
1562 const display::ManagedDisplayInfo new_first_display_info = 1550 const display::ManagedDisplayInfo new_first_display_info =
1563 CreateDisplayInfo(new_display_id, 0, display::Display::ROTATE_0); 1551 CreateDisplayInfo(new_display_id, 0, display::Display::ROTATE_0);
1564 1552
1565 display_info_list.push_back(new_first_display_info); 1553 display_info_list.push_back(new_first_display_info);
1566 display_manager()->OnNativeDisplaysChanged(display_info_list); 1554 display_manager()->OnNativeDisplaysChanged(display_info_list);
1567 EXPECT_EQ("0,0 500x500", test_observer.shelf_display_bounds().ToString()); 1555 EXPECT_EQ("0,0 500x500", test_observer.shelf_display_bounds().ToString());
1568 primary_root->RemoveObserver(&test_observer); 1556 primary_root->RemoveObserver(&test_observer);
1569 } 1557 }
1570 1558
1571 TEST_P(WindowTreeHostManagerTest, UpdateMouseLocationAfterDisplayChange) { 1559 TEST_F(WindowTreeHostManagerTest, UpdateMouseLocationAfterDisplayChange) {
1572 UpdateDisplay("200x200,300x300"); 1560 UpdateDisplay("200x200,300x300");
1573 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1561 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1574 1562
1575 aura::Env* env = aura::Env::GetInstance(); 1563 aura::Env* env = aura::Env::GetInstance();
1576 1564
1577 ui::test::EventGenerator generator(root_windows[0]); 1565 ui::test::EventGenerator generator(root_windows[0]);
1578 1566
1579 // Set the initial position. 1567 // Set the initial position.
1580 generator.MoveMouseToInHost(350, 150); 1568 generator.MoveMouseToInHost(350, 150);
1581 EXPECT_EQ("350,150", env->last_mouse_location().ToString()); 1569 EXPECT_EQ("350,150", env->last_mouse_location().ToString());
(...skipping 19 matching lines...) Expand all
1601 1589
1602 // Move the mouse pointer to the bottom of 1st display. 1590 // Move the mouse pointer to the bottom of 1st display.
1603 generator.MoveMouseToInHost(150, 290); 1591 generator.MoveMouseToInHost(150, 290);
1604 EXPECT_EQ("150,290", env->last_mouse_location().ToString()); 1592 EXPECT_EQ("150,290", env->last_mouse_location().ToString());
1605 1593
1606 // The mouse pointer is now on 2nd display. 1594 // The mouse pointer is now on 2nd display.
1607 UpdateDisplay("300x280,200x200"); 1595 UpdateDisplay("300x280,200x200");
1608 EXPECT_EQ("450,10", env->last_mouse_location().ToString()); 1596 EXPECT_EQ("450,10", env->last_mouse_location().ToString());
1609 } 1597 }
1610 1598
1611 TEST_P(WindowTreeHostManagerTest, 1599 TEST_F(WindowTreeHostManagerTest,
1612 UpdateMouseLocationAfterDisplayChange_2ndOnLeft) { 1600 UpdateMouseLocationAfterDisplayChange_2ndOnLeft) {
1613 // Set the 2nd display on the left. 1601 // Set the 2nd display on the left.
1614 display::DisplayLayoutStore* layout_store = display_manager()->layout_store(); 1602 display::DisplayLayoutStore* layout_store = display_manager()->layout_store();
1615 display::DisplayPlacement new_default(display::DisplayPlacement::LEFT, 0); 1603 display::DisplayPlacement new_default(display::DisplayPlacement::LEFT, 0);
1616 layout_store->SetDefaultDisplayPlacement(new_default); 1604 layout_store->SetDefaultDisplayPlacement(new_default);
1617 1605
1618 UpdateDisplay("200x200,300x300"); 1606 UpdateDisplay("200x200,300x300");
1619 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1607 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1620 1608
1621 EXPECT_EQ("-300,0 300x300", 1609 EXPECT_EQ("-300,0 300x300",
(...skipping 15 matching lines...) Expand all
1637 EXPECT_EQ("-100,50", env->last_mouse_location().ToString()); 1625 EXPECT_EQ("-100,50", env->last_mouse_location().ToString());
1638 1626
1639 // 2nd display was disconnected. Mouse pointer should move to 1627 // 2nd display was disconnected. Mouse pointer should move to
1640 // 1st display. 1628 // 1st display.
1641 UpdateDisplay("300x300"); 1629 UpdateDisplay("300x300");
1642 EXPECT_EQ("150,150", env->last_mouse_location().ToString()); 1630 EXPECT_EQ("150,150", env->last_mouse_location().ToString());
1643 } 1631 }
1644 1632
1645 // Test that the cursor swaps displays and that its scale factor and rotation 1633 // Test that the cursor swaps displays and that its scale factor and rotation
1646 // are updated when the primary display is swapped. 1634 // are updated when the primary display is swapped.
1647 TEST_P(WindowTreeHostManagerTest, 1635 TEST_F(WindowTreeHostManagerTest,
1648 UpdateMouseLocationAfterDisplayChange_SwapPrimary) { 1636 UpdateMouseLocationAfterDisplayChange_SwapPrimary) {
1649 UpdateDisplay("200x200,200x200*2/r"); 1637 UpdateDisplay("200x200,200x200*2/r");
1650 1638
1651 aura::Env* env = aura::Env::GetInstance(); 1639 aura::Env* env = aura::Env::GetInstance();
1652 Shell* shell = Shell::GetInstance(); 1640 Shell* shell = Shell::GetInstance();
1653 WindowTreeHostManager* window_tree_host_manager = 1641 WindowTreeHostManager* window_tree_host_manager =
1654 shell->window_tree_host_manager(); 1642 shell->window_tree_host_manager();
1655 test::CursorManagerTestApi test_api(shell->cursor_manager()); 1643 test::CursorManagerTestApi test_api(shell->cursor_manager());
1656 1644
1657 window_tree_host_manager->GetPrimaryRootWindow()->MoveCursorTo( 1645 window_tree_host_manager->GetPrimaryRootWindow()->MoveCursorTo(
1658 gfx::Point(20, 50)); 1646 gfx::Point(20, 50));
1659 1647
1660 EXPECT_EQ("20,50", env->last_mouse_location().ToString()); 1648 EXPECT_EQ("20,50", env->last_mouse_location().ToString());
1661 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); 1649 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor());
1662 EXPECT_EQ(display::Display::ROTATE_0, test_api.GetCurrentCursorRotation()); 1650 EXPECT_EQ(display::Display::ROTATE_0, test_api.GetCurrentCursorRotation());
1663 1651
1664 SwapPrimaryDisplay(); 1652 SwapPrimaryDisplay();
1665 1653
1666 EXPECT_EQ("20,50", env->last_mouse_location().ToString()); 1654 EXPECT_EQ("20,50", env->last_mouse_location().ToString());
1667 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); 1655 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor());
1668 EXPECT_EQ(display::Display::ROTATE_90, test_api.GetCurrentCursorRotation()); 1656 EXPECT_EQ(display::Display::ROTATE_90, test_api.GetCurrentCursorRotation());
1669 } 1657 }
1670 1658
1671 // Test that the cursor moves to the other display and that its scale factor 1659 // Test that the cursor moves to the other display and that its scale factor
1672 // and rotation are updated when the primary display is disconnected. 1660 // and rotation are updated when the primary display is disconnected.
1673 TEST_P(WindowTreeHostManagerTest, 1661 TEST_F(WindowTreeHostManagerTest,
1674 UpdateMouseLocationAfterDisplayChange_PrimaryDisconnected) { 1662 UpdateMouseLocationAfterDisplayChange_PrimaryDisconnected) {
1675 aura::Env* env = aura::Env::GetInstance(); 1663 aura::Env* env = aura::Env::GetInstance();
1676 Shell* shell = Shell::GetInstance(); 1664 Shell* shell = Shell::GetInstance();
1677 WindowTreeHostManager* window_tree_host_manager = 1665 WindowTreeHostManager* window_tree_host_manager =
1678 shell->window_tree_host_manager(); 1666 shell->window_tree_host_manager();
1679 test::CursorManagerTestApi test_api(shell->cursor_manager()); 1667 test::CursorManagerTestApi test_api(shell->cursor_manager());
1680 1668
1681 UpdateDisplay("300x300*2/r,200x200"); 1669 UpdateDisplay("300x300*2/r,200x200");
1682 // Swap the primary display to make it possible to remove the primary display 1670 // Swap the primary display to make it possible to remove the primary display
1683 // via UpdateDisplay(). 1671 // via UpdateDisplay().
(...skipping 12 matching lines...) Expand all
1696 window_tree_host_manager->GetPrimaryDisplayId()); 1684 window_tree_host_manager->GetPrimaryDisplayId());
1697 1685
1698 // Cursor should be centered on the remaining display. 1686 // Cursor should be centered on the remaining display.
1699 EXPECT_EQ("75,75", env->last_mouse_location().ToString()); 1687 EXPECT_EQ("75,75", env->last_mouse_location().ToString());
1700 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); 1688 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor());
1701 EXPECT_EQ(display::Display::ROTATE_90, test_api.GetCurrentCursorRotation()); 1689 EXPECT_EQ(display::Display::ROTATE_90, test_api.GetCurrentCursorRotation());
1702 } 1690 }
1703 1691
1704 // GetRootWindowForDisplayId() for removed display::Display during 1692 // GetRootWindowForDisplayId() for removed display::Display during
1705 // OnDisplayRemoved() should not cause crash. See http://crbug.com/415222 1693 // OnDisplayRemoved() should not cause crash. See http://crbug.com/415222
1706 TEST_P(WindowTreeHostManagerTest, 1694 TEST_F(WindowTreeHostManagerTest,
1707 GetRootWindowForDisplayIdDuringDisplayDisconnection) { 1695 GetRootWindowForDisplayIdDuringDisplayDisconnection) {
1708 UpdateDisplay("300x300,200x200"); 1696 UpdateDisplay("300x300,200x200");
1709 aura::Window* root2 = Shell::GetInstance() 1697 aura::Window* root2 = Shell::GetInstance()
1710 ->window_tree_host_manager() 1698 ->window_tree_host_manager()
1711 ->GetRootWindowForDisplayId( 1699 ->GetRootWindowForDisplayId(
1712 display_manager()->GetSecondaryDisplay().id()); 1700 display_manager()->GetSecondaryDisplay().id());
1713 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( 1701 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds(
1714 nullptr, root2, gfx::Rect(350, 0, 100, 100)); 1702 nullptr, root2, gfx::Rect(350, 0, 100, 100));
1715 views::View* view = new views::View(); 1703 views::View* view = new views::View();
1716 widget->GetContentsView()->AddChildView(view); 1704 widget->GetContentsView()->AddChildView(view);
1717 view->SetBounds(0, 0, 100, 100); 1705 view->SetBounds(0, 0, 100, 100);
1718 widget->Show(); 1706 widget->Show();
1719 1707
1720 TestMouseWatcherListener listener; 1708 TestMouseWatcherListener listener;
1721 views::MouseWatcher watcher( 1709 views::MouseWatcher watcher(
1722 new views::MouseWatcherViewHost(view, gfx::Insets()), &listener); 1710 new views::MouseWatcherViewHost(view, gfx::Insets()), &listener);
1723 watcher.Start(); 1711 watcher.Start();
1724 1712
1725 ui::test::EventGenerator event_generator( 1713 ui::test::EventGenerator event_generator(
1726 widget->GetNativeWindow()->GetRootWindow()); 1714 widget->GetNativeWindow()->GetRootWindow());
1727 event_generator.MoveMouseToCenterOf(widget->GetNativeWindow()); 1715 event_generator.MoveMouseToCenterOf(widget->GetNativeWindow());
1728 1716
1729 UpdateDisplay("300x300"); 1717 UpdateDisplay("300x300");
1730 watcher.Stop(); 1718 watcher.Stop();
1731 1719
1732 widget->CloseNow(); 1720 widget->CloseNow();
1733 } 1721 }
1734 1722
1735 } // namespace ash 1723 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_manager_unittest.cc ('k') | ash/mus/test/wm_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698