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

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

Issue 2692663002: Gut ash::MaterialDesignController, and remove the about:flags entry. (Closed)
Patch Set: yet another rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/dip_unittest.cc ('k') | ash/display/window_tree_host_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/display/manager/display_manager.h" 5 #include "ui/display/manager/display_manager.h"
6 6
7 #include "ash/accelerators/accelerator_commands_aura.h" 7 #include "ash/accelerators/accelerator_commands_aura.h"
8 #include "ash/common/ash_switches.h" 8 #include "ash/common/ash_switches.h"
9 #include "ash/common/material_design/material_design_controller.h"
10 #include "ash/common/wm/window_state.h" 9 #include "ash/common/wm/window_state.h"
11 #include "ash/display/display_configuration_controller.h" 10 #include "ash/display/display_configuration_controller.h"
12 #include "ash/display/display_util.h" 11 #include "ash/display/display_util.h"
13 #include "ash/display/mirror_window_controller.h" 12 #include "ash/display/mirror_window_controller.h"
14 #include "ash/display/window_tree_host_manager.h" 13 #include "ash/display/window_tree_host_manager.h"
15 #include "ash/screen_util.h" 14 #include "ash/screen_util.h"
16 #include "ash/shell.h" 15 #include "ash/shell.h"
17 #include "ash/test/ash_md_test_base.h"
18 #include "ash/test/ash_test_base.h" 16 #include "ash/test/ash_test_base.h"
19 #include "ash/test/mirror_window_test_api.h" 17 #include "ash/test/mirror_window_test_api.h"
20 #include "ash/wm/window_state_aura.h" 18 #include "ash/wm/window_state_aura.h"
21 #include "base/command_line.h" 19 #include "base/command_line.h"
22 #include "base/format_macros.h" 20 #include "base/format_macros.h"
23 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
24 #include "base/strings/stringprintf.h" 22 #include "base/strings/stringprintf.h"
25 #include "build/build_config.h" 23 #include "build/build_config.h"
26 #include "grit/ash_strings.h" 24 #include "grit/ash_strings.h"
27 #include "ui/aura/client/aura_constants.h" 25 #include "ui/aura/client/aura_constants.h"
(...skipping 21 matching lines...) Expand all
49 using base::StringPrintf; 47 using base::StringPrintf;
50 48
51 namespace { 49 namespace {
52 50
53 std::string ToDisplayName(int64_t id) { 51 std::string ToDisplayName(int64_t id) {
54 return "x-" + base::Int64ToString(id); 52 return "x-" + base::Int64ToString(id);
55 } 53 }
56 54
57 } // namespace 55 } // namespace
58 56
59 class DisplayManagerTest : public test::AshMDTestBase, 57 class DisplayManagerTest : public test::AshTestBase,
60 public display::DisplayObserver, 58 public display::DisplayObserver,
61 public aura::WindowObserver { 59 public aura::WindowObserver {
62 public: 60 public:
63 DisplayManagerTest() 61 DisplayManagerTest()
64 : removed_count_(0U), 62 : removed_count_(0U),
65 root_window_destroyed_(false), 63 root_window_destroyed_(false),
66 changed_metrics_(0U) {} 64 changed_metrics_(0U) {}
67 ~DisplayManagerTest() override {} 65 ~DisplayManagerTest() override {}
68 66
69 void SetUp() override { 67 void SetUp() override {
70 AshMDTestBase::SetUp(); 68 AshTestBase::SetUp();
71 display::Screen::GetScreen()->AddObserver(this); 69 display::Screen::GetScreen()->AddObserver(this);
72 Shell::GetPrimaryRootWindow()->AddObserver(this); 70 Shell::GetPrimaryRootWindow()->AddObserver(this);
73 } 71 }
74 void TearDown() override { 72 void TearDown() override {
75 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 73 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
76 display::Screen::GetScreen()->RemoveObserver(this); 74 display::Screen::GetScreen()->RemoveObserver(this);
77 AshMDTestBase::TearDown(); 75 AshTestBase::TearDown();
78 } 76 }
79 77
80 const vector<display::Display>& changed() const { return changed_; } 78 const vector<display::Display>& changed() const { return changed_; }
81 const vector<display::Display>& added() const { return added_; } 79 const vector<display::Display>& added() const { return added_; }
82 uint32_t changed_metrics() const { return changed_metrics_; } 80 uint32_t changed_metrics() const { return changed_metrics_; }
83 81
84 string GetCountSummary() const { 82 string GetCountSummary() const {
85 return StringPrintf("%" PRIuS " %" PRIuS " %" PRIuS, changed_.size(), 83 return StringPrintf("%" PRIuS " %" PRIuS " %" PRIuS, changed_.size(),
86 added_.size(), removed_count_); 84 added_.size(), removed_count_);
87 } 85 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 private: 133 private:
136 vector<display::Display> changed_; 134 vector<display::Display> changed_;
137 vector<display::Display> added_; 135 vector<display::Display> added_;
138 size_t removed_count_; 136 size_t removed_count_;
139 bool root_window_destroyed_; 137 bool root_window_destroyed_;
140 uint32_t changed_metrics_; 138 uint32_t changed_metrics_;
141 139
142 DISALLOW_COPY_AND_ASSIGN(DisplayManagerTest); 140 DISALLOW_COPY_AND_ASSIGN(DisplayManagerTest);
143 }; 141 };
144 142
145 INSTANTIATE_TEST_CASE_P( 143 TEST_F(DisplayManagerTest, UpdateDisplayTest) {
146 /* prefix intentionally left blank due to only one parameterization */,
147 DisplayManagerTest,
148 testing::Values(MaterialDesignController::NON_MATERIAL,
149 MaterialDesignController::MATERIAL_NORMAL,
150 MaterialDesignController::MATERIAL_EXPERIMENTAL));
151
152 TEST_P(DisplayManagerTest, UpdateDisplayTest) {
153 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 144 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
154 145
155 // Update primary and add seconary. 146 // Update primary and add seconary.
156 UpdateDisplay("100+0-500x500,0+501-400x400"); 147 UpdateDisplay("100+0-500x500,0+501-400x400");
157 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); 148 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
158 EXPECT_EQ("0,0 500x500", 149 EXPECT_EQ("0,0 500x500",
159 display_manager()->GetDisplayAt(0).bounds().ToString()); 150 display_manager()->GetDisplayAt(0).bounds().ToString());
160 151
161 EXPECT_EQ("2 1 0", GetCountSummary()); 152 EXPECT_EQ("2 1 0", GetCountSummary());
162 EXPECT_EQ(display_manager()->GetDisplayAt(1).id(), changed()[0].id()); 153 EXPECT_EQ(display_manager()->GetDisplayAt(1).id(), changed()[0].id());
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // Changing primary will update secondary as well. 235 // Changing primary will update secondary as well.
245 UpdateDisplay("0+0-800x600,1000+1000-600x400"); 236 UpdateDisplay("0+0-800x600,1000+1000-600x400");
246 EXPECT_EQ("2 0 0", GetCountSummary()); 237 EXPECT_EQ("2 0 0", GetCountSummary());
247 reset(); 238 reset();
248 EXPECT_EQ("0,0 800x600", 239 EXPECT_EQ("0,0 800x600",
249 display_manager()->GetDisplayAt(0).bounds().ToString()); 240 display_manager()->GetDisplayAt(0).bounds().ToString());
250 EXPECT_EQ("800,0 600x400", 241 EXPECT_EQ("800,0 600x400",
251 display_manager()->GetDisplayAt(1).bounds().ToString()); 242 display_manager()->GetDisplayAt(1).bounds().ToString());
252 } 243 }
253 244
254 TEST_P(DisplayManagerTest, ScaleOnlyChange) { 245 TEST_F(DisplayManagerTest, ScaleOnlyChange) {
255 display_manager()->ToggleDisplayScaleFactor(); 246 display_manager()->ToggleDisplayScaleFactor();
256 EXPECT_TRUE(changed_metrics() & 247 EXPECT_TRUE(changed_metrics() &
257 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); 248 display::DisplayObserver::DISPLAY_METRIC_BOUNDS);
258 EXPECT_TRUE(changed_metrics() & 249 EXPECT_TRUE(changed_metrics() &
259 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 250 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
260 } 251 }
261 252
262 // Test in emulation mode (use_fullscreen_host_window=false) 253 // Test in emulation mode (use_fullscreen_host_window=false)
263 TEST_P(DisplayManagerTest, EmulatorTest) { 254 TEST_F(DisplayManagerTest, EmulatorTest) {
264 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 255 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
265 256
266 display_manager()->AddRemoveDisplay(); 257 display_manager()->AddRemoveDisplay();
267 // Update primary and add seconary. 258 // Update primary and add seconary.
268 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); 259 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
269 EXPECT_EQ("1 1 0", GetCountSummary()); 260 EXPECT_EQ("1 1 0", GetCountSummary());
270 reset(); 261 reset();
271 262
272 display_manager()->AddRemoveDisplay(); 263 display_manager()->AddRemoveDisplay();
273 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 264 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
274 EXPECT_EQ("0 0 1", GetCountSummary()); 265 EXPECT_EQ("0 0 1", GetCountSummary());
275 reset(); 266 reset();
276 267
277 display_manager()->AddRemoveDisplay(); 268 display_manager()->AddRemoveDisplay();
278 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); 269 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
279 EXPECT_EQ("1 1 0", GetCountSummary()); 270 EXPECT_EQ("1 1 0", GetCountSummary());
280 } 271 }
281 272
282 // Tests support for 3 displays. 273 // Tests support for 3 displays.
283 TEST_P(DisplayManagerTest, UpdateThreeDisplaysWithDefaultLayout) { 274 TEST_F(DisplayManagerTest, UpdateThreeDisplaysWithDefaultLayout) {
284 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 275 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
285 276
286 // Test with three displays. Native origin will not affect ash 277 // Test with three displays. Native origin will not affect ash
287 // display layout. 278 // display layout.
288 UpdateDisplay("0+0-640x480,1000+0-320x200,2000+0-400x300"); 279 UpdateDisplay("0+0-640x480,1000+0-320x200,2000+0-400x300");
289 280
290 EXPECT_EQ(3U, display_manager()->GetNumDisplays()); 281 EXPECT_EQ(3U, display_manager()->GetNumDisplays());
291 EXPECT_EQ("0,0 640x480", 282 EXPECT_EQ("0,0 640x480",
292 display_manager()->GetDisplayAt(0).bounds().ToString()); 283 display_manager()->GetDisplayAt(0).bounds().ToString());
293 EXPECT_EQ("640,0 320x200", 284 EXPECT_EQ("640,0 320x200",
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 UpdateDisplay("640x480,320x200,400x300"); 323 UpdateDisplay("640x480,320x200,400x300");
333 324
334 EXPECT_EQ("0,0 640x480", 325 EXPECT_EQ("0,0 640x480",
335 display_manager()->GetDisplayAt(0).bounds().ToString()); 326 display_manager()->GetDisplayAt(0).bounds().ToString());
336 EXPECT_EQ("10,480 320x200", 327 EXPECT_EQ("10,480 320x200",
337 display_manager()->GetDisplayAt(1).bounds().ToString()); 328 display_manager()->GetDisplayAt(1).bounds().ToString());
338 EXPECT_EQ("20,680 400x300", 329 EXPECT_EQ("20,680 400x300",
339 display_manager()->GetDisplayAt(2).bounds().ToString()); 330 display_manager()->GetDisplayAt(2).bounds().ToString());
340 } 331 }
341 332
342 TEST_P(DisplayManagerTest, LayoutMorethanThreeDisplaysTest) { 333 TEST_F(DisplayManagerTest, LayoutMorethanThreeDisplaysTest) {
343 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 334 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
344 display::DisplayIdList list = display::test::CreateDisplayIdListN( 335 display::DisplayIdList list = display::test::CreateDisplayIdListN(
345 3, primary_id, primary_id + 1, primary_id + 2); 336 3, primary_id, primary_id + 1, primary_id + 2);
346 { 337 {
347 // Layout: [2] 338 // Layout: [2]
348 // [1][P] 339 // [1][P]
349 display::DisplayLayoutBuilder builder(primary_id); 340 display::DisplayLayoutBuilder builder(primary_id);
350 builder.AddDisplayPlacement(list[1], primary_id, 341 builder.AddDisplayPlacement(list[1], primary_id,
351 display::DisplayPlacement::LEFT, 10); 342 display::DisplayPlacement::LEFT, 10);
352 builder.AddDisplayPlacement(list[2], list[1], 343 builder.AddDisplayPlacement(list[2], list[1],
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 EXPECT_EQ("-290,480 300x200", 441 EXPECT_EQ("-290,480 300x200",
451 display_manager()->GetDisplayAt(3).bounds().ToString()); 442 display_manager()->GetDisplayAt(3).bounds().ToString());
452 // 1st is the bottom of 3rd. 443 // 1st is the bottom of 3rd.
453 EXPECT_EQ("-280,680 320x200", 444 EXPECT_EQ("-280,680 320x200",
454 display_manager()->GetDisplayAt(1).bounds().ToString()); 445 display_manager()->GetDisplayAt(1).bounds().ToString());
455 } 446 }
456 } 447 }
457 448
458 // Makes sure that layouts with overlapped displays are detected and fixed when 449 // Makes sure that layouts with overlapped displays are detected and fixed when
459 // applied. 450 // applied.
460 TEST_P(DisplayManagerTest, NoOverlappedDisplays) { 451 TEST_F(DisplayManagerTest, NoOverlappedDisplays) {
461 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 452 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
462 { 453 {
463 // Layout with multiple overlaps and special cases: 454 // Layout with multiple overlaps and special cases:
464 // 455 //
465 // +-----+ 456 // +-----+
466 // +----+-+6 | 457 // +----+-+6 |
467 // | 5 | | | 458 // | 5 | | |
468 // +----+----+ | | 459 // +----+----+ | |
469 // | 7 | | | | 460 // | 7 | | | |
470 // +----+----+-+---+---+-+---------+ 461 // +----+----+-+---+---+-+---------+
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 EXPECT_EQ(3U, display_manager()->GetNumDisplays()); 728 EXPECT_EQ(3U, display_manager()->GetNumDisplays());
738 EXPECT_EQ(gfx::Rect(0, 0, 696, 500), 729 EXPECT_EQ(gfx::Rect(0, 0, 696, 500),
739 display_manager()->GetDisplayAt(0).bounds()); 730 display_manager()->GetDisplayAt(0).bounds());
740 EXPECT_EQ(gfx::Rect(0, -500, 696, 500), 731 EXPECT_EQ(gfx::Rect(0, -500, 696, 500),
741 display_manager()->GetDisplayAt(1).bounds()); 732 display_manager()->GetDisplayAt(1).bounds());
742 EXPECT_EQ(gfx::Rect(-696, -500, 696, 500), 733 EXPECT_EQ(gfx::Rect(-696, -500, 696, 500),
743 display_manager()->GetDisplayAt(2).bounds()); 734 display_manager()->GetDisplayAt(2).bounds());
744 } 735 }
745 } 736 }
746 737
747 TEST_P(DisplayManagerTest, NoOverlappedDisplaysNotFitBetweenTwo) { 738 TEST_F(DisplayManagerTest, NoOverlappedDisplaysNotFitBetweenTwo) {
748 // +------+--+----+--+------+ 739 // +------+--+----+--+------+
749 // | 1 | | 2 | | 3 | 740 // | 1 | | 2 | | 3 |
750 // | | | | | | 741 // | | | | | |
751 // | | | | | | 742 // | | | | | |
752 // | | | | | | 743 // | | | | | |
753 // +-+----+--+----+--+---+--+ 744 // +-+----+--+----+--+---+--+
754 // | P | 745 // | P |
755 // | | 746 // | |
756 // | | 747 // | |
757 // | | 748 // | |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 EXPECT_EQ(gfx::Rect(0, 0, 1200, 500), 782 EXPECT_EQ(gfx::Rect(0, 0, 1200, 500),
792 display_manager()->GetDisplayAt(0).bounds()); 783 display_manager()->GetDisplayAt(0).bounds());
793 EXPECT_EQ(gfx::Rect(-110, -500, 600, 500), 784 EXPECT_EQ(gfx::Rect(-110, -500, 600, 500),
794 display_manager()->GetDisplayAt(1).bounds()); 785 display_manager()->GetDisplayAt(1).bounds());
795 EXPECT_EQ(gfx::Rect(490, -500, 600, 500), 786 EXPECT_EQ(gfx::Rect(490, -500, 600, 500),
796 display_manager()->GetDisplayAt(2).bounds()); 787 display_manager()->GetDisplayAt(2).bounds());
797 EXPECT_EQ(gfx::Rect(1090, -500, 600, 500), 788 EXPECT_EQ(gfx::Rect(1090, -500, 600, 500),
798 display_manager()->GetDisplayAt(3).bounds()); 789 display_manager()->GetDisplayAt(3).bounds());
799 } 790 }
800 791
801 TEST_P(DisplayManagerTest, NoOverlappedDisplaysAfterResolutionChange) { 792 TEST_F(DisplayManagerTest, NoOverlappedDisplaysAfterResolutionChange) {
802 // Starting with a good layout with no overlaps, test that if the resolution 793 // Starting with a good layout with no overlaps, test that if the resolution
803 // of one of the displays is changed, it won't result in any overlaps. 794 // of one of the displays is changed, it won't result in any overlaps.
804 // 795 //
805 // +-------------------+ 796 // +-------------------+
806 // | 4 | 797 // | 4 |
807 // | | 798 // | |
808 // | | 799 // | |
809 // | | 800 // | |
810 // +----+----+---------+----+----+ 801 // +----+----+---------+----+----+
811 // | 1 | 2 | 3 | 802 // | 1 | 2 | 3 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 EXPECT_EQ(gfx::Rect(-250, -500, 500, 500), 871 EXPECT_EQ(gfx::Rect(-250, -500, 500, 500),
881 display_manager()->GetDisplayAt(1).bounds()); 872 display_manager()->GetDisplayAt(1).bounds());
882 EXPECT_EQ(gfx::Rect(250, -600, 600, 600), 873 EXPECT_EQ(gfx::Rect(250, -600, 600, 600),
883 display_manager()->GetDisplayAt(2).bounds()); 874 display_manager()->GetDisplayAt(2).bounds());
884 EXPECT_EQ(gfx::Rect(850, -500, 500, 500), 875 EXPECT_EQ(gfx::Rect(850, -500, 500, 500),
885 display_manager()->GetDisplayAt(3).bounds()); 876 display_manager()->GetDisplayAt(3).bounds());
886 EXPECT_EQ(gfx::Rect(0, -1100, 1000, 500), 877 EXPECT_EQ(gfx::Rect(0, -1100, 1000, 500),
887 display_manager()->GetDisplayAt(4).bounds()); 878 display_manager()->GetDisplayAt(4).bounds());
888 } 879 }
889 880
890 TEST_P(DisplayManagerTest, NoOverlappedDisplaysWithDetachedDisplays) { 881 TEST_F(DisplayManagerTest, NoOverlappedDisplaysWithDetachedDisplays) {
891 // Detached displays that intersect other non-detached displays. 882 // Detached displays that intersect other non-detached displays.
892 // 883 //
893 // +---------+---------+---------+ 884 // +---------+---------+---------+
894 // | 1 | 2 | 3 | 885 // | 1 | 2 | 3 |
895 // | | | | 886 // | | | |
896 // | | | | 887 // | | | |
897 // | | | | 888 // | | | |
898 // +----+----+-----+---+----+----+ 889 // +----+----+-----+---+----+----+
899 // | 4, 5 | P | 890 // | 4, 5 | P |
900 // | detached | | 891 // | detached | |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 expected_layout_builder.AddDisplayPlacement( 958 expected_layout_builder.AddDisplayPlacement(
968 list[4], primary_id, display::DisplayPlacement::BOTTOM, 0); 959 list[4], primary_id, display::DisplayPlacement::BOTTOM, 0);
969 expected_layout_builder.AddDisplayPlacement( 960 expected_layout_builder.AddDisplayPlacement(
970 list[5], list[4], display::DisplayPlacement::BOTTOM, 0); 961 list[5], list[4], display::DisplayPlacement::BOTTOM, 0);
971 962
972 const display::DisplayLayout& layout = 963 const display::DisplayLayout& layout =
973 display_manager()->GetCurrentResolvedDisplayLayout(); 964 display_manager()->GetCurrentResolvedDisplayLayout();
974 EXPECT_TRUE(layout.HasSamePlacementList(*(expected_layout_builder.Build()))); 965 EXPECT_TRUE(layout.HasSamePlacementList(*(expected_layout_builder.Build())));
975 } 966 }
976 967
977 TEST_P(DisplayManagerTest, NoMirrorInThreeDisplays) { 968 TEST_F(DisplayManagerTest, NoMirrorInThreeDisplays) {
978 UpdateDisplay("640x480,320x200,400x300"); 969 UpdateDisplay("640x480,320x200,400x300");
979 ash::Shell::GetInstance()->display_configuration_controller()->SetMirrorMode( 970 ash::Shell::GetInstance()->display_configuration_controller()->SetMirrorMode(
980 true, true); 971 true, true);
981 EXPECT_FALSE(display_manager()->IsInMirrorMode()); 972 EXPECT_FALSE(display_manager()->IsInMirrorMode());
982 EXPECT_EQ(3u, display_manager()->GetNumDisplays()); 973 EXPECT_EQ(3u, display_manager()->GetNumDisplays());
983 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_MIRRORING_NOT_SUPPORTED), 974 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_MIRRORING_NOT_SUPPORTED),
984 GetDisplayErrorNotificationMessageForTest()); 975 GetDisplayErrorNotificationMessageForTest());
985 } 976 }
986 977
987 TEST_P(DisplayManagerTest, OverscanInsetsTest) { 978 TEST_F(DisplayManagerTest, OverscanInsetsTest) {
988 UpdateDisplay("0+0-500x500,0+501-400x400"); 979 UpdateDisplay("0+0-500x500,0+501-400x400");
989 reset(); 980 reset();
990 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); 981 ASSERT_EQ(2u, display_manager()->GetNumDisplays());
991 const display::ManagedDisplayInfo display_info1 = GetDisplayInfoAt(0); 982 const display::ManagedDisplayInfo display_info1 = GetDisplayInfoAt(0);
992 const display::ManagedDisplayInfo display_info2 = GetDisplayInfoAt(1); 983 const display::ManagedDisplayInfo display_info2 = GetDisplayInfoAt(1);
993 984
994 display_manager()->SetOverscanInsets(display_info2.id(), 985 display_manager()->SetOverscanInsets(display_info2.id(),
995 gfx::Insets(13, 12, 11, 10)); 986 gfx::Insets(13, 12, 11, 10));
996 987
997 std::vector<display::Display> changed_displays = changed(); 988 std::vector<display::Display> changed_displays = changed();
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 display_manager()->SetOverscanInsets(primary_id, gfx::Insets(0, 0, 0, 0)); 1090 display_manager()->SetOverscanInsets(primary_id, gfx::Insets(0, 0, 0, 0));
1100 EXPECT_TRUE(changed_metrics() & 1091 EXPECT_TRUE(changed_metrics() &
1101 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); 1092 display::DisplayObserver::DISPLAY_METRIC_BOUNDS);
1102 EXPECT_TRUE(changed_metrics() & 1093 EXPECT_TRUE(changed_metrics() &
1103 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 1094 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
1104 EXPECT_EQ( 1095 EXPECT_EQ(
1105 "0,0 500x500", 1096 "0,0 500x500",
1106 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString()); 1097 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString());
1107 } 1098 }
1108 1099
1109 TEST_P(DisplayManagerTest, ZeroOverscanInsets) { 1100 TEST_F(DisplayManagerTest, ZeroOverscanInsets) {
1110 // Make sure the display change events is emitted for overscan inset changes. 1101 // Make sure the display change events is emitted for overscan inset changes.
1111 UpdateDisplay("0+0-500x500,0+501-400x400"); 1102 UpdateDisplay("0+0-500x500,0+501-400x400");
1112 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); 1103 ASSERT_EQ(2u, display_manager()->GetNumDisplays());
1113 int64_t display2_id = display_manager()->GetDisplayAt(1).id(); 1104 int64_t display2_id = display_manager()->GetDisplayAt(1).id();
1114 1105
1115 reset(); 1106 reset();
1116 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0)); 1107 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0));
1117 EXPECT_EQ(0u, changed().size()); 1108 EXPECT_EQ(0u, changed().size());
1118 1109
1119 reset(); 1110 reset();
1120 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(1, 0, 0, 0)); 1111 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(1, 0, 0, 0));
1121 EXPECT_EQ(1u, changed().size()); 1112 EXPECT_EQ(1u, changed().size());
1122 EXPECT_EQ(display2_id, changed()[0].id()); 1113 EXPECT_EQ(display2_id, changed()[0].id());
1123 1114
1124 reset(); 1115 reset();
1125 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0)); 1116 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0));
1126 EXPECT_EQ(1u, changed().size()); 1117 EXPECT_EQ(1u, changed().size());
1127 EXPECT_EQ(display2_id, changed()[0].id()); 1118 EXPECT_EQ(display2_id, changed()[0].id());
1128 } 1119 }
1129 1120
1130 TEST_P(DisplayManagerTest, TouchCalibrationTest) { 1121 TEST_F(DisplayManagerTest, TouchCalibrationTest) {
1131 UpdateDisplay("0+0-500x500,0+501-1024x600"); 1122 UpdateDisplay("0+0-500x500,0+501-1024x600");
1132 reset(); 1123 reset();
1133 1124
1134 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); 1125 ASSERT_EQ(2u, display_manager()->GetNumDisplays());
1135 const display::ManagedDisplayInfo display_info1 = GetDisplayInfoAt(0); 1126 const display::ManagedDisplayInfo display_info1 = GetDisplayInfoAt(0);
1136 const display::ManagedDisplayInfo display_info2 = GetDisplayInfoAt(1); 1127 const display::ManagedDisplayInfo display_info2 = GetDisplayInfoAt(1);
1137 1128
1138 EXPECT_FALSE(display_info2.has_touch_calibration_data()); 1129 EXPECT_FALSE(display_info2.has_touch_calibration_data());
1139 1130
1140 display::TouchCalibrationData::CalibrationPointPairQuad point_pair_quad = { 1131 display::TouchCalibrationData::CalibrationPointPairQuad point_pair_quad = {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 std::vector<display::ManagedDisplayInfo> display_info_list; 1181 std::vector<display::ManagedDisplayInfo> display_info_list;
1191 display_info_list.push_back(display_info1); 1182 display_info_list.push_back(display_info1);
1192 display_info_list.push_back(display_info2); 1183 display_info_list.push_back(display_info2);
1193 display_manager()->OnNativeDisplaysChanged(display_info_list); 1184 display_manager()->OnNativeDisplaysChanged(display_info_list);
1194 updated_display_info2 = GetDisplayInfoAt(1); 1185 updated_display_info2 = GetDisplayInfoAt(1);
1195 1186
1196 EXPECT_FALSE(updated_display_info2.has_touch_calibration_data()); 1187 EXPECT_FALSE(updated_display_info2.has_touch_calibration_data());
1197 EXPECT_EQ(touch_data, updated_display_info2.GetTouchCalibrationData()); 1188 EXPECT_EQ(touch_data, updated_display_info2.GetTouchCalibrationData());
1198 } 1189 }
1199 1190
1200 TEST_P(DisplayManagerTest, TestDeviceScaleOnlyChange) { 1191 TEST_F(DisplayManagerTest, TestDeviceScaleOnlyChange) {
1201 UpdateDisplay("1000x600"); 1192 UpdateDisplay("1000x600");
1202 aura::WindowTreeHost* host = Shell::GetPrimaryRootWindow()->GetHost(); 1193 aura::WindowTreeHost* host = Shell::GetPrimaryRootWindow()->GetHost();
1203 EXPECT_EQ(1, host->compositor()->device_scale_factor()); 1194 EXPECT_EQ(1, host->compositor()->device_scale_factor());
1204 EXPECT_EQ("1000x600", 1195 EXPECT_EQ("1000x600",
1205 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); 1196 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
1206 EXPECT_EQ("1 0 0", GetCountSummary()); 1197 EXPECT_EQ("1 0 0", GetCountSummary());
1207 1198
1208 UpdateDisplay("1000x600*2"); 1199 UpdateDisplay("1000x600*2");
1209 EXPECT_EQ(2, host->compositor()->device_scale_factor()); 1200 EXPECT_EQ(2, host->compositor()->device_scale_factor());
1210 EXPECT_EQ("2 0 0", GetCountSummary()); 1201 EXPECT_EQ("2 0 0", GetCountSummary());
1211 EXPECT_EQ("500x300", 1202 EXPECT_EQ("500x300",
1212 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); 1203 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
1213 } 1204 }
1214 1205
1215 display::ManagedDisplayInfo CreateDisplayInfo(int64_t id, 1206 display::ManagedDisplayInfo CreateDisplayInfo(int64_t id,
1216 const gfx::Rect& bounds) { 1207 const gfx::Rect& bounds) {
1217 display::ManagedDisplayInfo info(id, ToDisplayName(id), false); 1208 display::ManagedDisplayInfo info(id, ToDisplayName(id), false);
1218 info.SetBounds(bounds); 1209 info.SetBounds(bounds);
1219 return info; 1210 return info;
1220 } 1211 }
1221 1212
1222 TEST_P(DisplayManagerTest, TestNativeDisplaysChanged) { 1213 TEST_F(DisplayManagerTest, TestNativeDisplaysChanged) {
1223 const int64_t internal_display_id = 1214 const int64_t internal_display_id =
1224 display::test::DisplayManagerTestApi(display_manager()) 1215 display::test::DisplayManagerTestApi(display_manager())
1225 .SetFirstDisplayAsInternalDisplay(); 1216 .SetFirstDisplayAsInternalDisplay();
1226 const int external_id = 10; 1217 const int external_id = 10;
1227 const int mirror_id = 11; 1218 const int mirror_id = 11;
1228 const int64_t invalid_id = display::kInvalidDisplayId; 1219 const int64_t invalid_id = display::kInvalidDisplayId;
1229 const display::ManagedDisplayInfo internal_display_info = 1220 const display::ManagedDisplayInfo internal_display_info =
1230 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); 1221 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500));
1231 const display::ManagedDisplayInfo external_display_info = 1222 const display::ManagedDisplayInfo external_display_info =
1232 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); 1223 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100));
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 1368 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
1378 EXPECT_EQ( 1369 EXPECT_EQ(
1379 "0,0 500x500", 1370 "0,0 500x500",
1380 GetDisplayInfoForId(internal_display_id).bounds_in_native().ToString()); 1371 GetDisplayInfoForId(internal_display_id).bounds_in_native().ToString());
1381 EXPECT_EQ(1U, display_manager()->num_connected_displays()); 1372 EXPECT_EQ(1U, display_manager()->num_connected_displays());
1382 EXPECT_FALSE(display_manager()->IsInMirrorMode()); 1373 EXPECT_FALSE(display_manager()->IsInMirrorMode());
1383 } 1374 }
1384 1375
1385 // Make sure crash does not happen if add and remove happens at the same time. 1376 // Make sure crash does not happen if add and remove happens at the same time.
1386 // See: crbug.com/414394 1377 // See: crbug.com/414394
1387 TEST_P(DisplayManagerTest, DisplayAddRemoveAtTheSameTime) { 1378 TEST_F(DisplayManagerTest, DisplayAddRemoveAtTheSameTime) {
1388 UpdateDisplay("100+0-500x500,0+501-400x400"); 1379 UpdateDisplay("100+0-500x500,0+501-400x400");
1389 1380
1390 const int64_t primary_id = WindowTreeHostManager::GetPrimaryDisplayId(); 1381 const int64_t primary_id = WindowTreeHostManager::GetPrimaryDisplayId();
1391 const int64_t secondary_id = display_manager()->GetSecondaryDisplay().id(); 1382 const int64_t secondary_id = display_manager()->GetSecondaryDisplay().id();
1392 1383
1393 display::ManagedDisplayInfo primary_info = 1384 display::ManagedDisplayInfo primary_info =
1394 display_manager()->GetDisplayInfo(primary_id); 1385 display_manager()->GetDisplayInfo(primary_id);
1395 display::ManagedDisplayInfo secondary_info = 1386 display::ManagedDisplayInfo secondary_info =
1396 display_manager()->GetDisplayInfo(secondary_id); 1387 display_manager()->GetDisplayInfo(secondary_id);
1397 1388
1398 // An id which is different from primary and secondary. 1389 // An id which is different from primary and secondary.
1399 const int64_t third_id = secondary_id + 1; 1390 const int64_t third_id = secondary_id + 1;
1400 1391
1401 display::ManagedDisplayInfo third_info = 1392 display::ManagedDisplayInfo third_info =
1402 CreateDisplayInfo(third_id, gfx::Rect(0, 0, 600, 600)); 1393 CreateDisplayInfo(third_id, gfx::Rect(0, 0, 600, 600));
1403 1394
1404 std::vector<display::ManagedDisplayInfo> display_info_list; 1395 std::vector<display::ManagedDisplayInfo> display_info_list;
1405 display_info_list.push_back(third_info); 1396 display_info_list.push_back(third_info);
1406 display_info_list.push_back(secondary_info); 1397 display_info_list.push_back(secondary_info);
1407 display_manager()->OnNativeDisplaysChanged(display_info_list); 1398 display_manager()->OnNativeDisplaysChanged(display_info_list);
1408 1399
1409 // Secondary seconary_id becomes the primary as it has smaller output index. 1400 // Secondary seconary_id becomes the primary as it has smaller output index.
1410 EXPECT_EQ(secondary_id, WindowTreeHostManager::GetPrimaryDisplayId()); 1401 EXPECT_EQ(secondary_id, WindowTreeHostManager::GetPrimaryDisplayId());
1411 EXPECT_EQ(third_id, display_manager()->GetSecondaryDisplay().id()); 1402 EXPECT_EQ(third_id, display_manager()->GetSecondaryDisplay().id());
1412 EXPECT_EQ("600x600", GetDisplayForId(third_id).size().ToString()); 1403 EXPECT_EQ("600x600", GetDisplayForId(third_id).size().ToString());
1413 } 1404 }
1414 1405
1415 TEST_P(DisplayManagerTest, TestNativeDisplaysChangedNoInternal) { 1406 TEST_F(DisplayManagerTest, TestNativeDisplaysChangedNoInternal) {
1416 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 1407 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
1417 1408
1418 // Don't change the display info if all displays are disconnected. 1409 // Don't change the display info if all displays are disconnected.
1419 std::vector<display::ManagedDisplayInfo> display_info_list; 1410 std::vector<display::ManagedDisplayInfo> display_info_list;
1420 display_manager()->OnNativeDisplaysChanged(display_info_list); 1411 display_manager()->OnNativeDisplaysChanged(display_info_list);
1421 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 1412 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
1422 1413
1423 // Connect another display which will become primary. 1414 // Connect another display which will become primary.
1424 const display::ManagedDisplayInfo external_display_info = 1415 const display::ManagedDisplayInfo external_display_info =
1425 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); 1416 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100));
1426 display_info_list.push_back(external_display_info); 1417 display_info_list.push_back(external_display_info);
1427 display_manager()->OnNativeDisplaysChanged(display_info_list); 1418 display_manager()->OnNativeDisplaysChanged(display_info_list);
1428 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 1419 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
1429 EXPECT_EQ("1,1 100x100", 1420 EXPECT_EQ("1,1 100x100",
1430 GetDisplayInfoForId(10).bounds_in_native().ToString()); 1421 GetDisplayInfoForId(10).bounds_in_native().ToString());
1431 EXPECT_EQ("100x100", ash::Shell::GetPrimaryRootWindow() 1422 EXPECT_EQ("100x100", ash::Shell::GetPrimaryRootWindow()
1432 ->GetHost() 1423 ->GetHost()
1433 ->GetBoundsInPixels() 1424 ->GetBoundsInPixels()
1434 .size() 1425 .size()
1435 .ToString()); 1426 .ToString());
1436 } 1427 }
1437 1428
1438 TEST_P(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) { 1429 TEST_F(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) {
1439 const int64_t internal_display_id = 1430 const int64_t internal_display_id =
1440 display::test::DisplayManagerTestApi(display_manager()) 1431 display::test::DisplayManagerTestApi(display_manager())
1441 .SetFirstDisplayAsInternalDisplay(); 1432 .SetFirstDisplayAsInternalDisplay();
1442 const display::ManagedDisplayInfo native_display_info = 1433 const display::ManagedDisplayInfo native_display_info =
1443 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); 1434 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500));
1444 const display::ManagedDisplayInfo secondary_display_info = 1435 const display::ManagedDisplayInfo secondary_display_info =
1445 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); 1436 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100));
1446 1437
1447 std::vector<display::ManagedDisplayInfo> display_info_list; 1438 std::vector<display::ManagedDisplayInfo> display_info_list;
1448 display_info_list.push_back(native_display_info); 1439 display_info_list.push_back(native_display_info);
(...skipping 11 matching lines...) Expand all
1460 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString()); 1451 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString());
1461 1452
1462 // OnNativeDisplaysChanged may change the display bounds. Here makes sure 1453 // OnNativeDisplaysChanged may change the display bounds. Here makes sure
1463 // nothing changed if the exactly same displays are specified. 1454 // nothing changed if the exactly same displays are specified.
1464 display_manager()->OnNativeDisplaysChanged(display_info_list); 1455 display_manager()->OnNativeDisplaysChanged(display_info_list);
1465 EXPECT_EQ("-500,0 500x500", 1456 EXPECT_EQ("-500,0 500x500",
1466 GetDisplayForId(internal_display_id).bounds().ToString()); 1457 GetDisplayForId(internal_display_id).bounds().ToString());
1467 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString()); 1458 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString());
1468 } 1459 }
1469 1460
1470 TEST_P(DisplayManagerTest, DontRememberBestResolution) { 1461 TEST_F(DisplayManagerTest, DontRememberBestResolution) {
1471 int display_id = 1000; 1462 int display_id = 1000;
1472 display::ManagedDisplayInfo native_display_info = 1463 display::ManagedDisplayInfo native_display_info =
1473 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); 1464 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500));
1474 display::ManagedDisplayInfo::ManagedDisplayModeList display_modes; 1465 display::ManagedDisplayInfo::ManagedDisplayModeList display_modes;
1475 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode( 1466 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode(
1476 gfx::Size(1000, 500), 58.0f, false, true))); 1467 gfx::Size(1000, 500), 58.0f, false, true)));
1477 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode( 1468 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode(
1478 gfx::Size(800, 300), 59.0f, false, false))); 1469 gfx::Size(800, 300), 59.0f, false, false)));
1479 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode( 1470 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode(
1480 gfx::Size(400, 500), 60.0f, false, false))); 1471 gfx::Size(400, 500), 60.0f, false, false)));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 EXPECT_EQ(58.0f, mode->refresh_rate()); 1518 EXPECT_EQ(58.0f, mode->refresh_rate());
1528 EXPECT_TRUE(mode->native()); 1519 EXPECT_TRUE(mode->native());
1529 1520
1530 expected_mode = 1521 expected_mode =
1531 new display::ManagedDisplayMode(gfx::Size(1000, 500), 0.0f, false, false); 1522 new display::ManagedDisplayMode(gfx::Size(1000, 500), 0.0f, false, false);
1532 1523
1533 EXPECT_TRUE(expected_mode->IsEquivalent( 1524 EXPECT_TRUE(expected_mode->IsEquivalent(
1534 display_manager()->GetActiveModeForDisplayId(display_id))); 1525 display_manager()->GetActiveModeForDisplayId(display_id)));
1535 } 1526 }
1536 1527
1537 TEST_P(DisplayManagerTest, ResolutionFallback) { 1528 TEST_F(DisplayManagerTest, ResolutionFallback) {
1538 int display_id = 1000; 1529 int display_id = 1000;
1539 display::ManagedDisplayInfo native_display_info = 1530 display::ManagedDisplayInfo native_display_info =
1540 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); 1531 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500));
1541 display::ManagedDisplayInfo::ManagedDisplayModeList display_modes; 1532 display::ManagedDisplayInfo::ManagedDisplayModeList display_modes;
1542 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode( 1533 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode(
1543 gfx::Size(1000, 500), 58.0f, false, true))); 1534 gfx::Size(1000, 500), 58.0f, false, true)));
1544 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode( 1535 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode(
1545 gfx::Size(800, 300), 59.0f, false, false))); 1536 gfx::Size(800, 300), 59.0f, false, false)));
1546 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode( 1537 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode(
1547 gfx::Size(400, 500), 60.0f, false, false))); 1538 gfx::Size(400, 500), 60.0f, false, false)));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 1575
1585 scoped_refptr<display::ManagedDisplayMode> mode = 1576 scoped_refptr<display::ManagedDisplayMode> mode =
1586 display_manager()->GetSelectedModeForDisplayId(display_id); 1577 display_manager()->GetSelectedModeForDisplayId(display_id);
1587 EXPECT_TRUE(!!mode); 1578 EXPECT_TRUE(!!mode);
1588 EXPECT_EQ("1000x500", mode->size().ToString()); 1579 EXPECT_EQ("1000x500", mode->size().ToString());
1589 EXPECT_EQ(58.0f, mode->refresh_rate()); 1580 EXPECT_EQ(58.0f, mode->refresh_rate());
1590 EXPECT_TRUE(mode->native()); 1581 EXPECT_TRUE(mode->native());
1591 } 1582 }
1592 } 1583 }
1593 1584
1594 TEST_P(DisplayManagerTest, Rotate) { 1585 TEST_F(DisplayManagerTest, Rotate) {
1595 UpdateDisplay("100x200/r,300x400/l"); 1586 UpdateDisplay("100x200/r,300x400/l");
1596 EXPECT_EQ("1,1 100x200", GetDisplayInfoAt(0).bounds_in_native().ToString()); 1587 EXPECT_EQ("1,1 100x200", GetDisplayInfoAt(0).bounds_in_native().ToString());
1597 EXPECT_EQ("200x100", GetDisplayInfoAt(0).size_in_pixel().ToString()); 1588 EXPECT_EQ("200x100", GetDisplayInfoAt(0).size_in_pixel().ToString());
1598 1589
1599 EXPECT_EQ("1,201 300x400", GetDisplayInfoAt(1).bounds_in_native().ToString()); 1590 EXPECT_EQ("1,201 300x400", GetDisplayInfoAt(1).bounds_in_native().ToString());
1600 EXPECT_EQ("400x300", GetDisplayInfoAt(1).size_in_pixel().ToString()); 1591 EXPECT_EQ("400x300", GetDisplayInfoAt(1).size_in_pixel().ToString());
1601 reset(); 1592 reset();
1602 UpdateDisplay("100x200/b,300x400"); 1593 UpdateDisplay("100x200/b,300x400");
1603 EXPECT_EQ("2 0 0", GetCountSummary()); 1594 EXPECT_EQ("2 0 0", GetCountSummary());
1604 reset(); 1595 reset();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1669 internal_display_id, display::Display::ROTATE_180, 1660 internal_display_id, display::Display::ROTATE_180,
1670 display::Display::ROTATION_SOURCE_ACTIVE); 1661 display::Display::ROTATION_SOURCE_ACTIVE);
1671 const display::ManagedDisplayInfo& post_rotation_info = 1662 const display::ManagedDisplayInfo& post_rotation_info =
1672 display::test::DisplayManagerTestApi(display_manager()) 1663 display::test::DisplayManagerTestApi(display_manager())
1673 .GetInternalManagedDisplayInfo(internal_display_id); 1664 .GetInternalManagedDisplayInfo(internal_display_id);
1674 EXPECT_NE(info.GetActiveRotation(), post_rotation_info.GetActiveRotation()); 1665 EXPECT_NE(info.GetActiveRotation(), post_rotation_info.GetActiveRotation());
1675 EXPECT_EQ(display::Display::ROTATE_180, 1666 EXPECT_EQ(display::Display::ROTATE_180,
1676 post_rotation_info.GetActiveRotation()); 1667 post_rotation_info.GetActiveRotation());
1677 } 1668 }
1678 1669
1679 TEST_P(DisplayManagerTest, UIScale) { 1670 TEST_F(DisplayManagerTest, UIScale) {
1680 display::test::ScopedDisable125DSFForUIScaling disable; 1671 display::test::ScopedDisable125DSFForUIScaling disable;
1681 1672
1682 UpdateDisplay("1280x800"); 1673 UpdateDisplay("1280x800");
1683 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1674 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1684 display::test::DisplayManagerTestApi(display_manager()) 1675 display::test::DisplayManagerTestApi(display_manager())
1685 .SetDisplayUIScale(display_id, 1.125f); 1676 .SetDisplayUIScale(display_id, 1.125f);
1686 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale()); 1677 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale());
1687 display::test::DisplayManagerTestApi(display_manager()) 1678 display::test::DisplayManagerTestApi(display_manager())
1688 .SetDisplayUIScale(display_id, 0.8f); 1679 .SetDisplayUIScale(display_id, 0.8f);
1689 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1680 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 UpdateDisplay("1280x850*1.25"); 1786 UpdateDisplay("1280x850*1.25");
1796 display::test::DisplayManagerTestApi(display_manager()) 1787 display::test::DisplayManagerTestApi(display_manager())
1797 .SetDisplayUIScale(display_id, 1.25f); 1788 .SetDisplayUIScale(display_id, 1.25f);
1798 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).configured_ui_scale()); 1789 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).configured_ui_scale());
1799 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1790 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1800 display = display::Screen::GetScreen()->GetPrimaryDisplay(); 1791 display = display::Screen::GetScreen()->GetPrimaryDisplay();
1801 EXPECT_EQ(1.0f, display.device_scale_factor()); 1792 EXPECT_EQ(1.0f, display.device_scale_factor());
1802 EXPECT_EQ("1280x850", display.bounds().size().ToString()); 1793 EXPECT_EQ("1280x850", display.bounds().size().ToString());
1803 } 1794 }
1804 1795
1805 TEST_P(DisplayManagerTest, UIScaleWithDisplayMode) { 1796 TEST_F(DisplayManagerTest, UIScaleWithDisplayMode) {
1806 int display_id = 1000; 1797 int display_id = 1000;
1807 1798
1808 // Setup the display modes with UI-scale. 1799 // Setup the display modes with UI-scale.
1809 display::ManagedDisplayInfo native_display_info = 1800 display::ManagedDisplayInfo native_display_info =
1810 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1280, 800)); 1801 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1280, 800));
1811 const scoped_refptr<display::ManagedDisplayMode>& base_mode( 1802 const scoped_refptr<display::ManagedDisplayMode>& base_mode(
1812 new display::ManagedDisplayMode(gfx::Size(1280, 800), 60.0f, false, 1803 new display::ManagedDisplayMode(gfx::Size(1280, 800), 60.0f, false,
1813 false)); 1804 false));
1814 display::ManagedDisplayInfo::ManagedDisplayModeList mode_list = 1805 display::ManagedDisplayInfo::ManagedDisplayModeList mode_list =
1815 CreateInternalManagedDisplayModeList(base_mode); 1806 CreateInternalManagedDisplayModeList(base_mode);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1887 expected_mode->size(), expected_mode->refresh_rate(), 1878 expected_mode->size(), expected_mode->refresh_rate(),
1888 expected_mode->is_interlaced(), expected_mode->native(), 1879 expected_mode->is_interlaced(), expected_mode->native(),
1889 0.5f /* ui_scale */, expected_mode->device_scale_factor()); 1880 0.5f /* ui_scale */, expected_mode->device_scale_factor());
1890 1881
1891 EXPECT_TRUE(expected_mode->IsEquivalent( 1882 EXPECT_TRUE(expected_mode->IsEquivalent(
1892 display_manager()->GetActiveModeForDisplayId(display_id))); 1883 display_manager()->GetActiveModeForDisplayId(display_id)));
1893 } 1884 }
1894 1885
1895 // Tests that ResetInternalDisplayZoom() resets to the default 0.8f UI scale 1886 // Tests that ResetInternalDisplayZoom() resets to the default 0.8f UI scale
1896 // defined for the 1.25x displays. 1887 // defined for the 1.25x displays.
1897 TEST_P(DisplayManagerTest, ResetInternalDisplayZoomFor1_25x) { 1888 TEST_F(DisplayManagerTest, ResetInternalDisplayZoomFor1_25x) {
1898 // Setup the display modes with UI-scale. 1889 // Setup the display modes with UI-scale.
1899 const scoped_refptr<display::ManagedDisplayMode> base_mode( 1890 const scoped_refptr<display::ManagedDisplayMode> base_mode(
1900 new display::ManagedDisplayMode(gfx::Size(1920, 1080), 60.0f, 1891 new display::ManagedDisplayMode(gfx::Size(1920, 1080), 60.0f,
1901 false /* is_interlaced */, 1892 false /* is_interlaced */,
1902 true /* native */, 1.0f /* ui_scale */, 1893 true /* native */, 1.0f /* ui_scale */,
1903 1.25f /* device_scale_factor */)); 1894 1.25f /* device_scale_factor */));
1904 display::ManagedDisplayInfo::ManagedDisplayModeList mode_list = 1895 display::ManagedDisplayInfo::ManagedDisplayModeList mode_list =
1905 CreateInternalManagedDisplayModeList(base_mode); 1896 CreateInternalManagedDisplayModeList(base_mode);
1906 1897
1907 const int display_id = 1000; 1898 const int display_id = 1000;
(...skipping 22 matching lines...) Expand all
1930 1921
1931 // Reset the internal display zoom and expect the UI scale to go to the 1922 // Reset the internal display zoom and expect the UI scale to go to the
1932 // default 0.8f. 1923 // default 0.8f.
1933 display_manager()->ResetInternalDisplayZoom(); 1924 display_manager()->ResetInternalDisplayZoom();
1934 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1925 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1935 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1926 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1936 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); 1927 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale());
1937 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString()); 1928 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString());
1938 } 1929 }
1939 1930
1940 TEST_P(DisplayManagerTest, Use125DSFForUIScaling) { 1931 TEST_F(DisplayManagerTest, Use125DSFForUIScaling) {
1941 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1932 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1942 1933
1943 display::test::ScopedSetInternalDisplayId set_internal(display_manager(), 1934 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
1944 display_id); 1935 display_id);
1945 UpdateDisplay("1920x1080*1.25"); 1936 UpdateDisplay("1920x1080*1.25");
1946 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1937 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1947 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1938 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1948 1939
1949 display::test::DisplayManagerTestApi(display_manager()) 1940 display::test::DisplayManagerTestApi(display_manager())
1950 .SetDisplayUIScale(display_id, 0.8f); 1941 .SetDisplayUIScale(display_id, 0.8f);
1951 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1942 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1952 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1943 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1953 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString()); 1944 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString());
1954 1945
1955 display::test::DisplayManagerTestApi(display_manager()) 1946 display::test::DisplayManagerTestApi(display_manager())
1956 .SetDisplayUIScale(display_id, 0.5f); 1947 .SetDisplayUIScale(display_id, 0.5f);
1957 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1948 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1958 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1949 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1959 EXPECT_EQ("960x540", GetDisplayForId(display_id).size().ToString()); 1950 EXPECT_EQ("960x540", GetDisplayForId(display_id).size().ToString());
1960 1951
1961 display::test::DisplayManagerTestApi(display_manager()) 1952 display::test::DisplayManagerTestApi(display_manager())
1962 .SetDisplayUIScale(display_id, 1.25f); 1953 .SetDisplayUIScale(display_id, 1.25f);
1963 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1954 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1964 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1955 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1965 EXPECT_EQ("2400x1350", GetDisplayForId(display_id).size().ToString()); 1956 EXPECT_EQ("2400x1350", GetDisplayForId(display_id).size().ToString());
1966 } 1957 }
1967 1958
1968 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScaling) { 1959 TEST_F(DisplayManagerTest, FHD125DefaultsTo08UIScaling) {
1969 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1960 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1970 1961
1971 display_id++; 1962 display_id++;
1972 display::test::ScopedSetInternalDisplayId set_internal(display_manager(), 1963 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
1973 display_id); 1964 display_id);
1974 1965
1975 // Setup the display modes with UI-scale. 1966 // Setup the display modes with UI-scale.
1976 display::ManagedDisplayInfo native_display_info = 1967 display::ManagedDisplayInfo native_display_info =
1977 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080)); 1968 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080));
1978 native_display_info.set_device_scale_factor(1.25); 1969 native_display_info.set_device_scale_factor(1.25);
1979 1970
1980 const scoped_refptr<display::ManagedDisplayMode>& base_mode( 1971 const scoped_refptr<display::ManagedDisplayMode>& base_mode(
1981 new display::ManagedDisplayMode(gfx::Size(1920, 1080), 60.0f, false, 1972 new display::ManagedDisplayMode(gfx::Size(1920, 1080), 60.0f, false,
1982 false)); 1973 false));
1983 display::ManagedDisplayInfo::ManagedDisplayModeList mode_list = 1974 display::ManagedDisplayInfo::ManagedDisplayModeList mode_list =
1984 CreateInternalManagedDisplayModeList(base_mode); 1975 CreateInternalManagedDisplayModeList(base_mode);
1985 native_display_info.SetManagedDisplayModes(mode_list); 1976 native_display_info.SetManagedDisplayModes(mode_list);
1986 1977
1987 std::vector<display::ManagedDisplayInfo> display_info_list; 1978 std::vector<display::ManagedDisplayInfo> display_info_list;
1988 display_info_list.push_back(native_display_info); 1979 display_info_list.push_back(native_display_info);
1989 1980
1990 display_manager()->OnNativeDisplaysChanged(display_info_list); 1981 display_manager()->OnNativeDisplaysChanged(display_info_list);
1991 1982
1992 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1983 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1993 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1984 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1994 } 1985 }
1995 1986
1996 // Don't default to 1.25 DSF if the user already has a prefrence stored for 1987 // Don't default to 1.25 DSF if the user already has a prefrence stored for
1997 // the internal display. 1988 // the internal display.
1998 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScalingNoOverride) { 1989 TEST_F(DisplayManagerTest, FHD125DefaultsTo08UIScalingNoOverride) {
1999 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1990 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
2000 1991
2001 display_id++; 1992 display_id++;
2002 display::test::ScopedSetInternalDisplayId set_internal(display_manager(), 1993 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
2003 display_id); 1994 display_id);
2004 const gfx::Insets dummy_overscan_insets; 1995 const gfx::Insets dummy_overscan_insets;
2005 display_manager()->RegisterDisplayProperty( 1996 display_manager()->RegisterDisplayProperty(
2006 display_id, display::Display::ROTATE_0, 1.0f, &dummy_overscan_insets, 1997 display_id, display::Display::ROTATE_0, 1.0f, &dummy_overscan_insets,
2007 gfx::Size(), 1.0f, display::ColorCalibrationProfile(), nullptr); 1998 gfx::Size(), 1.0f, display::ColorCalibrationProfile(), nullptr);
2008 1999
(...skipping 11 matching lines...) Expand all
2020 2011
2021 std::vector<display::ManagedDisplayInfo> display_info_list; 2012 std::vector<display::ManagedDisplayInfo> display_info_list;
2022 display_info_list.push_back(native_display_info); 2013 display_info_list.push_back(native_display_info);
2023 2014
2024 display_manager()->OnNativeDisplaysChanged(display_info_list); 2015 display_manager()->OnNativeDisplaysChanged(display_info_list);
2025 2016
2026 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 2017 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
2027 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 2018 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
2028 } 2019 }
2029 2020
2030 TEST_P(DisplayManagerTest, ResolutionChangeInUnifiedMode) { 2021 TEST_F(DisplayManagerTest, ResolutionChangeInUnifiedMode) {
2031 // Don't check root window destruction in unified mode. 2022 // Don't check root window destruction in unified mode.
2032 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 2023 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
2033 2024
2034 display_manager()->SetUnifiedDesktopEnabled(true); 2025 display_manager()->SetUnifiedDesktopEnabled(true);
2035 2026
2036 UpdateDisplay("200x200, 400x400"); 2027 UpdateDisplay("200x200, 400x400");
2037 2028
2038 int64_t unified_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 2029 int64_t unified_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
2039 display::ManagedDisplayInfo info = 2030 display::ManagedDisplayInfo info =
2040 display_manager()->GetDisplayInfo(unified_id); 2031 display_manager()->GetDisplayInfo(unified_id);
(...skipping 24 matching lines...) Expand all
2065 UpdateDisplay("600x600, 200x200"); 2056 UpdateDisplay("600x600, 200x200");
2066 EXPECT_EQ( 2057 EXPECT_EQ(
2067 "1200x600", 2058 "1200x600",
2068 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); 2059 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString());
2069 active_mode = display_manager()->GetActiveModeForDisplayId(unified_id); 2060 active_mode = display_manager()->GetActiveModeForDisplayId(unified_id);
2070 EXPECT_EQ(1.0f, active_mode->ui_scale()); 2061 EXPECT_EQ(1.0f, active_mode->ui_scale());
2071 EXPECT_TRUE(active_mode->native()); 2062 EXPECT_TRUE(active_mode->native());
2072 EXPECT_EQ("1200x600", active_mode->size().ToString()); 2063 EXPECT_EQ("1200x600", active_mode->size().ToString());
2073 } 2064 }
2074 2065
2075 TEST_P(DisplayManagerTest, UpdateMouseCursorAfterRotateZoom) { 2066 TEST_F(DisplayManagerTest, UpdateMouseCursorAfterRotateZoom) {
2076 // Make sure just rotating will not change native location. 2067 // Make sure just rotating will not change native location.
2077 UpdateDisplay("300x200,200x150"); 2068 UpdateDisplay("300x200,200x150");
2078 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 2069 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
2079 aura::Env* env = aura::Env::GetInstance(); 2070 aura::Env* env = aura::Env::GetInstance();
2080 2071
2081 ui::test::EventGenerator generator1(root_windows[0]); 2072 ui::test::EventGenerator generator1(root_windows[0]);
2082 ui::test::EventGenerator generator2(root_windows[1]); 2073 ui::test::EventGenerator generator2(root_windows[1]);
2083 2074
2084 // Test on 1st display. 2075 // Test on 1st display.
2085 generator1.MoveMouseToInHost(150, 50); 2076 generator1.MoveMouseToInHost(150, 50);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2146 return changed; 2137 return changed;
2147 } 2138 }
2148 2139
2149 private: 2140 private:
2150 test::MirrorWindowTestApi test_api; 2141 test::MirrorWindowTestApi test_api;
2151 bool changed_; 2142 bool changed_;
2152 2143
2153 DISALLOW_COPY_AND_ASSIGN(TestDisplayObserver); 2144 DISALLOW_COPY_AND_ASSIGN(TestDisplayObserver);
2154 }; 2145 };
2155 2146
2156 TEST_P(DisplayManagerTest, SoftwareMirroring) { 2147 TEST_F(DisplayManagerTest, SoftwareMirroring) {
2157 UpdateDisplay("300x400,400x500"); 2148 UpdateDisplay("300x400,400x500");
2158 2149
2159 test::MirrorWindowTestApi test_api; 2150 test::MirrorWindowTestApi test_api;
2160 EXPECT_EQ(nullptr, test_api.GetHost()); 2151 EXPECT_EQ(nullptr, test_api.GetHost());
2161 2152
2162 TestDisplayObserver display_observer; 2153 TestDisplayObserver display_observer;
2163 display::Screen::GetScreen()->AddObserver(&display_observer); 2154 display::Screen::GetScreen()->AddObserver(&display_observer);
2164 2155
2165 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING); 2156 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING);
2166 display_manager()->UpdateDisplays(); 2157 display_manager()->UpdateDisplays();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2209 2200
2210 // Overscan insets are ignored. 2201 // Overscan insets are ignored.
2211 UpdateDisplay("400x600/o,600x800/o"); 2202 UpdateDisplay("400x600/o,600x800/o");
2212 EXPECT_FALSE(display_observer.changed_and_reset()); 2203 EXPECT_FALSE(display_observer.changed_and_reset());
2213 EXPECT_EQ("400x600", 2204 EXPECT_EQ("400x600",
2214 test_api.GetHost()->window()->bounds().size().ToString()); 2205 test_api.GetHost()->window()->bounds().size().ToString());
2215 2206
2216 display::Screen::GetScreen()->RemoveObserver(&display_observer); 2207 display::Screen::GetScreen()->RemoveObserver(&display_observer);
2217 } 2208 }
2218 2209
2219 TEST_P(DisplayManagerTest, RotateInSoftwareMirroring) { 2210 TEST_F(DisplayManagerTest, RotateInSoftwareMirroring) {
2220 UpdateDisplay("600x400,500x300"); 2211 UpdateDisplay("600x400,500x300");
2221 display_manager()->SetMirrorMode(true); 2212 display_manager()->SetMirrorMode(true);
2222 2213
2223 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 2214 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
2224 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 2215 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
2225 display_manager()->SetDisplayRotation( 2216 display_manager()->SetDisplayRotation(
2226 primary_id, display::Display::ROTATE_180, 2217 primary_id, display::Display::ROTATE_180,
2227 display::Display::ROTATION_SOURCE_ACTIVE); 2218 display::Display::ROTATION_SOURCE_ACTIVE);
2228 display_manager()->SetMirrorMode(false); 2219 display_manager()->SetMirrorMode(false);
2229 } 2220 }
2230 2221
2231 TEST_P(DisplayManagerTest, SingleDisplayToSoftwareMirroring) { 2222 TEST_F(DisplayManagerTest, SingleDisplayToSoftwareMirroring) {
2232 UpdateDisplay("600x400"); 2223 UpdateDisplay("600x400");
2233 2224
2234 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING); 2225 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING);
2235 UpdateDisplay("600x400,600x400"); 2226 UpdateDisplay("600x400,600x400");
2236 2227
2237 EXPECT_TRUE(display_manager()->IsInMirrorMode()); 2228 EXPECT_TRUE(display_manager()->IsInMirrorMode());
2238 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 2229 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
2239 WindowTreeHostManager* window_tree_host_manager = 2230 WindowTreeHostManager* window_tree_host_manager =
2240 ash::Shell::GetInstance()->window_tree_host_manager(); 2231 ash::Shell::GetInstance()->window_tree_host_manager();
2241 EXPECT_TRUE( 2232 EXPECT_TRUE(
2242 window_tree_host_manager->mirror_window_controller()->GetWindow()); 2233 window_tree_host_manager->mirror_window_controller()->GetWindow());
2243 2234
2244 UpdateDisplay("600x400"); 2235 UpdateDisplay("600x400");
2245 EXPECT_FALSE(display_manager()->IsInMirrorMode()); 2236 EXPECT_FALSE(display_manager()->IsInMirrorMode());
2246 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 2237 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
2247 EXPECT_FALSE( 2238 EXPECT_FALSE(
2248 window_tree_host_manager->mirror_window_controller()->GetWindow()); 2239 window_tree_host_manager->mirror_window_controller()->GetWindow());
2249 } 2240 }
2250 2241
2251 // Make sure this does not cause any crashes. See http://crbug.com/412910 2242 // Make sure this does not cause any crashes. See http://crbug.com/412910
2252 TEST_P(DisplayManagerTest, SoftwareMirroringWithCompositingCursor) { 2243 TEST_F(DisplayManagerTest, SoftwareMirroringWithCompositingCursor) {
2253 UpdateDisplay("300x400,400x500"); 2244 UpdateDisplay("300x400,400x500");
2254 2245
2255 test::MirrorWindowTestApi test_api; 2246 test::MirrorWindowTestApi test_api;
2256 EXPECT_EQ(nullptr, test_api.GetHost()); 2247 EXPECT_EQ(nullptr, test_api.GetHost());
2257 2248
2258 display::ManagedDisplayInfo secondary_info = 2249 display::ManagedDisplayInfo secondary_info =
2259 display_manager()->GetDisplayInfo( 2250 display_manager()->GetDisplayInfo(
2260 display_manager()->GetSecondaryDisplay().id()); 2251 display_manager()->GetSecondaryDisplay().id());
2261 2252
2262 display_manager()->SetSoftwareMirroring(true); 2253 display_manager()->SetSoftwareMirroring(true);
(...skipping 11 matching lines...) Expand all
2274 std::vector<display::ManagedDisplayInfo> new_info_list; 2265 std::vector<display::ManagedDisplayInfo> new_info_list;
2275 new_info_list.push_back(secondary_info); 2266 new_info_list.push_back(secondary_info);
2276 display_manager()->OnNativeDisplaysChanged(new_info_list); 2267 display_manager()->OnNativeDisplaysChanged(new_info_list);
2277 2268
2278 root_windows = Shell::GetAllRootWindows(); 2269 root_windows = Shell::GetAllRootWindows();
2279 EXPECT_TRUE(root_windows[0]->Contains(test_api.GetCursorWindow())); 2270 EXPECT_TRUE(root_windows[0]->Contains(test_api.GetCursorWindow()));
2280 2271
2281 Shell::GetInstance()->SetCursorCompositingEnabled(false); 2272 Shell::GetInstance()->SetCursorCompositingEnabled(false);
2282 } 2273 }
2283 2274
2284 TEST_P(DisplayManagerTest, MirroredLayout) { 2275 TEST_F(DisplayManagerTest, MirroredLayout) {
2285 UpdateDisplay("500x500,400x400"); 2276 UpdateDisplay("500x500,400x400");
2286 EXPECT_FALSE(display_manager()->GetCurrentDisplayLayout().mirrored); 2277 EXPECT_FALSE(display_manager()->GetCurrentDisplayLayout().mirrored);
2287 EXPECT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); 2278 EXPECT_EQ(2, display::Screen::GetScreen()->GetNumDisplays());
2288 EXPECT_EQ(2U, display_manager()->num_connected_displays()); 2279 EXPECT_EQ(2U, display_manager()->num_connected_displays());
2289 2280
2290 UpdateDisplay("1+0-500x500,1+0-500x500"); 2281 UpdateDisplay("1+0-500x500,1+0-500x500");
2291 EXPECT_TRUE(display_manager()->GetCurrentDisplayLayout().mirrored); 2282 EXPECT_TRUE(display_manager()->GetCurrentDisplayLayout().mirrored);
2292 EXPECT_EQ(1, display::Screen::GetScreen()->GetNumDisplays()); 2283 EXPECT_EQ(1, display::Screen::GetScreen()->GetNumDisplays());
2293 EXPECT_EQ(2U, display_manager()->num_connected_displays()); 2284 EXPECT_EQ(2U, display_manager()->num_connected_displays());
2294 2285
2295 UpdateDisplay("500x500,500x500"); 2286 UpdateDisplay("500x500,500x500");
2296 EXPECT_FALSE(display_manager()->GetCurrentDisplayLayout().mirrored); 2287 EXPECT_FALSE(display_manager()->GetCurrentDisplayLayout().mirrored);
2297 EXPECT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); 2288 EXPECT_EQ(2, display::Screen::GetScreen()->GetNumDisplays());
2298 EXPECT_EQ(2U, display_manager()->num_connected_displays()); 2289 EXPECT_EQ(2U, display_manager()->num_connected_displays());
2299 } 2290 }
2300 2291
2301 TEST_P(DisplayManagerTest, InvertLayout) { 2292 TEST_F(DisplayManagerTest, InvertLayout) {
2302 EXPECT_EQ("left, 0", 2293 EXPECT_EQ("left, 0",
2303 display::DisplayPlacement(display::DisplayPlacement::RIGHT, 0) 2294 display::DisplayPlacement(display::DisplayPlacement::RIGHT, 0)
2304 .Swap() 2295 .Swap()
2305 .ToString()); 2296 .ToString());
2306 EXPECT_EQ("left, -100", 2297 EXPECT_EQ("left, -100",
2307 display::DisplayPlacement(display::DisplayPlacement::RIGHT, 100) 2298 display::DisplayPlacement(display::DisplayPlacement::RIGHT, 100)
2308 .Swap() 2299 .Swap()
2309 .ToString()); 2300 .ToString());
2310 EXPECT_EQ("left, 50", 2301 EXPECT_EQ("left, 50",
2311 display::DisplayPlacement(display::DisplayPlacement::RIGHT, -50) 2302 display::DisplayPlacement(display::DisplayPlacement::RIGHT, -50)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2345 EXPECT_EQ("top, -70", 2336 EXPECT_EQ("top, -70",
2346 display::DisplayPlacement(display::DisplayPlacement::BOTTOM, 70) 2337 display::DisplayPlacement(display::DisplayPlacement::BOTTOM, 70)
2347 .Swap() 2338 .Swap()
2348 .ToString()); 2339 .ToString());
2349 EXPECT_EQ("top, 80", 2340 EXPECT_EQ("top, 80",
2350 display::DisplayPlacement(display::DisplayPlacement::BOTTOM, -80) 2341 display::DisplayPlacement(display::DisplayPlacement::BOTTOM, -80)
2351 .Swap() 2342 .Swap()
2352 .ToString()); 2343 .ToString());
2353 } 2344 }
2354 2345
2355 TEST_P(DisplayManagerTest, NotifyPrimaryChange) { 2346 TEST_F(DisplayManagerTest, NotifyPrimaryChange) {
2356 UpdateDisplay("500x500,500x500"); 2347 UpdateDisplay("500x500,500x500");
2357 SwapPrimaryDisplay(); 2348 SwapPrimaryDisplay();
2358 reset(); 2349 reset();
2359 UpdateDisplay("500x500"); 2350 UpdateDisplay("500x500");
2360 EXPECT_FALSE(changed_metrics() & 2351 EXPECT_FALSE(changed_metrics() &
2361 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); 2352 display::DisplayObserver::DISPLAY_METRIC_BOUNDS);
2362 EXPECT_FALSE(changed_metrics() & 2353 EXPECT_FALSE(changed_metrics() &
2363 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 2354 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
2364 EXPECT_TRUE(changed_metrics() & 2355 EXPECT_TRUE(changed_metrics() &
2365 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); 2356 display::DisplayObserver::DISPLAY_METRIC_PRIMARY);
2366 2357
2367 UpdateDisplay("500x500,500x500"); 2358 UpdateDisplay("500x500,500x500");
2368 SwapPrimaryDisplay(); 2359 SwapPrimaryDisplay();
2369 UpdateDisplay("500x400"); 2360 UpdateDisplay("500x400");
2370 EXPECT_TRUE(changed_metrics() & 2361 EXPECT_TRUE(changed_metrics() &
2371 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); 2362 display::DisplayObserver::DISPLAY_METRIC_BOUNDS);
2372 EXPECT_TRUE(changed_metrics() & 2363 EXPECT_TRUE(changed_metrics() &
2373 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 2364 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
2374 EXPECT_TRUE(changed_metrics() & 2365 EXPECT_TRUE(changed_metrics() &
2375 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); 2366 display::DisplayObserver::DISPLAY_METRIC_PRIMARY);
2376 } 2367 }
2377 2368
2378 TEST_P(DisplayManagerTest, NotifyPrimaryChangeUndock) { 2369 TEST_F(DisplayManagerTest, NotifyPrimaryChangeUndock) {
2379 // Assume the default display is an external display, and 2370 // Assume the default display is an external display, and
2380 // emulates undocking by switching to another display. 2371 // emulates undocking by switching to another display.
2381 display::ManagedDisplayInfo another_display_info = 2372 display::ManagedDisplayInfo another_display_info =
2382 CreateDisplayInfo(1, gfx::Rect(0, 0, 1280, 800)); 2373 CreateDisplayInfo(1, gfx::Rect(0, 0, 1280, 800));
2383 std::vector<display::ManagedDisplayInfo> info_list; 2374 std::vector<display::ManagedDisplayInfo> info_list;
2384 info_list.push_back(another_display_info); 2375 info_list.push_back(another_display_info);
2385 reset(); 2376 reset();
2386 display_manager()->OnNativeDisplaysChanged(info_list); 2377 display_manager()->OnNativeDisplaysChanged(info_list);
2387 EXPECT_TRUE(changed_metrics() & 2378 EXPECT_TRUE(changed_metrics() &
2388 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); 2379 display::DisplayObserver::DISPLAY_METRIC_BOUNDS);
2389 EXPECT_TRUE(changed_metrics() & 2380 EXPECT_TRUE(changed_metrics() &
2390 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 2381 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
2391 EXPECT_TRUE(changed_metrics() & 2382 EXPECT_TRUE(changed_metrics() &
2392 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); 2383 display::DisplayObserver::DISPLAY_METRIC_PRIMARY);
2393 } 2384 }
2394 2385
2395 TEST_P(DisplayManagerTest, UpdateDisplayWithHostOrigin) { 2386 TEST_F(DisplayManagerTest, UpdateDisplayWithHostOrigin) {
2396 UpdateDisplay("100x200,300x400"); 2387 UpdateDisplay("100x200,300x400");
2397 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); 2388 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays());
2398 aura::Window::Windows root_windows = 2389 aura::Window::Windows root_windows =
2399 Shell::GetInstance()->GetAllRootWindows(); 2390 Shell::GetInstance()->GetAllRootWindows();
2400 ASSERT_EQ(2U, root_windows.size()); 2391 ASSERT_EQ(2U, root_windows.size());
2401 aura::WindowTreeHost* host0 = root_windows[0]->GetHost(); 2392 aura::WindowTreeHost* host0 = root_windows[0]->GetHost();
2402 aura::WindowTreeHost* host1 = root_windows[1]->GetHost(); 2393 aura::WindowTreeHost* host1 = root_windows[1]->GetHost();
2403 2394
2404 EXPECT_EQ("1,1", host0->GetBoundsInPixels().origin().ToString()); 2395 EXPECT_EQ("1,1", host0->GetBoundsInPixels().origin().ToString());
2405 EXPECT_EQ("100x200", host0->GetBoundsInPixels().size().ToString()); 2396 EXPECT_EQ("100x200", host0->GetBoundsInPixels().size().ToString());
(...skipping 16 matching lines...) Expand all
2422 EXPECT_EQ("300x400", host1->GetBoundsInPixels().size().ToString()); 2413 EXPECT_EQ("300x400", host1->GetBoundsInPixels().size().ToString());
2423 2414
2424 UpdateDisplay("100+200-100x200,300+500-200x300"); 2415 UpdateDisplay("100+200-100x200,300+500-200x300");
2425 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); 2416 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays());
2426 EXPECT_EQ("100,200", host0->GetBoundsInPixels().origin().ToString()); 2417 EXPECT_EQ("100,200", host0->GetBoundsInPixels().origin().ToString());
2427 EXPECT_EQ("100x200", host0->GetBoundsInPixels().size().ToString()); 2418 EXPECT_EQ("100x200", host0->GetBoundsInPixels().size().ToString());
2428 EXPECT_EQ("300,500", host1->GetBoundsInPixels().origin().ToString()); 2419 EXPECT_EQ("300,500", host1->GetBoundsInPixels().origin().ToString());
2429 EXPECT_EQ("200x300", host1->GetBoundsInPixels().size().ToString()); 2420 EXPECT_EQ("200x300", host1->GetBoundsInPixels().size().ToString());
2430 } 2421 }
2431 2422
2432 TEST_P(DisplayManagerTest, UnifiedDesktopBasic) { 2423 TEST_F(DisplayManagerTest, UnifiedDesktopBasic) {
2433 // Don't check root window destruction in unified mode. 2424 // Don't check root window destruction in unified mode.
2434 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 2425 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
2435 2426
2436 UpdateDisplay("400x500,300x200"); 2427 UpdateDisplay("400x500,300x200");
2437 2428
2438 // Enable after extended mode. 2429 // Enable after extended mode.
2439 display_manager()->SetUnifiedDesktopEnabled(true); 2430 display_manager()->SetUnifiedDesktopEnabled(true);
2440 2431
2441 // Defaults to the unified desktop. 2432 // Defaults to the unified desktop.
2442 display::Screen* screen = display::Screen::GetScreen(); 2433 display::Screen* screen = display::Screen::GetScreen();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2481 EXPECT_EQ(gfx::Size(500, 300), screen->GetPrimaryDisplay().size()); 2472 EXPECT_EQ(gfx::Size(500, 300), screen->GetPrimaryDisplay().size());
2482 EXPECT_EQ(gfx::Size(400, 500), 2473 EXPECT_EQ(gfx::Size(400, 500),
2483 display_manager()->GetSecondaryDisplay().size()); 2474 display_manager()->GetSecondaryDisplay().size());
2484 EXPECT_EQ( 2475 EXPECT_EQ(
2485 gfx::Size(500, 300), 2476 gfx::Size(500, 300),
2486 display_manager() 2477 display_manager()
2487 ->GetDisplayForId(display_manager()->GetSecondaryDisplay().id() + 1) 2478 ->GetDisplayForId(display_manager()->GetSecondaryDisplay().id() + 1)
2488 .size()); 2479 .size());
2489 } 2480 }
2490 2481
2491 TEST_P(DisplayManagerTest, UnifiedDesktopWithHardwareMirroring) { 2482 TEST_F(DisplayManagerTest, UnifiedDesktopWithHardwareMirroring) {
2492 // Don't check root window destruction in unified mode. 2483 // Don't check root window destruction in unified mode.
2493 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 2484 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
2494 2485
2495 // Enter to hardware mirroring. 2486 // Enter to hardware mirroring.
2496 display::ManagedDisplayInfo d1(1, "", false); 2487 display::ManagedDisplayInfo d1(1, "", false);
2497 d1.SetBounds(gfx::Rect(0, 0, 500, 500)); 2488 d1.SetBounds(gfx::Rect(0, 0, 500, 500));
2498 display::ManagedDisplayInfo d2(2, "", false); 2489 display::ManagedDisplayInfo d2(2, "", false);
2499 d2.SetBounds(gfx::Rect(0, 0, 500, 500)); 2490 d2.SetBounds(gfx::Rect(0, 0, 500, 500));
2500 std::vector<display::ManagedDisplayInfo> display_info_list; 2491 std::vector<display::ManagedDisplayInfo> display_info_list;
2501 display_info_list.push_back(d1); 2492 display_info_list.push_back(d1);
(...skipping 17 matching lines...) Expand all
2519 // Exit from hardware mirroring. 2510 // Exit from hardware mirroring.
2520 d2.SetBounds(gfx::Rect(0, 500, 500, 500)); 2511 d2.SetBounds(gfx::Rect(0, 500, 500, 500));
2521 display_info_list.clear(); 2512 display_info_list.clear();
2522 display_info_list.push_back(d1); 2513 display_info_list.push_back(d1);
2523 display_info_list.push_back(d2); 2514 display_info_list.push_back(d2);
2524 display_manager()->OnNativeDisplaysChanged(display_info_list); 2515 display_manager()->OnNativeDisplaysChanged(display_info_list);
2525 EXPECT_FALSE(display_manager()->IsInMirrorMode()); 2516 EXPECT_FALSE(display_manager()->IsInMirrorMode());
2526 EXPECT_TRUE(display_manager()->IsInUnifiedMode()); 2517 EXPECT_TRUE(display_manager()->IsInUnifiedMode());
2527 } 2518 }
2528 2519
2529 TEST_P(DisplayManagerTest, UnifiedDesktopEnabledWithExtended) { 2520 TEST_F(DisplayManagerTest, UnifiedDesktopEnabledWithExtended) {
2530 // Don't check root window destruction in unified mode. 2521 // Don't check root window destruction in unified mode.
2531 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 2522 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
2532 2523
2533 UpdateDisplay("400x500,300x200"); 2524 UpdateDisplay("400x500,300x200");
2534 display::DisplayIdList list = display_manager()->GetCurrentDisplayIdList(); 2525 display::DisplayIdList list = display_manager()->GetCurrentDisplayIdList();
2535 display::DisplayLayoutBuilder builder( 2526 display::DisplayLayoutBuilder builder(
2536 display_manager()->layout_store()->GetRegisteredDisplayLayout(list)); 2527 display_manager()->layout_store()->GetRegisteredDisplayLayout(list));
2537 builder.SetDefaultUnified(false); 2528 builder.SetDefaultUnified(false);
2538 display_manager()->layout_store()->RegisterLayoutForDisplayIdList( 2529 display_manager()->layout_store()->RegisterLayoutForDisplayIdList(
2539 list, builder.Build()); 2530 list, builder.Build());
2540 display_manager()->SetUnifiedDesktopEnabled(true); 2531 display_manager()->SetUnifiedDesktopEnabled(true);
2541 EXPECT_FALSE(display_manager()->IsInUnifiedMode()); 2532 EXPECT_FALSE(display_manager()->IsInUnifiedMode());
2542 } 2533 }
2543 2534
2544 TEST_P(DisplayManagerTest, UnifiedDesktopWith2xDSF) { 2535 TEST_F(DisplayManagerTest, UnifiedDesktopWith2xDSF) {
2545 // Don't check root window destruction in unified mode. 2536 // Don't check root window destruction in unified mode.
2546 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 2537 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
2547 2538
2548 display_manager()->SetUnifiedDesktopEnabled(true); 2539 display_manager()->SetUnifiedDesktopEnabled(true);
2549 display::Screen* screen = display::Screen::GetScreen(); 2540 display::Screen* screen = display::Screen::GetScreen();
2550 2541
2551 // 2nd display is 2x. 2542 // 2nd display is 2x.
2552 UpdateDisplay("400x500,1000x800*2"); 2543 UpdateDisplay("400x500,1000x800*2");
2553 display::ManagedDisplayInfo info = 2544 display::ManagedDisplayInfo info =
2554 display_manager()->GetDisplayInfo(screen->GetPrimaryDisplay().id()); 2545 display_manager()->GetDisplayInfo(screen->GetPrimaryDisplay().id());
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
2636 EXPECT_EQ("1300x800", 2627 EXPECT_EQ("1300x800",
2637 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); 2628 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
2638 accelerators::ZoomInternalDisplay(false); 2629 accelerators::ZoomInternalDisplay(false);
2639 EXPECT_EQ("650x400", screen->GetPrimaryDisplay().size().ToString()); 2630 EXPECT_EQ("650x400", screen->GetPrimaryDisplay().size().ToString());
2640 EXPECT_EQ("650x400", 2631 EXPECT_EQ("650x400",
2641 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); 2632 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
2642 } 2633 }
2643 2634
2644 // Updating displays again in unified desktop mode should not crash. 2635 // Updating displays again in unified desktop mode should not crash.
2645 // crbug.com/491094. 2636 // crbug.com/491094.
2646 TEST_P(DisplayManagerTest, ConfigureUnifiedTwice) { 2637 TEST_F(DisplayManagerTest, ConfigureUnifiedTwice) {
2647 // Don't check root window destruction in unified mode. 2638 // Don't check root window destruction in unified mode.
2648 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 2639 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
2649 2640
2650 UpdateDisplay("300x200,400x500"); 2641 UpdateDisplay("300x200,400x500");
2651 // Mirror windows are created in a posted task. 2642 // Mirror windows are created in a posted task.
2652 RunAllPendingInMessageLoop(); 2643 RunAllPendingInMessageLoop();
2653 2644
2654 UpdateDisplay("300x250,400x550"); 2645 UpdateDisplay("300x250,400x550");
2655 RunAllPendingInMessageLoop(); 2646 RunAllPendingInMessageLoop();
2656 } 2647 }
2657 2648
2658 TEST_P(DisplayManagerTest, NoRotateUnifiedDesktop) { 2649 TEST_F(DisplayManagerTest, NoRotateUnifiedDesktop) {
2659 display_manager()->SetUnifiedDesktopEnabled(true); 2650 display_manager()->SetUnifiedDesktopEnabled(true);
2660 2651
2661 // Don't check root window destruction in unified mode. 2652 // Don't check root window destruction in unified mode.
2662 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 2653 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
2663 2654
2664 UpdateDisplay("400x500,300x200"); 2655 UpdateDisplay("400x500,300x200");
2665 2656
2666 display::Screen* screen = display::Screen::GetScreen(); 2657 display::Screen* screen = display::Screen::GetScreen();
2667 const display::Display& display = screen->GetPrimaryDisplay(); 2658 const display::Display& display = screen->GetPrimaryDisplay();
2668 EXPECT_EQ("1150x500", display.size().ToString()); 2659 EXPECT_EQ("1150x500", display.size().ToString());
2669 display_manager()->SetDisplayRotation( 2660 display_manager()->SetDisplayRotation(
2670 display.id(), display::Display::ROTATE_90, 2661 display.id(), display::Display::ROTATE_90,
2671 display::Display::ROTATION_SOURCE_ACTIVE); 2662 display::Display::ROTATION_SOURCE_ACTIVE);
2672 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString()); 2663 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString());
2673 display_manager()->SetDisplayRotation( 2664 display_manager()->SetDisplayRotation(
2674 display.id(), display::Display::ROTATE_0, 2665 display.id(), display::Display::ROTATE_0,
2675 display::Display::ROTATION_SOURCE_ACTIVE); 2666 display::Display::ROTATION_SOURCE_ACTIVE);
2676 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString()); 2667 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString());
2677 2668
2678 UpdateDisplay("400x500"); 2669 UpdateDisplay("400x500");
2679 EXPECT_EQ("400x500", screen->GetPrimaryDisplay().size().ToString()); 2670 EXPECT_EQ("400x500", screen->GetPrimaryDisplay().size().ToString());
2680 } 2671 }
2681 2672
2682 // Makes sure the transition from unified to single won't crash 2673 // Makes sure the transition from unified to single won't crash
2683 // with docked windows. 2674 // with docked windows.
2684 TEST_P(DisplayManagerTest, UnifiedWithDockWindows) { 2675 TEST_F(DisplayManagerTest, UnifiedWithDockWindows) {
2685 // Enable window docking for this test. 2676 // Enable window docking for this test.
2686 base::CommandLine::ForCurrentProcess()->AppendSwitch( 2677 base::CommandLine::ForCurrentProcess()->AppendSwitch(
2687 ash::switches::kAshEnableDockedWindows); 2678 ash::switches::kAshEnableDockedWindows);
2688 2679
2689 const int height_offset = GetMdMaximizedWindowHeightOffset();
2690 display_manager()->SetUnifiedDesktopEnabled(true); 2680 display_manager()->SetUnifiedDesktopEnabled(true);
2691 2681
2692 // Don't check root window destruction in unified mode. 2682 // Don't check root window destruction in unified mode.
2693 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 2683 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
2694 2684
2695 UpdateDisplay("400x500,300x200"); 2685 UpdateDisplay("400x500,300x200");
2696 2686
2697 std::unique_ptr<aura::Window> docked( 2687 std::unique_ptr<aura::Window> docked(
2698 CreateTestWindowInShellWithBounds(gfx::Rect(10, 10, 50, 50))); 2688 CreateTestWindowInShellWithBounds(gfx::Rect(10, 10, 50, 50)));
2699 docked->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DOCKED); 2689 docked->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DOCKED);
2700 ASSERT_TRUE(wm::GetWindowState(docked.get())->IsDocked()); 2690 ASSERT_TRUE(wm::GetWindowState(docked.get())->IsDocked());
2701 // 47 pixels reserved for launcher shelf height in non-material design, and 2691 // 48 pixels reserved for launcher shelf height.
2702 // 48 pixels reserved in material design. 2692 EXPECT_EQ(gfx::Rect(0, 0, 250, 452).ToString(), docked->bounds().ToString());
2703 EXPECT_EQ(gfx::Rect(0, 0, 250, 453 + height_offset).ToString(),
2704 docked->bounds().ToString());
2705 UpdateDisplay("300x300"); 2693 UpdateDisplay("300x300");
2706 // Make sure the window is still docked. 2694 // Make sure the window is still docked.
2707 EXPECT_TRUE(wm::GetWindowState(docked.get())->IsDocked()); 2695 EXPECT_TRUE(wm::GetWindowState(docked.get())->IsDocked());
2708 EXPECT_EQ(gfx::Rect(0, 0, 250, 253 + height_offset).ToString(), 2696 EXPECT_EQ(gfx::Rect(0, 0, 250, 252).ToString(), docked->bounds().ToString());
2709 docked->bounds().ToString());
2710 } 2697 }
2711 2698
2712 TEST_P(DisplayManagerTest, DockMode) { 2699 TEST_F(DisplayManagerTest, DockMode) {
2713 const int64_t internal_id = 1; 2700 const int64_t internal_id = 1;
2714 const int64_t external_id = 2; 2701 const int64_t external_id = 2;
2715 2702
2716 const display::ManagedDisplayInfo internal_display_info = 2703 const display::ManagedDisplayInfo internal_display_info =
2717 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500)); 2704 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500));
2718 const display::ManagedDisplayInfo external_display_info = 2705 const display::ManagedDisplayInfo external_display_info =
2719 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); 2706 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100));
2720 std::vector<display::ManagedDisplayInfo> display_info_list; 2707 std::vector<display::ManagedDisplayInfo> display_info_list;
2721 2708
2722 // software mirroring. 2709 // software mirroring.
(...skipping 13 matching lines...) Expand all
2736 EXPECT_TRUE(display_manager()->IsActiveDisplayId(external_id)); 2723 EXPECT_TRUE(display_manager()->IsActiveDisplayId(external_id));
2737 EXPECT_FALSE(display_manager()->IsActiveDisplayId(internal_id)); 2724 EXPECT_FALSE(display_manager()->IsActiveDisplayId(internal_id));
2738 2725
2739 EXPECT_FALSE(display_manager()->ZoomInternalDisplay(true)); 2726 EXPECT_FALSE(display_manager()->ZoomInternalDisplay(true));
2740 EXPECT_FALSE(display_manager()->ZoomInternalDisplay(false)); 2727 EXPECT_FALSE(display_manager()->ZoomInternalDisplay(false));
2741 EXPECT_FALSE(display::test::DisplayManagerTestApi(display_manager()) 2728 EXPECT_FALSE(display::test::DisplayManagerTestApi(display_manager())
2742 .SetDisplayUIScale(internal_id, 1.0f)); 2729 .SetDisplayUIScale(internal_id, 1.0f));
2743 } 2730 }
2744 2731
2745 // Make sure that bad layout information is ignored and does not crash. 2732 // Make sure that bad layout information is ignored and does not crash.
2746 TEST_P(DisplayManagerTest, DontRegisterBadConfig) { 2733 TEST_F(DisplayManagerTest, DontRegisterBadConfig) {
2747 display::DisplayIdList list = display::test::CreateDisplayIdList2(1, 2); 2734 display::DisplayIdList list = display::test::CreateDisplayIdList2(1, 2);
2748 display::DisplayLayoutBuilder builder(1); 2735 display::DisplayLayoutBuilder builder(1);
2749 builder.AddDisplayPlacement(2, 1, display::DisplayPlacement::LEFT, 0); 2736 builder.AddDisplayPlacement(2, 1, display::DisplayPlacement::LEFT, 0);
2750 builder.AddDisplayPlacement(3, 1, display::DisplayPlacement::BOTTOM, 0); 2737 builder.AddDisplayPlacement(3, 1, display::DisplayPlacement::BOTTOM, 0);
2751 2738
2752 display_manager()->layout_store()->RegisterLayoutForDisplayIdList( 2739 display_manager()->layout_store()->RegisterLayoutForDisplayIdList(
2753 list, builder.Build()); 2740 list, builder.Build());
2754 } 2741 }
2755 2742
2756 class ScreenShutdownTest : public test::AshTestBase { 2743 class ScreenShutdownTest : public test::AshTestBase {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
2900 .SetDisplayUIScale(display::Screen::GetScreen()->GetPrimaryDisplay().id(), 2887 .SetDisplayUIScale(display::Screen::GetScreen()->GetPrimaryDisplay().id(),
2901 0.8f); 2888 0.8f);
2902 2889
2903 ASSERT_DOUBLE_EQ( 2890 ASSERT_DOUBLE_EQ(
2904 1.25f, 2891 1.25f,
2905 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 2892 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
2906 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); 2893 EXPECT_TRUE(IsTextSubpixelPositioningEnabled());
2907 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); 2894 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
2908 } 2895 }
2909 2896
2910 TEST_P(DisplayManagerTest, CheckInitializationOfRotationProperty) { 2897 TEST_F(DisplayManagerTest, CheckInitializationOfRotationProperty) {
2911 int64_t id = display_manager()->GetDisplayAt(0).id(); 2898 int64_t id = display_manager()->GetDisplayAt(0).id();
2912 display_manager()->RegisterDisplayProperty( 2899 display_manager()->RegisterDisplayProperty(
2913 id, display::Display::ROTATE_90, 1.0f, nullptr, gfx::Size(), 1.0f, 2900 id, display::Display::ROTATE_90, 1.0f, nullptr, gfx::Size(), 1.0f,
2914 display::COLOR_PROFILE_STANDARD, nullptr); 2901 display::COLOR_PROFILE_STANDARD, nullptr);
2915 2902
2916 const display::ManagedDisplayInfo& info = 2903 const display::ManagedDisplayInfo& info =
2917 display_manager()->GetDisplayInfo(id); 2904 display_manager()->GetDisplayInfo(id);
2918 2905
2919 EXPECT_EQ(display::Display::ROTATE_90, 2906 EXPECT_EQ(display::Display::ROTATE_90,
2920 info.GetRotation(display::Display::ROTATION_SOURCE_USER)); 2907 info.GetRotation(display::Display::ROTATION_SOURCE_USER));
2921 EXPECT_EQ(display::Display::ROTATE_90, 2908 EXPECT_EQ(display::Display::ROTATE_90,
2922 info.GetRotation(display::Display::ROTATION_SOURCE_ACTIVE)); 2909 info.GetRotation(display::Display::ROTATION_SOURCE_ACTIVE));
2923 } 2910 }
2924 2911
2925 TEST_P(DisplayManagerTest, RejectInvalidLayoutData) { 2912 TEST_F(DisplayManagerTest, RejectInvalidLayoutData) {
2926 display::DisplayLayoutStore* layout_store = display_manager()->layout_store(); 2913 display::DisplayLayoutStore* layout_store = display_manager()->layout_store();
2927 int64_t id1 = 10001; 2914 int64_t id1 = 10001;
2928 int64_t id2 = 10002; 2915 int64_t id2 = 10002;
2929 ASSERT_TRUE(display::CompareDisplayIds(id1, id2)); 2916 ASSERT_TRUE(display::CompareDisplayIds(id1, id2));
2930 display::DisplayLayoutBuilder good_builder(id1); 2917 display::DisplayLayoutBuilder good_builder(id1);
2931 good_builder.SetSecondaryPlacement(id2, display::DisplayPlacement::LEFT, 0); 2918 good_builder.SetSecondaryPlacement(id2, display::DisplayPlacement::LEFT, 0);
2932 std::unique_ptr<display::DisplayLayout> good(good_builder.Build()); 2919 std::unique_ptr<display::DisplayLayout> good(good_builder.Build());
2933 2920
2934 display::DisplayIdList good_list = 2921 display::DisplayIdList good_list =
2935 display::test::CreateDisplayIdList2(id1, id2); 2922 display::test::CreateDisplayIdList2(id1, id2);
2936 layout_store->RegisterLayoutForDisplayIdList(good_list, good->Copy()); 2923 layout_store->RegisterLayoutForDisplayIdList(good_list, good->Copy());
2937 2924
2938 display::DisplayLayoutBuilder bad(id1); 2925 display::DisplayLayoutBuilder bad(id1);
2939 bad.SetSecondaryPlacement(id2, display::DisplayPlacement::BOTTOM, 0); 2926 bad.SetSecondaryPlacement(id2, display::DisplayPlacement::BOTTOM, 0);
2940 2927
2941 display::DisplayIdList bad_list(2); 2928 display::DisplayIdList bad_list(2);
2942 bad_list[0] = id2; 2929 bad_list[0] = id2;
2943 bad_list[1] = id1; 2930 bad_list[1] = id1;
2944 layout_store->RegisterLayoutForDisplayIdList(bad_list, bad.Build()); 2931 layout_store->RegisterLayoutForDisplayIdList(bad_list, bad.Build());
2945 2932
2946 EXPECT_EQ(good->ToString(), 2933 EXPECT_EQ(good->ToString(),
2947 layout_store->GetRegisteredDisplayLayout(good_list).ToString()); 2934 layout_store->GetRegisteredDisplayLayout(good_list).ToString());
2948 } 2935 }
2949 2936
2950 TEST_P(DisplayManagerTest, GuessDisplayIdFieldsInDisplayLayout) { 2937 TEST_F(DisplayManagerTest, GuessDisplayIdFieldsInDisplayLayout) {
2951 int64_t id1 = 10001; 2938 int64_t id1 = 10001;
2952 int64_t id2 = 10002; 2939 int64_t id2 = 10002;
2953 2940
2954 std::unique_ptr<display::DisplayLayout> old_layout( 2941 std::unique_ptr<display::DisplayLayout> old_layout(
2955 new display::DisplayLayout); 2942 new display::DisplayLayout);
2956 old_layout->placement_list.emplace_back(display::DisplayPlacement::BOTTOM, 0); 2943 old_layout->placement_list.emplace_back(display::DisplayPlacement::BOTTOM, 0);
2957 old_layout->primary_id = id1; 2944 old_layout->primary_id = id1;
2958 2945
2959 display::DisplayLayoutStore* layout_store = display_manager()->layout_store(); 2946 display::DisplayLayoutStore* layout_store = display_manager()->layout_store();
2960 display::DisplayIdList list = display::test::CreateDisplayIdList2(id1, id2); 2947 display::DisplayIdList list = display::test::CreateDisplayIdList2(id1, id2);
2961 layout_store->RegisterLayoutForDisplayIdList(list, std::move(old_layout)); 2948 layout_store->RegisterLayoutForDisplayIdList(list, std::move(old_layout));
2962 const display::DisplayLayout& stored = 2949 const display::DisplayLayout& stored =
2963 layout_store->GetRegisteredDisplayLayout(list); 2950 layout_store->GetRegisteredDisplayLayout(list);
2964 2951
2965 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id); 2952 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id);
2966 EXPECT_EQ(id2, stored.placement_list[0].display_id); 2953 EXPECT_EQ(id2, stored.placement_list[0].display_id);
2967 } 2954 }
2968 2955
2969 } // namespace ash 2956 } // namespace ash
OLDNEW
« no previous file with comments | « ash/dip_unittest.cc ('k') | ash/display/window_tree_host_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698