OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/display/display_manager.h" | 5 #include "ash/display/display_manager.h" |
6 | 6 |
7 #include "ash/common/material_design/material_design_controller.h" | |
7 #include "ash/accelerators/accelerator_commands.h" | 8 #include "ash/accelerators/accelerator_commands.h" |
8 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
9 #include "ash/common/wm/window_state.h" | 10 #include "ash/common/wm/window_state.h" |
10 #include "ash/display/display_configuration_controller.h" | 11 #include "ash/display/display_configuration_controller.h" |
11 #include "ash/display/display_info.h" | 12 #include "ash/display/display_info.h" |
12 #include "ash/display/display_layout_store.h" | 13 #include "ash/display/display_layout_store.h" |
13 #include "ash/display/display_util.h" | 14 #include "ash/display/display_util.h" |
14 #include "ash/display/mirror_window_controller.h" | 15 #include "ash/display/mirror_window_controller.h" |
15 #include "ash/display/window_tree_host_manager.h" | 16 #include "ash/display/window_tree_host_manager.h" |
16 #include "ash/screen_util.h" | 17 #include "ash/screen_util.h" |
17 #include "ash/shell.h" | 18 #include "ash/shell.h" |
18 #include "ash/test/ash_test_base.h" | 19 #include "ash/test/ash_test_base.h" |
19 #include "ash/test/display_manager_test_api.h" | 20 #include "ash/test/display_manager_test_api.h" |
21 #include "ash/test/material_design_controller_test_api.h" | |
20 #include "ash/test/mirror_window_test_api.h" | 22 #include "ash/test/mirror_window_test_api.h" |
21 #include "ash/wm/window_state_aura.h" | 23 #include "ash/wm/window_state_aura.h" |
22 #include "base/command_line.h" | 24 #include "base/command_line.h" |
23 #include "base/format_macros.h" | 25 #include "base/format_macros.h" |
24 #include "base/strings/string_number_conversions.h" | 26 #include "base/strings/string_number_conversions.h" |
25 #include "base/strings/stringprintf.h" | 27 #include "base/strings/stringprintf.h" |
26 #include "grit/ash_strings.h" | 28 #include "grit/ash_strings.h" |
27 #include "ui/aura/client/aura_constants.h" | 29 #include "ui/aura/client/aura_constants.h" |
28 #include "ui/aura/env.h" | 30 #include "ui/aura/env.h" |
29 #include "ui/aura/window_observer.h" | 31 #include "ui/aura/window_observer.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
44 using base::StringPrintf; | 46 using base::StringPrintf; |
45 | 47 |
46 namespace { | 48 namespace { |
47 | 49 |
48 std::string ToDisplayName(int64_t id) { | 50 std::string ToDisplayName(int64_t id) { |
49 return "x-" + base::Int64ToString(id); | 51 return "x-" + base::Int64ToString(id); |
50 } | 52 } |
51 | 53 |
52 } // namespace | 54 } // namespace |
53 | 55 |
54 class DisplayManagerTest : public test::AshTestBase, | 56 class DisplayManagerTest |
55 public display::DisplayObserver, | 57 : public test::AshTestBase, |
56 public aura::WindowObserver { | 58 public display::DisplayObserver, |
59 public aura::WindowObserver, | |
60 public testing::WithParamInterface<ash::MaterialDesignController::Mode> { | |
varkha
2016/06/16 02:55:05
Here and in other fixtures that inherit from testi
James Cook
2016/06/16 16:08:56
+1
tdanderson
2016/06/21 19:52:20
Done.
| |
57 public: | 61 public: |
58 DisplayManagerTest() | 62 DisplayManagerTest() |
59 : removed_count_(0U), | 63 : removed_count_(0U), |
60 root_window_destroyed_(false), | 64 root_window_destroyed_(false), |
61 changed_metrics_(0U) { | 65 changed_metrics_(0U), |
66 md_docked_window_height_offset_(0) { | |
62 } | 67 } |
63 ~DisplayManagerTest() override {} | 68 ~DisplayManagerTest() override {} |
64 | 69 |
65 void SetUp() override { | 70 void SetUp() override { |
66 AshTestBase::SetUp(); | 71 AshTestBase::SetUp(); |
72 material_design_state_.reset( | |
73 new test::MaterialDesignControllerTestAPI(GetParam())); | |
74 md_docked_window_height_offset_ = | |
75 ash::MaterialDesignController::IsMaterial() ? -1 : 0; | |
67 display::Screen::GetScreen()->AddObserver(this); | 76 display::Screen::GetScreen()->AddObserver(this); |
68 Shell::GetPrimaryRootWindow()->AddObserver(this); | 77 Shell::GetPrimaryRootWindow()->AddObserver(this); |
69 } | 78 } |
70 void TearDown() override { | 79 void TearDown() override { |
71 Shell::GetPrimaryRootWindow()->RemoveObserver(this); | 80 Shell::GetPrimaryRootWindow()->RemoveObserver(this); |
72 display::Screen::GetScreen()->RemoveObserver(this); | 81 display::Screen::GetScreen()->RemoveObserver(this); |
82 material_design_state_.reset(); | |
73 AshTestBase::TearDown(); | 83 AshTestBase::TearDown(); |
74 } | 84 } |
75 | 85 |
76 DisplayManager* display_manager() { | 86 DisplayManager* display_manager() { |
77 return Shell::GetInstance()->display_manager(); | 87 return Shell::GetInstance()->display_manager(); |
78 } | 88 } |
79 const vector<display::Display>& changed() const { return changed_; } | 89 const vector<display::Display>& changed() const { return changed_; } |
80 const vector<display::Display>& added() const { return added_; } | 90 const vector<display::Display>& added() const { return added_; } |
81 uint32_t changed_metrics() const { return changed_metrics_; } | 91 uint32_t changed_metrics() const { return changed_metrics_; } |
82 | 92 |
(...skipping 23 matching lines...) Expand all Loading... | |
106 } | 116 } |
107 | 117 |
108 const display::Display& GetDisplayForId(int64_t id) { | 118 const display::Display& GetDisplayForId(int64_t id) { |
109 return display_manager()->GetDisplayForId(id); | 119 return display_manager()->GetDisplayForId(id); |
110 } | 120 } |
111 | 121 |
112 const DisplayInfo& GetDisplayInfoForId(int64_t id) { | 122 const DisplayInfo& GetDisplayInfoForId(int64_t id) { |
113 return GetDisplayInfo(display_manager()->GetDisplayForId(id)); | 123 return GetDisplayInfo(display_manager()->GetDisplayForId(id)); |
114 } | 124 } |
115 | 125 |
126 int GetMdDockedWindowHeightOffset() { | |
127 return md_docked_window_height_offset_; | |
128 } | |
129 | |
116 // aura::DisplayObserver overrides: | 130 // aura::DisplayObserver overrides: |
117 void OnDisplayMetricsChanged(const display::Display& display, | 131 void OnDisplayMetricsChanged(const display::Display& display, |
118 uint32_t changed_metrics) override { | 132 uint32_t changed_metrics) override { |
119 changed_.push_back(display); | 133 changed_.push_back(display); |
120 changed_metrics_ |= changed_metrics; | 134 changed_metrics_ |= changed_metrics; |
121 } | 135 } |
122 void OnDisplayAdded(const display::Display& new_display) override { | 136 void OnDisplayAdded(const display::Display& new_display) override { |
123 added_.push_back(new_display); | 137 added_.push_back(new_display); |
124 } | 138 } |
125 void OnDisplayRemoved(const display::Display& old_display) override { | 139 void OnDisplayRemoved(const display::Display& old_display) override { |
126 ++removed_count_; | 140 ++removed_count_; |
127 } | 141 } |
128 | 142 |
129 // aura::WindowObserver overrides: | 143 // aura::WindowObserver overrides: |
130 void OnWindowDestroying(aura::Window* window) override { | 144 void OnWindowDestroying(aura::Window* window) override { |
131 ASSERT_EQ(Shell::GetPrimaryRootWindow(), window); | 145 ASSERT_EQ(Shell::GetPrimaryRootWindow(), window); |
132 root_window_destroyed_ = true; | 146 root_window_destroyed_ = true; |
133 } | 147 } |
134 | 148 |
135 private: | 149 private: |
136 vector<display::Display> changed_; | 150 vector<display::Display> changed_; |
137 vector<display::Display> added_; | 151 vector<display::Display> added_; |
138 size_t removed_count_; | 152 size_t removed_count_; |
139 bool root_window_destroyed_; | 153 bool root_window_destroyed_; |
140 uint32_t changed_metrics_; | 154 uint32_t changed_metrics_; |
155 std::unique_ptr<test::MaterialDesignControllerTestAPI> | |
156 material_design_state_; | |
157 | |
158 // The material design shelf is taller (by 1px) so use this offset to | |
159 // adjust the expected height of a docked window. | |
160 int md_docked_window_height_offset_; | |
141 | 161 |
142 DISALLOW_COPY_AND_ASSIGN(DisplayManagerTest); | 162 DISALLOW_COPY_AND_ASSIGN(DisplayManagerTest); |
143 }; | 163 }; |
144 | 164 |
145 TEST_F(DisplayManagerTest, UpdateDisplayTest) { | 165 // Note: First argument is optional and intentionally left blank. |
166 // (it's a prefix for the generated test cases) | |
167 INSTANTIATE_TEST_CASE_P( | |
168 , | |
169 DisplayManagerTest, | |
170 testing::Values(ash::MaterialDesignController::NON_MATERIAL, | |
171 ash::MaterialDesignController::MATERIAL_NORMAL, | |
172 ash::MaterialDesignController::MATERIAL_EXPERIMENTAL)); | |
173 | |
174 TEST_P(DisplayManagerTest, UpdateDisplayTest) { | |
146 if (!SupportsMultipleDisplays()) | 175 if (!SupportsMultipleDisplays()) |
147 return; | 176 return; |
148 | 177 |
149 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 178 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
150 | 179 |
151 // Update primary and add seconary. | 180 // Update primary and add seconary. |
152 UpdateDisplay("100+0-500x500,0+501-400x400"); | 181 UpdateDisplay("100+0-500x500,0+501-400x400"); |
153 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); | 182 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); |
154 EXPECT_EQ("0,0 500x500", | 183 EXPECT_EQ("0,0 500x500", |
155 display_manager()->GetDisplayAt(0).bounds().ToString()); | 184 display_manager()->GetDisplayAt(0).bounds().ToString()); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
237 // Changing primary will update secondary as well. | 266 // Changing primary will update secondary as well. |
238 UpdateDisplay("0+0-800x600,1000+1000-600x400"); | 267 UpdateDisplay("0+0-800x600,1000+1000-600x400"); |
239 EXPECT_EQ("2 0 0", GetCountSummary()); | 268 EXPECT_EQ("2 0 0", GetCountSummary()); |
240 reset(); | 269 reset(); |
241 EXPECT_EQ("0,0 800x600", | 270 EXPECT_EQ("0,0 800x600", |
242 display_manager()->GetDisplayAt(0).bounds().ToString()); | 271 display_manager()->GetDisplayAt(0).bounds().ToString()); |
243 EXPECT_EQ("800,0 600x400", | 272 EXPECT_EQ("800,0 600x400", |
244 display_manager()->GetDisplayAt(1).bounds().ToString()); | 273 display_manager()->GetDisplayAt(1).bounds().ToString()); |
245 } | 274 } |
246 | 275 |
247 TEST_F(DisplayManagerTest, ScaleOnlyChange) { | 276 TEST_P(DisplayManagerTest, ScaleOnlyChange) { |
248 if (!SupportsMultipleDisplays()) | 277 if (!SupportsMultipleDisplays()) |
249 return; | 278 return; |
250 display_manager()->ToggleDisplayScaleFactor(); | 279 display_manager()->ToggleDisplayScaleFactor(); |
251 EXPECT_TRUE(changed_metrics() & | 280 EXPECT_TRUE(changed_metrics() & |
252 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); | 281 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); |
253 EXPECT_TRUE(changed_metrics() & | 282 EXPECT_TRUE(changed_metrics() & |
254 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); | 283 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); |
255 } | 284 } |
256 | 285 |
257 // Test in emulation mode (use_fullscreen_host_window=false) | 286 // Test in emulation mode (use_fullscreen_host_window=false) |
258 TEST_F(DisplayManagerTest, EmulatorTest) { | 287 TEST_P(DisplayManagerTest, EmulatorTest) { |
259 if (!SupportsMultipleDisplays()) | 288 if (!SupportsMultipleDisplays()) |
260 return; | 289 return; |
261 | 290 |
262 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 291 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
263 | 292 |
264 display_manager()->AddRemoveDisplay(); | 293 display_manager()->AddRemoveDisplay(); |
265 // Update primary and add seconary. | 294 // Update primary and add seconary. |
266 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); | 295 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); |
267 EXPECT_EQ("0 1 0", GetCountSummary()); | 296 EXPECT_EQ("0 1 0", GetCountSummary()); |
268 reset(); | 297 reset(); |
269 | 298 |
270 display_manager()->AddRemoveDisplay(); | 299 display_manager()->AddRemoveDisplay(); |
271 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 300 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
272 EXPECT_EQ("0 0 1", GetCountSummary()); | 301 EXPECT_EQ("0 0 1", GetCountSummary()); |
273 reset(); | 302 reset(); |
274 | 303 |
275 display_manager()->AddRemoveDisplay(); | 304 display_manager()->AddRemoveDisplay(); |
276 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); | 305 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); |
277 EXPECT_EQ("0 1 0", GetCountSummary()); | 306 EXPECT_EQ("0 1 0", GetCountSummary()); |
278 } | 307 } |
279 | 308 |
280 // Tests support for 3 displays. | 309 // Tests support for 3 displays. |
281 TEST_F(DisplayManagerTest, UpdateThreeDisplaysWithDefaultLayout) { | 310 TEST_P(DisplayManagerTest, UpdateThreeDisplaysWithDefaultLayout) { |
282 if (!SupportsMultipleDisplays()) | 311 if (!SupportsMultipleDisplays()) |
283 return; | 312 return; |
284 | 313 |
285 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 314 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
286 | 315 |
287 // Test with three displays. Native origin will not affect ash | 316 // Test with three displays. Native origin will not affect ash |
288 // display layout. | 317 // display layout. |
289 UpdateDisplay("0+0-640x480,1000+0-320x200,2000+0-400x300"); | 318 UpdateDisplay("0+0-640x480,1000+0-320x200,2000+0-400x300"); |
290 | 319 |
291 EXPECT_EQ(3U, display_manager()->GetNumDisplays()); | 320 EXPECT_EQ(3U, display_manager()->GetNumDisplays()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
329 UpdateDisplay("640x480,320x200,400x300"); | 358 UpdateDisplay("640x480,320x200,400x300"); |
330 | 359 |
331 EXPECT_EQ("0,0 640x480", | 360 EXPECT_EQ("0,0 640x480", |
332 display_manager()->GetDisplayAt(0).bounds().ToString()); | 361 display_manager()->GetDisplayAt(0).bounds().ToString()); |
333 EXPECT_EQ("10,480 320x200", | 362 EXPECT_EQ("10,480 320x200", |
334 display_manager()->GetDisplayAt(1).bounds().ToString()); | 363 display_manager()->GetDisplayAt(1).bounds().ToString()); |
335 EXPECT_EQ("20,680 400x300", | 364 EXPECT_EQ("20,680 400x300", |
336 display_manager()->GetDisplayAt(2).bounds().ToString()); | 365 display_manager()->GetDisplayAt(2).bounds().ToString()); |
337 } | 366 } |
338 | 367 |
339 TEST_F(DisplayManagerTest, LayoutMorethanThreeDisplaysTest) { | 368 TEST_P(DisplayManagerTest, LayoutMorethanThreeDisplaysTest) { |
340 if (!SupportsMultipleDisplays()) | 369 if (!SupportsMultipleDisplays()) |
341 return; | 370 return; |
342 | 371 |
343 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 372 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
344 display::DisplayIdList list = ash::test::CreateDisplayIdListN( | 373 display::DisplayIdList list = ash::test::CreateDisplayIdListN( |
345 3, primary_id, primary_id + 1, primary_id + 2); | 374 3, primary_id, primary_id + 1, primary_id + 2); |
346 { | 375 { |
347 // Layout: [2] | 376 // Layout: [2] |
348 // [1][P] | 377 // [1][P] |
349 display::DisplayLayoutBuilder builder(primary_id); | 378 display::DisplayLayoutBuilder builder(primary_id); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
444 display_manager()->GetDisplayAt(4).bounds().ToString()); | 473 display_manager()->GetDisplayAt(4).bounds().ToString()); |
445 // 3rd is the left of 4th. | 474 // 3rd is the left of 4th. |
446 EXPECT_EQ("-290,480 300x200", | 475 EXPECT_EQ("-290,480 300x200", |
447 display_manager()->GetDisplayAt(3).bounds().ToString()); | 476 display_manager()->GetDisplayAt(3).bounds().ToString()); |
448 // 1st is the bottom of 3rd. | 477 // 1st is the bottom of 3rd. |
449 EXPECT_EQ("-280,680 320x200", | 478 EXPECT_EQ("-280,680 320x200", |
450 display_manager()->GetDisplayAt(1).bounds().ToString()); | 479 display_manager()->GetDisplayAt(1).bounds().ToString()); |
451 } | 480 } |
452 } | 481 } |
453 | 482 |
454 TEST_F(DisplayManagerTest, NoMirrorInThreeDisplays) { | 483 TEST_P(DisplayManagerTest, NoMirrorInThreeDisplays) { |
455 if (!SupportsMultipleDisplays()) | 484 if (!SupportsMultipleDisplays()) |
456 return; | 485 return; |
457 | 486 |
458 UpdateDisplay("640x480,320x200,400x300"); | 487 UpdateDisplay("640x480,320x200,400x300"); |
459 ash::Shell::GetInstance()->display_configuration_controller()->SetMirrorMode( | 488 ash::Shell::GetInstance()->display_configuration_controller()->SetMirrorMode( |
460 true, true); | 489 true, true); |
461 EXPECT_FALSE(display_manager()->IsInMirrorMode()); | 490 EXPECT_FALSE(display_manager()->IsInMirrorMode()); |
462 EXPECT_EQ(3u, display_manager()->GetNumDisplays()); | 491 EXPECT_EQ(3u, display_manager()->GetNumDisplays()); |
463 #if defined(OS_CHROMEOS) | 492 #if defined(OS_CHROMEOS) |
464 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_MIRRORING_NOT_SUPPORTED), | 493 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_MIRRORING_NOT_SUPPORTED), |
465 GetDisplayErrorNotificationMessageForTest()); | 494 GetDisplayErrorNotificationMessageForTest()); |
466 #endif | 495 #endif |
467 } | 496 } |
468 | 497 |
469 TEST_F(DisplayManagerTest, OverscanInsetsTest) { | 498 TEST_P(DisplayManagerTest, OverscanInsetsTest) { |
470 if (!SupportsMultipleDisplays()) | 499 if (!SupportsMultipleDisplays()) |
471 return; | 500 return; |
472 | 501 |
473 UpdateDisplay("0+0-500x500,0+501-400x400"); | 502 UpdateDisplay("0+0-500x500,0+501-400x400"); |
474 reset(); | 503 reset(); |
475 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); | 504 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); |
476 const DisplayInfo& display_info1 = GetDisplayInfoAt(0); | 505 const DisplayInfo& display_info1 = GetDisplayInfoAt(0); |
477 const DisplayInfo& display_info2 = GetDisplayInfoAt(1); | 506 const DisplayInfo& display_info2 = GetDisplayInfoAt(1); |
478 display_manager()->SetOverscanInsets( | 507 display_manager()->SetOverscanInsets( |
479 display_info2.id(), gfx::Insets(13, 12, 11, 10)); | 508 display_info2.id(), gfx::Insets(13, 12, 11, 10)); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
592 display_manager()->SetOverscanInsets(primary_id, gfx::Insets(0, 0, 0, 0)); | 621 display_manager()->SetOverscanInsets(primary_id, gfx::Insets(0, 0, 0, 0)); |
593 EXPECT_TRUE(changed_metrics() & | 622 EXPECT_TRUE(changed_metrics() & |
594 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); | 623 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); |
595 EXPECT_TRUE(changed_metrics() & | 624 EXPECT_TRUE(changed_metrics() & |
596 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); | 625 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); |
597 EXPECT_EQ( | 626 EXPECT_EQ( |
598 "0,0 500x500", | 627 "0,0 500x500", |
599 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString()); | 628 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString()); |
600 } | 629 } |
601 | 630 |
602 TEST_F(DisplayManagerTest, ZeroOverscanInsets) { | 631 TEST_P(DisplayManagerTest, ZeroOverscanInsets) { |
603 if (!SupportsMultipleDisplays()) | 632 if (!SupportsMultipleDisplays()) |
604 return; | 633 return; |
605 | 634 |
606 // Make sure the display change events is emitted for overscan inset changes. | 635 // Make sure the display change events is emitted for overscan inset changes. |
607 UpdateDisplay("0+0-500x500,0+501-400x400"); | 636 UpdateDisplay("0+0-500x500,0+501-400x400"); |
608 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); | 637 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); |
609 int64_t display2_id = display_manager()->GetDisplayAt(1).id(); | 638 int64_t display2_id = display_manager()->GetDisplayAt(1).id(); |
610 | 639 |
611 reset(); | 640 reset(); |
612 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0)); | 641 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0)); |
613 EXPECT_EQ(0u, changed().size()); | 642 EXPECT_EQ(0u, changed().size()); |
614 | 643 |
615 reset(); | 644 reset(); |
616 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(1, 0, 0, 0)); | 645 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(1, 0, 0, 0)); |
617 EXPECT_EQ(1u, changed().size()); | 646 EXPECT_EQ(1u, changed().size()); |
618 EXPECT_EQ(display2_id, changed()[0].id()); | 647 EXPECT_EQ(display2_id, changed()[0].id()); |
619 | 648 |
620 reset(); | 649 reset(); |
621 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0)); | 650 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0)); |
622 EXPECT_EQ(1u, changed().size()); | 651 EXPECT_EQ(1u, changed().size()); |
623 EXPECT_EQ(display2_id, changed()[0].id()); | 652 EXPECT_EQ(display2_id, changed()[0].id()); |
624 } | 653 } |
625 | 654 |
626 TEST_F(DisplayManagerTest, TestDeviceScaleOnlyChange) { | 655 TEST_P(DisplayManagerTest, TestDeviceScaleOnlyChange) { |
627 if (!SupportsHostWindowResize()) | 656 if (!SupportsHostWindowResize()) |
628 return; | 657 return; |
629 | 658 |
630 UpdateDisplay("1000x600"); | 659 UpdateDisplay("1000x600"); |
631 aura::WindowTreeHost* host = Shell::GetPrimaryRootWindow()->GetHost(); | 660 aura::WindowTreeHost* host = Shell::GetPrimaryRootWindow()->GetHost(); |
632 EXPECT_EQ(1, host->compositor()->device_scale_factor()); | 661 EXPECT_EQ(1, host->compositor()->device_scale_factor()); |
633 EXPECT_EQ("1000x600", | 662 EXPECT_EQ("1000x600", |
634 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); | 663 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); |
635 EXPECT_EQ("1 0 0", GetCountSummary()); | 664 EXPECT_EQ("1 0 0", GetCountSummary()); |
636 | 665 |
637 UpdateDisplay("1000x600*2"); | 666 UpdateDisplay("1000x600*2"); |
638 EXPECT_EQ(2, host->compositor()->device_scale_factor()); | 667 EXPECT_EQ(2, host->compositor()->device_scale_factor()); |
639 EXPECT_EQ("2 0 0", GetCountSummary()); | 668 EXPECT_EQ("2 0 0", GetCountSummary()); |
640 EXPECT_EQ("500x300", | 669 EXPECT_EQ("500x300", |
641 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); | 670 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); |
642 } | 671 } |
643 | 672 |
644 DisplayInfo CreateDisplayInfo(int64_t id, const gfx::Rect& bounds) { | 673 DisplayInfo CreateDisplayInfo(int64_t id, const gfx::Rect& bounds) { |
645 DisplayInfo info(id, ToDisplayName(id), false); | 674 DisplayInfo info(id, ToDisplayName(id), false); |
646 info.SetBounds(bounds); | 675 info.SetBounds(bounds); |
647 return info; | 676 return info; |
648 } | 677 } |
649 | 678 |
650 TEST_F(DisplayManagerTest, TestNativeDisplaysChanged) { | 679 TEST_P(DisplayManagerTest, TestNativeDisplaysChanged) { |
651 const int64_t internal_display_id = | 680 const int64_t internal_display_id = |
652 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); | 681 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); |
653 const int external_id = 10; | 682 const int external_id = 10; |
654 const int mirror_id = 11; | 683 const int mirror_id = 11; |
655 const int64_t invalid_id = display::Display::kInvalidDisplayID; | 684 const int64_t invalid_id = display::Display::kInvalidDisplayID; |
656 const DisplayInfo internal_display_info = | 685 const DisplayInfo internal_display_info = |
657 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); | 686 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); |
658 const DisplayInfo external_display_info = | 687 const DisplayInfo external_display_info = |
659 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); | 688 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); |
660 const DisplayInfo mirroring_display_info = | 689 const DisplayInfo mirroring_display_info = |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
808 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 837 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
809 EXPECT_EQ( | 838 EXPECT_EQ( |
810 "0,0 500x500", | 839 "0,0 500x500", |
811 GetDisplayInfoForId(internal_display_id).bounds_in_native().ToString()); | 840 GetDisplayInfoForId(internal_display_id).bounds_in_native().ToString()); |
812 EXPECT_EQ(1U, display_manager()->num_connected_displays()); | 841 EXPECT_EQ(1U, display_manager()->num_connected_displays()); |
813 EXPECT_FALSE(display_manager()->IsInMirrorMode()); | 842 EXPECT_FALSE(display_manager()->IsInMirrorMode()); |
814 } | 843 } |
815 | 844 |
816 // Make sure crash does not happen if add and remove happens at the same time. | 845 // Make sure crash does not happen if add and remove happens at the same time. |
817 // See: crbug.com/414394 | 846 // See: crbug.com/414394 |
818 TEST_F(DisplayManagerTest, DisplayAddRemoveAtTheSameTime) { | 847 TEST_P(DisplayManagerTest, DisplayAddRemoveAtTheSameTime) { |
819 if (!SupportsMultipleDisplays()) | 848 if (!SupportsMultipleDisplays()) |
820 return; | 849 return; |
821 | 850 |
822 UpdateDisplay("100+0-500x500,0+501-400x400"); | 851 UpdateDisplay("100+0-500x500,0+501-400x400"); |
823 | 852 |
824 const int64_t primary_id = WindowTreeHostManager::GetPrimaryDisplayId(); | 853 const int64_t primary_id = WindowTreeHostManager::GetPrimaryDisplayId(); |
825 const int64_t secondary_id = ScreenUtil::GetSecondaryDisplay().id(); | 854 const int64_t secondary_id = ScreenUtil::GetSecondaryDisplay().id(); |
826 | 855 |
827 DisplayInfo primary_info = display_manager()->GetDisplayInfo(primary_id); | 856 DisplayInfo primary_info = display_manager()->GetDisplayInfo(primary_id); |
828 DisplayInfo secondary_info = display_manager()->GetDisplayInfo(secondary_id); | 857 DisplayInfo secondary_info = display_manager()->GetDisplayInfo(secondary_id); |
829 | 858 |
830 // An id which is different from primary and secondary. | 859 // An id which is different from primary and secondary. |
831 const int64_t third_id = secondary_id + 1; | 860 const int64_t third_id = secondary_id + 1; |
832 | 861 |
833 DisplayInfo third_info = | 862 DisplayInfo third_info = |
834 CreateDisplayInfo(third_id, gfx::Rect(0, 0, 600, 600)); | 863 CreateDisplayInfo(third_id, gfx::Rect(0, 0, 600, 600)); |
835 | 864 |
836 std::vector<DisplayInfo> display_info_list; | 865 std::vector<DisplayInfo> display_info_list; |
837 display_info_list.push_back(third_info); | 866 display_info_list.push_back(third_info); |
838 display_info_list.push_back(secondary_info); | 867 display_info_list.push_back(secondary_info); |
839 display_manager()->OnNativeDisplaysChanged(display_info_list); | 868 display_manager()->OnNativeDisplaysChanged(display_info_list); |
840 | 869 |
841 // Secondary seconary_id becomes the primary as it has smaller output index. | 870 // Secondary seconary_id becomes the primary as it has smaller output index. |
842 EXPECT_EQ(secondary_id, WindowTreeHostManager::GetPrimaryDisplayId()); | 871 EXPECT_EQ(secondary_id, WindowTreeHostManager::GetPrimaryDisplayId()); |
843 EXPECT_EQ(third_id, ScreenUtil::GetSecondaryDisplay().id()); | 872 EXPECT_EQ(third_id, ScreenUtil::GetSecondaryDisplay().id()); |
844 EXPECT_EQ("600x600", GetDisplayForId(third_id).size().ToString()); | 873 EXPECT_EQ("600x600", GetDisplayForId(third_id).size().ToString()); |
845 } | 874 } |
846 | 875 |
847 #if defined(OS_WIN) | |
848 // TODO(scottmg): RootWindow doesn't get resized on Windows | 876 // TODO(scottmg): RootWindow doesn't get resized on Windows |
849 // Ash. http://crbug.com/247916. | 877 // Ash. http://crbug.com/247916. |
850 #define MAYBE_TestNativeDisplaysChangedNoInternal \ | 878 #if defined(OS_CHROMEOS) |
851 DISABLED_TestNativeDisplaysChangedNoInternal | 879 TEST_P(DisplayManagerTest, TestNativeDisplaysChangedNoInternal) { |
852 #else | |
853 #define MAYBE_TestNativeDisplaysChangedNoInternal \ | |
854 TestNativeDisplaysChangedNoInternal | |
855 #endif | |
856 TEST_F(DisplayManagerTest, MAYBE_TestNativeDisplaysChangedNoInternal) { | |
857 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 880 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
858 | 881 |
859 // Don't change the display info if all displays are disconnected. | 882 // Don't change the display info if all displays are disconnected. |
860 std::vector<DisplayInfo> display_info_list; | 883 std::vector<DisplayInfo> display_info_list; |
861 display_manager()->OnNativeDisplaysChanged(display_info_list); | 884 display_manager()->OnNativeDisplaysChanged(display_info_list); |
862 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 885 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
863 | 886 |
864 // Connect another display which will become primary. | 887 // Connect another display which will become primary. |
865 const DisplayInfo external_display_info = | 888 const DisplayInfo external_display_info = |
866 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); | 889 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); |
867 display_info_list.push_back(external_display_info); | 890 display_info_list.push_back(external_display_info); |
868 display_manager()->OnNativeDisplaysChanged(display_info_list); | 891 display_manager()->OnNativeDisplaysChanged(display_info_list); |
869 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 892 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
870 EXPECT_EQ("1,1 100x100", | 893 EXPECT_EQ("1,1 100x100", |
871 GetDisplayInfoForId(10).bounds_in_native().ToString()); | 894 GetDisplayInfoForId(10).bounds_in_native().ToString()); |
872 EXPECT_EQ("100x100", ash::Shell::GetPrimaryRootWindow()->GetHost()-> | 895 EXPECT_EQ("100x100", ash::Shell::GetPrimaryRootWindow()->GetHost()-> |
873 GetBounds().size().ToString()); | 896 GetBounds().size().ToString()); |
874 } | 897 } |
898 #endif // defined(OS_CHROMEOS) | |
875 | 899 |
876 TEST_F(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) { | 900 TEST_P(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) { |
877 if (!SupportsMultipleDisplays()) | 901 if (!SupportsMultipleDisplays()) |
878 return; | 902 return; |
879 | 903 |
880 const int64_t internal_display_id = | 904 const int64_t internal_display_id = |
881 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); | 905 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); |
882 const DisplayInfo native_display_info = | 906 const DisplayInfo native_display_info = |
883 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); | 907 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); |
884 const DisplayInfo secondary_display_info = | 908 const DisplayInfo secondary_display_info = |
885 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); | 909 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); |
886 | 910 |
(...skipping 13 matching lines...) Expand all Loading... | |
900 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString()); | 924 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString()); |
901 | 925 |
902 // OnNativeDisplaysChanged may change the display bounds. Here makes sure | 926 // OnNativeDisplaysChanged may change the display bounds. Here makes sure |
903 // nothing changed if the exactly same displays are specified. | 927 // nothing changed if the exactly same displays are specified. |
904 display_manager()->OnNativeDisplaysChanged(display_info_list); | 928 display_manager()->OnNativeDisplaysChanged(display_info_list); |
905 EXPECT_EQ("-500,0 500x500", | 929 EXPECT_EQ("-500,0 500x500", |
906 GetDisplayForId(internal_display_id).bounds().ToString()); | 930 GetDisplayForId(internal_display_id).bounds().ToString()); |
907 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString()); | 931 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString()); |
908 } | 932 } |
909 | 933 |
910 #if defined(OS_WIN) | |
911 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 934 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
912 #define MAYBE_DontRememberBestResolution DISABLED_DontRememberBestResolution | 935 #if defined(OS_CHROMEOS) |
913 #else | 936 TEST_P(DisplayManagerTest, DontRememberBestResolution) { |
914 #define MAYBE_DontRememberBestResolution DontRememberBestResolution | |
915 #endif | |
916 TEST_F(DisplayManagerTest, MAYBE_DontRememberBestResolution) { | |
917 int display_id = 1000; | 937 int display_id = 1000; |
918 DisplayInfo native_display_info = | 938 DisplayInfo native_display_info = |
919 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); | 939 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); |
920 std::vector<DisplayMode> display_modes; | 940 std::vector<DisplayMode> display_modes; |
921 display_modes.push_back( | 941 display_modes.push_back( |
922 DisplayMode(gfx::Size(1000, 500), 58.0f, false, true)); | 942 DisplayMode(gfx::Size(1000, 500), 58.0f, false, true)); |
923 display_modes.push_back( | 943 display_modes.push_back( |
924 DisplayMode(gfx::Size(800, 300), 59.0f, false, false)); | 944 DisplayMode(gfx::Size(800, 300), 59.0f, false, false)); |
925 display_modes.push_back( | 945 display_modes.push_back( |
926 DisplayMode(gfx::Size(400, 500), 60.0f, false, false)); | 946 DisplayMode(gfx::Size(400, 500), 60.0f, false, false)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
961 test::SetDisplayResolution(display_id, gfx::Size(1000, 500)); | 981 test::SetDisplayResolution(display_id, gfx::Size(1000, 500)); |
962 EXPECT_TRUE( | 982 EXPECT_TRUE( |
963 display_manager()->GetSelectedModeForDisplayId(display_id, &mode)); | 983 display_manager()->GetSelectedModeForDisplayId(display_id, &mode)); |
964 EXPECT_EQ("1000x500", mode.size.ToString()); | 984 EXPECT_EQ("1000x500", mode.size.ToString()); |
965 EXPECT_EQ(58.0f, mode.refresh_rate); | 985 EXPECT_EQ(58.0f, mode.refresh_rate); |
966 EXPECT_TRUE(mode.native); | 986 EXPECT_TRUE(mode.native); |
967 expected_mode.size = gfx::Size(1000, 500); | 987 expected_mode.size = gfx::Size(1000, 500); |
968 EXPECT_TRUE(expected_mode.IsEquivalent( | 988 EXPECT_TRUE(expected_mode.IsEquivalent( |
969 display_manager()->GetActiveModeForDisplayId(display_id))); | 989 display_manager()->GetActiveModeForDisplayId(display_id))); |
970 } | 990 } |
991 #endif // defined(OS_CHROMEOS) | |
971 | 992 |
972 #if defined(OS_WIN) | |
973 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 993 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
974 #define MAYBE_ResolutionFallback DISABLED_ResolutionFallback | 994 #if defined(OS_CHROMEOS) |
975 #else | 995 TEST_P(DisplayManagerTest, ResolutionFallback) { |
976 #define MAYBE_ResolutionFallback ResolutionFallback | |
977 #endif | |
978 TEST_F(DisplayManagerTest, MAYBE_ResolutionFallback) { | |
979 int display_id = 1000; | 996 int display_id = 1000; |
980 DisplayInfo native_display_info = | 997 DisplayInfo native_display_info = |
981 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); | 998 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); |
982 std::vector<DisplayMode> display_modes; | 999 std::vector<DisplayMode> display_modes; |
983 display_modes.push_back( | 1000 display_modes.push_back( |
984 DisplayMode(gfx::Size(1000, 500), 58.0f, false, true)); | 1001 DisplayMode(gfx::Size(1000, 500), 58.0f, false, true)); |
985 display_modes.push_back( | 1002 display_modes.push_back( |
986 DisplayMode(gfx::Size(800, 300), 59.0f, false, false)); | 1003 DisplayMode(gfx::Size(800, 300), 59.0f, false, false)); |
987 display_modes.push_back( | 1004 display_modes.push_back( |
988 DisplayMode(gfx::Size(400, 500), 60.0f, false, false)); | 1005 DisplayMode(gfx::Size(400, 500), 60.0f, false, false)); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1022 display_manager()->OnNativeDisplaysChanged(new_display_info_list); | 1039 display_manager()->OnNativeDisplaysChanged(new_display_info_list); |
1023 | 1040 |
1024 DisplayMode mode; | 1041 DisplayMode mode; |
1025 EXPECT_TRUE( | 1042 EXPECT_TRUE( |
1026 display_manager()->GetSelectedModeForDisplayId(display_id, &mode)); | 1043 display_manager()->GetSelectedModeForDisplayId(display_id, &mode)); |
1027 EXPECT_EQ("1000x500", mode.size.ToString()); | 1044 EXPECT_EQ("1000x500", mode.size.ToString()); |
1028 EXPECT_EQ(58.0f, mode.refresh_rate); | 1045 EXPECT_EQ(58.0f, mode.refresh_rate); |
1029 EXPECT_TRUE(mode.native); | 1046 EXPECT_TRUE(mode.native); |
1030 } | 1047 } |
1031 } | 1048 } |
1049 #endif // defined(OS_CHROMEOS) | |
1032 | 1050 |
1033 TEST_F(DisplayManagerTest, Rotate) { | 1051 TEST_P(DisplayManagerTest, Rotate) { |
1034 if (!SupportsMultipleDisplays()) | 1052 if (!SupportsMultipleDisplays()) |
1035 return; | 1053 return; |
1036 | 1054 |
1037 UpdateDisplay("100x200/r,300x400/l"); | 1055 UpdateDisplay("100x200/r,300x400/l"); |
1038 EXPECT_EQ("1,1 100x200", | 1056 EXPECT_EQ("1,1 100x200", |
1039 GetDisplayInfoAt(0).bounds_in_native().ToString()); | 1057 GetDisplayInfoAt(0).bounds_in_native().ToString()); |
1040 EXPECT_EQ("200x100", | 1058 EXPECT_EQ("200x100", |
1041 GetDisplayInfoAt(0).size_in_pixel().ToString()); | 1059 GetDisplayInfoAt(0).size_in_pixel().ToString()); |
1042 | 1060 |
1043 EXPECT_EQ("1,201 300x400", | 1061 EXPECT_EQ("1,201 300x400", |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1115 display_manager()->SetDisplayRotation( | 1133 display_manager()->SetDisplayRotation( |
1116 internal_display_id, display::Display::ROTATE_180, | 1134 internal_display_id, display::Display::ROTATE_180, |
1117 display::Display::ROTATION_SOURCE_ACTIVE); | 1135 display::Display::ROTATION_SOURCE_ACTIVE); |
1118 const DisplayInfo post_rotation_info = | 1136 const DisplayInfo post_rotation_info = |
1119 display_manager()->display_info_[internal_display_id]; | 1137 display_manager()->display_info_[internal_display_id]; |
1120 EXPECT_NE(info.GetActiveRotation(), post_rotation_info.GetActiveRotation()); | 1138 EXPECT_NE(info.GetActiveRotation(), post_rotation_info.GetActiveRotation()); |
1121 EXPECT_EQ(display::Display::ROTATE_180, | 1139 EXPECT_EQ(display::Display::ROTATE_180, |
1122 post_rotation_info.GetActiveRotation()); | 1140 post_rotation_info.GetActiveRotation()); |
1123 } | 1141 } |
1124 | 1142 |
1125 #if defined(OS_WIN) | |
1126 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 1143 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
1127 #define MAYBE_UIScale DISABLED_UIScale | 1144 #if defined(OS_CHROMEOS) |
1128 #else | 1145 TEST_P(DisplayManagerTest, UIScale) { |
1129 #define MAYBE_UIScale UIScale | |
1130 #endif | |
1131 TEST_F(DisplayManagerTest, MAYBE_UIScale) { | |
1132 test::ScopedDisable125DSFForUIScaling disable; | 1146 test::ScopedDisable125DSFForUIScaling disable; |
1133 | 1147 |
1134 UpdateDisplay("1280x800"); | 1148 UpdateDisplay("1280x800"); |
1135 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 1149 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
1136 SetDisplayUIScale(display_id, 1.125f); | 1150 SetDisplayUIScale(display_id, 1.125f); |
1137 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale()); | 1151 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale()); |
1138 SetDisplayUIScale(display_id, 0.8f); | 1152 SetDisplayUIScale(display_id, 0.8f); |
1139 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); | 1153 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); |
1140 SetDisplayUIScale(display_id, 0.75f); | 1154 SetDisplayUIScale(display_id, 0.75f); |
1141 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); | 1155 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1214 // 1.25 ui scaling on 1.25 DSF device should use 1.0 DSF | 1228 // 1.25 ui scaling on 1.25 DSF device should use 1.0 DSF |
1215 // on screen. | 1229 // on screen. |
1216 UpdateDisplay("1280x850*1.25"); | 1230 UpdateDisplay("1280x850*1.25"); |
1217 SetDisplayUIScale(display_id, 1.25f); | 1231 SetDisplayUIScale(display_id, 1.25f); |
1218 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).configured_ui_scale()); | 1232 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).configured_ui_scale()); |
1219 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); | 1233 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); |
1220 display = display::Screen::GetScreen()->GetPrimaryDisplay(); | 1234 display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
1221 EXPECT_EQ(1.0f, display.device_scale_factor()); | 1235 EXPECT_EQ(1.0f, display.device_scale_factor()); |
1222 EXPECT_EQ("1280x850", display.bounds().size().ToString()); | 1236 EXPECT_EQ("1280x850", display.bounds().size().ToString()); |
1223 } | 1237 } |
1238 #endif // defined(OS_CHROMEOS) | |
1224 | 1239 |
1225 TEST_F(DisplayManagerTest, UIScaleWithDisplayMode) { | 1240 TEST_P(DisplayManagerTest, UIScaleWithDisplayMode) { |
1226 int display_id = 1000; | 1241 int display_id = 1000; |
1227 | 1242 |
1228 // Setup the display modes with UI-scale. | 1243 // Setup the display modes with UI-scale. |
1229 DisplayInfo native_display_info = | 1244 DisplayInfo native_display_info = |
1230 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1280, 800)); | 1245 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1280, 800)); |
1231 const DisplayMode base_mode(gfx::Size(1280, 800), 60.0f, false, false); | 1246 const DisplayMode base_mode(gfx::Size(1280, 800), 60.0f, false, false); |
1232 std::vector<DisplayMode> mode_list = CreateInternalDisplayModeList(base_mode); | 1247 std::vector<DisplayMode> mode_list = CreateInternalDisplayModeList(base_mode); |
1233 native_display_info.SetDisplayModes(mode_list); | 1248 native_display_info.SetDisplayModes(mode_list); |
1234 | 1249 |
1235 std::vector<DisplayInfo> display_info_list; | 1250 std::vector<DisplayInfo> display_info_list; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1273 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); | 1288 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); |
1274 EXPECT_TRUE(expected_mode.IsEquivalent( | 1289 EXPECT_TRUE(expected_mode.IsEquivalent( |
1275 display_manager()->GetActiveModeForDisplayId(display_id))); | 1290 display_manager()->GetActiveModeForDisplayId(display_id))); |
1276 SetDisplayUIScale(display_id, 0.5f); | 1291 SetDisplayUIScale(display_id, 0.5f); |
1277 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale()); | 1292 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale()); |
1278 expected_mode.ui_scale = 0.5f; | 1293 expected_mode.ui_scale = 0.5f; |
1279 EXPECT_TRUE(expected_mode.IsEquivalent( | 1294 EXPECT_TRUE(expected_mode.IsEquivalent( |
1280 display_manager()->GetActiveModeForDisplayId(display_id))); | 1295 display_manager()->GetActiveModeForDisplayId(display_id))); |
1281 } | 1296 } |
1282 | 1297 |
1283 #if defined(OS_WIN) && !defined(USE_ASH) | |
1284 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 1298 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
1285 #define MAYBE_Use125DSFForUIScaling DISABLED_Use125DSFForUIScaling | 1299 #if defined(OS_CHROMEOS) |
1286 #else | 1300 TEST_P(DisplayManagerTest, Use125DSFForUIScaling) { |
1287 #define MAYBE_Use125DSFForUIScaling Use125DSFForUIScaling | |
1288 #endif | |
1289 TEST_F(DisplayManagerTest, MAYBE_Use125DSFForUIScaling) { | |
1290 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 1301 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
1291 | 1302 |
1292 test::ScopedSetInternalDisplayId set_internal(display_id); | 1303 test::ScopedSetInternalDisplayId set_internal(display_id); |
1293 UpdateDisplay("1920x1080*1.25"); | 1304 UpdateDisplay("1920x1080*1.25"); |
1294 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); | 1305 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); |
1295 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); | 1306 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); |
1296 | 1307 |
1297 SetDisplayUIScale(display_id, 0.8f); | 1308 SetDisplayUIScale(display_id, 0.8f); |
1298 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); | 1309 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); |
1299 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); | 1310 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); |
1300 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString()); | 1311 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString()); |
1301 | 1312 |
1302 SetDisplayUIScale(display_id, 0.5f); | 1313 SetDisplayUIScale(display_id, 0.5f); |
1303 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); | 1314 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); |
1304 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).GetEffectiveUIScale()); | 1315 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).GetEffectiveUIScale()); |
1305 EXPECT_EQ("960x540", GetDisplayForId(display_id).size().ToString()); | 1316 EXPECT_EQ("960x540", GetDisplayForId(display_id).size().ToString()); |
1306 | 1317 |
1307 SetDisplayUIScale(display_id, 1.25f); | 1318 SetDisplayUIScale(display_id, 1.25f); |
1308 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); | 1319 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); |
1309 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveUIScale()); | 1320 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveUIScale()); |
1310 EXPECT_EQ("2400x1350", GetDisplayForId(display_id).size().ToString()); | 1321 EXPECT_EQ("2400x1350", GetDisplayForId(display_id).size().ToString()); |
1311 } | 1322 } |
1323 #endif // defined(OS_CHROMEOS) | |
1312 | 1324 |
1313 #if defined(OS_WIN) && !defined(USE_ASH) | |
1314 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 1325 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
1315 #define MAYBE_FHD125DefaultsTo08UIScaling DISABLED_FHD125DefaultsTo08UIScaling | 1326 #if defined(OS_CHROMEOS) |
1316 #else | 1327 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScaling) { |
1317 #define MAYBE_FHD125DefaultsTo08UIScaling FHD125DefaultsTo08UIScaling | |
1318 #endif | |
1319 TEST_F(DisplayManagerTest, MAYBE_FHD125DefaultsTo08UIScaling) { | |
1320 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 1328 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
1321 | 1329 |
1322 display_id++; | 1330 display_id++; |
1323 test::ScopedSetInternalDisplayId set_internal(display_id); | 1331 test::ScopedSetInternalDisplayId set_internal(display_id); |
1324 | 1332 |
1325 // Setup the display modes with UI-scale. | 1333 // Setup the display modes with UI-scale. |
1326 DisplayInfo native_display_info = | 1334 DisplayInfo native_display_info = |
1327 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080)); | 1335 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080)); |
1328 native_display_info.set_device_scale_factor(1.25); | 1336 native_display_info.set_device_scale_factor(1.25); |
1329 | 1337 |
1330 const DisplayMode base_mode(gfx::Size(1920, 1080), 60.0f, false, false); | 1338 const DisplayMode base_mode(gfx::Size(1920, 1080), 60.0f, false, false); |
1331 std::vector<DisplayMode> mode_list = CreateInternalDisplayModeList(base_mode); | 1339 std::vector<DisplayMode> mode_list = CreateInternalDisplayModeList(base_mode); |
1332 native_display_info.SetDisplayModes(mode_list); | 1340 native_display_info.SetDisplayModes(mode_list); |
1333 | 1341 |
1334 std::vector<DisplayInfo> display_info_list; | 1342 std::vector<DisplayInfo> display_info_list; |
1335 display_info_list.push_back(native_display_info); | 1343 display_info_list.push_back(native_display_info); |
1336 | 1344 |
1337 display_manager()->OnNativeDisplaysChanged(display_info_list); | 1345 display_manager()->OnNativeDisplaysChanged(display_info_list); |
1338 | 1346 |
1339 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); | 1347 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); |
1340 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); | 1348 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); |
1341 } | 1349 } |
1350 #endif // defined(OS_CHROMEOS) | |
1342 | 1351 |
1343 #if defined(OS_WIN) && !defined(USE_ASH) | |
1344 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 1352 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
1345 #define MAYBE_FHD125DefaultsTo08UIScalingNoOverride \ | 1353 #if defined(OS_CHROMEOS) |
1346 DISABLED_FHD125DefaultsTo08UIScalingNoOverride | |
1347 #else | |
1348 #define MAYBE_FHD125DefaultsTo08UIScalingNoOverride \ | |
1349 FHD125DefaultsTo08UIScalingNoOverride | |
1350 #endif | |
1351 // Don't default to 1.25 DSF if the user already has a prefrence stored for | 1354 // Don't default to 1.25 DSF if the user already has a prefrence stored for |
1352 // the internal display. | 1355 // the internal display. |
1353 TEST_F(DisplayManagerTest, MAYBE_FHD125DefaultsTo08UIScalingNoOverride) { | 1356 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScalingNoOverride) { |
1354 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 1357 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
1355 | 1358 |
1356 display_id++; | 1359 display_id++; |
1357 test::ScopedSetInternalDisplayId set_internal(display_id); | 1360 test::ScopedSetInternalDisplayId set_internal(display_id); |
1358 const gfx::Insets dummy_overscan_insets; | 1361 const gfx::Insets dummy_overscan_insets; |
1359 display_manager()->RegisterDisplayProperty( | 1362 display_manager()->RegisterDisplayProperty( |
1360 display_id, display::Display::ROTATE_0, 1.0f, &dummy_overscan_insets, | 1363 display_id, display::Display::ROTATE_0, 1.0f, &dummy_overscan_insets, |
1361 gfx::Size(), 1.0f, ui::ColorCalibrationProfile()); | 1364 gfx::Size(), 1.0f, ui::ColorCalibrationProfile()); |
1362 | 1365 |
1363 // Setup the display modes with UI-scale. | 1366 // Setup the display modes with UI-scale. |
1364 DisplayInfo native_display_info = | 1367 DisplayInfo native_display_info = |
1365 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080)); | 1368 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080)); |
1366 native_display_info.set_device_scale_factor(1.25); | 1369 native_display_info.set_device_scale_factor(1.25); |
1367 | 1370 |
1368 const DisplayMode base_mode(gfx::Size(1920, 1080), 60.0f, false, false); | 1371 const DisplayMode base_mode(gfx::Size(1920, 1080), 60.0f, false, false); |
1369 std::vector<DisplayMode> mode_list = CreateInternalDisplayModeList(base_mode); | 1372 std::vector<DisplayMode> mode_list = CreateInternalDisplayModeList(base_mode); |
1370 native_display_info.SetDisplayModes(mode_list); | 1373 native_display_info.SetDisplayModes(mode_list); |
1371 | 1374 |
1372 std::vector<DisplayInfo> display_info_list; | 1375 std::vector<DisplayInfo> display_info_list; |
1373 display_info_list.push_back(native_display_info); | 1376 display_info_list.push_back(native_display_info); |
1374 | 1377 |
1375 display_manager()->OnNativeDisplaysChanged(display_info_list); | 1378 display_manager()->OnNativeDisplaysChanged(display_info_list); |
1376 | 1379 |
1377 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); | 1380 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); |
1378 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); | 1381 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); |
1379 } | 1382 } |
1383 #endif // defined(OS_CHROMEOS) | |
1380 | 1384 |
1381 TEST_F(DisplayManagerTest, ResolutionChangeInUnifiedMode) { | 1385 TEST_P(DisplayManagerTest, ResolutionChangeInUnifiedMode) { |
1382 if (!SupportsMultipleDisplays()) | 1386 if (!SupportsMultipleDisplays()) |
1383 return; | 1387 return; |
1384 // Don't check root window destruction in unified mode. | 1388 // Don't check root window destruction in unified mode. |
1385 Shell::GetPrimaryRootWindow()->RemoveObserver(this); | 1389 Shell::GetPrimaryRootWindow()->RemoveObserver(this); |
1386 | 1390 |
1387 display_manager()->SetUnifiedDesktopEnabled(true); | 1391 display_manager()->SetUnifiedDesktopEnabled(true); |
1388 | 1392 |
1389 UpdateDisplay("200x200, 400x400"); | 1393 UpdateDisplay("200x200, 400x400"); |
1390 | 1394 |
1391 int64_t unified_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 1395 int64_t unified_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
(...skipping 24 matching lines...) Expand all Loading... | |
1416 UpdateDisplay("600x600, 200x200"); | 1420 UpdateDisplay("600x600, 200x200"); |
1417 EXPECT_EQ( | 1421 EXPECT_EQ( |
1418 "1200x600", | 1422 "1200x600", |
1419 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); | 1423 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); |
1420 active_mode = display_manager()->GetActiveModeForDisplayId(unified_id); | 1424 active_mode = display_manager()->GetActiveModeForDisplayId(unified_id); |
1421 EXPECT_EQ(1.0f, active_mode.ui_scale); | 1425 EXPECT_EQ(1.0f, active_mode.ui_scale); |
1422 EXPECT_TRUE(active_mode.native); | 1426 EXPECT_TRUE(active_mode.native); |
1423 EXPECT_EQ("1200x600", active_mode.size.ToString()); | 1427 EXPECT_EQ("1200x600", active_mode.size.ToString()); |
1424 } | 1428 } |
1425 | 1429 |
1426 #if defined(OS_WIN) | |
1427 // TODO(scottmg): RootWindow doesn't get resized on Windows | 1430 // TODO(scottmg): RootWindow doesn't get resized on Windows |
1428 // Ash. http://crbug.com/247916. | 1431 // Ash. http://crbug.com/247916. |
1429 #define MAYBE_UpdateMouseCursorAfterRotateZoom \ | 1432 #if defined(OS_CHROMEOS) |
1430 DISABLED_UpdateMouseCursorAfterRotateZoom | 1433 TEST_P(DisplayManagerTest, UpdateMouseCursorAfterRotateZoom) { |
1431 #else | |
1432 #define MAYBE_UpdateMouseCursorAfterRotateZoom UpdateMouseCursorAfterRotateZoom | |
1433 #endif | |
1434 TEST_F(DisplayManagerTest, MAYBE_UpdateMouseCursorAfterRotateZoom) { | |
1435 // Make sure just rotating will not change native location. | 1434 // Make sure just rotating will not change native location. |
1436 UpdateDisplay("300x200,200x150"); | 1435 UpdateDisplay("300x200,200x150"); |
1437 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1436 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
1438 aura::Env* env = aura::Env::GetInstance(); | 1437 aura::Env* env = aura::Env::GetInstance(); |
1439 | 1438 |
1440 ui::test::EventGenerator generator1(root_windows[0]); | 1439 ui::test::EventGenerator generator1(root_windows[0]); |
1441 ui::test::EventGenerator generator2(root_windows[1]); | 1440 ui::test::EventGenerator generator2(root_windows[1]); |
1442 | 1441 |
1443 // Test on 1st display. | 1442 // Test on 1st display. |
1444 generator1.MoveMouseToInHost(150, 50); | 1443 generator1.MoveMouseToInHost(150, 50); |
(...skipping 26 matching lines...) Expand all Loading... | |
1471 generator2.MoveMouseToInHost(200, 250); | 1470 generator2.MoveMouseToInHost(200, 250); |
1472 EXPECT_EQ("700,125", env->last_mouse_location().ToString()); | 1471 EXPECT_EQ("700,125", env->last_mouse_location().ToString()); |
1473 UpdateDisplay("600x400,400x300*2@1.5"); | 1472 UpdateDisplay("600x400,400x300*2@1.5"); |
1474 EXPECT_EQ("750,187", env->last_mouse_location().ToString()); | 1473 EXPECT_EQ("750,187", env->last_mouse_location().ToString()); |
1475 | 1474 |
1476 // The native location is now outside, so move to the | 1475 // The native location is now outside, so move to the |
1477 // center of closest display. | 1476 // center of closest display. |
1478 UpdateDisplay("600x400,400x200*2@1.5"); | 1477 UpdateDisplay("600x400,400x200*2@1.5"); |
1479 EXPECT_EQ("750,75", env->last_mouse_location().ToString()); | 1478 EXPECT_EQ("750,75", env->last_mouse_location().ToString()); |
1480 } | 1479 } |
1480 #endif // defined(OS_CHROMEOS) | |
1481 | 1481 |
1482 class TestDisplayObserver : public display::DisplayObserver { | 1482 class TestDisplayObserver : public display::DisplayObserver { |
1483 public: | 1483 public: |
1484 TestDisplayObserver() : changed_(false) {} | 1484 TestDisplayObserver() : changed_(false) {} |
1485 ~TestDisplayObserver() override {} | 1485 ~TestDisplayObserver() override {} |
1486 | 1486 |
1487 // display::DisplayObserver overrides: | 1487 // display::DisplayObserver overrides: |
1488 void OnDisplayMetricsChanged(const display::Display&, uint32_t) override {} | 1488 void OnDisplayMetricsChanged(const display::Display&, uint32_t) override {} |
1489 void OnDisplayAdded(const display::Display& new_display) override { | 1489 void OnDisplayAdded(const display::Display& new_display) override { |
1490 // Mirror window should already be delete before restoring | 1490 // Mirror window should already be delete before restoring |
(...skipping 14 matching lines...) Expand all Loading... | |
1505 return changed; | 1505 return changed; |
1506 } | 1506 } |
1507 | 1507 |
1508 private: | 1508 private: |
1509 test::MirrorWindowTestApi test_api; | 1509 test::MirrorWindowTestApi test_api; |
1510 bool changed_; | 1510 bool changed_; |
1511 | 1511 |
1512 DISALLOW_COPY_AND_ASSIGN(TestDisplayObserver); | 1512 DISALLOW_COPY_AND_ASSIGN(TestDisplayObserver); |
1513 }; | 1513 }; |
1514 | 1514 |
1515 TEST_F(DisplayManagerTest, SoftwareMirroring) { | 1515 TEST_P(DisplayManagerTest, SoftwareMirroring) { |
1516 if (!SupportsMultipleDisplays()) | 1516 if (!SupportsMultipleDisplays()) |
1517 return; | 1517 return; |
1518 | 1518 |
1519 UpdateDisplay("300x400,400x500"); | 1519 UpdateDisplay("300x400,400x500"); |
1520 | 1520 |
1521 test::MirrorWindowTestApi test_api; | 1521 test::MirrorWindowTestApi test_api; |
1522 EXPECT_EQ(nullptr, test_api.GetHost()); | 1522 EXPECT_EQ(nullptr, test_api.GetHost()); |
1523 | 1523 |
1524 TestDisplayObserver display_observer; | 1524 TestDisplayObserver display_observer; |
1525 display::Screen::GetScreen()->AddObserver(&display_observer); | 1525 display::Screen::GetScreen()->AddObserver(&display_observer); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1571 | 1571 |
1572 // Overscan insets are ignored. | 1572 // Overscan insets are ignored. |
1573 UpdateDisplay("400x600/o,600x800/o"); | 1573 UpdateDisplay("400x600/o,600x800/o"); |
1574 EXPECT_FALSE(display_observer.changed_and_reset()); | 1574 EXPECT_FALSE(display_observer.changed_and_reset()); |
1575 EXPECT_EQ("400x600", | 1575 EXPECT_EQ("400x600", |
1576 test_api.GetHost()->window()->bounds().size().ToString()); | 1576 test_api.GetHost()->window()->bounds().size().ToString()); |
1577 | 1577 |
1578 display::Screen::GetScreen()->RemoveObserver(&display_observer); | 1578 display::Screen::GetScreen()->RemoveObserver(&display_observer); |
1579 } | 1579 } |
1580 | 1580 |
1581 TEST_F(DisplayManagerTest, RotateInSoftwareMirroring) { | 1581 TEST_P(DisplayManagerTest, RotateInSoftwareMirroring) { |
1582 if (!SupportsMultipleDisplays()) | 1582 if (!SupportsMultipleDisplays()) |
1583 return; | 1583 return; |
1584 | 1584 |
1585 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 1585 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
1586 UpdateDisplay("600x400,500x300"); | 1586 UpdateDisplay("600x400,500x300"); |
1587 display_manager->SetMirrorMode(true); | 1587 display_manager->SetMirrorMode(true); |
1588 | 1588 |
1589 EXPECT_EQ(1U, display_manager->GetNumDisplays()); | 1589 EXPECT_EQ(1U, display_manager->GetNumDisplays()); |
1590 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 1590 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
1591 display_manager->SetDisplayRotation(primary_id, display::Display::ROTATE_180, | 1591 display_manager->SetDisplayRotation(primary_id, display::Display::ROTATE_180, |
1592 display::Display::ROTATION_SOURCE_ACTIVE); | 1592 display::Display::ROTATION_SOURCE_ACTIVE); |
1593 display_manager->SetMirrorMode(false); | 1593 display_manager->SetMirrorMode(false); |
1594 } | 1594 } |
1595 | 1595 |
1596 TEST_F(DisplayManagerTest, SingleDisplayToSoftwareMirroring) { | 1596 TEST_P(DisplayManagerTest, SingleDisplayToSoftwareMirroring) { |
1597 if (!SupportsMultipleDisplays()) | 1597 if (!SupportsMultipleDisplays()) |
1598 return; | 1598 return; |
1599 UpdateDisplay("600x400"); | 1599 UpdateDisplay("600x400"); |
1600 | 1600 |
1601 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 1601 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
1602 display_manager->SetMultiDisplayMode(DisplayManager::MIRRORING); | 1602 display_manager->SetMultiDisplayMode(DisplayManager::MIRRORING); |
1603 UpdateDisplay("600x400,600x400"); | 1603 UpdateDisplay("600x400,600x400"); |
1604 | 1604 |
1605 EXPECT_TRUE(display_manager->IsInMirrorMode()); | 1605 EXPECT_TRUE(display_manager->IsInMirrorMode()); |
1606 EXPECT_EQ(1U, display_manager->GetNumDisplays()); | 1606 EXPECT_EQ(1U, display_manager->GetNumDisplays()); |
1607 WindowTreeHostManager* window_tree_host_manager = | 1607 WindowTreeHostManager* window_tree_host_manager = |
1608 ash::Shell::GetInstance()->window_tree_host_manager(); | 1608 ash::Shell::GetInstance()->window_tree_host_manager(); |
1609 EXPECT_TRUE( | 1609 EXPECT_TRUE( |
1610 window_tree_host_manager->mirror_window_controller()->GetWindow()); | 1610 window_tree_host_manager->mirror_window_controller()->GetWindow()); |
1611 | 1611 |
1612 UpdateDisplay("600x400"); | 1612 UpdateDisplay("600x400"); |
1613 EXPECT_FALSE(display_manager->IsInMirrorMode()); | 1613 EXPECT_FALSE(display_manager->IsInMirrorMode()); |
1614 EXPECT_EQ(1U, display_manager->GetNumDisplays()); | 1614 EXPECT_EQ(1U, display_manager->GetNumDisplays()); |
1615 EXPECT_FALSE( | 1615 EXPECT_FALSE( |
1616 window_tree_host_manager->mirror_window_controller()->GetWindow()); | 1616 window_tree_host_manager->mirror_window_controller()->GetWindow()); |
1617 } | 1617 } |
1618 | 1618 |
1619 #if defined(OS_CHROMEOS) | 1619 #if defined(OS_CHROMEOS) |
1620 // Make sure this does not cause any crashes. See http://crbug.com/412910 | 1620 // Make sure this does not cause any crashes. See http://crbug.com/412910 |
1621 // This test is limited to OS_CHROMEOS because CursorCompositingEnabled is only | 1621 // This test is limited to OS_CHROMEOS because CursorCompositingEnabled is only |
1622 // for ChromeOS. | 1622 // for ChromeOS. |
1623 TEST_F(DisplayManagerTest, SoftwareMirroringWithCompositingCursor) { | 1623 TEST_P(DisplayManagerTest, SoftwareMirroringWithCompositingCursor) { |
1624 if (!SupportsMultipleDisplays()) | 1624 if (!SupportsMultipleDisplays()) |
1625 return; | 1625 return; |
1626 | 1626 |
1627 UpdateDisplay("300x400,400x500"); | 1627 UpdateDisplay("300x400,400x500"); |
1628 | 1628 |
1629 test::MirrorWindowTestApi test_api; | 1629 test::MirrorWindowTestApi test_api; |
1630 EXPECT_EQ(nullptr, test_api.GetHost()); | 1630 EXPECT_EQ(nullptr, test_api.GetHost()); |
1631 | 1631 |
1632 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 1632 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
1633 DisplayInfo secondary_info = display_manager->GetDisplayInfo( | 1633 DisplayInfo secondary_info = display_manager->GetDisplayInfo( |
(...skipping 15 matching lines...) Expand all Loading... | |
1649 new_info_list.push_back(secondary_info); | 1649 new_info_list.push_back(secondary_info); |
1650 display_manager->OnNativeDisplaysChanged(new_info_list); | 1650 display_manager->OnNativeDisplaysChanged(new_info_list); |
1651 | 1651 |
1652 root_windows = Shell::GetAllRootWindows(); | 1652 root_windows = Shell::GetAllRootWindows(); |
1653 EXPECT_TRUE(root_windows[0]->Contains(test_api.GetCursorWindow())); | 1653 EXPECT_TRUE(root_windows[0]->Contains(test_api.GetCursorWindow())); |
1654 | 1654 |
1655 Shell::GetInstance()->SetCursorCompositingEnabled(false); | 1655 Shell::GetInstance()->SetCursorCompositingEnabled(false); |
1656 } | 1656 } |
1657 #endif // OS_CHROMEOS | 1657 #endif // OS_CHROMEOS |
1658 | 1658 |
1659 TEST_F(DisplayManagerTest, MirroredLayout) { | 1659 TEST_P(DisplayManagerTest, MirroredLayout) { |
1660 if (!SupportsMultipleDisplays()) | 1660 if (!SupportsMultipleDisplays()) |
1661 return; | 1661 return; |
1662 | 1662 |
1663 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 1663 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
1664 UpdateDisplay("500x500,400x400"); | 1664 UpdateDisplay("500x500,400x400"); |
1665 EXPECT_FALSE(display_manager->GetCurrentDisplayLayout().mirrored); | 1665 EXPECT_FALSE(display_manager->GetCurrentDisplayLayout().mirrored); |
1666 EXPECT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); | 1666 EXPECT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); |
1667 EXPECT_EQ(2U, display_manager->num_connected_displays()); | 1667 EXPECT_EQ(2U, display_manager->num_connected_displays()); |
1668 | 1668 |
1669 UpdateDisplay("1+0-500x500,1+0-500x500"); | 1669 UpdateDisplay("1+0-500x500,1+0-500x500"); |
1670 EXPECT_TRUE(display_manager->GetCurrentDisplayLayout().mirrored); | 1670 EXPECT_TRUE(display_manager->GetCurrentDisplayLayout().mirrored); |
1671 EXPECT_EQ(1, display::Screen::GetScreen()->GetNumDisplays()); | 1671 EXPECT_EQ(1, display::Screen::GetScreen()->GetNumDisplays()); |
1672 EXPECT_EQ(2U, display_manager->num_connected_displays()); | 1672 EXPECT_EQ(2U, display_manager->num_connected_displays()); |
1673 | 1673 |
1674 UpdateDisplay("500x500,500x500"); | 1674 UpdateDisplay("500x500,500x500"); |
1675 EXPECT_FALSE(display_manager->GetCurrentDisplayLayout().mirrored); | 1675 EXPECT_FALSE(display_manager->GetCurrentDisplayLayout().mirrored); |
1676 EXPECT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); | 1676 EXPECT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); |
1677 EXPECT_EQ(2U, display_manager->num_connected_displays()); | 1677 EXPECT_EQ(2U, display_manager->num_connected_displays()); |
1678 } | 1678 } |
1679 | 1679 |
1680 TEST_F(DisplayManagerTest, InvertLayout) { | 1680 TEST_P(DisplayManagerTest, InvertLayout) { |
1681 EXPECT_EQ("left, 0", | 1681 EXPECT_EQ("left, 0", |
1682 display::DisplayPlacement(display::DisplayPlacement::RIGHT, 0) | 1682 display::DisplayPlacement(display::DisplayPlacement::RIGHT, 0) |
1683 .Swap() | 1683 .Swap() |
1684 .ToString()); | 1684 .ToString()); |
1685 EXPECT_EQ("left, -100", | 1685 EXPECT_EQ("left, -100", |
1686 display::DisplayPlacement(display::DisplayPlacement::RIGHT, 100) | 1686 display::DisplayPlacement(display::DisplayPlacement::RIGHT, 100) |
1687 .Swap() | 1687 .Swap() |
1688 .ToString()); | 1688 .ToString()); |
1689 EXPECT_EQ("left, 50", | 1689 EXPECT_EQ("left, 50", |
1690 display::DisplayPlacement(display::DisplayPlacement::RIGHT, -50) | 1690 display::DisplayPlacement(display::DisplayPlacement::RIGHT, -50) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1724 EXPECT_EQ("top, -70", | 1724 EXPECT_EQ("top, -70", |
1725 display::DisplayPlacement(display::DisplayPlacement::BOTTOM, 70) | 1725 display::DisplayPlacement(display::DisplayPlacement::BOTTOM, 70) |
1726 .Swap() | 1726 .Swap() |
1727 .ToString()); | 1727 .ToString()); |
1728 EXPECT_EQ("top, 80", | 1728 EXPECT_EQ("top, 80", |
1729 display::DisplayPlacement(display::DisplayPlacement::BOTTOM, -80) | 1729 display::DisplayPlacement(display::DisplayPlacement::BOTTOM, -80) |
1730 .Swap() | 1730 .Swap() |
1731 .ToString()); | 1731 .ToString()); |
1732 } | 1732 } |
1733 | 1733 |
1734 TEST_F(DisplayManagerTest, NotifyPrimaryChange) { | 1734 TEST_P(DisplayManagerTest, NotifyPrimaryChange) { |
1735 if (!SupportsMultipleDisplays()) | 1735 if (!SupportsMultipleDisplays()) |
1736 return; | 1736 return; |
1737 UpdateDisplay("500x500,500x500"); | 1737 UpdateDisplay("500x500,500x500"); |
1738 test::SwapPrimaryDisplay(); | 1738 test::SwapPrimaryDisplay(); |
1739 reset(); | 1739 reset(); |
1740 UpdateDisplay("500x500"); | 1740 UpdateDisplay("500x500"); |
1741 EXPECT_FALSE(changed_metrics() & | 1741 EXPECT_FALSE(changed_metrics() & |
1742 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); | 1742 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); |
1743 EXPECT_FALSE(changed_metrics() & | 1743 EXPECT_FALSE(changed_metrics() & |
1744 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); | 1744 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); |
1745 EXPECT_TRUE(changed_metrics() & | 1745 EXPECT_TRUE(changed_metrics() & |
1746 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); | 1746 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); |
1747 | 1747 |
1748 UpdateDisplay("500x500,500x500"); | 1748 UpdateDisplay("500x500,500x500"); |
1749 test::SwapPrimaryDisplay(); | 1749 test::SwapPrimaryDisplay(); |
1750 UpdateDisplay("500x400"); | 1750 UpdateDisplay("500x400"); |
1751 EXPECT_TRUE(changed_metrics() & | 1751 EXPECT_TRUE(changed_metrics() & |
1752 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); | 1752 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); |
1753 EXPECT_TRUE(changed_metrics() & | 1753 EXPECT_TRUE(changed_metrics() & |
1754 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); | 1754 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); |
1755 EXPECT_TRUE(changed_metrics() & | 1755 EXPECT_TRUE(changed_metrics() & |
1756 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); | 1756 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); |
1757 } | 1757 } |
1758 | 1758 |
1759 TEST_F(DisplayManagerTest, NotifyPrimaryChangeUndock) { | 1759 TEST_P(DisplayManagerTest, NotifyPrimaryChangeUndock) { |
1760 if (!SupportsMultipleDisplays()) | 1760 if (!SupportsMultipleDisplays()) |
1761 return; | 1761 return; |
1762 // Assume the default display is an external display, and | 1762 // Assume the default display is an external display, and |
1763 // emulates undocking by switching to another display. | 1763 // emulates undocking by switching to another display. |
1764 DisplayInfo another_display_info = | 1764 DisplayInfo another_display_info = |
1765 CreateDisplayInfo(1, gfx::Rect(0, 0, 1280, 800)); | 1765 CreateDisplayInfo(1, gfx::Rect(0, 0, 1280, 800)); |
1766 std::vector<DisplayInfo> info_list; | 1766 std::vector<DisplayInfo> info_list; |
1767 info_list.push_back(another_display_info); | 1767 info_list.push_back(another_display_info); |
1768 reset(); | 1768 reset(); |
1769 display_manager()->OnNativeDisplaysChanged(info_list); | 1769 display_manager()->OnNativeDisplaysChanged(info_list); |
1770 EXPECT_TRUE(changed_metrics() & | 1770 EXPECT_TRUE(changed_metrics() & |
1771 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); | 1771 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); |
1772 EXPECT_TRUE(changed_metrics() & | 1772 EXPECT_TRUE(changed_metrics() & |
1773 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); | 1773 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); |
1774 EXPECT_TRUE(changed_metrics() & | 1774 EXPECT_TRUE(changed_metrics() & |
1775 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); | 1775 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); |
1776 } | 1776 } |
1777 | 1777 |
1778 #if defined(OS_WIN) | |
1779 // TODO(scottmg): RootWindow doesn't get resized on Windows | 1778 // TODO(scottmg): RootWindow doesn't get resized on Windows |
1780 // Ash. http://crbug.com/247916. | 1779 // Ash. http://crbug.com/247916. |
1781 #define MAYBE_UpdateDisplayWithHostOrigin DISABLED_UpdateDisplayWithHostOrigin | 1780 #if defined(OS_CHROMEOS) |
1782 #else | 1781 TEST_P(DisplayManagerTest, UpdateDisplayWithHostOrigin) { |
1783 #define MAYBE_UpdateDisplayWithHostOrigin UpdateDisplayWithHostOrigin | |
1784 #endif | |
1785 | |
1786 TEST_F(DisplayManagerTest, MAYBE_UpdateDisplayWithHostOrigin) { | |
1787 UpdateDisplay("100x200,300x400"); | 1782 UpdateDisplay("100x200,300x400"); |
1788 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); | 1783 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); |
1789 aura::Window::Windows root_windows = | 1784 aura::Window::Windows root_windows = |
1790 Shell::GetInstance()->GetAllRootWindows(); | 1785 Shell::GetInstance()->GetAllRootWindows(); |
1791 ASSERT_EQ(2U, root_windows.size()); | 1786 ASSERT_EQ(2U, root_windows.size()); |
1792 aura::WindowTreeHost* host0 = root_windows[0]->GetHost(); | 1787 aura::WindowTreeHost* host0 = root_windows[0]->GetHost(); |
1793 aura::WindowTreeHost* host1 = root_windows[1]->GetHost(); | 1788 aura::WindowTreeHost* host1 = root_windows[1]->GetHost(); |
1794 | 1789 |
1795 EXPECT_EQ("1,1", host0->GetBounds().origin().ToString()); | 1790 EXPECT_EQ("1,1", host0->GetBounds().origin().ToString()); |
1796 EXPECT_EQ("100x200", host0->GetBounds().size().ToString()); | 1791 EXPECT_EQ("100x200", host0->GetBounds().size().ToString()); |
(...skipping 15 matching lines...) Expand all Loading... | |
1812 EXPECT_EQ("0,0", host1->GetBounds().origin().ToString()); | 1807 EXPECT_EQ("0,0", host1->GetBounds().origin().ToString()); |
1813 EXPECT_EQ("300x400", host1->GetBounds().size().ToString()); | 1808 EXPECT_EQ("300x400", host1->GetBounds().size().ToString()); |
1814 | 1809 |
1815 UpdateDisplay("100+200-100x200,300+500-200x300"); | 1810 UpdateDisplay("100+200-100x200,300+500-200x300"); |
1816 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); | 1811 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); |
1817 EXPECT_EQ("100,200", host0->GetBounds().origin().ToString()); | 1812 EXPECT_EQ("100,200", host0->GetBounds().origin().ToString()); |
1818 EXPECT_EQ("100x200", host0->GetBounds().size().ToString()); | 1813 EXPECT_EQ("100x200", host0->GetBounds().size().ToString()); |
1819 EXPECT_EQ("300,500", host1->GetBounds().origin().ToString()); | 1814 EXPECT_EQ("300,500", host1->GetBounds().origin().ToString()); |
1820 EXPECT_EQ("200x300", host1->GetBounds().size().ToString()); | 1815 EXPECT_EQ("200x300", host1->GetBounds().size().ToString()); |
1821 } | 1816 } |
1817 #endif // defined(OS_CHROMEOS) | |
1822 | 1818 |
1823 TEST_F(DisplayManagerTest, UnifiedDesktopBasic) { | 1819 TEST_P(DisplayManagerTest, UnifiedDesktopBasic) { |
1824 if (!SupportsMultipleDisplays()) | 1820 if (!SupportsMultipleDisplays()) |
1825 return; | 1821 return; |
1826 | 1822 |
1827 // Don't check root window destruction in unified mode. | 1823 // Don't check root window destruction in unified mode. |
1828 Shell::GetPrimaryRootWindow()->RemoveObserver(this); | 1824 Shell::GetPrimaryRootWindow()->RemoveObserver(this); |
1829 | 1825 |
1830 UpdateDisplay("400x500,300x200"); | 1826 UpdateDisplay("400x500,300x200"); |
1831 | 1827 |
1832 // Enable after extended mode. | 1828 // Enable after extended mode. |
1833 display_manager()->SetUnifiedDesktopEnabled(true); | 1829 display_manager()->SetUnifiedDesktopEnabled(true); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1872 // Switch back to extended desktop. | 1868 // Switch back to extended desktop. |
1873 display_manager()->SetUnifiedDesktopEnabled(false); | 1869 display_manager()->SetUnifiedDesktopEnabled(false); |
1874 EXPECT_EQ(gfx::Size(500, 300), screen->GetPrimaryDisplay().size()); | 1870 EXPECT_EQ(gfx::Size(500, 300), screen->GetPrimaryDisplay().size()); |
1875 EXPECT_EQ(gfx::Size(400, 500), ScreenUtil::GetSecondaryDisplay().size()); | 1871 EXPECT_EQ(gfx::Size(400, 500), ScreenUtil::GetSecondaryDisplay().size()); |
1876 EXPECT_EQ(gfx::Size(500, 300), | 1872 EXPECT_EQ(gfx::Size(500, 300), |
1877 display_manager() | 1873 display_manager() |
1878 ->GetDisplayForId(ScreenUtil::GetSecondaryDisplay().id() + 1) | 1874 ->GetDisplayForId(ScreenUtil::GetSecondaryDisplay().id() + 1) |
1879 .size()); | 1875 .size()); |
1880 } | 1876 } |
1881 | 1877 |
1882 TEST_F(DisplayManagerTest, UnifiedDesktopWithHardwareMirroring) { | 1878 TEST_P(DisplayManagerTest, UnifiedDesktopWithHardwareMirroring) { |
1883 if (!SupportsMultipleDisplays()) | 1879 if (!SupportsMultipleDisplays()) |
1884 return; | 1880 return; |
1885 // Don't check root window destruction in unified mode. | 1881 // Don't check root window destruction in unified mode. |
1886 Shell::GetPrimaryRootWindow()->RemoveObserver(this); | 1882 Shell::GetPrimaryRootWindow()->RemoveObserver(this); |
1887 | 1883 |
1888 // Enter to hardware mirroring. | 1884 // Enter to hardware mirroring. |
1889 DisplayInfo d1(1, "", false); | 1885 DisplayInfo d1(1, "", false); |
1890 d1.SetBounds(gfx::Rect(0, 0, 500, 500)); | 1886 d1.SetBounds(gfx::Rect(0, 0, 500, 500)); |
1891 DisplayInfo d2(2, "", false); | 1887 DisplayInfo d2(2, "", false); |
1892 d2.SetBounds(gfx::Rect(0, 0, 500, 500)); | 1888 d2.SetBounds(gfx::Rect(0, 0, 500, 500)); |
(...skipping 19 matching lines...) Expand all Loading... | |
1912 // Exit from hardware mirroring. | 1908 // Exit from hardware mirroring. |
1913 d2.SetBounds(gfx::Rect(0, 500, 500, 500)); | 1909 d2.SetBounds(gfx::Rect(0, 500, 500, 500)); |
1914 display_info_list.clear(); | 1910 display_info_list.clear(); |
1915 display_info_list.push_back(d1); | 1911 display_info_list.push_back(d1); |
1916 display_info_list.push_back(d2); | 1912 display_info_list.push_back(d2); |
1917 display_manager()->OnNativeDisplaysChanged(display_info_list); | 1913 display_manager()->OnNativeDisplaysChanged(display_info_list); |
1918 EXPECT_FALSE(display_manager()->IsInMirrorMode()); | 1914 EXPECT_FALSE(display_manager()->IsInMirrorMode()); |
1919 EXPECT_TRUE(display_manager()->IsInUnifiedMode()); | 1915 EXPECT_TRUE(display_manager()->IsInUnifiedMode()); |
1920 } | 1916 } |
1921 | 1917 |
1922 TEST_F(DisplayManagerTest, UnifiedDesktopEnabledWithExtended) { | 1918 TEST_P(DisplayManagerTest, UnifiedDesktopEnabledWithExtended) { |
1923 if (!SupportsMultipleDisplays()) | 1919 if (!SupportsMultipleDisplays()) |
1924 return; | 1920 return; |
1925 // Don't check root window destruction in unified mode. | 1921 // Don't check root window destruction in unified mode. |
1926 Shell::GetPrimaryRootWindow()->RemoveObserver(this); | 1922 Shell::GetPrimaryRootWindow()->RemoveObserver(this); |
1927 | 1923 |
1928 UpdateDisplay("400x500,300x200"); | 1924 UpdateDisplay("400x500,300x200"); |
1929 display::DisplayIdList list = display_manager()->GetCurrentDisplayIdList(); | 1925 display::DisplayIdList list = display_manager()->GetCurrentDisplayIdList(); |
1930 display::DisplayLayoutBuilder builder( | 1926 display::DisplayLayoutBuilder builder( |
1931 display_manager()->layout_store()->GetRegisteredDisplayLayout(list)); | 1927 display_manager()->layout_store()->GetRegisteredDisplayLayout(list)); |
1932 builder.SetDefaultUnified(false); | 1928 builder.SetDefaultUnified(false); |
1933 display_manager()->layout_store()->RegisterLayoutForDisplayIdList( | 1929 display_manager()->layout_store()->RegisterLayoutForDisplayIdList( |
1934 list, builder.Build()); | 1930 list, builder.Build()); |
1935 display_manager()->SetUnifiedDesktopEnabled(true); | 1931 display_manager()->SetUnifiedDesktopEnabled(true); |
1936 EXPECT_FALSE(display_manager()->IsInUnifiedMode()); | 1932 EXPECT_FALSE(display_manager()->IsInUnifiedMode()); |
1937 } | 1933 } |
1938 | 1934 |
1939 TEST_F(DisplayManagerTest, UnifiedDesktopWith2xDSF) { | 1935 TEST_P(DisplayManagerTest, UnifiedDesktopWith2xDSF) { |
1940 if (!SupportsMultipleDisplays()) | 1936 if (!SupportsMultipleDisplays()) |
1941 return; | 1937 return; |
1942 // Don't check root window destruction in unified mode. | 1938 // Don't check root window destruction in unified mode. |
1943 Shell::GetPrimaryRootWindow()->RemoveObserver(this); | 1939 Shell::GetPrimaryRootWindow()->RemoveObserver(this); |
1944 | 1940 |
1945 display_manager()->SetUnifiedDesktopEnabled(true); | 1941 display_manager()->SetUnifiedDesktopEnabled(true); |
1946 display::Screen* screen = display::Screen::GetScreen(); | 1942 display::Screen* screen = display::Screen::GetScreen(); |
1947 | 1943 |
1948 // 2nd display is 2x. | 1944 // 2nd display is 2x. |
1949 UpdateDisplay("400x500,1000x800*2"); | 1945 UpdateDisplay("400x500,1000x800*2"); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2033 EXPECT_EQ("1300x800", | 2029 EXPECT_EQ("1300x800", |
2034 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); | 2030 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); |
2035 accelerators::ZoomInternalDisplay(false); | 2031 accelerators::ZoomInternalDisplay(false); |
2036 EXPECT_EQ("650x400", screen->GetPrimaryDisplay().size().ToString()); | 2032 EXPECT_EQ("650x400", screen->GetPrimaryDisplay().size().ToString()); |
2037 EXPECT_EQ("650x400", | 2033 EXPECT_EQ("650x400", |
2038 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); | 2034 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); |
2039 } | 2035 } |
2040 | 2036 |
2041 // Updating displays again in unified desktop mode should not crash. | 2037 // Updating displays again in unified desktop mode should not crash. |
2042 // crbug.com/491094. | 2038 // crbug.com/491094. |
2043 TEST_F(DisplayManagerTest, ConfigureUnifiedTwice) { | 2039 TEST_P(DisplayManagerTest, ConfigureUnifiedTwice) { |
2044 if (!SupportsMultipleDisplays()) | 2040 if (!SupportsMultipleDisplays()) |
2045 return; | 2041 return; |
2046 // Don't check root window destruction in unified mode. | 2042 // Don't check root window destruction in unified mode. |
2047 Shell::GetPrimaryRootWindow()->RemoveObserver(this); | 2043 Shell::GetPrimaryRootWindow()->RemoveObserver(this); |
2048 | 2044 |
2049 UpdateDisplay("300x200,400x500"); | 2045 UpdateDisplay("300x200,400x500"); |
2050 // Mirror windows are created in a posted task. | 2046 // Mirror windows are created in a posted task. |
2051 RunAllPendingInMessageLoop(); | 2047 RunAllPendingInMessageLoop(); |
2052 | 2048 |
2053 UpdateDisplay("300x250,400x550"); | 2049 UpdateDisplay("300x250,400x550"); |
2054 RunAllPendingInMessageLoop(); | 2050 RunAllPendingInMessageLoop(); |
2055 } | 2051 } |
2056 | 2052 |
2057 TEST_F(DisplayManagerTest, NoRotateUnifiedDesktop) { | 2053 TEST_P(DisplayManagerTest, NoRotateUnifiedDesktop) { |
2058 if (!SupportsMultipleDisplays()) | 2054 if (!SupportsMultipleDisplays()) |
2059 return; | 2055 return; |
2060 display_manager()->SetUnifiedDesktopEnabled(true); | 2056 display_manager()->SetUnifiedDesktopEnabled(true); |
2061 | 2057 |
2062 // Don't check root window destruction in unified mode. | 2058 // Don't check root window destruction in unified mode. |
2063 Shell::GetPrimaryRootWindow()->RemoveObserver(this); | 2059 Shell::GetPrimaryRootWindow()->RemoveObserver(this); |
2064 | 2060 |
2065 UpdateDisplay("400x500,300x200"); | 2061 UpdateDisplay("400x500,300x200"); |
2066 | 2062 |
2067 display::Screen* screen = display::Screen::GetScreen(); | 2063 display::Screen* screen = display::Screen::GetScreen(); |
2068 const display::Display& display = screen->GetPrimaryDisplay(); | 2064 const display::Display& display = screen->GetPrimaryDisplay(); |
2069 EXPECT_EQ("1150x500", display.size().ToString()); | 2065 EXPECT_EQ("1150x500", display.size().ToString()); |
2070 display_manager()->SetDisplayRotation( | 2066 display_manager()->SetDisplayRotation( |
2071 display.id(), display::Display::ROTATE_90, | 2067 display.id(), display::Display::ROTATE_90, |
2072 display::Display::ROTATION_SOURCE_ACTIVE); | 2068 display::Display::ROTATION_SOURCE_ACTIVE); |
2073 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString()); | 2069 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString()); |
2074 display_manager()->SetDisplayRotation( | 2070 display_manager()->SetDisplayRotation( |
2075 display.id(), display::Display::ROTATE_0, | 2071 display.id(), display::Display::ROTATE_0, |
2076 display::Display::ROTATION_SOURCE_ACTIVE); | 2072 display::Display::ROTATION_SOURCE_ACTIVE); |
2077 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString()); | 2073 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString()); |
2078 | 2074 |
2079 UpdateDisplay("400x500"); | 2075 UpdateDisplay("400x500"); |
2080 EXPECT_EQ("400x500", screen->GetPrimaryDisplay().size().ToString()); | 2076 EXPECT_EQ("400x500", screen->GetPrimaryDisplay().size().ToString()); |
2081 } | 2077 } |
2082 | 2078 |
2083 // Makes sure the transition from unified to single won't crash | 2079 // Makes sure the transition from unified to single won't crash |
2084 // with docked windows. | 2080 // with docked windows. |
2085 TEST_F(DisplayManagerTest, UnifiedWithDockWindows) { | 2081 TEST_P(DisplayManagerTest, UnifiedWithDockWindows) { |
2086 if (!SupportsMultipleDisplays()) | 2082 if (!SupportsMultipleDisplays()) |
2087 return; | 2083 return; |
2084 const int height_offset = GetMdDockedWindowHeightOffset(); | |
2088 display_manager()->SetUnifiedDesktopEnabled(true); | 2085 display_manager()->SetUnifiedDesktopEnabled(true); |
2089 | 2086 |
2090 // Don't check root window destruction in unified mode. | 2087 // Don't check root window destruction in unified mode. |
2091 Shell::GetPrimaryRootWindow()->RemoveObserver(this); | 2088 Shell::GetPrimaryRootWindow()->RemoveObserver(this); |
2092 | 2089 |
2093 UpdateDisplay("400x500,300x200"); | 2090 UpdateDisplay("400x500,300x200"); |
2094 | 2091 |
2095 std::unique_ptr<aura::Window> docked( | 2092 std::unique_ptr<aura::Window> docked( |
2096 CreateTestWindowInShellWithBounds(gfx::Rect(10, 10, 50, 50))); | 2093 CreateTestWindowInShellWithBounds(gfx::Rect(10, 10, 50, 50))); |
2097 docked->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DOCKED); | 2094 docked->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DOCKED); |
2098 ASSERT_TRUE(wm::GetWindowState(docked.get())->IsDocked()); | 2095 ASSERT_TRUE(wm::GetWindowState(docked.get())->IsDocked()); |
2099 // 47 pixels reserved for launcher shelf height. | 2096 // 47 pixels reserved for launcher shelf height in non-material design, and |
2100 EXPECT_EQ("0,0 250x453", docked->bounds().ToString()); | 2097 // 48 pixels reserved in material design. |
2098 EXPECT_EQ(gfx::Rect(0, 0, 250, 453 + height_offset).ToString(), | |
2099 docked->bounds().ToString()); | |
2101 UpdateDisplay("300x300"); | 2100 UpdateDisplay("300x300"); |
2102 // Make sure the window is still docked. | 2101 // Make sure the window is still docked. |
2103 EXPECT_TRUE(wm::GetWindowState(docked.get())->IsDocked()); | 2102 EXPECT_TRUE(wm::GetWindowState(docked.get())->IsDocked()); |
2104 EXPECT_EQ("0,0 250x253", docked->bounds().ToString()); | 2103 EXPECT_EQ(gfx::Rect(0, 0, 250, 253 + height_offset).ToString(), |
2104 docked->bounds().ToString()); | |
2105 } | 2105 } |
2106 | 2106 |
2107 TEST_F(DisplayManagerTest, DockMode) { | 2107 TEST_P(DisplayManagerTest, DockMode) { |
2108 if (!SupportsMultipleDisplays()) | 2108 if (!SupportsMultipleDisplays()) |
2109 return; | 2109 return; |
2110 const int64_t internal_id = 1; | 2110 const int64_t internal_id = 1; |
2111 const int64_t external_id = 2; | 2111 const int64_t external_id = 2; |
2112 | 2112 |
2113 const DisplayInfo internal_display_info = | 2113 const DisplayInfo internal_display_info = |
2114 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500)); | 2114 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500)); |
2115 const DisplayInfo external_display_info = | 2115 const DisplayInfo external_display_info = |
2116 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); | 2116 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); |
2117 std::vector<DisplayInfo> display_info_list; | 2117 std::vector<DisplayInfo> display_info_list; |
(...skipping 21 matching lines...) Expand all Loading... | |
2139 EXPECT_FALSE(GetDisplayModeForNextUIScale(info, false, &mode)); | 2139 EXPECT_FALSE(GetDisplayModeForNextUIScale(info, false, &mode)); |
2140 EXPECT_FALSE(SetDisplayUIScale(internal_id, 1.0f)); | 2140 EXPECT_FALSE(SetDisplayUIScale(internal_id, 1.0f)); |
2141 | 2141 |
2142 DisplayInfo invalid_info; | 2142 DisplayInfo invalid_info; |
2143 EXPECT_FALSE(GetDisplayModeForNextUIScale(invalid_info, true, &mode)); | 2143 EXPECT_FALSE(GetDisplayModeForNextUIScale(invalid_info, true, &mode)); |
2144 EXPECT_FALSE(GetDisplayModeForNextUIScale(invalid_info, false, &mode)); | 2144 EXPECT_FALSE(GetDisplayModeForNextUIScale(invalid_info, false, &mode)); |
2145 EXPECT_FALSE(SetDisplayUIScale(display::Display::kInvalidDisplayID, 1.0f)); | 2145 EXPECT_FALSE(SetDisplayUIScale(display::Display::kInvalidDisplayID, 1.0f)); |
2146 } | 2146 } |
2147 | 2147 |
2148 // Make sure that bad layout information is ignored and does not crash. | 2148 // Make sure that bad layout information is ignored and does not crash. |
2149 TEST_F(DisplayManagerTest, DontRegisterBadConfig) { | 2149 TEST_P(DisplayManagerTest, DontRegisterBadConfig) { |
2150 if (!SupportsMultipleDisplays()) | 2150 if (!SupportsMultipleDisplays()) |
2151 return; | 2151 return; |
2152 display::DisplayIdList list = ash::test::CreateDisplayIdList2(1, 2); | 2152 display::DisplayIdList list = ash::test::CreateDisplayIdList2(1, 2); |
2153 display::DisplayLayoutBuilder builder(1); | 2153 display::DisplayLayoutBuilder builder(1); |
2154 builder.AddDisplayPlacement(2, 1, display::DisplayPlacement::LEFT, 0); | 2154 builder.AddDisplayPlacement(2, 1, display::DisplayPlacement::LEFT, 0); |
2155 builder.AddDisplayPlacement(3, 1, display::DisplayPlacement::BOTTOM, 0); | 2155 builder.AddDisplayPlacement(3, 1, display::DisplayPlacement::BOTTOM, 0); |
2156 | 2156 |
2157 display_manager()->layout_store()->RegisterLayoutForDisplayIdList( | 2157 display_manager()->layout_store()->RegisterLayoutForDisplayIdList( |
2158 list, builder.Build()); | 2158 list, builder.Build()); |
2159 } | 2159 } |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2313 SetDisplayUIScale(display::Screen::GetScreen()->GetPrimaryDisplay().id(), | 2313 SetDisplayUIScale(display::Screen::GetScreen()->GetPrimaryDisplay().id(), |
2314 0.8f); | 2314 0.8f); |
2315 | 2315 |
2316 ASSERT_DOUBLE_EQ( | 2316 ASSERT_DOUBLE_EQ( |
2317 1.25f, | 2317 1.25f, |
2318 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 2318 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
2319 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); | 2319 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); |
2320 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); | 2320 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); |
2321 } | 2321 } |
2322 | 2322 |
2323 TEST_F(DisplayManagerTest, CheckInitializationOfRotationProperty) { | 2323 TEST_P(DisplayManagerTest, CheckInitializationOfRotationProperty) { |
2324 int64_t id = display_manager()->GetDisplayAt(0).id(); | 2324 int64_t id = display_manager()->GetDisplayAt(0).id(); |
2325 display_manager()->RegisterDisplayProperty(id, display::Display::ROTATE_90, | 2325 display_manager()->RegisterDisplayProperty(id, display::Display::ROTATE_90, |
2326 1.0f, nullptr, gfx::Size(), 1.0f, | 2326 1.0f, nullptr, gfx::Size(), 1.0f, |
2327 ui::COLOR_PROFILE_STANDARD); | 2327 ui::COLOR_PROFILE_STANDARD); |
2328 | 2328 |
2329 const DisplayInfo& info = display_manager()->GetDisplayInfo(id); | 2329 const DisplayInfo& info = display_manager()->GetDisplayInfo(id); |
2330 | 2330 |
2331 EXPECT_EQ(display::Display::ROTATE_90, | 2331 EXPECT_EQ(display::Display::ROTATE_90, |
2332 info.GetRotation(display::Display::ROTATION_SOURCE_USER)); | 2332 info.GetRotation(display::Display::ROTATION_SOURCE_USER)); |
2333 EXPECT_EQ(display::Display::ROTATE_90, | 2333 EXPECT_EQ(display::Display::ROTATE_90, |
2334 info.GetRotation(display::Display::ROTATION_SOURCE_ACTIVE)); | 2334 info.GetRotation(display::Display::ROTATION_SOURCE_ACTIVE)); |
2335 } | 2335 } |
2336 | 2336 |
2337 TEST_F(DisplayManagerTest, RejectInvalidLayoutData) { | 2337 TEST_P(DisplayManagerTest, RejectInvalidLayoutData) { |
2338 DisplayLayoutStore* layout_store = display_manager()->layout_store(); | 2338 DisplayLayoutStore* layout_store = display_manager()->layout_store(); |
2339 int64_t id1 = 10001; | 2339 int64_t id1 = 10001; |
2340 int64_t id2 = 10002; | 2340 int64_t id2 = 10002; |
2341 ASSERT_TRUE(CompareDisplayIds(id1, id2)); | 2341 ASSERT_TRUE(CompareDisplayIds(id1, id2)); |
2342 display::DisplayLayoutBuilder good_builder(id1); | 2342 display::DisplayLayoutBuilder good_builder(id1); |
2343 good_builder.SetSecondaryPlacement(id2, display::DisplayPlacement::LEFT, 0); | 2343 good_builder.SetSecondaryPlacement(id2, display::DisplayPlacement::LEFT, 0); |
2344 std::unique_ptr<display::DisplayLayout> good(good_builder.Build()); | 2344 std::unique_ptr<display::DisplayLayout> good(good_builder.Build()); |
2345 | 2345 |
2346 display::DisplayIdList good_list = test::CreateDisplayIdList2(id1, id2); | 2346 display::DisplayIdList good_list = test::CreateDisplayIdList2(id1, id2); |
2347 layout_store->RegisterLayoutForDisplayIdList(good_list, good->Copy()); | 2347 layout_store->RegisterLayoutForDisplayIdList(good_list, good->Copy()); |
2348 | 2348 |
2349 display::DisplayLayoutBuilder bad(id1); | 2349 display::DisplayLayoutBuilder bad(id1); |
2350 bad.SetSecondaryPlacement(id2, display::DisplayPlacement::BOTTOM, 0); | 2350 bad.SetSecondaryPlacement(id2, display::DisplayPlacement::BOTTOM, 0); |
2351 | 2351 |
2352 display::DisplayIdList bad_list(2); | 2352 display::DisplayIdList bad_list(2); |
2353 bad_list[0] = id2; | 2353 bad_list[0] = id2; |
2354 bad_list[1] = id1; | 2354 bad_list[1] = id1; |
2355 layout_store->RegisterLayoutForDisplayIdList(bad_list, bad.Build()); | 2355 layout_store->RegisterLayoutForDisplayIdList(bad_list, bad.Build()); |
2356 | 2356 |
2357 EXPECT_EQ(good->ToString(), | 2357 EXPECT_EQ(good->ToString(), |
2358 layout_store->GetRegisteredDisplayLayout(good_list).ToString()); | 2358 layout_store->GetRegisteredDisplayLayout(good_list).ToString()); |
2359 } | 2359 } |
2360 | 2360 |
2361 TEST_F(DisplayManagerTest, GuessDisplayIdFieldsInDisplayLayout) { | 2361 TEST_P(DisplayManagerTest, GuessDisplayIdFieldsInDisplayLayout) { |
2362 int64_t id1 = 10001; | 2362 int64_t id1 = 10001; |
2363 int64_t id2 = 10002; | 2363 int64_t id2 = 10002; |
2364 | 2364 |
2365 std::unique_ptr<display::DisplayLayout> old_layout( | 2365 std::unique_ptr<display::DisplayLayout> old_layout( |
2366 new display::DisplayLayout); | 2366 new display::DisplayLayout); |
2367 old_layout->placement_list.emplace_back(display::DisplayPlacement::BOTTOM, 0); | 2367 old_layout->placement_list.emplace_back(display::DisplayPlacement::BOTTOM, 0); |
2368 old_layout->primary_id = id1; | 2368 old_layout->primary_id = id1; |
2369 | 2369 |
2370 DisplayLayoutStore* layout_store = display_manager()->layout_store(); | 2370 DisplayLayoutStore* layout_store = display_manager()->layout_store(); |
2371 display::DisplayIdList list = test::CreateDisplayIdList2(id1, id2); | 2371 display::DisplayIdList list = test::CreateDisplayIdList2(id1, id2); |
2372 layout_store->RegisterLayoutForDisplayIdList(list, std::move(old_layout)); | 2372 layout_store->RegisterLayoutForDisplayIdList(list, std::move(old_layout)); |
2373 const display::DisplayLayout& stored = | 2373 const display::DisplayLayout& stored = |
2374 layout_store->GetRegisteredDisplayLayout(list); | 2374 layout_store->GetRegisteredDisplayLayout(list); |
2375 | 2375 |
2376 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id); | 2376 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id); |
2377 EXPECT_EQ(id2, stored.placement_list[0].display_id); | 2377 EXPECT_EQ(id2, stored.placement_list[0].display_id); |
2378 } | 2378 } |
2379 | 2379 |
2380 #endif // OS_CHROMEOS | 2380 #endif // OS_CHROMEOS |
2381 | 2381 |
2382 } // namespace ash | 2382 } // namespace ash |
OLD | NEW |