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

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

Issue 64933002: Eliminate Shell::RootWindowList in favor of aura::Window::Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 1 month 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
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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 } 275 }
276 276
277 float GetStoredUIScale(int64 id) { 277 float GetStoredUIScale(int64 id) {
278 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).ui_scale(); 278 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).ui_scale();
279 } 279 }
280 280
281 #if defined(USE_X11) 281 #if defined(USE_X11)
282 void GetPrimaryAndSeconary(aura::Window** primary, 282 void GetPrimaryAndSeconary(aura::Window** primary,
283 aura::Window** secondary) { 283 aura::Window** secondary) {
284 *primary = Shell::GetPrimaryRootWindow(); 284 *primary = Shell::GetPrimaryRootWindow();
285 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 285 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
286 *secondary = root_windows[0] == *primary ? root_windows[1] : root_windows[0]; 286 *secondary = root_windows[0] == *primary ? root_windows[1] : root_windows[0];
287 } 287 }
288 288
289 std::string GetXWindowName(aura::RootWindow* window) { 289 std::string GetXWindowName(aura::RootWindow* window) {
290 char* name = NULL; 290 char* name = NULL;
291 XFetchName(gfx::GetXDisplay(), window->GetAcceleratedWidget(), &name); 291 XFetchName(gfx::GetXDisplay(), window->GetAcceleratedWidget(), &name);
292 std::string ret(name); 292 std::string ret(name);
293 XFree(name); 293 XFree(name);
294 return ret; 294 return ret;
295 } 295 }
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 if (!SupportsMultipleDisplays()) 898 if (!SupportsMultipleDisplays())
899 return; 899 return;
900 900
901 DisplayController* display_controller = 901 DisplayController* display_controller =
902 Shell::GetInstance()->display_controller(); 902 Shell::GetInstance()->display_controller();
903 TestEventHandler event_handler; 903 TestEventHandler event_handler;
904 Shell::GetInstance()->AddPreTargetHandler(&event_handler); 904 Shell::GetInstance()->AddPreTargetHandler(&event_handler);
905 905
906 UpdateDisplay("120x200,300x400*2"); 906 UpdateDisplay("120x200,300x400*2");
907 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); 907 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay();
908 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 908 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
909 909
910 display_controller->SetOverscanInsets(display1.id(), 910 display_controller->SetOverscanInsets(display1.id(),
911 gfx::Insets(10, 15, 20, 25)); 911 gfx::Insets(10, 15, 20, 25));
912 EXPECT_EQ("0,0 80x170", root_windows[0]->bounds().ToString()); 912 EXPECT_EQ("0,0 80x170", root_windows[0]->bounds().ToString());
913 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); 913 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString());
914 EXPECT_EQ("80,0 150x200", 914 EXPECT_EQ("80,0 150x200",
915 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); 915 ScreenAsh::GetSecondaryDisplay().bounds().ToString());
916 916
917 aura::test::EventGenerator generator(root_windows[0]); 917 aura::test::EventGenerator generator(root_windows[0]);
918 generator.MoveMouseToInHost(20, 25); 918 generator.MoveMouseToInHost(20, 25);
919 EXPECT_EQ("5,15", event_handler.GetLocationAndReset()); 919 EXPECT_EQ("5,15", event_handler.GetLocationAndReset());
920 920
921 display_controller->SetOverscanInsets(display1.id(), gfx::Insets()); 921 display_controller->SetOverscanInsets(display1.id(), gfx::Insets());
922 EXPECT_EQ("0,0 120x200", root_windows[0]->bounds().ToString()); 922 EXPECT_EQ("0,0 120x200", root_windows[0]->bounds().ToString());
923 EXPECT_EQ("120,0 150x200", 923 EXPECT_EQ("120,0 150x200",
924 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); 924 ScreenAsh::GetSecondaryDisplay().bounds().ToString());
925 925
926 generator.MoveMouseToInHost(30, 20); 926 generator.MoveMouseToInHost(30, 20);
927 EXPECT_EQ("30,20", event_handler.GetLocationAndReset()); 927 EXPECT_EQ("30,20", event_handler.GetLocationAndReset());
928 928
929 // Make sure the root window transformer uses correct scale 929 // Make sure the root window transformer uses correct scale
930 // factor when swapping display. Test crbug.com/253690. 930 // factor when swapping display. Test crbug.com/253690.
931 UpdateDisplay("400x300*2,600x400/o"); 931 UpdateDisplay("400x300*2,600x400/o");
932 root_windows = Shell::GetAllRootWindows(); 932 root_windows = Shell::GetAllRootWindows();
933 gfx::Point point; 933 gfx::Point point;
934 Shell::GetAllRootWindows()[1]->GetRootTransform().TransformPoint(&point); 934 Shell::GetAllRootWindows()[1]->GetDispatcher()->
935 GetRootTransform().TransformPoint(&point);
935 EXPECT_EQ("15,10", point.ToString()); 936 EXPECT_EQ("15,10", point.ToString());
936 937
937 display_controller->SwapPrimaryDisplay(); 938 display_controller->SwapPrimaryDisplay();
938 point.SetPoint(0, 0); 939 point.SetPoint(0, 0);
939 Shell::GetAllRootWindows()[1]->GetRootTransform().TransformPoint(&point); 940 Shell::GetAllRootWindows()[1]->GetDispatcher()->
941 GetRootTransform().TransformPoint(&point);
940 EXPECT_EQ("15,10", point.ToString()); 942 EXPECT_EQ("15,10", point.ToString());
941 943
942 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 944 Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
943 } 945 }
944 946
945 TEST_F(DisplayControllerTest, Rotate) { 947 TEST_F(DisplayControllerTest, Rotate) {
946 if (!SupportsMultipleDisplays()) 948 if (!SupportsMultipleDisplays())
947 return; 949 return;
948 950
949 internal::DisplayManager* display_manager = 951 internal::DisplayManager* display_manager =
950 Shell::GetInstance()->display_manager(); 952 Shell::GetInstance()->display_manager();
951 TestEventHandler event_handler; 953 TestEventHandler event_handler;
952 Shell::GetInstance()->AddPreTargetHandler(&event_handler); 954 Shell::GetInstance()->AddPreTargetHandler(&event_handler);
953 955
954 UpdateDisplay("120x200,300x400*2"); 956 UpdateDisplay("120x200,300x400*2");
955 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); 957 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay();
956 int64 display2_id = ScreenAsh::GetSecondaryDisplay().id(); 958 int64 display2_id = ScreenAsh::GetSecondaryDisplay().id();
957 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 959 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
958 aura::test::EventGenerator generator1(root_windows[0]); 960 aura::test::EventGenerator generator1(root_windows[0]);
959 961
960 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); 962 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString());
961 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); 963 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString());
962 EXPECT_EQ("120,0 150x200", 964 EXPECT_EQ("120,0 150x200",
963 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); 965 ScreenAsh::GetSecondaryDisplay().bounds().ToString());
964 generator1.MoveMouseToInHost(50, 40); 966 generator1.MoveMouseToInHost(50, 40);
965 EXPECT_EQ("50,40", event_handler.GetLocationAndReset()); 967 EXPECT_EQ("50,40", event_handler.GetLocationAndReset());
966 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id())); 968 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id()));
967 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); 969 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 1021
1020 TestEventHandler event_handler; 1022 TestEventHandler event_handler;
1021 Shell::GetInstance()->AddPreTargetHandler(&event_handler); 1023 Shell::GetInstance()->AddPreTargetHandler(&event_handler);
1022 1024
1023 UpdateDisplay("600x400*2@1.5,500x300"); 1025 UpdateDisplay("600x400*2@1.5,500x300");
1024 1026
1025 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); 1027 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay();
1026 gfx::Display::SetInternalDisplayId(display1.id()); 1028 gfx::Display::SetInternalDisplayId(display1.id());
1027 1029
1028 gfx::Display display2 = ScreenAsh::GetSecondaryDisplay(); 1030 gfx::Display display2 = ScreenAsh::GetSecondaryDisplay();
1029 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 1031 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1030 EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); 1032 EXPECT_EQ("0,0 450x300", display1.bounds().ToString());
1031 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); 1033 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString());
1032 EXPECT_EQ("450,0 500x300", display2.bounds().ToString()); 1034 EXPECT_EQ("450,0 500x300", display2.bounds().ToString());
1033 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); 1035 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id()));
1034 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); 1036 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id()));
1035 1037
1036 aura::test::EventGenerator generator(root_windows[0]); 1038 aura::test::EventGenerator generator(root_windows[0]);
1037 generator.MoveMouseToInHost(599, 200); 1039 generator.MoveMouseToInHost(599, 200);
1038 EXPECT_EQ("449,150", event_handler.GetLocationAndReset()); 1040 EXPECT_EQ("449,150", event_handler.GetLocationAndReset());
1039 1041
(...skipping 13 matching lines...) Expand all
1053 1055
1054 TEST_F(DisplayControllerTest, TouchScale) { 1056 TEST_F(DisplayControllerTest, TouchScale) {
1055 if (!SupportsMultipleDisplays()) 1057 if (!SupportsMultipleDisplays())
1056 return; 1058 return;
1057 1059
1058 TestEventHandler event_handler; 1060 TestEventHandler event_handler;
1059 Shell::GetInstance()->AddPreTargetHandler(&event_handler); 1061 Shell::GetInstance()->AddPreTargetHandler(&event_handler);
1060 1062
1061 UpdateDisplay("200x200*2"); 1063 UpdateDisplay("200x200*2");
1062 gfx::Display display = Shell::GetScreen()->GetPrimaryDisplay(); 1064 gfx::Display display = Shell::GetScreen()->GetPrimaryDisplay();
1063 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 1065 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1064 aura::RootWindow* root_window = root_windows[0]; 1066 aura::Window* root_window = root_windows[0];
1065 aura::test::EventGenerator generator(root_window); 1067 aura::test::EventGenerator generator(root_window);
1066 1068
1067 generator.PressMoveAndReleaseTouchTo(50, 50); 1069 generator.PressMoveAndReleaseTouchTo(50, 50);
1068 // Default test touches have radius_x/y = 1.0, with device scale 1070 // Default test touches have radius_x/y = 1.0, with device scale
1069 // factor = 2, the scaled radius_x/y should be 0.5. 1071 // factor = 2, the scaled radius_x/y should be 0.5.
1070 EXPECT_EQ(0.5, event_handler.touch_radius_x()); 1072 EXPECT_EQ(0.5, event_handler.touch_radius_x());
1071 EXPECT_EQ(0.5, event_handler.touch_radius_y()); 1073 EXPECT_EQ(0.5, event_handler.touch_radius_y());
1072 1074
1073 generator.ScrollSequence(gfx::Point(0,0), 1075 generator.ScrollSequence(gfx::Point(0,0),
1074 base::TimeDelta::FromMilliseconds(100), 1076 base::TimeDelta::FromMilliseconds(100),
(...skipping 11 matching lines...) Expand all
1086 TEST_F(DisplayControllerTest, ConvertHostToRootCoords) { 1088 TEST_F(DisplayControllerTest, ConvertHostToRootCoords) {
1087 if (!SupportsMultipleDisplays()) 1089 if (!SupportsMultipleDisplays())
1088 return; 1090 return;
1089 1091
1090 TestEventHandler event_handler; 1092 TestEventHandler event_handler;
1091 Shell::GetInstance()->AddPreTargetHandler(&event_handler); 1093 Shell::GetInstance()->AddPreTargetHandler(&event_handler);
1092 1094
1093 UpdateDisplay("600x400*2/r@1.5"); 1095 UpdateDisplay("600x400*2/r@1.5");
1094 1096
1095 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); 1097 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay();
1096 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 1098 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1097 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); 1099 EXPECT_EQ("0,0 300x450", display1.bounds().ToString());
1098 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); 1100 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString());
1099 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); 1101 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id()));
1100 1102
1101 aura::test::EventGenerator generator(root_windows[0]); 1103 aura::test::EventGenerator generator(root_windows[0]);
1102 generator.MoveMouseToInHost(0, 0); 1104 generator.MoveMouseToInHost(0, 0);
1103 EXPECT_EQ("0,449", event_handler.GetLocationAndReset()); 1105 EXPECT_EQ("0,449", event_handler.GetLocationAndReset());
1104 generator.MoveMouseToInHost(599, 0); 1106 generator.MoveMouseToInHost(599, 0);
1105 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); 1107 EXPECT_EQ("0,0", event_handler.GetLocationAndReset());
1106 generator.MoveMouseToInHost(599, 399); 1108 generator.MoveMouseToInHost(599, 399);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetDispatcher())); 1165 EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetDispatcher()));
1164 1166
1165 // Switching back to single display. 1167 // Switching back to single display.
1166 UpdateDisplay("300x400"); 1168 UpdateDisplay("300x400");
1167 EXPECT_EQ("aura_root_0", GetXWindowName( 1169 EXPECT_EQ("aura_root_0", GetXWindowName(
1168 Shell::GetPrimaryRootWindow()->GetDispatcher())); 1170 Shell::GetPrimaryRootWindow()->GetDispatcher()));
1169 } 1171 }
1170 #endif 1172 #endif
1171 1173
1172 } // namespace ash 1174 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698