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

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

Issue 1924703002: Rename gfx::Display/Screen to display::Display/Screen in ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/root_window_transformers.cc ('k') | ash/display/screen_ash.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/root_window_transformers.h" 5 #include "ash/display/root_window_transformers.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "ash/display/display_info.h" 9 #include "ash/display/display_info.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
11 #include "ash/display/display_util.h" 11 #include "ash/display/display_util.h"
12 #include "ash/host/root_window_transformer.h" 12 #include "ash/host/root_window_transformer.h"
13 #include "ash/magnifier/magnification_controller.h" 13 #include "ash/magnifier/magnification_controller.h"
14 #include "ash/screen_util.h" 14 #include "ash/screen_util.h"
15 #include "ash/shelf/shelf.h" 15 #include "ash/shelf/shelf.h"
16 #include "ash/shelf/shelf_widget.h" 16 #include "ash/shelf/shelf_widget.h"
17 #include "ash/shell.h" 17 #include "ash/shell.h"
18 #include "ash/test/ash_test_base.h" 18 #include "ash/test/ash_test_base.h"
19 #include "ash/test/cursor_manager_test_api.h" 19 #include "ash/test/cursor_manager_test_api.h"
20 #include "ash/test/display_manager_test_api.h" 20 #include "ash/test/display_manager_test_api.h"
21 #include "ash/test/mirror_window_test_api.h" 21 #include "ash/test/mirror_window_test_api.h"
22 #include "base/synchronization/waitable_event.h" 22 #include "base/synchronization/waitable_event.h"
23 #include "ui/aura/env.h" 23 #include "ui/aura/env.h"
24 #include "ui/aura/window_event_dispatcher.h" 24 #include "ui/aura/window_event_dispatcher.h"
25 #include "ui/aura/window_tracker.h" 25 #include "ui/aura/window_tracker.h"
26 #include "ui/display/display.h"
26 #include "ui/display/manager/display_layout.h" 27 #include "ui/display/manager/display_layout.h"
28 #include "ui/display/screen.h"
27 #include "ui/events/event_handler.h" 29 #include "ui/events/event_handler.h"
28 #include "ui/events/test/event_generator.h" 30 #include "ui/events/test/event_generator.h"
29 #include "ui/gfx/display.h"
30 #include "ui/gfx/geometry/rect_conversions.h" 31 #include "ui/gfx/geometry/rect_conversions.h"
31 #include "ui/gfx/screen.h"
32 #include "ui/views/widget/widget.h" 32 #include "ui/views/widget/widget.h"
33 33
34 namespace ash { 34 namespace ash {
35 namespace { 35 namespace {
36 36
37 const char kDesktopBackgroundView[] = "DesktopBackgroundView"; 37 const char kDesktopBackgroundView[] = "DesktopBackgroundView";
38 38
39 class TestEventHandler : public ui::EventHandler { 39 class TestEventHandler : public ui::EventHandler {
40 public: 40 public:
41 TestEventHandler() 41 TestEventHandler()
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 GetEffectiveUIScale(); 117 GetEffectiveUIScale();
118 } 118 }
119 119
120 std::unique_ptr<RootWindowTransformer> 120 std::unique_ptr<RootWindowTransformer>
121 CreateCurrentRootWindowTransformerForMirroring() { 121 CreateCurrentRootWindowTransformerForMirroring() {
122 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 122 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
123 DCHECK(display_manager->IsInMirrorMode()); 123 DCHECK(display_manager->IsInMirrorMode());
124 const DisplayInfo& mirror_display_info = 124 const DisplayInfo& mirror_display_info =
125 display_manager->GetDisplayInfo(display_manager->mirroring_display_id()); 125 display_manager->GetDisplayInfo(display_manager->mirroring_display_id());
126 const DisplayInfo& source_display_info = display_manager->GetDisplayInfo( 126 const DisplayInfo& source_display_info = display_manager->GetDisplayInfo(
127 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); 127 display::Screen::GetScreen()->GetPrimaryDisplay().id());
128 return std::unique_ptr<RootWindowTransformer>( 128 return std::unique_ptr<RootWindowTransformer>(
129 CreateRootWindowTransformerForMirroredDisplay(source_display_info, 129 CreateRootWindowTransformerForMirroredDisplay(source_display_info,
130 mirror_display_info)); 130 mirror_display_info));
131 } 131 }
132 132
133 } // namespace 133 } // namespace
134 134
135 typedef test::AshTestBase RootWindowTransformersTest; 135 typedef test::AshTestBase RootWindowTransformersTest;
136 136
137 #if defined(OS_WIN) 137 #if defined(OS_WIN)
(...skipping 10 matching lines...) Expand all
148 148
149 TEST_F(RootWindowTransformersTest, MAYBE_RotateAndMagnify) { 149 TEST_F(RootWindowTransformersTest, MAYBE_RotateAndMagnify) {
150 MagnificationController* magnifier = 150 MagnificationController* magnifier =
151 Shell::GetInstance()->magnification_controller(); 151 Shell::GetInstance()->magnification_controller();
152 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 152 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
153 153
154 TestEventHandler event_handler; 154 TestEventHandler event_handler;
155 Shell::GetInstance()->AddPreTargetHandler(&event_handler); 155 Shell::GetInstance()->AddPreTargetHandler(&event_handler);
156 156
157 UpdateDisplay("120x200,300x400*2"); 157 UpdateDisplay("120x200,300x400*2");
158 gfx::Display display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 158 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay();
159 int64_t display2_id = ScreenUtil::GetSecondaryDisplay().id(); 159 int64_t display2_id = ScreenUtil::GetSecondaryDisplay().id();
160 160
161 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 161 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
162 ui::test::EventGenerator generator1(root_windows[0]); 162 ui::test::EventGenerator generator1(root_windows[0]);
163 ui::test::EventGenerator generator2(root_windows[1]); 163 ui::test::EventGenerator generator2(root_windows[1]);
164 164
165 magnifier->SetEnabled(true); 165 magnifier->SetEnabled(true);
166 EXPECT_EQ(2.0f, magnifier->GetScale()); 166 EXPECT_EQ(2.0f, magnifier->GetScale());
167 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); 167 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString());
168 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); 168 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString());
169 EXPECT_EQ("120,0 150x200", 169 EXPECT_EQ("120,0 150x200",
170 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 170 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
171 generator1.MoveMouseToInHost(40, 80); 171 generator1.MoveMouseToInHost(40, 80);
172 EXPECT_EQ("50,90", event_handler.GetLocationAndReset()); 172 EXPECT_EQ("50,90", event_handler.GetLocationAndReset());
173 EXPECT_EQ("50,90", 173 EXPECT_EQ("50,90",
174 aura::Env::GetInstance()->last_mouse_location().ToString()); 174 aura::Env::GetInstance()->last_mouse_location().ToString());
175 EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display1.id())); 175 EXPECT_EQ(display::Display::ROTATE_0,
176 EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display2_id)); 176 GetActiveDisplayRotation(display1.id()));
177 EXPECT_EQ(display::Display::ROTATE_0, GetActiveDisplayRotation(display2_id));
177 magnifier->SetEnabled(false); 178 magnifier->SetEnabled(false);
178 179
179 display_manager->SetDisplayRotation(display1.id(), gfx::Display::ROTATE_90, 180 display_manager->SetDisplayRotation(display1.id(),
180 gfx::Display::ROTATION_SOURCE_ACTIVE); 181 display::Display::ROTATE_90,
182 display::Display::ROTATION_SOURCE_ACTIVE);
181 // Move the cursor to the center of the first root window. 183 // Move the cursor to the center of the first root window.
182 generator1.MoveMouseToInHost(59, 100); 184 generator1.MoveMouseToInHost(59, 100);
183 185
184 magnifier->SetEnabled(true); 186 magnifier->SetEnabled(true);
185 EXPECT_EQ(2.0f, magnifier->GetScale()); 187 EXPECT_EQ(2.0f, magnifier->GetScale());
186 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); 188 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString());
187 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); 189 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString());
188 EXPECT_EQ("200,0 150x200", 190 EXPECT_EQ("200,0 150x200",
189 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 191 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
190 generator1.MoveMouseToInHost(39, 120); 192 generator1.MoveMouseToInHost(39, 120);
191 EXPECT_EQ("110,70", event_handler.GetLocationAndReset()); 193 EXPECT_EQ("110,70", event_handler.GetLocationAndReset());
192 EXPECT_EQ("110,70", 194 EXPECT_EQ("110,70",
193 aura::Env::GetInstance()->last_mouse_location().ToString()); 195 aura::Env::GetInstance()->last_mouse_location().ToString());
194 EXPECT_EQ(gfx::Display::ROTATE_90, GetActiveDisplayRotation(display1.id())); 196 EXPECT_EQ(display::Display::ROTATE_90,
195 EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display2_id)); 197 GetActiveDisplayRotation(display1.id()));
198 EXPECT_EQ(display::Display::ROTATE_0, GetActiveDisplayRotation(display2_id));
196 magnifier->SetEnabled(false); 199 magnifier->SetEnabled(false);
197 200
198 display_manager->SetLayoutForCurrentDisplays( 201 display_manager->SetLayoutForCurrentDisplays(
199 test::CreateDisplayLayout(display::DisplayPlacement::BOTTOM, 50)); 202 test::CreateDisplayLayout(display::DisplayPlacement::BOTTOM, 50));
200 EXPECT_EQ("50,120 150x200", 203 EXPECT_EQ("50,120 150x200",
201 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 204 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
202 205
203 display_manager->SetDisplayRotation(display2_id, gfx::Display::ROTATE_270, 206 display_manager->SetDisplayRotation(display2_id, display::Display::ROTATE_270,
204 gfx::Display::ROTATION_SOURCE_ACTIVE); 207 display::Display::ROTATION_SOURCE_ACTIVE);
205 // Move the cursor to the center of the second root window. 208 // Move the cursor to the center of the second root window.
206 generator2.MoveMouseToInHost(151, 199); 209 generator2.MoveMouseToInHost(151, 199);
207 210
208 magnifier->SetEnabled(true); 211 magnifier->SetEnabled(true);
209 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); 212 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString());
210 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); 213 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString());
211 EXPECT_EQ("50,120 200x150", 214 EXPECT_EQ("50,120 200x150",
212 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 215 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
213 generator2.MoveMouseToInHost(172, 219); 216 generator2.MoveMouseToInHost(172, 219);
214 EXPECT_EQ("95,80", event_handler.GetLocationAndReset()); 217 EXPECT_EQ("95,80", event_handler.GetLocationAndReset());
215 EXPECT_EQ("145,200", 218 EXPECT_EQ("145,200",
216 aura::Env::GetInstance()->last_mouse_location().ToString()); 219 aura::Env::GetInstance()->last_mouse_location().ToString());
217 EXPECT_EQ(gfx::Display::ROTATE_90, GetActiveDisplayRotation(display1.id())); 220 EXPECT_EQ(display::Display::ROTATE_90,
218 EXPECT_EQ(gfx::Display::ROTATE_270, GetActiveDisplayRotation(display2_id)); 221 GetActiveDisplayRotation(display1.id()));
222 EXPECT_EQ(display::Display::ROTATE_270,
223 GetActiveDisplayRotation(display2_id));
219 magnifier->SetEnabled(false); 224 magnifier->SetEnabled(false);
220 225
221 display_manager->SetDisplayRotation(display1.id(), gfx::Display::ROTATE_180, 226 display_manager->SetDisplayRotation(display1.id(),
222 gfx::Display::ROTATION_SOURCE_ACTIVE); 227 display::Display::ROTATE_180,
228 display::Display::ROTATION_SOURCE_ACTIVE);
223 // Move the cursor to the center of the first root window. 229 // Move the cursor to the center of the first root window.
224 generator1.MoveMouseToInHost(59, 99); 230 generator1.MoveMouseToInHost(59, 99);
225 231
226 magnifier->SetEnabled(true); 232 magnifier->SetEnabled(true);
227 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); 233 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString());
228 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); 234 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString());
229 // Dislay must share at least 100, so the x's offset becomes 20. 235 // Dislay must share at least 100, so the x's offset becomes 20.
230 EXPECT_EQ("20,200 200x150", 236 EXPECT_EQ("20,200 200x150",
231 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 237 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
232 generator1.MoveMouseToInHost(39, 59); 238 generator1.MoveMouseToInHost(39, 59);
233 EXPECT_EQ("70,120", event_handler.GetLocationAndReset()); 239 EXPECT_EQ("70,120", event_handler.GetLocationAndReset());
234 EXPECT_EQ(gfx::Display::ROTATE_180, GetActiveDisplayRotation(display1.id())); 240 EXPECT_EQ(display::Display::ROTATE_180,
235 EXPECT_EQ(gfx::Display::ROTATE_270, GetActiveDisplayRotation(display2_id)); 241 GetActiveDisplayRotation(display1.id()));
242 EXPECT_EQ(display::Display::ROTATE_270,
243 GetActiveDisplayRotation(display2_id));
236 magnifier->SetEnabled(false); 244 magnifier->SetEnabled(false);
237 245
238 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 246 Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
239 } 247 }
240 248
241 TEST_F(RootWindowTransformersTest, ScaleAndMagnify) { 249 TEST_F(RootWindowTransformersTest, ScaleAndMagnify) {
242 if (!SupportsMultipleDisplays()) 250 if (!SupportsMultipleDisplays())
243 return; 251 return;
244 252
245 TestEventHandler event_handler; 253 TestEventHandler event_handler;
246 Shell::GetInstance()->AddPreTargetHandler(&event_handler); 254 Shell::GetInstance()->AddPreTargetHandler(&event_handler);
247 255
248 UpdateDisplay("600x400*2@1.5,500x300"); 256 UpdateDisplay("600x400*2@1.5,500x300");
249 257
250 gfx::Display display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 258 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay();
251 test::ScopedSetInternalDisplayId set_internal(display1.id()); 259 test::ScopedSetInternalDisplayId set_internal(display1.id());
252 gfx::Display display2 = ScreenUtil::GetSecondaryDisplay(); 260 display::Display display2 = ScreenUtil::GetSecondaryDisplay();
253 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 261 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
254 MagnificationController* magnifier = 262 MagnificationController* magnifier =
255 Shell::GetInstance()->magnification_controller(); 263 Shell::GetInstance()->magnification_controller();
256 264
257 magnifier->SetEnabled(true); 265 magnifier->SetEnabled(true);
258 EXPECT_EQ(2.0f, magnifier->GetScale()); 266 EXPECT_EQ(2.0f, magnifier->GetScale());
259 EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); 267 EXPECT_EQ("0,0 450x300", display1.bounds().ToString());
260 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); 268 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString());
261 EXPECT_EQ("450,0 500x300", display2.bounds().ToString()); 269 EXPECT_EQ("450,0 500x300", display2.bounds().ToString());
262 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); 270 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id()));
263 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); 271 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id()));
264 272
265 ui::test::EventGenerator generator(root_windows[0]); 273 ui::test::EventGenerator generator(root_windows[0]);
266 generator.MoveMouseToInHost(500, 200); 274 generator.MoveMouseToInHost(500, 200);
267 EXPECT_EQ("299,150", event_handler.GetLocationAndReset()); 275 EXPECT_EQ("299,150", event_handler.GetLocationAndReset());
268 magnifier->SetEnabled(false); 276 magnifier->SetEnabled(false);
269 277
270 SetDisplayUIScale(display1.id(), 1.25f); 278 SetDisplayUIScale(display1.id(), 1.25f);
271 display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 279 display1 = display::Screen::GetScreen()->GetPrimaryDisplay();
272 display2 = ScreenUtil::GetSecondaryDisplay(); 280 display2 = ScreenUtil::GetSecondaryDisplay();
273 magnifier->SetEnabled(true); 281 magnifier->SetEnabled(true);
274 EXPECT_EQ(2.0f, magnifier->GetScale()); 282 EXPECT_EQ(2.0f, magnifier->GetScale());
275 EXPECT_EQ("0,0 375x250", display1.bounds().ToString()); 283 EXPECT_EQ("0,0 375x250", display1.bounds().ToString());
276 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString()); 284 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString());
277 EXPECT_EQ("375,0 500x300", display2.bounds().ToString()); 285 EXPECT_EQ("375,0 500x300", display2.bounds().ToString());
278 EXPECT_EQ(1.25f, GetStoredUIScale(display1.id())); 286 EXPECT_EQ(1.25f, GetStoredUIScale(display1.id()));
279 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); 287 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id()));
280 magnifier->SetEnabled(false); 288 magnifier->SetEnabled(false);
281 289
282 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 290 Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
283 } 291 }
284 292
285 TEST_F(RootWindowTransformersTest, MAYBE_TouchScaleAndMagnify) { 293 TEST_F(RootWindowTransformersTest, MAYBE_TouchScaleAndMagnify) {
286 TestEventHandler event_handler; 294 TestEventHandler event_handler;
287 Shell::GetInstance()->AddPreTargetHandler(&event_handler); 295 Shell::GetInstance()->AddPreTargetHandler(&event_handler);
288 296
289 UpdateDisplay("200x200*2"); 297 UpdateDisplay("200x200*2");
290 gfx::Display display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 298 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay();
291 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 299 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
292 aura::Window* root_window = root_windows[0]; 300 aura::Window* root_window = root_windows[0];
293 ui::test::EventGenerator generator(root_window); 301 ui::test::EventGenerator generator(root_window);
294 MagnificationController* magnifier = 302 MagnificationController* magnifier =
295 Shell::GetInstance()->magnification_controller(); 303 Shell::GetInstance()->magnification_controller();
296 304
297 magnifier->SetEnabled(true); 305 magnifier->SetEnabled(true);
298 EXPECT_FLOAT_EQ(2.0f, magnifier->GetScale()); 306 EXPECT_FLOAT_EQ(2.0f, magnifier->GetScale());
299 magnifier->SetScale(2.5f, false); 307 magnifier->SetScale(2.5f, false);
300 EXPECT_FLOAT_EQ(2.5f, magnifier->GetScale()); 308 EXPECT_FLOAT_EQ(2.5f, magnifier->GetScale());
(...skipping 19 matching lines...) Expand all
320 328
321 TEST_F(RootWindowTransformersTest, MAYBE_ConvertHostToRootCoords) { 329 TEST_F(RootWindowTransformersTest, MAYBE_ConvertHostToRootCoords) {
322 TestEventHandler event_handler; 330 TestEventHandler event_handler;
323 Shell::GetInstance()->AddPreTargetHandler(&event_handler); 331 Shell::GetInstance()->AddPreTargetHandler(&event_handler);
324 MagnificationController* magnifier = 332 MagnificationController* magnifier =
325 Shell::GetInstance()->magnification_controller(); 333 Shell::GetInstance()->magnification_controller();
326 334
327 // Test 1 335 // Test 1
328 UpdateDisplay("600x400*2/r@1.5"); 336 UpdateDisplay("600x400*2/r@1.5");
329 337
330 gfx::Display display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 338 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay();
331 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 339 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
332 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); 340 EXPECT_EQ("0,0 300x450", display1.bounds().ToString());
333 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); 341 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString());
334 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); 342 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id()));
335 343
336 ui::test::EventGenerator generator(root_windows[0]); 344 ui::test::EventGenerator generator(root_windows[0]);
337 generator.MoveMouseToInHost(300, 200); 345 generator.MoveMouseToInHost(300, 200);
338 magnifier->SetEnabled(true); 346 magnifier->SetEnabled(true);
339 EXPECT_EQ("150,224", event_handler.GetLocationAndReset()); 347 EXPECT_EQ("150,224", event_handler.GetLocationAndReset());
340 EXPECT_FLOAT_EQ(2.0f, magnifier->GetScale()); 348 EXPECT_FLOAT_EQ(2.0f, magnifier->GetScale());
341 349
342 generator.MoveMouseToInHost(300, 200); 350 generator.MoveMouseToInHost(300, 200);
343 EXPECT_EQ("150,224", event_handler.GetLocationAndReset()); 351 EXPECT_EQ("150,224", event_handler.GetLocationAndReset());
344 generator.MoveMouseToInHost(200, 300); 352 generator.MoveMouseToInHost(200, 300);
345 EXPECT_EQ("187,261", event_handler.GetLocationAndReset()); 353 EXPECT_EQ("187,261", event_handler.GetLocationAndReset());
346 generator.MoveMouseToInHost(100, 400); 354 generator.MoveMouseToInHost(100, 400);
347 EXPECT_EQ("237,299", event_handler.GetLocationAndReset()); 355 EXPECT_EQ("237,299", event_handler.GetLocationAndReset());
348 generator.MoveMouseToInHost(0, 0); 356 generator.MoveMouseToInHost(0, 0);
349 EXPECT_EQ("137,348", event_handler.GetLocationAndReset()); 357 EXPECT_EQ("137,348", event_handler.GetLocationAndReset());
350 358
351 magnifier->SetEnabled(false); 359 magnifier->SetEnabled(false);
352 EXPECT_FLOAT_EQ(1.0f, magnifier->GetScale()); 360 EXPECT_FLOAT_EQ(1.0f, magnifier->GetScale());
353 361
354 // Test 2 362 // Test 2
355 UpdateDisplay("600x400*2/u@1.5"); 363 UpdateDisplay("600x400*2/u@1.5");
356 display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 364 display1 = display::Screen::GetScreen()->GetPrimaryDisplay();
357 root_windows = Shell::GetAllRootWindows(); 365 root_windows = Shell::GetAllRootWindows();
358 EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); 366 EXPECT_EQ("0,0 450x300", display1.bounds().ToString());
359 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); 367 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString());
360 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); 368 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id()));
361 369
362 generator.MoveMouseToInHost(300, 200); 370 generator.MoveMouseToInHost(300, 200);
363 magnifier->SetEnabled(true); 371 magnifier->SetEnabled(true);
364 EXPECT_EQ("224,149", event_handler.GetLocationAndReset()); 372 EXPECT_EQ("224,149", event_handler.GetLocationAndReset());
365 EXPECT_FLOAT_EQ(2.0f, magnifier->GetScale()); 373 EXPECT_FLOAT_EQ(2.0f, magnifier->GetScale());
366 374
367 generator.MoveMouseToInHost(300, 200); 375 generator.MoveMouseToInHost(300, 200);
368 EXPECT_EQ("224,148", event_handler.GetLocationAndReset()); 376 EXPECT_EQ("224,148", event_handler.GetLocationAndReset());
369 generator.MoveMouseToInHost(200, 300); 377 generator.MoveMouseToInHost(200, 300);
370 EXPECT_EQ("261,111", event_handler.GetLocationAndReset()); 378 EXPECT_EQ("261,111", event_handler.GetLocationAndReset());
371 generator.MoveMouseToInHost(100, 400); 379 generator.MoveMouseToInHost(100, 400);
372 EXPECT_EQ("299,60", event_handler.GetLocationAndReset()); 380 EXPECT_EQ("299,60", event_handler.GetLocationAndReset());
373 generator.MoveMouseToInHost(0, 0); 381 generator.MoveMouseToInHost(0, 0);
374 EXPECT_EQ("348,159", event_handler.GetLocationAndReset()); 382 EXPECT_EQ("348,159", event_handler.GetLocationAndReset());
375 383
376 magnifier->SetEnabled(false); 384 magnifier->SetEnabled(false);
377 EXPECT_FLOAT_EQ(1.0f, magnifier->GetScale()); 385 EXPECT_FLOAT_EQ(1.0f, magnifier->GetScale());
378 386
379 // Test 3 387 // Test 3
380 UpdateDisplay("600x400*2/l@1.5"); 388 UpdateDisplay("600x400*2/l@1.5");
381 display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 389 display1 = display::Screen::GetScreen()->GetPrimaryDisplay();
382 root_windows = Shell::GetAllRootWindows(); 390 root_windows = Shell::GetAllRootWindows();
383 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); 391 EXPECT_EQ("0,0 300x450", display1.bounds().ToString());
384 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); 392 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString());
385 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); 393 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id()));
386 394
387 generator.MoveMouseToInHost(300, 200); 395 generator.MoveMouseToInHost(300, 200);
388 magnifier->SetEnabled(true); 396 magnifier->SetEnabled(true);
389 EXPECT_EQ("149,225", event_handler.GetLocationAndReset()); 397 EXPECT_EQ("149,225", event_handler.GetLocationAndReset());
390 EXPECT_FLOAT_EQ(2.0f, magnifier->GetScale()); 398 EXPECT_FLOAT_EQ(2.0f, magnifier->GetScale());
391 399
(...skipping 24 matching lines...) Expand all
416 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125. 424 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125.
417 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString()); 425 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString());
418 426
419 UpdateDisplay("200x400,500x500"); 427 UpdateDisplay("200x400,500x500");
420 // The aspect ratio is flipped, so X margin is now 125. 428 // The aspect ratio is flipped, so X margin is now 125.
421 transformer = CreateCurrentRootWindowTransformerForMirroring(); 429 transformer = CreateCurrentRootWindowTransformerForMirroring();
422 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString()); 430 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString());
423 } 431 }
424 432
425 } // namespace ash 433 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/root_window_transformers.cc ('k') | ash/display/screen_ash.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698