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

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

Issue 1608053002: Remove now-unnecessary wrappers around gfx::Screen::GetScreen() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@metro-mode-5
Patch Set: cros Created 4 years, 11 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/screen_position_controller.cc ('k') | ash/display/shared_display_edge_indicator.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/screen_position_controller.h" 5 #include "ash/display/screen_position_controller.h"
6 6
7 #include "ash/display/display_manager.h" 7 #include "ash/display/display_manager.h"
8 #include "ash/screen_util.h" 8 #include "ash/screen_util.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 EXPECT_EQ("200x200", 107 EXPECT_EQ("200x200",
108 root_windows[0]->GetHost()->GetBounds().size().ToString()); 108 root_windows[0]->GetHost()->GetBounds().size().ToString());
109 EXPECT_EQ("100,500", 109 EXPECT_EQ("100,500",
110 root_windows[1]->GetHost()->GetBounds().origin().ToString()); 110 root_windows[1]->GetHost()->GetBounds().origin().ToString());
111 EXPECT_EQ("200x200", 111 EXPECT_EQ("200x200",
112 root_windows[1]->GetHost()->GetBounds().size().ToString()); 112 root_windows[1]->GetHost()->GetBounds().size().ToString());
113 113
114 const gfx::Point window_pos(100, 100); 114 const gfx::Point window_pos(100, 100);
115 window_->SetBoundsInScreen( 115 window_->SetBoundsInScreen(
116 gfx::Rect(window_pos, gfx::Size(100, 100)), 116 gfx::Rect(window_pos, gfx::Size(100, 100)),
117 Shell::GetScreen()->GetDisplayNearestPoint(window_pos)); 117 gfx::Screen::GetScreen()->GetDisplayNearestPoint(window_pos));
118 SetSecondaryDisplayLayout(DisplayLayout::RIGHT); 118 SetSecondaryDisplayLayout(DisplayLayout::RIGHT);
119 // The point is on the primary root window. 119 // The point is on the primary root window.
120 EXPECT_EQ("50,50", ConvertHostPointToScreen(50, 50)); 120 EXPECT_EQ("50,50", ConvertHostPointToScreen(50, 50));
121 // The point is out of the all root windows. 121 // The point is out of the all root windows.
122 EXPECT_EQ("250,250", ConvertHostPointToScreen(250, 250)); 122 EXPECT_EQ("250,250", ConvertHostPointToScreen(250, 250));
123 // The point is on the secondary display. 123 // The point is on the secondary display.
124 EXPECT_EQ("250,0", ConvertHostPointToScreen(50, 400)); 124 EXPECT_EQ("250,0", ConvertHostPointToScreen(50, 400));
125 125
126 SetSecondaryDisplayLayout(DisplayLayout::BOTTOM); 126 SetSecondaryDisplayLayout(DisplayLayout::BOTTOM);
127 // The point is on the primary root window. 127 // The point is on the primary root window.
(...skipping 17 matching lines...) Expand all
145 // The point is out of the all root windows. 145 // The point is out of the all root windows.
146 EXPECT_EQ("250,250", ConvertHostPointToScreen(250, 250)); 146 EXPECT_EQ("250,250", ConvertHostPointToScreen(250, 250));
147 // The point is on the secondary display. 147 // The point is on the secondary display.
148 EXPECT_EQ("50,-200", ConvertHostPointToScreen(50, 400)); 148 EXPECT_EQ("50,-200", ConvertHostPointToScreen(50, 400));
149 149
150 150
151 SetSecondaryDisplayLayout(DisplayLayout::RIGHT); 151 SetSecondaryDisplayLayout(DisplayLayout::RIGHT);
152 const gfx::Point window_pos2(300, 100); 152 const gfx::Point window_pos2(300, 100);
153 window_->SetBoundsInScreen( 153 window_->SetBoundsInScreen(
154 gfx::Rect(window_pos2, gfx::Size(100, 100)), 154 gfx::Rect(window_pos2, gfx::Size(100, 100)),
155 Shell::GetScreen()->GetDisplayNearestPoint(window_pos2)); 155 gfx::Screen::GetScreen()->GetDisplayNearestPoint(window_pos2));
156 // The point is on the secondary display. 156 // The point is on the secondary display.
157 EXPECT_EQ("250,50", ConvertHostPointToScreen(50, 50)); 157 EXPECT_EQ("250,50", ConvertHostPointToScreen(50, 50));
158 // The point is out of the all root windows. 158 // The point is out of the all root windows.
159 EXPECT_EQ("450,250", ConvertHostPointToScreen(250, 250)); 159 EXPECT_EQ("450,250", ConvertHostPointToScreen(250, 250));
160 // The point is on the primary root window. 160 // The point is on the primary root window.
161 EXPECT_EQ("50,0", ConvertHostPointToScreen(50, -400)); 161 EXPECT_EQ("50,0", ConvertHostPointToScreen(50, -400));
162 162
163 SetSecondaryDisplayLayout(DisplayLayout::BOTTOM); 163 SetSecondaryDisplayLayout(DisplayLayout::BOTTOM);
164 // The point is on the secondary display. 164 // The point is on the secondary display.
165 EXPECT_EQ("50,250", ConvertHostPointToScreen(50, 50)); 165 EXPECT_EQ("50,250", ConvertHostPointToScreen(50, 50));
(...skipping 24 matching lines...) Expand all
190 190
191 aura::Window::Windows root_windows = 191 aura::Window::Windows root_windows =
192 Shell::GetInstance()->GetAllRootWindows(); 192 Shell::GetInstance()->GetAllRootWindows();
193 EXPECT_EQ("50,50 200x200", 193 EXPECT_EQ("50,50 200x200",
194 root_windows[0]->GetHost()->GetBounds().ToString()); 194 root_windows[0]->GetHost()->GetBounds().ToString());
195 EXPECT_EQ("50,300 300x300", 195 EXPECT_EQ("50,300 300x300",
196 root_windows[1]->GetHost()->GetBounds().ToString()); 196 root_windows[1]->GetHost()->GetBounds().ToString());
197 197
198 // Put |window_| to the primary 2x display. 198 // Put |window_| to the primary 2x display.
199 window_->SetBoundsInScreen(gfx::Rect(20, 20, 50, 50), 199 window_->SetBoundsInScreen(gfx::Rect(20, 20, 50, 50),
200 Shell::GetScreen()->GetPrimaryDisplay()); 200 gfx::Screen::GetScreen()->GetPrimaryDisplay());
201 // (30, 30) means the host coordinate, so the point is still on the primary 201 // (30, 30) means the host coordinate, so the point is still on the primary
202 // root window. Since it's 2x, the specified native point was halved. 202 // root window. Since it's 2x, the specified native point was halved.
203 EXPECT_EQ("15,15", ConvertHostPointToScreen(30, 30)); 203 EXPECT_EQ("15,15", ConvertHostPointToScreen(30, 30));
204 // Similar to above but the point is out of the all root windows. 204 // Similar to above but the point is out of the all root windows.
205 EXPECT_EQ("200,200", ConvertHostPointToScreen(400, 400)); 205 EXPECT_EQ("200,200", ConvertHostPointToScreen(400, 400));
206 // Similar to above but the point is on the secondary display. 206 // Similar to above but the point is on the secondary display.
207 EXPECT_EQ("100,15", ConvertHostPointToScreen(200, 30)); 207 EXPECT_EQ("100,15", ConvertHostPointToScreen(200, 30));
208 208
209 // On secondary display. The position on the 2nd host window is (150,200) 209 // On secondary display. The position on the 2nd host window is (150,200)
210 // so the screen position is (100,0) + (150,200). 210 // so the screen position is (100,0) + (150,200).
211 EXPECT_EQ("250,200", ConvertHostPointToScreen(150, 450)); 211 EXPECT_EQ("250,200", ConvertHostPointToScreen(150, 450));
212 212
213 // At the edge but still in the primary display. Remaining of the primary 213 // At the edge but still in the primary display. Remaining of the primary
214 // display is (50, 50) but adding ~100 since it's 2x-display. 214 // display is (50, 50) but adding ~100 since it's 2x-display.
215 EXPECT_EQ("79,79", ConvertHostPointToScreen(158, 158)); 215 EXPECT_EQ("79,79", ConvertHostPointToScreen(158, 158));
216 // At the edge of the secondary display. 216 // At the edge of the secondary display.
217 EXPECT_EQ("80,80", ConvertHostPointToScreen(160, 160)); 217 EXPECT_EQ("80,80", ConvertHostPointToScreen(160, 160));
218 } 218 }
219 219
220 TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreenRotate) { 220 TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreenRotate) {
221 // 1st display is rotated 90 clockise, and 2nd display is rotated 221 // 1st display is rotated 90 clockise, and 2nd display is rotated
222 // 270 clockwise. 222 // 270 clockwise.
223 UpdateDisplay("100+100-200x200/r,100+500-200x200/l"); 223 UpdateDisplay("100+100-200x200/r,100+500-200x200/l");
224 // Put |window_| to the 1st. 224 // Put |window_| to the 1st.
225 window_->SetBoundsInScreen(gfx::Rect(20, 20, 50, 50), 225 window_->SetBoundsInScreen(gfx::Rect(20, 20, 50, 50),
226 Shell::GetScreen()->GetPrimaryDisplay()); 226 gfx::Screen::GetScreen()->GetPrimaryDisplay());
227 227
228 // The point is on the 1st host. 228 // The point is on the 1st host.
229 EXPECT_EQ("70,149", ConvertHostPointToScreen(50, 70)); 229 EXPECT_EQ("70,149", ConvertHostPointToScreen(50, 70));
230 // The point is out of the host windows. 230 // The point is out of the host windows.
231 EXPECT_EQ("250,-51", ConvertHostPointToScreen(250, 250)); 231 EXPECT_EQ("250,-51", ConvertHostPointToScreen(250, 250));
232 // The point is on the 2nd host. Point on 2nd host (30,150) - 232 // The point is on the 2nd host. Point on 2nd host (30,150) -
233 // rotate 270 clockwise -> (149, 30) - layout [+(200,0)] -> (349,30). 233 // rotate 270 clockwise -> (149, 30) - layout [+(200,0)] -> (349,30).
234 EXPECT_EQ("349,30", ConvertHostPointToScreen(30, 450)); 234 EXPECT_EQ("349,30", ConvertHostPointToScreen(30, 450));
235 235
236 // Move |window_| to the 2nd. 236 // Move |window_| to the 2nd.
(...skipping 11 matching lines...) Expand all
248 // The point is on the 2nd host. Point on 2nd host (50,50) - 248 // The point is on the 2nd host. Point on 2nd host (50,50) -
249 // rotate 90 clockwise -> (50, 149) 249 // rotate 90 clockwise -> (50, 149)
250 EXPECT_EQ("50,149", ConvertHostPointToScreen(50, -350)); 250 EXPECT_EQ("50,149", ConvertHostPointToScreen(50, -350));
251 } 251 }
252 252
253 TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreenUIScale) { 253 TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreenUIScale) {
254 // 1st display is 2x density with 1.5 UI scale. 254 // 1st display is 2x density with 1.5 UI scale.
255 UpdateDisplay("100+100-200x200*2@1.5,100+500-200x200"); 255 UpdateDisplay("100+100-200x200*2@1.5,100+500-200x200");
256 // Put |window_| to the 1st. 256 // Put |window_| to the 1st.
257 window_->SetBoundsInScreen(gfx::Rect(20, 20, 50, 50), 257 window_->SetBoundsInScreen(gfx::Rect(20, 20, 50, 50),
258 Shell::GetScreen()->GetPrimaryDisplay()); 258 gfx::Screen::GetScreen()->GetPrimaryDisplay());
259 259
260 // The point is on the 1st host. 260 // The point is on the 1st host.
261 EXPECT_EQ("45,45", ConvertHostPointToScreen(60, 60)); 261 EXPECT_EQ("45,45", ConvertHostPointToScreen(60, 60));
262 // The point is out of the host windows. 262 // The point is out of the host windows.
263 EXPECT_EQ("45,225", ConvertHostPointToScreen(60, 300)); 263 EXPECT_EQ("45,225", ConvertHostPointToScreen(60, 300));
264 // The point is on the 2nd host. Point on 2nd host (60,150) - 264 // The point is on the 2nd host. Point on 2nd host (60,150) -
265 // - screen [+(150,0)] 265 // - screen [+(150,0)]
266 EXPECT_EQ("210,49", ConvertHostPointToScreen(60, 450)); 266 EXPECT_EQ("210,49", ConvertHostPointToScreen(60, 450));
267 267
268 // Move |window_| to the 2nd. 268 // Move |window_| to the 2nd.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 // destroyed. 354 // destroyed.
355 EXPECT_FALSE(tracker.Contains(root_windows[1])); 355 EXPECT_FALSE(tracker.Contains(root_windows[1]));
356 356
357 // Check that we could convert all of the mouse events we got to screen 357 // Check that we could convert all of the mouse events we got to screen
358 // coordinates. 358 // coordinates.
359 EXPECT_TRUE(event_handler->could_convert_to_screen()); 359 EXPECT_TRUE(event_handler->could_convert_to_screen());
360 } 360 }
361 361
362 } // namespace test 362 } // namespace test
363 } // namespace ash 363 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/screen_position_controller.cc ('k') | ash/display/shared_display_edge_indicator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698