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
3 // found in the LICENSE file.
5 #include "ash/display/display_manager.h"
7 #include "ash/ash_switches.h"
8 #include "ash/display/display_controller.h"
9 #include "ash/display/display_info.h"
10 #include "ash/display/display_layout_store.h"
11 #include "ash/screen_util.h"
12 #include "ash/shell.h"
13 #include "ash/test/ash_test_base.h"
14 #include "ash/test/display_manager_test_api.h"
15 #include "ash/test/mirror_window_test_api.h"
16 #include "base/command_line.h"
17 #include "base/format_macros.h"
18 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/stringprintf.h"
20 #include "ui/aura/env.h"
21 #include "ui/aura/window_observer.h"
22 #include "ui/aura/window_tree_host.h"
23 #include "ui/events/test/event_generator.h"
24 #include "ui/gfx/display.h"
25 #include "ui/gfx/display_observer.h"
26 #include "ui/gfx/font_render_params.h"
27 #include "ui/gfx/screen.h"
28 #include "ui/gfx/screen_type_delegate.h"
35 using base::StringPrintf
;
39 std::string
ToDisplayName(int64 id
) {
40 return "x-" + base::Int64ToString(id
);
45 class DisplayManagerTest
: public test::AshTestBase
,
46 public gfx::DisplayObserver
,
47 public aura::WindowObserver
{
51 root_window_destroyed_(false) {
53 virtual ~DisplayManagerTest() {}
55 virtual void SetUp() override
{
57 Shell::GetScreen()->AddObserver(this);
58 Shell::GetPrimaryRootWindow()->AddObserver(this);
60 virtual void TearDown() override
{
61 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
62 Shell::GetScreen()->RemoveObserver(this);
63 AshTestBase::TearDown();
66 DisplayManager
* display_manager() {
67 return Shell::GetInstance()->display_manager();
69 const vector
<gfx::Display
>& changed() const { return changed_
; }
70 const vector
<gfx::Display
>& added() const { return added_
; }
72 string
GetCountSummary() const {
73 return StringPrintf("%" PRIuS
" %" PRIuS
" %" PRIuS
,
74 changed_
.size(), added_
.size(), removed_count_
);
81 root_window_destroyed_
= false;
84 bool root_window_destroyed() const {
85 return root_window_destroyed_
;
88 const DisplayInfo
& GetDisplayInfo(const gfx::Display
& display
) {
89 return display_manager()->GetDisplayInfo(display
.id());
92 const DisplayInfo
& GetDisplayInfoAt(int index
) {
93 return GetDisplayInfo(display_manager()->GetDisplayAt(index
));
96 const gfx::Display
& GetDisplayForId(int64 id
) {
97 return display_manager()->GetDisplayForId(id
);
100 const DisplayInfo
& GetDisplayInfoForId(int64 id
) {
101 return GetDisplayInfo(display_manager()->GetDisplayForId(id
));
104 // aura::DisplayObserver overrides:
105 virtual void OnDisplayMetricsChanged(const gfx::Display
& display
,
107 changed_
.push_back(display
);
109 virtual void OnDisplayAdded(const gfx::Display
& new_display
) override
{
110 added_
.push_back(new_display
);
112 virtual void OnDisplayRemoved(const gfx::Display
& old_display
) override
{
116 // aura::WindowObserver overrides:
117 virtual void OnWindowDestroying(aura::Window
* window
) override
{
118 ASSERT_EQ(Shell::GetPrimaryRootWindow(), window
);
119 root_window_destroyed_
= true;
123 vector
<gfx::Display
> changed_
;
124 vector
<gfx::Display
> added_
;
125 size_t removed_count_
;
126 bool root_window_destroyed_
;
128 DISALLOW_COPY_AND_ASSIGN(DisplayManagerTest
);
131 TEST_F(DisplayManagerTest
, UpdateDisplayTest
) {
132 if (!SupportsMultipleDisplays())
135 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
137 // Update primary and add seconary.
138 UpdateDisplay("100+0-500x500,0+501-400x400");
139 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
140 EXPECT_EQ("0,0 500x500",
141 display_manager()->GetDisplayAt(0).bounds().ToString());
143 EXPECT_EQ("1 1 0", GetCountSummary());
144 EXPECT_EQ(display_manager()->GetDisplayAt(0).id(), changed()[0].id());
145 EXPECT_EQ(display_manager()->GetDisplayAt(1).id(), added()[0].id());
146 EXPECT_EQ("0,0 500x500", changed()[0].bounds().ToString());
147 // Secondary display is on right.
148 EXPECT_EQ("500,0 400x400", added()[0].bounds().ToString());
149 EXPECT_EQ("0,501 400x400",
150 GetDisplayInfo(added()[0]).bounds_in_native().ToString());
154 UpdateDisplay("100+0-500x500");
155 EXPECT_EQ("0 0 1", GetCountSummary());
159 UpdateDisplay("1+1-1000x600");
160 EXPECT_EQ("1 0 0", GetCountSummary());
161 EXPECT_EQ(display_manager()->GetDisplayAt(0).id(), changed()[0].id());
162 EXPECT_EQ("0,0 1000x600", changed()[0].bounds().ToString());
166 UpdateDisplay("1+1-1000x600,1002+0-600x400");
167 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
168 EXPECT_EQ("0 1 0", GetCountSummary());
169 EXPECT_EQ(display_manager()->GetDisplayAt(1).id(), added()[0].id());
170 // Secondary display is on right.
171 EXPECT_EQ("1000,0 600x400", added()[0].bounds().ToString());
172 EXPECT_EQ("1002,0 600x400",
173 GetDisplayInfo(added()[0]).bounds_in_native().ToString());
176 // Secondary removed, primary changed.
177 UpdateDisplay("1+1-800x300");
178 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
179 EXPECT_EQ("1 0 1", GetCountSummary());
180 EXPECT_EQ(display_manager()->GetDisplayAt(0).id(), changed()[0].id());
181 EXPECT_EQ("0,0 800x300", changed()[0].bounds().ToString());
184 // # of display can go to zero when screen is off.
185 const vector
<DisplayInfo
> empty
;
186 display_manager()->OnNativeDisplaysChanged(empty
);
187 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
188 EXPECT_EQ("0 0 0", GetCountSummary());
189 EXPECT_FALSE(root_window_destroyed());
190 // Display configuration stays the same
191 EXPECT_EQ("0,0 800x300",
192 display_manager()->GetDisplayAt(0).bounds().ToString());
195 // Connect to display again
196 UpdateDisplay("100+100-500x400");
197 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
198 EXPECT_EQ("1 0 0", GetCountSummary());
199 EXPECT_FALSE(root_window_destroyed());
200 EXPECT_EQ("0,0 500x400", changed()[0].bounds().ToString());
201 EXPECT_EQ("100,100 500x400",
202 GetDisplayInfo(changed()[0]).bounds_in_native().ToString());
205 // Go back to zero and wake up with multiple displays.
206 display_manager()->OnNativeDisplaysChanged(empty
);
207 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
208 EXPECT_FALSE(root_window_destroyed());
212 UpdateDisplay("0+0-1000x600,1000+1000-600x400");
213 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
214 EXPECT_EQ("0,0 1000x600",
215 display_manager()->GetDisplayAt(0).bounds().ToString());
216 // Secondary display is on right.
217 EXPECT_EQ("1000,0 600x400",
218 display_manager()->GetDisplayAt(1).bounds().ToString());
219 EXPECT_EQ("1000,1000 600x400",
220 GetDisplayInfoAt(1).bounds_in_native().ToString());
223 // Changing primary will update secondary as well.
224 UpdateDisplay("0+0-800x600,1000+1000-600x400");
225 EXPECT_EQ("2 0 0", GetCountSummary());
227 EXPECT_EQ("0,0 800x600",
228 display_manager()->GetDisplayAt(0).bounds().ToString());
229 EXPECT_EQ("800,0 600x400",
230 display_manager()->GetDisplayAt(1).bounds().ToString());
233 // Test in emulation mode (use_fullscreen_host_window=false)
234 TEST_F(DisplayManagerTest
, EmulatorTest
) {
235 if (!SupportsMultipleDisplays())
238 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
240 display_manager()->AddRemoveDisplay();
241 // Update primary and add seconary.
242 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
243 EXPECT_EQ("0 1 0", GetCountSummary());
246 display_manager()->AddRemoveDisplay();
247 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
248 EXPECT_EQ("0 0 1", GetCountSummary());
251 display_manager()->AddRemoveDisplay();
252 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
253 EXPECT_EQ("0 1 0", GetCountSummary());
257 TEST_F(DisplayManagerTest
, OverscanInsetsTest
) {
258 if (!SupportsMultipleDisplays())
261 UpdateDisplay("0+0-500x500,0+501-400x400");
263 ASSERT_EQ(2u, display_manager()->GetNumDisplays());
264 const DisplayInfo
& display_info1
= GetDisplayInfoAt(0);
265 const DisplayInfo
& display_info2
= GetDisplayInfoAt(1);
266 display_manager()->SetOverscanInsets(
267 display_info2
.id(), gfx::Insets(13, 12, 11, 10));
269 std::vector
<gfx::Display
> changed_displays
= changed();
270 EXPECT_EQ(1u, changed_displays
.size());
271 EXPECT_EQ(display_info2
.id(), changed_displays
[0].id());
272 EXPECT_EQ("0,0 500x500",
273 GetDisplayInfoAt(0).bounds_in_native().ToString());
274 DisplayInfo updated_display_info2
= GetDisplayInfoAt(1);
275 EXPECT_EQ("0,501 400x400",
276 updated_display_info2
.bounds_in_native().ToString());
278 updated_display_info2
.size_in_pixel().ToString());
279 EXPECT_EQ("13,12,11,10",
280 updated_display_info2
.overscan_insets_in_dip().ToString());
281 EXPECT_EQ("500,0 378x376",
282 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
284 // Make sure that SetOverscanInsets() is idempotent.
285 display_manager()->SetOverscanInsets(display_info1
.id(), gfx::Insets());
286 display_manager()->SetOverscanInsets(
287 display_info2
.id(), gfx::Insets(13, 12, 11, 10));
288 EXPECT_EQ("0,0 500x500",
289 GetDisplayInfoAt(0).bounds_in_native().ToString());
290 updated_display_info2
= GetDisplayInfoAt(1);
291 EXPECT_EQ("0,501 400x400",
292 updated_display_info2
.bounds_in_native().ToString());
294 updated_display_info2
.size_in_pixel().ToString());
295 EXPECT_EQ("13,12,11,10",
296 updated_display_info2
.overscan_insets_in_dip().ToString());
298 display_manager()->SetOverscanInsets(
299 display_info2
.id(), gfx::Insets(10, 11, 12, 13));
300 EXPECT_EQ("0,0 500x500",
301 GetDisplayInfoAt(0).bounds_in_native().ToString());
303 GetDisplayInfoAt(1).size_in_pixel().ToString());
304 EXPECT_EQ("10,11,12,13",
305 GetDisplayInfoAt(1).overscan_insets_in_dip().ToString());
307 // Recreate a new 2nd display. It won't apply the overscan inset because the
308 // new display has a different ID.
309 UpdateDisplay("0+0-500x500");
310 UpdateDisplay("0+0-500x500,0+501-400x400");
311 EXPECT_EQ("0,0 500x500",
312 GetDisplayInfoAt(0).bounds_in_native().ToString());
313 EXPECT_EQ("0,501 400x400",
314 GetDisplayInfoAt(1).bounds_in_native().ToString());
316 // Recreate the displays with the same ID. It should apply the overscan
318 UpdateDisplay("0+0-500x500");
319 std::vector
<DisplayInfo
> display_info_list
;
320 display_info_list
.push_back(display_info1
);
321 display_info_list
.push_back(display_info2
);
322 display_manager()->OnNativeDisplaysChanged(display_info_list
);
323 EXPECT_EQ("1,1 500x500",
324 GetDisplayInfoAt(0).bounds_in_native().ToString());
325 updated_display_info2
= GetDisplayInfoAt(1);
327 updated_display_info2
.size_in_pixel().ToString());
328 EXPECT_EQ("10,11,12,13",
329 updated_display_info2
.overscan_insets_in_dip().ToString());
331 // HiDPI but overscan display. The specified insets size should be doubled.
332 UpdateDisplay("0+0-500x500,0+501-400x400*2");
333 display_manager()->SetOverscanInsets(
334 display_manager()->GetDisplayAt(1).id(), gfx::Insets(4, 5, 6, 7));
335 EXPECT_EQ("0,0 500x500",
336 GetDisplayInfoAt(0).bounds_in_native().ToString());
337 updated_display_info2
= GetDisplayInfoAt(1);
338 EXPECT_EQ("0,501 400x400",
339 updated_display_info2
.bounds_in_native().ToString());
341 updated_display_info2
.size_in_pixel().ToString());
343 updated_display_info2
.overscan_insets_in_dip().ToString());
344 EXPECT_EQ("8,10,12,14",
345 updated_display_info2
.GetOverscanInsetsInPixel().ToString());
347 // Make sure switching primary display applies the overscan offset only once.
348 ash::Shell::GetInstance()->display_controller()->SetPrimaryDisplay(
349 ScreenUtil::GetSecondaryDisplay());
350 EXPECT_EQ("-500,0 500x500",
351 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
352 EXPECT_EQ("0,0 500x500",
353 GetDisplayInfo(ScreenUtil::GetSecondaryDisplay()).
354 bounds_in_native().ToString());
355 EXPECT_EQ("0,501 400x400",
356 GetDisplayInfo(Shell::GetScreen()->GetPrimaryDisplay()).
357 bounds_in_native().ToString());
358 EXPECT_EQ("0,0 188x190",
359 Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString());
362 TEST_F(DisplayManagerTest
, ZeroOverscanInsets
) {
363 if (!SupportsMultipleDisplays())
366 // Make sure the display change events is emitted for overscan inset changes.
367 UpdateDisplay("0+0-500x500,0+501-400x400");
368 ASSERT_EQ(2u, display_manager()->GetNumDisplays());
369 int64 display2_id
= display_manager()->GetDisplayAt(1).id();
372 display_manager()->SetOverscanInsets(display2_id
, gfx::Insets(0, 0, 0, 0));
373 EXPECT_EQ(0u, changed().size());
376 display_manager()->SetOverscanInsets(display2_id
, gfx::Insets(1, 0, 0, 0));
377 EXPECT_EQ(1u, changed().size());
378 EXPECT_EQ(display2_id
, changed()[0].id());
381 display_manager()->SetOverscanInsets(display2_id
, gfx::Insets(0, 0, 0, 0));
382 EXPECT_EQ(1u, changed().size());
383 EXPECT_EQ(display2_id
, changed()[0].id());
386 TEST_F(DisplayManagerTest
, TestDeviceScaleOnlyChange
) {
387 if (!SupportsHostWindowResize())
390 UpdateDisplay("1000x600");
391 aura::WindowTreeHost
* host
= Shell::GetPrimaryRootWindow()->GetHost();
392 EXPECT_EQ(1, host
->compositor()->device_scale_factor());
393 EXPECT_EQ("1000x600",
394 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
395 EXPECT_EQ("1 0 0", GetCountSummary());
397 UpdateDisplay("1000x600*2");
398 EXPECT_EQ(2, host
->compositor()->device_scale_factor());
399 EXPECT_EQ("2 0 0", GetCountSummary());
401 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
404 DisplayInfo
CreateDisplayInfo(int64 id
, const gfx::Rect
& bounds
) {
405 DisplayInfo
info(id
, ToDisplayName(id
), false);
406 info
.SetBounds(bounds
);
410 TEST_F(DisplayManagerTest
, TestNativeDisplaysChanged
) {
411 const int64 internal_display_id
=
412 test::DisplayManagerTestApi(display_manager()).
413 SetFirstDisplayAsInternalDisplay();
414 const int external_id
= 10;
415 const int mirror_id
= 11;
416 const int64 invalid_id
= gfx::Display::kInvalidDisplayID
;
417 const DisplayInfo internal_display_info
=
418 CreateDisplayInfo(internal_display_id
, gfx::Rect(0, 0, 500, 500));
419 const DisplayInfo external_display_info
=
420 CreateDisplayInfo(external_id
, gfx::Rect(1, 1, 100, 100));
421 const DisplayInfo mirrored_display_info
=
422 CreateDisplayInfo(mirror_id
, gfx::Rect(0, 0, 500, 500));
424 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
425 EXPECT_EQ(1U, display_manager()->num_connected_displays());
426 std::string default_bounds
=
427 display_manager()->GetDisplayAt(0).bounds().ToString();
429 std::vector
<DisplayInfo
> display_info_list
;
430 // Primary disconnected.
431 display_manager()->OnNativeDisplaysChanged(display_info_list
);
432 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
433 EXPECT_EQ(default_bounds
,
434 display_manager()->GetDisplayAt(0).bounds().ToString());
435 EXPECT_EQ(1U, display_manager()->num_connected_displays());
436 EXPECT_FALSE(display_manager()->IsMirrored());
438 if (!SupportsMultipleDisplays())
441 // External connected while primary was disconnected.
442 display_info_list
.push_back(external_display_info
);
443 display_manager()->OnNativeDisplaysChanged(display_info_list
);
444 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
446 EXPECT_EQ(invalid_id
, GetDisplayForId(internal_display_id
).id());
447 EXPECT_EQ("1,1 100x100",
448 GetDisplayInfoForId(external_id
).bounds_in_native().ToString());
449 EXPECT_EQ(1U, display_manager()->num_connected_displays());
450 EXPECT_FALSE(display_manager()->IsMirrored());
451 EXPECT_EQ(external_id
, Shell::GetScreen()->GetPrimaryDisplay().id());
453 EXPECT_EQ(internal_display_id
, gfx::Display::InternalDisplayId());
455 // Primary connected, with different bounds.
456 display_info_list
.clear();
457 display_info_list
.push_back(internal_display_info
);
458 display_info_list
.push_back(external_display_info
);
459 display_manager()->OnNativeDisplaysChanged(display_info_list
);
460 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
461 EXPECT_EQ(internal_display_id
, Shell::GetScreen()->GetPrimaryDisplay().id());
463 // This combinatino is new, so internal display becomes primary.
464 EXPECT_EQ("0,0 500x500",
465 GetDisplayForId(internal_display_id
).bounds().ToString());
466 EXPECT_EQ("1,1 100x100",
467 GetDisplayInfoForId(10).bounds_in_native().ToString());
468 EXPECT_EQ(2U, display_manager()->num_connected_displays());
469 EXPECT_FALSE(display_manager()->IsMirrored());
470 EXPECT_EQ(ToDisplayName(internal_display_id
),
471 display_manager()->GetDisplayNameForId(internal_display_id
));
474 display_info_list
.clear();
475 display_manager()->OnNativeDisplaysChanged(display_info_list
);
476 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
477 EXPECT_EQ("0,0 500x500",
478 GetDisplayForId(internal_display_id
).bounds().ToString());
479 EXPECT_EQ("1,1 100x100",
480 GetDisplayInfoForId(10).bounds_in_native().ToString());
481 EXPECT_EQ(2U, display_manager()->num_connected_displays());
482 EXPECT_FALSE(display_manager()->IsMirrored());
483 EXPECT_EQ(ToDisplayName(internal_display_id
),
484 display_manager()->GetDisplayNameForId(internal_display_id
));
486 // External display has disconnected then resumed.
487 display_info_list
.push_back(internal_display_info
);
488 display_manager()->OnNativeDisplaysChanged(display_info_list
);
489 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
490 EXPECT_EQ("0,0 500x500",
491 GetDisplayForId(internal_display_id
).bounds().ToString());
492 EXPECT_EQ(1U, display_manager()->num_connected_displays());
493 EXPECT_FALSE(display_manager()->IsMirrored());
495 // External display was changed during suspend.
496 display_info_list
.push_back(external_display_info
);
497 display_manager()->OnNativeDisplaysChanged(display_info_list
);
498 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
499 EXPECT_EQ(2U, display_manager()->num_connected_displays());
500 EXPECT_FALSE(display_manager()->IsMirrored());
503 display_info_list
.clear();
504 display_manager()->OnNativeDisplaysChanged(display_info_list
);
505 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
506 EXPECT_EQ(2U, display_manager()->num_connected_displays());
507 EXPECT_FALSE(display_manager()->IsMirrored());
509 // and resume with different external display.
510 display_info_list
.push_back(internal_display_info
);
511 display_info_list
.push_back(CreateDisplayInfo(12, gfx::Rect(1, 1, 100, 100)));
512 display_manager()->OnNativeDisplaysChanged(display_info_list
);
513 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
514 EXPECT_EQ(2U, display_manager()->num_connected_displays());
515 EXPECT_FALSE(display_manager()->IsMirrored());
516 EXPECT_FALSE(display_manager()->IsMirrored());
519 display_info_list
.clear();
520 display_info_list
.push_back(internal_display_info
);
521 display_info_list
.push_back(mirrored_display_info
);
522 display_manager()->OnNativeDisplaysChanged(display_info_list
);
523 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
524 EXPECT_EQ("0,0 500x500",
525 GetDisplayForId(internal_display_id
).bounds().ToString());
526 EXPECT_EQ(2U, display_manager()->num_connected_displays());
527 EXPECT_EQ(11U, display_manager()->mirrored_display_id());
528 EXPECT_TRUE(display_manager()->IsMirrored());
530 // Test display name.
531 EXPECT_EQ(ToDisplayName(internal_display_id
),
532 display_manager()->GetDisplayNameForId(internal_display_id
));
533 EXPECT_EQ("x-10", display_manager()->GetDisplayNameForId(10));
534 EXPECT_EQ("x-11", display_manager()->GetDisplayNameForId(11));
535 EXPECT_EQ("x-12", display_manager()->GetDisplayNameForId(12));
536 // Default name for the id that doesn't exist.
537 EXPECT_EQ("Display 100", display_manager()->GetDisplayNameForId(100));
539 // and exit mirroring.
540 display_info_list
.clear();
541 display_info_list
.push_back(internal_display_info
);
542 display_info_list
.push_back(external_display_info
);
543 display_manager()->OnNativeDisplaysChanged(display_info_list
);
544 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
545 EXPECT_EQ(2U, display_manager()->num_connected_displays());
546 EXPECT_FALSE(display_manager()->IsMirrored());
547 EXPECT_EQ("0,0 500x500",
548 GetDisplayForId(internal_display_id
).bounds().ToString());
549 EXPECT_EQ("500,0 100x100",
550 GetDisplayForId(10).bounds().ToString());
553 display_info_list
.clear();
554 display_info_list
.push_back(external_display_info
);
555 display_manager()->OnNativeDisplaysChanged(display_info_list
);
556 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
557 EXPECT_EQ(invalid_id
, GetDisplayForId(internal_display_id
).id());
558 EXPECT_EQ("1,1 100x100",
559 GetDisplayInfoForId(external_id
).bounds_in_native().ToString());
560 EXPECT_EQ(1U, display_manager()->num_connected_displays());
561 EXPECT_FALSE(display_manager()->IsMirrored());
563 // Switched to another display
564 display_info_list
.clear();
565 display_info_list
.push_back(internal_display_info
);
566 display_manager()->OnNativeDisplaysChanged(display_info_list
);
567 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
570 GetDisplayInfoForId(internal_display_id
).bounds_in_native().ToString());
571 EXPECT_EQ(1U, display_manager()->num_connected_displays());
572 EXPECT_FALSE(display_manager()->IsMirrored());
575 // Make sure crash does not happen if add and remove happens at the same time.
576 // See: crbug.com/414394
577 TEST_F(DisplayManagerTest
, DisplayAddRemoveAtTheSameTime
) {
578 if (!SupportsMultipleDisplays())
581 UpdateDisplay("100+0-500x500,0+501-400x400");
583 const int64 primary_id
= DisplayController::GetPrimaryDisplayId();
584 const int64 secondary_id
= ScreenUtil::GetSecondaryDisplay().id();
586 DisplayInfo primary_info
= display_manager()->GetDisplayInfo(primary_id
);
587 DisplayInfo secondary_info
= display_manager()->GetDisplayInfo(secondary_id
);
589 // An id which is different from primary and secondary.
590 const int64 third_id
= primary_id
+ secondary_id
;
592 DisplayInfo third_info
=
593 CreateDisplayInfo(third_id
, gfx::Rect(0, 0, 600, 600));
595 std::vector
<DisplayInfo
> display_info_list
;
596 display_info_list
.push_back(third_info
);
597 display_info_list
.push_back(secondary_info
);
598 display_manager()->OnNativeDisplaysChanged(display_info_list
);
600 EXPECT_EQ(third_id
, DisplayController::GetPrimaryDisplayId());
601 EXPECT_EQ("600x600", GetDisplayForId(third_id
).size().ToString());
602 EXPECT_EQ(secondary_id
, ScreenUtil::GetSecondaryDisplay().id());
606 // TODO(scottmg): RootWindow doesn't get resized on Windows
607 // Ash. http://crbug.com/247916.
608 #define MAYBE_TestNativeDisplaysChangedNoInternal \
609 DISABLED_TestNativeDisplaysChangedNoInternal
611 #define MAYBE_TestNativeDisplaysChangedNoInternal \
612 TestNativeDisplaysChangedNoInternal
615 TEST_F(DisplayManagerTest
, MAYBE_TestNativeDisplaysChangedNoInternal
) {
616 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
618 // Don't change the display info if all displays are disconnected.
619 std::vector
<DisplayInfo
> display_info_list
;
620 display_manager()->OnNativeDisplaysChanged(display_info_list
);
621 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
623 // Connect another display which will become primary.
624 const DisplayInfo external_display_info
=
625 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100));
626 display_info_list
.push_back(external_display_info
);
627 display_manager()->OnNativeDisplaysChanged(display_info_list
);
628 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
629 EXPECT_EQ("1,1 100x100",
630 GetDisplayInfoForId(10).bounds_in_native().ToString());
631 EXPECT_EQ("100x100", ash::Shell::GetPrimaryRootWindow()->GetHost()->
632 GetBounds().size().ToString());
636 // Tests that rely on the actual host size/location does not work on windows.
637 #define MAYBE_EnsurePointerInDisplays DISABLED_EnsurePointerInDisplays
638 #define MAYBE_EnsurePointerInDisplays_2ndOnLeft DISABLED_EnsurePointerInDisplays_2ndOnLeft
640 #define MAYBE_EnsurePointerInDisplays EnsurePointerInDisplays
641 #define MAYBE_EnsurePointerInDisplays_2ndOnLeft EnsurePointerInDisplays_2ndOnLeft
644 TEST_F(DisplayManagerTest
, MAYBE_EnsurePointerInDisplays
) {
645 UpdateDisplay("200x200,300x300");
646 aura::Window::Windows root_windows
= Shell::GetAllRootWindows();
648 aura::Env
* env
= aura::Env::GetInstance();
650 ui::test::EventGenerator
generator(root_windows
[0]);
652 // Set the initial position.
653 generator
.MoveMouseToInHost(350, 150);
654 EXPECT_EQ("350,150", env
->last_mouse_location().ToString());
656 // A mouse pointer will stay in the 2nd display.
657 UpdateDisplay("300x300,200x200");
658 EXPECT_EQ("450,50", env
->last_mouse_location().ToString());
660 // A mouse pointer will be outside of displays and move to the
661 // center of 2nd display.
662 UpdateDisplay("300x300,100x100");
663 EXPECT_EQ("350,50", env
->last_mouse_location().ToString());
665 // 2nd display was disconnected, and the cursor is
666 // now in the 1st display.
667 UpdateDisplay("400x400");
668 EXPECT_EQ("50,350", env
->last_mouse_location().ToString());
670 // 1st display's resolution has changed, and the mouse pointer is
671 // now outside. Move the mouse pointer to the center of 1st display.
672 UpdateDisplay("300x300");
673 EXPECT_EQ("150,150", env
->last_mouse_location().ToString());
675 // Move the mouse pointer to the bottom of 1st display.
676 generator
.MoveMouseToInHost(150, 290);
677 EXPECT_EQ("150,290", env
->last_mouse_location().ToString());
679 // The mouse pointer is now on 2nd display.
680 UpdateDisplay("300x280,200x200");
681 EXPECT_EQ("450,10", env
->last_mouse_location().ToString());
684 TEST_F(DisplayManagerTest
, MAYBE_EnsurePointerInDisplays_2ndOnLeft
) {
685 // Set the 2nd display on the left.
686 DisplayLayoutStore
* layout_store
=
687 Shell::GetInstance()->display_manager()->layout_store();
688 DisplayLayout layout
= layout_store
->default_display_layout();
689 layout
.position
= DisplayLayout::LEFT
;
690 layout_store
->SetDefaultDisplayLayout(layout
);
692 UpdateDisplay("200x200,300x300");
693 aura::Window::Windows root_windows
= Shell::GetAllRootWindows();
695 EXPECT_EQ("-300,0 300x300",
696 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
698 aura::Env
* env
= aura::Env::GetInstance();
700 // Set the initial position.
701 root_windows
[0]->MoveCursorTo(gfx::Point(-150, 250));
702 EXPECT_EQ("-150,250", env
->last_mouse_location().ToString());
704 // A mouse pointer will stay in 2nd display.
705 UpdateDisplay("300x300,200x300");
706 EXPECT_EQ("-50,150", env
->last_mouse_location().ToString());
708 // A mouse pointer will be outside of displays and move to the
709 // center of 2nd display.
710 UpdateDisplay("300x300,200x100");
711 EXPECT_EQ("-100,50", env
->last_mouse_location().ToString());
713 // 2nd display was disconnected. Mouse pointer should move to
715 UpdateDisplay("300x300");
716 EXPECT_EQ("150,150", env
->last_mouse_location().ToString());
719 TEST_F(DisplayManagerTest
, NativeDisplaysChangedAfterPrimaryChange
) {
720 if (!SupportsMultipleDisplays())
723 const int64 internal_display_id
=
724 test::DisplayManagerTestApi(display_manager()).
725 SetFirstDisplayAsInternalDisplay();
726 const DisplayInfo native_display_info
=
727 CreateDisplayInfo(internal_display_id
, gfx::Rect(0, 0, 500, 500));
728 const DisplayInfo secondary_display_info
=
729 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100));
731 std::vector
<DisplayInfo
> display_info_list
;
732 display_info_list
.push_back(native_display_info
);
733 display_info_list
.push_back(secondary_display_info
);
734 display_manager()->OnNativeDisplaysChanged(display_info_list
);
735 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
736 EXPECT_EQ("0,0 500x500",
737 GetDisplayForId(internal_display_id
).bounds().ToString());
738 EXPECT_EQ("500,0 100x100", GetDisplayForId(10).bounds().ToString());
740 ash::Shell::GetInstance()->display_controller()->SetPrimaryDisplay(
741 GetDisplayForId(secondary_display_info
.id()));
742 EXPECT_EQ("-500,0 500x500",
743 GetDisplayForId(internal_display_id
).bounds().ToString());
744 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString());
746 // OnNativeDisplaysChanged may change the display bounds. Here makes sure
747 // nothing changed if the exactly same displays are specified.
748 display_manager()->OnNativeDisplaysChanged(display_info_list
);
749 EXPECT_EQ("-500,0 500x500",
750 GetDisplayForId(internal_display_id
).bounds().ToString());
751 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString());
754 TEST_F(DisplayManagerTest
, DontRememberBestResolution
) {
755 int display_id
= 1000;
756 DisplayInfo native_display_info
=
757 CreateDisplayInfo(display_id
, gfx::Rect(0, 0, 1000, 500));
758 std::vector
<DisplayMode
> display_modes
;
759 display_modes
.push_back(
760 DisplayMode(gfx::Size(1000, 500), 58.0f
, false, true));
761 display_modes
.push_back(
762 DisplayMode(gfx::Size(800, 300), 59.0f
, false, false));
763 display_modes
.push_back(
764 DisplayMode(gfx::Size(400, 500), 60.0f
, false, false));
766 native_display_info
.set_display_modes(display_modes
);
768 std::vector
<DisplayInfo
> display_info_list
;
769 display_info_list
.push_back(native_display_info
);
770 display_manager()->OnNativeDisplaysChanged(display_info_list
);
773 DisplayMode expected_mode
;
774 expected_mode
.size
= gfx::Size(1000, 500);
776 display_manager()->GetSelectedModeForDisplayId(display_id
, &mode
));
777 EXPECT_TRUE(expected_mode
.IsEquivalent(
778 display_manager()->GetActiveModeForDisplayId(display_id
)));
780 // Unsupported resolution.
781 display_manager()->SetDisplayResolution(display_id
, gfx::Size(800, 4000));
783 display_manager()->GetSelectedModeForDisplayId(display_id
, &mode
));
784 EXPECT_TRUE(expected_mode
.IsEquivalent(
785 display_manager()->GetActiveModeForDisplayId(display_id
)));
787 // Supported resolution.
788 display_manager()->SetDisplayResolution(display_id
, gfx::Size(800, 300));
790 display_manager()->GetSelectedModeForDisplayId(display_id
, &mode
));
791 EXPECT_EQ("800x300", mode
.size
.ToString());
792 EXPECT_EQ(59.0f
, mode
.refresh_rate
);
793 EXPECT_FALSE(mode
.native
);
794 expected_mode
.size
= gfx::Size(800, 300);
795 EXPECT_TRUE(expected_mode
.IsEquivalent(
796 display_manager()->GetActiveModeForDisplayId(display_id
)));
799 display_manager()->SetDisplayResolution(display_id
, gfx::Size(1000, 500));
801 display_manager()->GetSelectedModeForDisplayId(display_id
, &mode
));
802 EXPECT_EQ("1000x500", mode
.size
.ToString());
803 EXPECT_EQ(58.0f
, mode
.refresh_rate
);
804 EXPECT_TRUE(mode
.native
);
805 expected_mode
.size
= gfx::Size(1000, 500);
806 EXPECT_TRUE(expected_mode
.IsEquivalent(
807 display_manager()->GetActiveModeForDisplayId(display_id
)));
810 TEST_F(DisplayManagerTest
, ResolutionFallback
) {
811 int display_id
= 1000;
812 DisplayInfo native_display_info
=
813 CreateDisplayInfo(display_id
, gfx::Rect(0, 0, 1000, 500));
814 std::vector
<DisplayMode
> display_modes
;
815 display_modes
.push_back(
816 DisplayMode(gfx::Size(1000, 500), 58.0f
, false, true));
817 display_modes
.push_back(
818 DisplayMode(gfx::Size(800, 300), 59.0f
, false, false));
819 display_modes
.push_back(
820 DisplayMode(gfx::Size(400, 500), 60.0f
, false, false));
822 std::vector
<DisplayMode
> copy
= display_modes
;
823 native_display_info
.set_display_modes(copy
);
825 std::vector
<DisplayInfo
> display_info_list
;
826 display_info_list
.push_back(native_display_info
);
827 display_manager()->OnNativeDisplaysChanged(display_info_list
);
829 display_manager()->SetDisplayResolution(display_id
, gfx::Size(800, 300));
830 DisplayInfo new_native_display_info
=
831 CreateDisplayInfo(display_id
, gfx::Rect(0, 0, 400, 500));
832 copy
= display_modes
;
833 new_native_display_info
.set_display_modes(copy
);
834 std::vector
<DisplayInfo
> new_display_info_list
;
835 new_display_info_list
.push_back(new_native_display_info
);
836 display_manager()->OnNativeDisplaysChanged(new_display_info_list
);
840 display_manager()->GetSelectedModeForDisplayId(display_id
, &mode
));
841 EXPECT_EQ("400x500", mode
.size
.ToString());
842 EXPECT_EQ(60.0f
, mode
.refresh_rate
);
843 EXPECT_FALSE(mode
.native
);
846 // Best resolution should find itself on the resolutions list.
847 display_manager()->SetDisplayResolution(display_id
, gfx::Size(800, 300));
848 DisplayInfo new_native_display_info
=
849 CreateDisplayInfo(display_id
, gfx::Rect(0, 0, 1000, 500));
850 std::vector
<DisplayMode
> copy
= display_modes
;
851 new_native_display_info
.set_display_modes(copy
);
852 std::vector
<DisplayInfo
> new_display_info_list
;
853 new_display_info_list
.push_back(new_native_display_info
);
854 display_manager()->OnNativeDisplaysChanged(new_display_info_list
);
858 display_manager()->GetSelectedModeForDisplayId(display_id
, &mode
));
859 EXPECT_EQ("1000x500", mode
.size
.ToString());
860 EXPECT_EQ(58.0f
, mode
.refresh_rate
);
861 EXPECT_TRUE(mode
.native
);
865 TEST_F(DisplayManagerTest
, Rotate
) {
866 if (!SupportsMultipleDisplays())
869 UpdateDisplay("100x200/r,300x400/l");
870 EXPECT_EQ("1,1 100x200",
871 GetDisplayInfoAt(0).bounds_in_native().ToString());
873 GetDisplayInfoAt(0).size_in_pixel().ToString());
875 EXPECT_EQ("1,201 300x400",
876 GetDisplayInfoAt(1).bounds_in_native().ToString());
878 GetDisplayInfoAt(1).size_in_pixel().ToString());
880 UpdateDisplay("100x200/b,300x400");
881 EXPECT_EQ("2 0 0", GetCountSummary());
884 EXPECT_EQ("1,1 100x200",
885 GetDisplayInfoAt(0).bounds_in_native().ToString());
887 GetDisplayInfoAt(0).size_in_pixel().ToString());
889 EXPECT_EQ("1,201 300x400",
890 GetDisplayInfoAt(1).bounds_in_native().ToString());
892 GetDisplayInfoAt(1).size_in_pixel().ToString());
894 // Just Rotating display will change the bounds on both display.
895 UpdateDisplay("100x200/l,300x400");
896 EXPECT_EQ("2 0 0", GetCountSummary());
899 // Updating to the same configuration should report no changes.
900 UpdateDisplay("100x200/l,300x400");
901 EXPECT_EQ("0 0 0", GetCountSummary());
904 // Rotating 180 degrees should report one change.
905 UpdateDisplay("100x200/r,300x400");
906 EXPECT_EQ("1 0 0", GetCountSummary());
909 UpdateDisplay("200x200");
910 EXPECT_EQ("1 0 1", GetCountSummary());
913 // Rotating 180 degrees should report one change.
914 UpdateDisplay("200x200/u");
915 EXPECT_EQ("1 0 0", GetCountSummary());
918 UpdateDisplay("200x200/l");
919 EXPECT_EQ("1 0 0", GetCountSummary());
922 TEST_F(DisplayManagerTest
, UIScale
) {
923 DisplayInfo::SetUse125DSFForUIScaling(false);
925 UpdateDisplay("1280x800");
926 int64 display_id
= Shell::GetScreen()->GetPrimaryDisplay().id();
927 display_manager()->SetDisplayUIScale(display_id
, 1.125f
);
928 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale());
929 display_manager()->SetDisplayUIScale(display_id
, 0.8f
);
930 EXPECT_EQ(1.0f
, GetDisplayInfoAt(0).configured_ui_scale());
931 display_manager()->SetDisplayUIScale(display_id
, 0.75f
);
932 EXPECT_EQ(1.0f
, GetDisplayInfoAt(0).configured_ui_scale());
933 display_manager()->SetDisplayUIScale(display_id
, 0.625f
);
934 EXPECT_EQ(1.0f
, GetDisplayInfoAt(0).configured_ui_scale());
936 gfx::Display::SetInternalDisplayId(display_id
);
938 display_manager()->SetDisplayUIScale(display_id
, 1.5f
);
939 EXPECT_EQ(1.0f
, GetDisplayInfoAt(0).configured_ui_scale());
940 display_manager()->SetDisplayUIScale(display_id
, 1.25f
);
941 EXPECT_EQ(1.0f
, GetDisplayInfoAt(0).configured_ui_scale());
942 display_manager()->SetDisplayUIScale(display_id
, 1.125f
);
943 EXPECT_EQ(1.125f
, GetDisplayInfoAt(0).configured_ui_scale());
944 display_manager()->SetDisplayUIScale(display_id
, 0.8f
);
945 EXPECT_EQ(0.8f
, GetDisplayInfoAt(0).configured_ui_scale());
946 display_manager()->SetDisplayUIScale(display_id
, 0.75f
);
947 EXPECT_EQ(0.8f
, GetDisplayInfoAt(0).configured_ui_scale());
948 display_manager()->SetDisplayUIScale(display_id
, 0.625f
);
949 EXPECT_EQ(0.625f
, GetDisplayInfoAt(0).configured_ui_scale());
950 display_manager()->SetDisplayUIScale(display_id
, 0.6f
);
951 EXPECT_EQ(0.625f
, GetDisplayInfoAt(0).configured_ui_scale());
952 display_manager()->SetDisplayUIScale(display_id
, 0.5f
);
953 EXPECT_EQ(0.5f
, GetDisplayInfoAt(0).configured_ui_scale());
955 UpdateDisplay("1366x768");
956 display_manager()->SetDisplayUIScale(display_id
, 1.5f
);
957 EXPECT_EQ(1.0f
, GetDisplayInfoAt(0).configured_ui_scale());
958 display_manager()->SetDisplayUIScale(display_id
, 1.25f
);
959 EXPECT_EQ(1.0f
, GetDisplayInfoAt(0).configured_ui_scale());
960 display_manager()->SetDisplayUIScale(display_id
, 1.125f
);
961 EXPECT_EQ(1.125f
, GetDisplayInfoAt(0).configured_ui_scale());
962 display_manager()->SetDisplayUIScale(display_id
, 0.8f
);
963 EXPECT_EQ(1.125f
, GetDisplayInfoAt(0).configured_ui_scale());
964 display_manager()->SetDisplayUIScale(display_id
, 0.75f
);
965 EXPECT_EQ(0.75f
, GetDisplayInfoAt(0).configured_ui_scale());
966 display_manager()->SetDisplayUIScale(display_id
, 0.6f
);
967 EXPECT_EQ(0.6f
, GetDisplayInfoAt(0).configured_ui_scale());
968 display_manager()->SetDisplayUIScale(display_id
, 0.625f
);
969 EXPECT_EQ(0.6f
, GetDisplayInfoAt(0).configured_ui_scale());
970 display_manager()->SetDisplayUIScale(display_id
, 0.5f
);
971 EXPECT_EQ(0.5f
, GetDisplayInfoAt(0).configured_ui_scale());
973 UpdateDisplay("1280x850*2");
974 EXPECT_EQ(1.0f
, GetDisplayInfoAt(0).configured_ui_scale());
975 display_manager()->SetDisplayUIScale(display_id
, 1.5f
);
976 EXPECT_EQ(1.5f
, GetDisplayInfoAt(0).configured_ui_scale());
977 display_manager()->SetDisplayUIScale(display_id
, 1.25f
);
978 EXPECT_EQ(1.25f
, GetDisplayInfoAt(0).configured_ui_scale());
979 display_manager()->SetDisplayUIScale(display_id
, 1.125f
);
980 EXPECT_EQ(1.125f
, GetDisplayInfoAt(0).configured_ui_scale());
981 display_manager()->SetDisplayUIScale(display_id
, 1.0f
);
982 EXPECT_EQ(1.0f
, GetDisplayInfoAt(0).configured_ui_scale());
983 gfx::Display display
= Shell::GetScreen()->GetPrimaryDisplay();
984 EXPECT_EQ(2.0f
, display
.device_scale_factor());
985 EXPECT_EQ("640x425", display
.bounds().size().ToString());
987 display_manager()->SetDisplayUIScale(display_id
, 0.8f
);
988 EXPECT_EQ(0.8f
, GetDisplayInfoAt(0).configured_ui_scale());
989 display_manager()->SetDisplayUIScale(display_id
, 0.75f
);
990 EXPECT_EQ(0.8f
, GetDisplayInfoAt(0).configured_ui_scale());
991 display_manager()->SetDisplayUIScale(display_id
, 0.625f
);
992 EXPECT_EQ(0.625f
, GetDisplayInfoAt(0).configured_ui_scale());
993 display_manager()->SetDisplayUIScale(display_id
, 0.6f
);
994 EXPECT_EQ(0.625f
, GetDisplayInfoAt(0).configured_ui_scale());
995 display_manager()->SetDisplayUIScale(display_id
, 0.5f
);
996 EXPECT_EQ(0.5f
, GetDisplayInfoAt(0).configured_ui_scale());
998 display_manager()->SetDisplayUIScale(display_id
, 2.0f
);
999 EXPECT_EQ(2.0f
, GetDisplayInfoAt(0).configured_ui_scale());
1000 EXPECT_EQ(1.0f
, GetDisplayInfoAt(0).GetEffectiveUIScale());
1001 display
= Shell::GetScreen()->GetPrimaryDisplay();
1002 EXPECT_EQ(1.0f
, display
.device_scale_factor());
1003 EXPECT_EQ("1280x850", display
.bounds().size().ToString());
1005 // 1.25 ui scaling on 1.25 DSF device should use 1.0 DSF
1007 UpdateDisplay("1280x850*1.25");
1008 display_manager()->SetDisplayUIScale(display_id
, 1.25f
);
1009 EXPECT_EQ(1.25f
, GetDisplayInfoAt(0).configured_ui_scale());
1010 EXPECT_EQ(1.0f
, GetDisplayInfoAt(0).GetEffectiveUIScale());
1011 display
= Shell::GetScreen()->GetPrimaryDisplay();
1012 EXPECT_EQ(1.0f
, display
.device_scale_factor());
1013 EXPECT_EQ("1280x850", display
.bounds().size().ToString());
1016 TEST_F(DisplayManagerTest
, UIScaleWithDisplayMode
) {
1017 int display_id
= 1000;
1019 // Setup the display modes with UI-scale.
1020 DisplayInfo native_display_info
=
1021 CreateDisplayInfo(display_id
, gfx::Rect(0, 0, 1280, 800));
1022 std::vector
<DisplayMode
> display_modes
;
1023 const DisplayMode
base_mode(gfx::Size(1280, 800), 60.0f
, false, false);
1024 std::vector
<float> scales
=
1025 DisplayManager::GetScalesForDisplay(native_display_info
);
1026 for (size_t i
= 0; i
< scales
.size(); i
++) {
1027 DisplayMode mode
= base_mode
;
1028 mode
.ui_scale
= scales
[i
];
1029 mode
.native
= (scales
[i
] == 1.0f
);
1030 display_modes
.push_back(mode
);
1032 native_display_info
.set_display_modes(display_modes
);
1033 std::vector
<DisplayInfo
> display_info_list
;
1034 display_info_list
.push_back(native_display_info
);
1035 display_manager()->OnNativeDisplaysChanged(display_info_list
);
1037 DisplayMode expected_mode
= base_mode
;
1038 EXPECT_TRUE(expected_mode
.IsEquivalent(
1039 display_manager()->GetActiveModeForDisplayId(display_id
)));
1041 display_manager()->SetDisplayUIScale(display_id
, 1.125f
);
1042 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale());
1043 EXPECT_TRUE(expected_mode
.IsEquivalent(
1044 display_manager()->GetActiveModeForDisplayId(display_id
)));
1045 display_manager()->SetDisplayUIScale(display_id
, 0.8f
);
1046 EXPECT_EQ(1.0f
, GetDisplayInfoAt(0).configured_ui_scale());
1047 EXPECT_TRUE(expected_mode
.IsEquivalent(
1048 display_manager()->GetActiveModeForDisplayId(display_id
)));
1049 display_manager()->SetDisplayUIScale(display_id
, 0.75f
);
1050 EXPECT_EQ(1.0f
, GetDisplayInfoAt(0).configured_ui_scale());
1051 EXPECT_TRUE(expected_mode
.IsEquivalent(
1052 display_manager()->GetActiveModeForDisplayId(display_id
)));
1053 display_manager()->SetDisplayUIScale(display_id
, 0.625f
);
1054 EXPECT_EQ(1.0f
, GetDisplayInfoAt(0).configured_ui_scale());
1055 EXPECT_TRUE(expected_mode
.IsEquivalent(
1056 display_manager()->GetActiveModeForDisplayId(display_id
)));
1058 gfx::Display::SetInternalDisplayId(display_id
);
1060 display_manager()->SetDisplayUIScale(display_id
, 1.5f
);
1061 EXPECT_EQ(1.0f
, GetDisplayInfoAt(0).configured_ui_scale());
1062 EXPECT_TRUE(expected_mode
.IsEquivalent(
1063 display_manager()->GetActiveModeForDisplayId(display_id
)));
1064 display_manager()->SetDisplayUIScale(display_id
, 1.25f
);
1065 EXPECT_EQ(1.0f
, GetDisplayInfoAt(0).configured_ui_scale());
1066 EXPECT_TRUE(expected_mode
.IsEquivalent(
1067 display_manager()->GetActiveModeForDisplayId(display_id
)));
1068 display_manager()->SetDisplayUIScale(display_id
, 1.125f
);
1069 EXPECT_EQ(1.125f
, GetDisplayInfoAt(0).configured_ui_scale());
1070 expected_mode
.ui_scale
= 1.125f
;
1071 EXPECT_TRUE(expected_mode
.IsEquivalent(
1072 display_manager()->GetActiveModeForDisplayId(display_id
)));
1073 display_manager()->SetDisplayUIScale(display_id
, 0.8f
);
1074 EXPECT_EQ(0.8f
, GetDisplayInfoAt(0).configured_ui_scale());
1075 expected_mode
.ui_scale
= 0.8f
;
1076 EXPECT_TRUE(expected_mode
.IsEquivalent(
1077 display_manager()->GetActiveModeForDisplayId(display_id
)));
1078 display_manager()->SetDisplayUIScale(display_id
, 0.75f
);
1079 EXPECT_EQ(0.8f
, GetDisplayInfoAt(0).configured_ui_scale());
1080 EXPECT_TRUE(expected_mode
.IsEquivalent(
1081 display_manager()->GetActiveModeForDisplayId(display_id
)));
1082 display_manager()->SetDisplayUIScale(display_id
, 0.625f
);
1083 EXPECT_EQ(0.625f
, GetDisplayInfoAt(0).configured_ui_scale());
1084 expected_mode
.ui_scale
= 0.625f
;
1085 EXPECT_TRUE(expected_mode
.IsEquivalent(
1086 display_manager()->GetActiveModeForDisplayId(display_id
)));
1087 display_manager()->SetDisplayUIScale(display_id
, 0.6f
);
1088 EXPECT_EQ(0.625f
, GetDisplayInfoAt(0).configured_ui_scale());
1089 EXPECT_TRUE(expected_mode
.IsEquivalent(
1090 display_manager()->GetActiveModeForDisplayId(display_id
)));
1091 display_manager()->SetDisplayUIScale(display_id
, 0.5f
);
1092 EXPECT_EQ(0.5f
, GetDisplayInfoAt(0).configured_ui_scale());
1093 expected_mode
.ui_scale
= 0.5f
;
1094 EXPECT_TRUE(expected_mode
.IsEquivalent(
1095 display_manager()->GetActiveModeForDisplayId(display_id
)));
1099 TEST_F(DisplayManagerTest
, Use125DSFRorUIScaling
) {
1100 int64 display_id
= Shell::GetScreen()->GetPrimaryDisplay().id();
1101 gfx::Display::SetInternalDisplayId(display_id
);
1102 DisplayInfo::SetUse125DSFForUIScaling(true);
1104 UpdateDisplay("1920x1080*1.25");
1105 EXPECT_EQ(1.0f
, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1106 EXPECT_EQ(1.0f
, GetDisplayInfoAt(0).GetEffectiveUIScale());
1108 display_manager()->SetDisplayUIScale(display_id
, 0.8f
);
1109 EXPECT_EQ(1.25f
, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1110 EXPECT_EQ(1.0f
, GetDisplayInfoAt(0).GetEffectiveUIScale());
1111 EXPECT_EQ("1536x864", GetDisplayForId(display_id
).size().ToString());
1113 display_manager()->SetDisplayUIScale(display_id
, 0.5f
);
1114 EXPECT_EQ(1.0f
, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1115 EXPECT_EQ(0.5f
, GetDisplayInfoAt(0).GetEffectiveUIScale());
1116 EXPECT_EQ("960x540", GetDisplayForId(display_id
).size().ToString());
1118 display_manager()->SetDisplayUIScale(display_id
, 1.25f
);
1119 EXPECT_EQ(1.0f
, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1120 EXPECT_EQ(1.25f
, GetDisplayInfoAt(0).GetEffectiveUIScale());
1121 EXPECT_EQ("2400x1350", GetDisplayForId(display_id
).size().ToString());
1123 DisplayInfo::SetUse125DSFForUIScaling(false);
1127 // TODO(scottmg): RootWindow doesn't get resized on Windows
1128 // Ash. http://crbug.com/247916.
1129 #define MAYBE_UpdateMouseCursorAfterRotateZoom DISABLED_UpdateMouseCursorAfterRotateZoom
1131 #define MAYBE_UpdateMouseCursorAfterRotateZoom UpdateMouseCursorAfterRotateZoom
1134 TEST_F(DisplayManagerTest
, MAYBE_UpdateMouseCursorAfterRotateZoom
) {
1135 // Make sure just rotating will not change native location.
1136 UpdateDisplay("300x200,200x150");
1137 aura::Window::Windows root_windows
= Shell::GetAllRootWindows();
1138 aura::Env
* env
= aura::Env::GetInstance();
1140 ui::test::EventGenerator
generator1(root_windows
[0]);
1141 ui::test::EventGenerator
generator2(root_windows
[1]);
1143 // Test on 1st display.
1144 generator1
.MoveMouseToInHost(150, 50);
1145 EXPECT_EQ("150,50", env
->last_mouse_location().ToString());
1146 UpdateDisplay("300x200/r,200x150");
1147 EXPECT_EQ("50,149", env
->last_mouse_location().ToString());
1149 // Test on 2nd display.
1150 generator2
.MoveMouseToInHost(50, 100);
1151 EXPECT_EQ("250,100", env
->last_mouse_location().ToString());
1152 UpdateDisplay("300x200/r,200x150/l");
1153 EXPECT_EQ("249,50", env
->last_mouse_location().ToString());
1155 // The native location is now outside, so move to the center
1156 // of closest display.
1157 UpdateDisplay("300x200/r,100x50/l");
1158 EXPECT_EQ("225,50", env
->last_mouse_location().ToString());
1160 // Make sure just zooming will not change native location.
1161 UpdateDisplay("600x400*2,400x300");
1163 // Test on 1st display.
1164 generator1
.MoveMouseToInHost(200, 300);
1165 EXPECT_EQ("100,150", env
->last_mouse_location().ToString());
1166 UpdateDisplay("600x400*2@1.5,400x300");
1167 EXPECT_EQ("150,225", env
->last_mouse_location().ToString());
1169 // Test on 2nd display.
1170 UpdateDisplay("600x400,400x300*2");
1171 generator2
.MoveMouseToInHost(200, 250);
1172 EXPECT_EQ("700,125", env
->last_mouse_location().ToString());
1173 UpdateDisplay("600x400,400x300*2@1.5");
1174 EXPECT_EQ("750,187", env
->last_mouse_location().ToString());
1176 // The native location is now outside, so move to the
1177 // center of closest display.
1178 UpdateDisplay("600x400,400x200*2@1.5");
1179 EXPECT_EQ("750,75", env
->last_mouse_location().ToString());
1182 class TestDisplayObserver
: public gfx::DisplayObserver
{
1184 TestDisplayObserver() : changed_(false) {}
1185 virtual ~TestDisplayObserver() {}
1187 // gfx::DisplayObserver overrides:
1188 virtual void OnDisplayMetricsChanged(const gfx::Display
&,uint32_t) override
{}
1189 virtual void OnDisplayAdded(const gfx::Display
& new_display
) override
{
1190 // Mirror window should already be delete before restoring
1191 // the external display.
1192 EXPECT_FALSE(test_api
.GetHost());
1195 virtual void OnDisplayRemoved(const gfx::Display
& old_display
) override
{
1196 // Mirror window should not be created until the external display
1198 EXPECT_FALSE(test_api
.GetHost());
1202 bool changed_and_reset() {
1203 bool changed
= changed_
;
1209 test::MirrorWindowTestApi test_api
;
1212 DISALLOW_COPY_AND_ASSIGN(TestDisplayObserver
);
1215 TEST_F(DisplayManagerTest
, SoftwareMirroring
) {
1216 if (!SupportsMultipleDisplays())
1219 UpdateDisplay("300x400,400x500");
1221 test::MirrorWindowTestApi test_api
;
1222 EXPECT_EQ(NULL
, test_api
.GetHost());
1224 TestDisplayObserver display_observer
;
1225 Shell::GetScreen()->AddObserver(&display_observer
);
1227 DisplayManager
* display_manager
= Shell::GetInstance()->display_manager();
1228 display_manager
->SetSecondDisplayMode(DisplayManager::MIRRORING
);
1229 display_manager
->UpdateDisplays();
1230 EXPECT_TRUE(display_observer
.changed_and_reset());
1231 EXPECT_EQ(1U, display_manager
->GetNumDisplays());
1232 EXPECT_EQ("0,0 300x400",
1233 Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString());
1234 EXPECT_EQ("400x500", test_api
.GetHost()->GetBounds().size().ToString());
1235 EXPECT_EQ("300x400",
1236 test_api
.GetHost()->window()->bounds().size().ToString());
1237 EXPECT_TRUE(display_manager
->IsMirrored());
1239 display_manager
->SetMirrorMode(false);
1240 EXPECT_TRUE(display_observer
.changed_and_reset());
1241 EXPECT_EQ(NULL
, test_api
.GetHost());
1242 EXPECT_EQ(2U, display_manager
->GetNumDisplays());
1243 EXPECT_FALSE(display_manager
->IsMirrored());
1245 // Make sure the mirror window has the pixel size of the
1247 display_manager
->SetMirrorMode(true);
1248 EXPECT_TRUE(display_observer
.changed_and_reset());
1250 UpdateDisplay("300x400@0.5,400x500");
1251 EXPECT_FALSE(display_observer
.changed_and_reset());
1252 EXPECT_EQ("300x400",
1253 test_api
.GetHost()->window()->bounds().size().ToString());
1255 UpdateDisplay("310x410*2,400x500");
1256 EXPECT_FALSE(display_observer
.changed_and_reset());
1257 EXPECT_EQ("310x410",
1258 test_api
.GetHost()->window()->bounds().size().ToString());
1260 UpdateDisplay("320x420/r,400x500");
1261 EXPECT_FALSE(display_observer
.changed_and_reset());
1262 EXPECT_EQ("320x420",
1263 test_api
.GetHost()->window()->bounds().size().ToString());
1265 UpdateDisplay("330x440/r,400x500");
1266 EXPECT_FALSE(display_observer
.changed_and_reset());
1267 EXPECT_EQ("330x440",
1268 test_api
.GetHost()->window()->bounds().size().ToString());
1270 // Overscan insets are ignored.
1271 UpdateDisplay("400x600/o,600x800/o");
1272 EXPECT_FALSE(display_observer
.changed_and_reset());
1273 EXPECT_EQ("400x600",
1274 test_api
.GetHost()->window()->bounds().size().ToString());
1276 Shell::GetScreen()->RemoveObserver(&display_observer
);
1279 #if defined(OS_CHROMEOS)
1280 // Make sure this does not cause any crashes. See http://crbug.com/412910
1281 // This test is limited to OS_CHROMEOS because CursorCompositingEnabled is only
1283 TEST_F(DisplayManagerTest
, SoftwareMirroringWithCompositingCursor
) {
1284 if (!SupportsMultipleDisplays())
1287 UpdateDisplay("300x400,400x500");
1289 test::MirrorWindowTestApi test_api
;
1290 EXPECT_EQ(NULL
, test_api
.GetHost());
1292 DisplayManager
* display_manager
= Shell::GetInstance()->display_manager();
1293 DisplayInfo secondary_info
= display_manager
->GetDisplayInfo(
1294 ScreenUtil::GetSecondaryDisplay().id());
1296 display_manager
->SetSoftwareMirroring(true);
1297 display_manager
->UpdateDisplays();
1299 aura::Window::Windows root_windows
= Shell::GetAllRootWindows();
1300 EXPECT_FALSE(root_windows
[0]->Contains(test_api
.GetCursorWindow()));
1302 Shell::GetInstance()->SetCursorCompositingEnabled(true);
1304 EXPECT_TRUE(root_windows
[0]->Contains(test_api
.GetCursorWindow()));
1306 // Removes the first display and keeps the second one.
1307 display_manager
->SetSoftwareMirroring(false);
1308 std::vector
<DisplayInfo
> new_info_list
;
1309 new_info_list
.push_back(secondary_info
);
1310 display_manager
->OnNativeDisplaysChanged(new_info_list
);
1312 root_windows
= Shell::GetAllRootWindows();
1313 EXPECT_TRUE(root_windows
[0]->Contains(test_api
.GetCursorWindow()));
1315 Shell::GetInstance()->SetCursorCompositingEnabled(false);
1317 #endif // OS_CHROMEOS
1319 TEST_F(DisplayManagerTest
, MirroredLayout
) {
1320 if (!SupportsMultipleDisplays())
1323 DisplayManager
* display_manager
= Shell::GetInstance()->display_manager();
1324 UpdateDisplay("500x500,400x400");
1325 EXPECT_FALSE(display_manager
->GetCurrentDisplayLayout().mirrored
);
1326 EXPECT_EQ(2, Shell::GetScreen()->GetNumDisplays());
1327 EXPECT_EQ(2U, display_manager
->num_connected_displays());
1329 UpdateDisplay("1+0-500x500,1+0-500x500");
1330 EXPECT_TRUE(display_manager
->GetCurrentDisplayLayout().mirrored
);
1331 EXPECT_EQ(1, Shell::GetScreen()->GetNumDisplays());
1332 EXPECT_EQ(2U, display_manager
->num_connected_displays());
1334 UpdateDisplay("500x500,500x500");
1335 EXPECT_FALSE(display_manager
->GetCurrentDisplayLayout().mirrored
);
1336 EXPECT_EQ(2, Shell::GetScreen()->GetNumDisplays());
1337 EXPECT_EQ(2U, display_manager
->num_connected_displays());
1340 TEST_F(DisplayManagerTest
, InvertLayout
) {
1341 EXPECT_EQ("left, 0",
1342 DisplayLayout(DisplayLayout::RIGHT
, 0).Invert().ToString());
1343 EXPECT_EQ("left, -100",
1344 DisplayLayout(DisplayLayout::RIGHT
, 100).Invert().ToString());
1345 EXPECT_EQ("left, 50",
1346 DisplayLayout(DisplayLayout::RIGHT
, -50).Invert().ToString());
1348 EXPECT_EQ("right, 0",
1349 DisplayLayout(DisplayLayout::LEFT
, 0).Invert().ToString());
1350 EXPECT_EQ("right, -90",
1351 DisplayLayout(DisplayLayout::LEFT
, 90).Invert().ToString());
1352 EXPECT_EQ("right, 60",
1353 DisplayLayout(DisplayLayout::LEFT
, -60).Invert().ToString());
1355 EXPECT_EQ("bottom, 0",
1356 DisplayLayout(DisplayLayout::TOP
, 0).Invert().ToString());
1357 EXPECT_EQ("bottom, -80",
1358 DisplayLayout(DisplayLayout::TOP
, 80).Invert().ToString());
1359 EXPECT_EQ("bottom, 70",
1360 DisplayLayout(DisplayLayout::TOP
, -70).Invert().ToString());
1363 DisplayLayout(DisplayLayout::BOTTOM
, 0).Invert().ToString());
1364 EXPECT_EQ("top, -70",
1365 DisplayLayout(DisplayLayout::BOTTOM
, 70).Invert().ToString());
1366 EXPECT_EQ("top, 80",
1367 DisplayLayout(DisplayLayout::BOTTOM
, -80).Invert().ToString());
1371 // TODO(scottmg): RootWindow doesn't get resized on Windows
1372 // Ash. http://crbug.com/247916.
1373 #define MAYBE_UpdateDisplayWithHostOrigin DISABLED_UpdateDisplayWithHostOrigin
1375 #define MAYBE_UpdateDisplayWithHostOrigin UpdateDisplayWithHostOrigin
1378 TEST_F(DisplayManagerTest
, MAYBE_UpdateDisplayWithHostOrigin
) {
1379 UpdateDisplay("100x200,300x400");
1380 ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays());
1381 aura::Window::Windows root_windows
=
1382 Shell::GetInstance()->GetAllRootWindows();
1383 ASSERT_EQ(2U, root_windows
.size());
1384 aura::WindowTreeHost
* host0
= root_windows
[0]->GetHost();
1385 aura::WindowTreeHost
* host1
= root_windows
[1]->GetHost();
1387 EXPECT_EQ("1,1", host0
->GetBounds().origin().ToString());
1388 EXPECT_EQ("100x200", host0
->GetBounds().size().ToString());
1389 // UpdateDisplay set the origin if it's not set.
1390 EXPECT_NE("1,1", host1
->GetBounds().origin().ToString());
1391 EXPECT_EQ("300x400", host1
->GetBounds().size().ToString());
1393 UpdateDisplay("100x200,200+300-300x400");
1394 ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays());
1395 EXPECT_EQ("0,0", host0
->GetBounds().origin().ToString());
1396 EXPECT_EQ("100x200", host0
->GetBounds().size().ToString());
1397 EXPECT_EQ("200,300", host1
->GetBounds().origin().ToString());
1398 EXPECT_EQ("300x400", host1
->GetBounds().size().ToString());
1400 UpdateDisplay("400+500-200x300,300x400");
1401 ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays());
1402 EXPECT_EQ("400,500", host0
->GetBounds().origin().ToString());
1403 EXPECT_EQ("200x300", host0
->GetBounds().size().ToString());
1404 EXPECT_EQ("0,0", host1
->GetBounds().origin().ToString());
1405 EXPECT_EQ("300x400", host1
->GetBounds().size().ToString());
1407 UpdateDisplay("100+200-100x200,300+500-200x300");
1408 ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays());
1409 EXPECT_EQ("100,200", host0
->GetBounds().origin().ToString());
1410 EXPECT_EQ("100x200", host0
->GetBounds().size().ToString());
1411 EXPECT_EQ("300,500", host1
->GetBounds().origin().ToString());
1412 EXPECT_EQ("200x300", host1
->GetBounds().size().ToString());
1416 class ScreenShutdownTest
: public test::AshTestBase
{
1418 ScreenShutdownTest() {
1420 virtual ~ScreenShutdownTest() {}
1422 virtual void TearDown() override
{
1423 gfx::Screen
* orig_screen
=
1424 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE
);
1425 AshTestBase::TearDown();
1426 if (!SupportsMultipleDisplays())
1428 gfx::Screen
* screen
=
1429 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE
);
1430 EXPECT_NE(orig_screen
, screen
);
1431 EXPECT_EQ(2, screen
->GetNumDisplays());
1432 EXPECT_EQ("500x300", screen
->GetPrimaryDisplay().size().ToString());
1433 std::vector
<gfx::Display
> all
= screen
->GetAllDisplays();
1434 EXPECT_EQ("500x300", all
[0].size().ToString());
1435 EXPECT_EQ("800x400", all
[1].size().ToString());
1439 DISALLOW_COPY_AND_ASSIGN(ScreenShutdownTest
);
1442 TEST_F(ScreenShutdownTest
, ScreenAfterShutdown
) {
1443 if (!SupportsMultipleDisplays())
1445 UpdateDisplay("500x300,800x400");
1449 #if defined(OS_CHROMEOS)
1452 // A helper class that sets the display configuration and starts ash.
1453 // This is to make sure the font configuration happens during ash
1454 // initialization process.
1455 class FontTestHelper
: public test::AshTestBase
{
1462 FontTestHelper(float scale
, DisplayType display_type
) {
1463 gfx::ClearFontRenderParamsCacheForTest();
1464 base::CommandLine
* command_line
= base::CommandLine::ForCurrentProcess();
1465 if (display_type
== INTERNAL
)
1466 command_line
->AppendSwitch(switches::kAshUseFirstDisplayAsInternal
);
1467 command_line
->AppendSwitchASCII(switches::kAshHostWindowBounds
,
1468 StringPrintf("1000x800*%f", scale
));
1472 virtual ~FontTestHelper() {
1476 // test::AshTestBase:
1477 virtual void TestBody() override
{
1482 DISALLOW_COPY_AND_ASSIGN(FontTestHelper
);
1486 bool IsTextSubpixelPositioningEnabled() {
1487 gfx::FontRenderParams params
=
1488 gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(false), NULL
);
1489 return params
.subpixel_positioning
;
1494 typedef testing::Test DisplayManagerFontTest
;
1496 TEST_F(DisplayManagerFontTest
, TextSubpixelPositioningWithDsf100Internal
) {
1497 FontTestHelper
helper(1.0f
, FontTestHelper::INTERNAL
);
1499 1.0f
, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor());
1500 EXPECT_FALSE(IsTextSubpixelPositioningEnabled());
1503 TEST_F(DisplayManagerFontTest
, TextSubpixelPositioningWithDsf125Internal
) {
1504 FontTestHelper
helper(1.25f
, FontTestHelper::INTERNAL
);
1506 1.25f
, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor());
1507 EXPECT_TRUE(IsTextSubpixelPositioningEnabled());
1510 TEST_F(DisplayManagerFontTest
, TextSubpixelPositioningWithDsf200Internal
) {
1511 FontTestHelper
helper(2.0f
, FontTestHelper::INTERNAL
);
1513 2.0f
, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor());
1514 EXPECT_TRUE(IsTextSubpixelPositioningEnabled());
1517 TEST_F(DisplayManagerFontTest
, TextSubpixelPositioningWithDsf100External
) {
1518 FontTestHelper
helper(1.0f
, FontTestHelper::EXTERNAL
);
1520 1.0f
, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor());
1521 EXPECT_FALSE(IsTextSubpixelPositioningEnabled());
1524 TEST_F(DisplayManagerFontTest
, TextSubpixelPositioningWithDsf125External
) {
1525 FontTestHelper
helper(1.25f
, FontTestHelper::EXTERNAL
);
1527 1.25f
, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor());
1528 EXPECT_FALSE(IsTextSubpixelPositioningEnabled());
1531 TEST_F(DisplayManagerFontTest
, TextSubpixelPositioningWithDsf200External
) {
1532 FontTestHelper
helper(2.0f
, FontTestHelper::EXTERNAL
);
1534 2.0f
, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor());
1535 EXPECT_FALSE(IsTextSubpixelPositioningEnabled());
1538 TEST_F(DisplayManagerFontTest
,
1539 TextSubpixelPositioningWithDsf125InternalWithScaling
) {
1540 DisplayInfo::SetUse125DSFForUIScaling(true);
1541 FontTestHelper
helper(1.25f
, FontTestHelper::INTERNAL
);
1543 1.0f
, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor());
1544 EXPECT_FALSE(IsTextSubpixelPositioningEnabled());
1545 DisplayInfo::SetUse125DSFForUIScaling(false);
1548 #endif // OS_CHROMEOS