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

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

Issue 224113005: Eliminate ash::internal namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « ash/display/display_controller.cc ('k') | ash/display/display_error_observer_chromeos.h » ('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/display_controller.h" 5 #include "ash/display/display_controller.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/display/display_info.h" 8 #include "ash/display/display_info.h"
9 #include "ash/display/display_layout_store.h" 9 #include "ash/display/display_layout_store.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); 502 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString());
503 EXPECT_EQ("-300,500 400x400", GetSecondaryDisplay().bounds().ToString()); 503 EXPECT_EQ("-300,500 400x400", GetSecondaryDisplay().bounds().ToString());
504 504
505 UpdateDisplay("500x500"); 505 UpdateDisplay("500x500");
506 EXPECT_LE(1, observer.GetFocusChangedCountAndReset()); 506 EXPECT_LE(1, observer.GetFocusChangedCountAndReset());
507 EXPECT_LE(1, observer.GetActivationChangedCountAndReset()); 507 EXPECT_LE(1, observer.GetActivationChangedCountAndReset());
508 } 508 }
509 509
510 namespace { 510 namespace {
511 511
512 internal::DisplayInfo CreateDisplayInfo(int64 id, 512 DisplayInfo CreateDisplayInfo(int64 id,
513 const gfx::Rect& bounds, 513 const gfx::Rect& bounds,
514 float device_scale_factor) { 514 float device_scale_factor) {
515 internal::DisplayInfo info(id, "", false); 515 DisplayInfo info(id, "", false);
516 info.SetBounds(bounds); 516 info.SetBounds(bounds);
517 info.set_device_scale_factor(device_scale_factor); 517 info.set_device_scale_factor(device_scale_factor);
518 return info; 518 return info;
519 } 519 }
520 520
521 } // namespace 521 } // namespace
522 522
523 TEST_F(DisplayControllerTest, MirrorToDockedWithFullscreen) { 523 TEST_F(DisplayControllerTest, MirrorToDockedWithFullscreen) {
524 // Creates windows to catch activation change event. 524 // Creates windows to catch activation change event.
525 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); 525 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1));
526 w1->Focus(); 526 w1->Focus();
527 527
528 // Docked mode. 528 // Docked mode.
529 internal::DisplayManager* display_manager = 529 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
530 Shell::GetInstance()->display_manager();
531 530
532 const internal::DisplayInfo internal_display_info = 531 const DisplayInfo internal_display_info =
533 CreateDisplayInfo(1, gfx::Rect(0, 0, 500, 500), 2.0f); 532 CreateDisplayInfo(1, gfx::Rect(0, 0, 500, 500), 2.0f);
534 const internal::DisplayInfo external_display_info = 533 const DisplayInfo external_display_info =
535 CreateDisplayInfo(2, gfx::Rect(0, 0, 500, 500), 1.0f); 534 CreateDisplayInfo(2, gfx::Rect(0, 0, 500, 500), 1.0f);
536 535
537 std::vector<internal::DisplayInfo> display_info_list; 536 std::vector<DisplayInfo> display_info_list;
538 // Mirror. 537 // Mirror.
539 display_info_list.push_back(internal_display_info); 538 display_info_list.push_back(internal_display_info);
540 display_info_list.push_back(external_display_info); 539 display_info_list.push_back(external_display_info);
541 display_manager->OnNativeDisplaysChanged(display_info_list); 540 display_manager->OnNativeDisplaysChanged(display_info_list);
542 const int64 internal_display_id = 541 const int64 internal_display_id =
543 test::DisplayManagerTestApi(display_manager). 542 test::DisplayManagerTestApi(display_manager).
544 SetFirstDisplayAsInternalDisplay(); 543 SetFirstDisplayAsInternalDisplay();
545 EXPECT_EQ(1, internal_display_id); 544 EXPECT_EQ(1, internal_display_id);
546 EXPECT_EQ(2U, display_manager->num_connected_displays()); 545 EXPECT_EQ(2U, display_manager->num_connected_displays());
547 EXPECT_EQ(1U, display_manager->GetNumDisplays()); 546 EXPECT_EQ(1U, display_manager->GetNumDisplays());
(...skipping 28 matching lines...) Expand all
576 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1)); 575 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithId(1));
577 w1->Focus(); 576 w1->Focus();
578 577
579 TestObserver observer; 578 TestObserver observer;
580 SetDefaultDisplayLayout(DisplayLayout::BOTTOM); 579 SetDefaultDisplayLayout(DisplayLayout::BOTTOM);
581 UpdateDisplay("200x200,300x300"); // layout, resize and add. 580 UpdateDisplay("200x200,300x300"); // layout, resize and add.
582 EXPECT_EQ(1, observer.CountAndReset()); 581 EXPECT_EQ(1, observer.CountAndReset());
583 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); 582 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
584 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); 583 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
585 584
586 internal::DisplayManager* display_manager = 585 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
587 Shell::GetInstance()->display_manager();
588 gfx::Insets insets(5, 5, 5, 5); 586 gfx::Insets insets(5, 5, 5, 5);
589 display_manager->UpdateWorkAreaOfDisplay( 587 display_manager->UpdateWorkAreaOfDisplay(
590 ScreenUtil::GetSecondaryDisplay().id(), insets); 588 ScreenUtil::GetSecondaryDisplay().id(), insets);
591 589
592 EXPECT_EQ("0,0 200x200", GetPrimaryDisplay().bounds().ToString()); 590 EXPECT_EQ("0,0 200x200", GetPrimaryDisplay().bounds().ToString());
593 EXPECT_EQ("0,200 300x300", GetSecondaryDisplay().bounds().ToString()); 591 EXPECT_EQ("0,200 300x300", GetSecondaryDisplay().bounds().ToString());
594 EXPECT_EQ("5,205 290x290", GetSecondaryDisplay().work_area().ToString()); 592 EXPECT_EQ("5,205 290x290", GetSecondaryDisplay().work_area().ToString());
595 593
596 UpdateDisplay("400x400,200x200"); 594 UpdateDisplay("400x400,200x200");
597 EXPECT_EQ(1, observer.CountAndReset()); // two resizes 595 EXPECT_EQ(1, observer.CountAndReset()); // two resizes
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); 657 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
660 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); 658 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
661 } 659 }
662 660
663 TEST_F(DisplayControllerTest, SwapPrimary) { 661 TEST_F(DisplayControllerTest, SwapPrimary) {
664 if (!SupportsMultipleDisplays()) 662 if (!SupportsMultipleDisplays())
665 return; 663 return;
666 664
667 DisplayController* display_controller = 665 DisplayController* display_controller =
668 Shell::GetInstance()->display_controller(); 666 Shell::GetInstance()->display_controller();
669 internal::DisplayManager* display_manager = 667 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
670 Shell::GetInstance()->display_manager();
671 668
672 UpdateDisplay("200x200,300x300"); 669 UpdateDisplay("200x200,300x300");
673 gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay(); 670 gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay();
674 gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); 671 gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay();
675 672
676 DisplayLayout display_layout(DisplayLayout::RIGHT, 50); 673 DisplayLayout display_layout(DisplayLayout::RIGHT, 50);
677 display_manager->SetLayoutForCurrentDisplays(display_layout); 674 display_manager->SetLayoutForCurrentDisplays(display_layout);
678 675
679 EXPECT_NE(primary_display.id(), secondary_display.id()); 676 EXPECT_NE(primary_display.id(), secondary_display.id());
680 aura::Window* primary_root = 677 aura::Window* primary_root =
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 EXPECT_FALSE(tracker.Contains(secondary_root)); 747 EXPECT_FALSE(tracker.Contains(secondary_root));
751 EXPECT_TRUE(primary_root->Contains(shelf_window)); 748 EXPECT_TRUE(primary_root->Contains(shelf_window));
752 } 749 }
753 750
754 TEST_F(DisplayControllerTest, FindNearestDisplay) { 751 TEST_F(DisplayControllerTest, FindNearestDisplay) {
755 if (!SupportsMultipleDisplays()) 752 if (!SupportsMultipleDisplays())
756 return; 753 return;
757 754
758 DisplayController* display_controller = 755 DisplayController* display_controller =
759 Shell::GetInstance()->display_controller(); 756 Shell::GetInstance()->display_controller();
760 internal::DisplayManager* display_manager = 757 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
761 Shell::GetInstance()->display_manager();
762 758
763 UpdateDisplay("200x200,300x300"); 759 UpdateDisplay("200x200,300x300");
764 DisplayLayout display_layout(DisplayLayout::RIGHT, 50); 760 DisplayLayout display_layout(DisplayLayout::RIGHT, 50);
765 display_manager->SetLayoutForCurrentDisplays(display_layout); 761 display_manager->SetLayoutForCurrentDisplays(display_layout);
766 762
767 gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay(); 763 gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay();
768 gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); 764 gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay();
769 EXPECT_NE(primary_display.id(), secondary_display.id()); 765 EXPECT_NE(primary_display.id(), secondary_display.id());
770 aura::Window* primary_root = 766 aura::Window* primary_root =
771 display_controller->GetRootWindowForDisplayId(primary_display.id()); 767 display_controller->GetRootWindowForDisplayId(primary_display.id());
(...skipping 24 matching lines...) Expand all
796 792
797 TEST_F(DisplayControllerTest, SwapPrimaryForLegacyShelfLayout) { 793 TEST_F(DisplayControllerTest, SwapPrimaryForLegacyShelfLayout) {
798 if (!SupportsMultipleDisplays()) 794 if (!SupportsMultipleDisplays())
799 return; 795 return;
800 796
801 CommandLine::ForCurrentProcess()->AppendSwitch( 797 CommandLine::ForCurrentProcess()->AppendSwitch(
802 switches::kAshDisableAlternateShelfLayout); 798 switches::kAshDisableAlternateShelfLayout);
803 799
804 DisplayController* display_controller = 800 DisplayController* display_controller =
805 Shell::GetInstance()->display_controller(); 801 Shell::GetInstance()->display_controller();
806 internal::DisplayManager* display_manager = 802 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
807 Shell::GetInstance()->display_manager();
808 803
809 UpdateDisplay("200x200,300x300"); 804 UpdateDisplay("200x200,300x300");
810 gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay(); 805 gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay();
811 gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); 806 gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay();
812 807
813 DisplayLayout display_layout(DisplayLayout::RIGHT, 50); 808 DisplayLayout display_layout(DisplayLayout::RIGHT, 50);
814 display_manager->SetLayoutForCurrentDisplays(display_layout); 809 display_manager->SetLayoutForCurrentDisplays(display_layout);
815 810
816 EXPECT_NE(primary_display.id(), secondary_display.id()); 811 EXPECT_NE(primary_display.id(), secondary_display.id());
817 aura::Window* primary_root = 812 aura::Window* primary_root =
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 EXPECT_FALSE(tracker.Contains(secondary_root)); 882 EXPECT_FALSE(tracker.Contains(secondary_root));
888 EXPECT_TRUE(primary_root->Contains(shelf_window)); 883 EXPECT_TRUE(primary_root->Contains(shelf_window));
889 } 884 }
890 885
891 TEST_F(DisplayControllerTest, SwapPrimaryById) { 886 TEST_F(DisplayControllerTest, SwapPrimaryById) {
892 if (!SupportsMultipleDisplays()) 887 if (!SupportsMultipleDisplays())
893 return; 888 return;
894 889
895 DisplayController* display_controller = 890 DisplayController* display_controller =
896 Shell::GetInstance()->display_controller(); 891 Shell::GetInstance()->display_controller();
897 internal::DisplayManager* display_manager = 892 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
898 Shell::GetInstance()->display_manager();
899 893
900 UpdateDisplay("200x200,300x300"); 894 UpdateDisplay("200x200,300x300");
901 gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay(); 895 gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay();
902 gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); 896 gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay();
903 897
904 DisplayLayout display_layout(DisplayLayout::RIGHT, 50); 898 DisplayLayout display_layout(DisplayLayout::RIGHT, 50);
905 display_manager->SetLayoutForCurrentDisplays(display_layout); 899 display_manager->SetLayoutForCurrentDisplays(display_layout);
906 900
907 EXPECT_NE(primary_display.id(), secondary_display.id()); 901 EXPECT_NE(primary_display.id(), secondary_display.id());
908 aura::Window* primary_root = 902 aura::Window* primary_root =
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 Shell::GetScreen()->GetDisplayNearestPoint( 953 Shell::GetScreen()->GetDisplayNearestPoint(
960 gfx::Point(-100, -100)).id()); 954 gfx::Point(-100, -100)).id());
961 EXPECT_EQ(primary_display.id(), 955 EXPECT_EQ(primary_display.id(),
962 Shell::GetScreen()->GetDisplayNearestWindow(NULL).id()); 956 Shell::GetScreen()->GetDisplayNearestWindow(NULL).id());
963 EXPECT_TRUE(tracker.Contains(primary_root)); 957 EXPECT_TRUE(tracker.Contains(primary_root));
964 EXPECT_FALSE(tracker.Contains(secondary_root)); 958 EXPECT_FALSE(tracker.Contains(secondary_root));
965 EXPECT_TRUE(primary_root->Contains(shelf_window)); 959 EXPECT_TRUE(primary_root->Contains(shelf_window));
966 960
967 // Adding 2nd display with the same ID. The 2nd display should become primary 961 // Adding 2nd display with the same ID. The 2nd display should become primary
968 // since secondary id is still stored as desirable_primary_id. 962 // since secondary id is still stored as desirable_primary_id.
969 std::vector<internal::DisplayInfo> display_info_list; 963 std::vector<DisplayInfo> display_info_list;
970 display_info_list.push_back( 964 display_info_list.push_back(
971 display_manager->GetDisplayInfo(primary_display.id())); 965 display_manager->GetDisplayInfo(primary_display.id()));
972 display_info_list.push_back( 966 display_info_list.push_back(
973 display_manager->GetDisplayInfo(secondary_display.id())); 967 display_manager->GetDisplayInfo(secondary_display.id()));
974 display_manager->OnNativeDisplaysChanged(display_info_list); 968 display_manager->OnNativeDisplaysChanged(display_info_list);
975 969
976 EXPECT_EQ(2, Shell::GetScreen()->GetNumDisplays()); 970 EXPECT_EQ(2, Shell::GetScreen()->GetNumDisplays());
977 EXPECT_EQ(secondary_display.id(), 971 EXPECT_EQ(secondary_display.id(),
978 Shell::GetScreen()->GetPrimaryDisplay().id()); 972 Shell::GetScreen()->GetPrimaryDisplay().id());
979 EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id()); 973 EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id());
980 EXPECT_EQ( 974 EXPECT_EQ(
981 primary_root, 975 primary_root,
982 display_controller->GetRootWindowForDisplayId(secondary_display.id())); 976 display_controller->GetRootWindowForDisplayId(secondary_display.id()));
983 EXPECT_NE( 977 EXPECT_NE(
984 primary_root, 978 primary_root,
985 display_controller->GetRootWindowForDisplayId(primary_display.id())); 979 display_controller->GetRootWindowForDisplayId(primary_display.id()));
986 EXPECT_TRUE(primary_root->Contains(shelf_window)); 980 EXPECT_TRUE(primary_root->Contains(shelf_window));
987 981
988 // Deleting 2nd display and adding 2nd display with a different ID. The 2nd 982 // Deleting 2nd display and adding 2nd display with a different ID. The 2nd
989 // display shouldn't become primary. 983 // display shouldn't become primary.
990 UpdateDisplay("200x200"); 984 UpdateDisplay("200x200");
991 internal::DisplayInfo third_display_info( 985 DisplayInfo third_display_info(
992 secondary_display.id() + 1, std::string(), false); 986 secondary_display.id() + 1, std::string(), false);
993 third_display_info.SetBounds(secondary_display.bounds()); 987 third_display_info.SetBounds(secondary_display.bounds());
994 ASSERT_NE(primary_display.id(), third_display_info.id()); 988 ASSERT_NE(primary_display.id(), third_display_info.id());
995 989
996 const internal::DisplayInfo& primary_display_info = 990 const DisplayInfo& primary_display_info =
997 display_manager->GetDisplayInfo(primary_display.id()); 991 display_manager->GetDisplayInfo(primary_display.id());
998 std::vector<internal::DisplayInfo> display_info_list2; 992 std::vector<DisplayInfo> display_info_list2;
999 display_info_list2.push_back(primary_display_info); 993 display_info_list2.push_back(primary_display_info);
1000 display_info_list2.push_back(third_display_info); 994 display_info_list2.push_back(third_display_info);
1001 display_manager->OnNativeDisplaysChanged(display_info_list2); 995 display_manager->OnNativeDisplaysChanged(display_info_list2);
1002 EXPECT_EQ(2, Shell::GetScreen()->GetNumDisplays()); 996 EXPECT_EQ(2, Shell::GetScreen()->GetNumDisplays());
1003 EXPECT_EQ(primary_display.id(), 997 EXPECT_EQ(primary_display.id(),
1004 Shell::GetScreen()->GetPrimaryDisplay().id()); 998 Shell::GetScreen()->GetPrimaryDisplay().id());
1005 EXPECT_EQ(third_display_info.id(), ScreenUtil::GetSecondaryDisplay().id()); 999 EXPECT_EQ(third_display_info.id(), ScreenUtil::GetSecondaryDisplay().id());
1006 EXPECT_EQ( 1000 EXPECT_EQ(
1007 primary_root, 1001 primary_root,
1008 display_controller->GetRootWindowForDisplayId(primary_display.id())); 1002 display_controller->GetRootWindowForDisplayId(primary_display.id()));
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 GetRootTransform().TransformPoint(&point); 1108 GetRootTransform().TransformPoint(&point);
1115 EXPECT_EQ("15,10", point.ToString()); 1109 EXPECT_EQ("15,10", point.ToString());
1116 1110
1117 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 1111 Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
1118 } 1112 }
1119 1113
1120 TEST_F(DisplayControllerTest, Rotate) { 1114 TEST_F(DisplayControllerTest, Rotate) {
1121 if (!SupportsMultipleDisplays()) 1115 if (!SupportsMultipleDisplays())
1122 return; 1116 return;
1123 1117
1124 internal::DisplayManager* display_manager = 1118 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
1125 Shell::GetInstance()->display_manager();
1126 TestEventHandler event_handler; 1119 TestEventHandler event_handler;
1127 Shell::GetInstance()->AddPreTargetHandler(&event_handler); 1120 Shell::GetInstance()->AddPreTargetHandler(&event_handler);
1128 1121
1129 UpdateDisplay("120x200,300x400*2"); 1122 UpdateDisplay("120x200,300x400*2");
1130 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); 1123 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay();
1131 int64 display2_id = ScreenUtil::GetSecondaryDisplay().id(); 1124 int64 display2_id = ScreenUtil::GetSecondaryDisplay().id();
1132 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1125 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1133 aura::test::EventGenerator generator1(root_windows[0]); 1126 aura::test::EventGenerator generator1(root_windows[0]);
1134 1127
1135 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); 1128 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString());
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); 1198 EXPECT_EQ("0,0 450x300", display1.bounds().ToString());
1206 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); 1199 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString());
1207 EXPECT_EQ("450,0 500x300", display2.bounds().ToString()); 1200 EXPECT_EQ("450,0 500x300", display2.bounds().ToString());
1208 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); 1201 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id()));
1209 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); 1202 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id()));
1210 1203
1211 aura::test::EventGenerator generator(root_windows[0]); 1204 aura::test::EventGenerator generator(root_windows[0]);
1212 generator.MoveMouseToInHost(599, 200); 1205 generator.MoveMouseToInHost(599, 200);
1213 EXPECT_EQ("449,150", event_handler.GetLocationAndReset()); 1206 EXPECT_EQ("449,150", event_handler.GetLocationAndReset());
1214 1207
1215 internal::DisplayManager* display_manager = 1208 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
1216 Shell::GetInstance()->display_manager();
1217 display_manager->SetDisplayUIScale(display1.id(), 1.25f); 1209 display_manager->SetDisplayUIScale(display1.id(), 1.25f);
1218 display1 = Shell::GetScreen()->GetPrimaryDisplay(); 1210 display1 = Shell::GetScreen()->GetPrimaryDisplay();
1219 display2 = ScreenUtil::GetSecondaryDisplay(); 1211 display2 = ScreenUtil::GetSecondaryDisplay();
1220 EXPECT_EQ("0,0 375x250", display1.bounds().ToString()); 1212 EXPECT_EQ("0,0 375x250", display1.bounds().ToString());
1221 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString()); 1213 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString());
1222 EXPECT_EQ("375,0 500x300", display2.bounds().ToString()); 1214 EXPECT_EQ("375,0 500x300", display2.bounds().ToString());
1223 EXPECT_EQ(1.25f, GetStoredUIScale(display1.id())); 1215 EXPECT_EQ(1.25f, GetStoredUIScale(display1.id()));
1224 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); 1216 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id()));
1225 1217
1226 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 1218 Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 generator.MoveMouseToInHost(599, 399); 1305 generator.MoveMouseToInHost(599, 399);
1314 EXPECT_EQ("0,449", event_handler.GetLocationAndReset()); 1306 EXPECT_EQ("0,449", event_handler.GetLocationAndReset());
1315 generator.MoveMouseToInHost(0, 399); 1307 generator.MoveMouseToInHost(0, 399);
1316 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); 1308 EXPECT_EQ("0,0", event_handler.GetLocationAndReset());
1317 1309
1318 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 1310 Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
1319 } 1311 }
1320 1312
1321 namespace { 1313 namespace {
1322 1314
1323 internal::DisplayInfo CreateDisplayInfo(int64 id, 1315 DisplayInfo CreateDisplayInfo(int64 id,
1324 int y, 1316 int y,
1325 gfx::Display::Rotation rotation) { 1317 gfx::Display::Rotation rotation) {
1326 internal::DisplayInfo info(id, "", false); 1318 DisplayInfo info(id, "", false);
1327 info.SetBounds(gfx::Rect(0, y, 500, 500)); 1319 info.SetBounds(gfx::Rect(0, y, 500, 500));
1328 info.set_rotation(rotation); 1320 info.set_rotation(rotation);
1329 return info; 1321 return info;
1330 } 1322 }
1331 1323
1332 } // namespace 1324 } // namespace
1333 1325
1334 // Make sure that the compositor based mirroring can switch 1326 // Make sure that the compositor based mirroring can switch
1335 // from/to dock mode. 1327 // from/to dock mode.
1336 TEST_F(DisplayControllerTest, DockToSingle) { 1328 TEST_F(DisplayControllerTest, DockToSingle) {
1337 if (!SupportsMultipleDisplays()) 1329 if (!SupportsMultipleDisplays())
1338 return; 1330 return;
1339 1331
1340 internal::DisplayManager* display_manager = 1332 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
1341 Shell::GetInstance()->display_manager();
1342 1333
1343 const int64 internal_id = 1; 1334 const int64 internal_id = 1;
1344 1335
1345 const internal::DisplayInfo internal_display_info = 1336 const DisplayInfo internal_display_info =
1346 CreateDisplayInfo(internal_id, 0, gfx::Display::ROTATE_0); 1337 CreateDisplayInfo(internal_id, 0, gfx::Display::ROTATE_0);
1347 const internal::DisplayInfo external_display_info = 1338 const DisplayInfo external_display_info =
1348 CreateDisplayInfo(2, 1, gfx::Display::ROTATE_90); 1339 CreateDisplayInfo(2, 1, gfx::Display::ROTATE_90);
1349 1340
1350 std::vector<internal::DisplayInfo> display_info_list; 1341 std::vector<DisplayInfo> display_info_list;
1351 // Extended 1342 // Extended
1352 display_info_list.push_back(internal_display_info); 1343 display_info_list.push_back(internal_display_info);
1353 display_info_list.push_back(external_display_info); 1344 display_info_list.push_back(external_display_info);
1354 display_manager->OnNativeDisplaysChanged(display_info_list); 1345 display_manager->OnNativeDisplaysChanged(display_info_list);
1355 const int64 internal_display_id = 1346 const int64 internal_display_id =
1356 test::DisplayManagerTestApi(display_manager). 1347 test::DisplayManagerTestApi(display_manager).
1357 SetFirstDisplayAsInternalDisplay(); 1348 SetFirstDisplayAsInternalDisplay();
1358 EXPECT_EQ(internal_id, internal_display_id); 1349 EXPECT_EQ(internal_id, internal_display_id);
1359 EXPECT_EQ(2U, display_manager->GetNumDisplays()); 1350 EXPECT_EQ(2U, display_manager->GetNumDisplays());
1360 1351
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetHost())); 1386 EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetHost()));
1396 1387
1397 // Switching back to single display. 1388 // Switching back to single display.
1398 UpdateDisplay("300x400"); 1389 UpdateDisplay("300x400");
1399 EXPECT_EQ("aura_root_0", GetXWindowName( 1390 EXPECT_EQ("aura_root_0", GetXWindowName(
1400 Shell::GetPrimaryRootWindow()->GetHost())); 1391 Shell::GetPrimaryRootWindow()->GetHost()));
1401 } 1392 }
1402 #endif 1393 #endif
1403 1394
1404 } // namespace ash 1395 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_controller.cc ('k') | ash/display/display_error_observer_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698