OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/display/display_manager.h" | 5 #include "ash/display/display_manager.h" |
6 | 6 |
7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
8 #include "ash/display/display_layout_store.h" | 8 #include "ash/display/display_layout_store.h" |
9 #include "ash/screen_util.h" | 9 #include "ash/screen_util.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 const gfx::Display& GetDisplayForId(int64 id) { | 92 const gfx::Display& GetDisplayForId(int64 id) { |
93 return display_manager()->GetDisplayForId(id); | 93 return display_manager()->GetDisplayForId(id); |
94 } | 94 } |
95 | 95 |
96 const DisplayInfo& GetDisplayInfoForId(int64 id) { | 96 const DisplayInfo& GetDisplayInfoForId(int64 id) { |
97 return GetDisplayInfo(display_manager()->GetDisplayForId(id)); | 97 return GetDisplayInfo(display_manager()->GetDisplayForId(id)); |
98 } | 98 } |
99 | 99 |
100 // aura::DisplayObserver overrides: | 100 // aura::DisplayObserver overrides: |
101 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE { | 101 virtual void OnDisplayMetricsChanged(const gfx::Display& display, |
| 102 uint32_t) OVERRIDE { |
102 changed_.push_back(display); | 103 changed_.push_back(display); |
103 } | 104 } |
104 virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE { | 105 virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE { |
105 added_.push_back(new_display); | 106 added_.push_back(new_display); |
106 } | 107 } |
107 virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE { | 108 virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE { |
108 ++removed_count_; | 109 ++removed_count_; |
109 } | 110 } |
110 | 111 |
111 // aura::WindowObserver overrides: | 112 // aura::WindowObserver overrides: |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 | 381 |
381 TEST_F(DisplayManagerTest, TestDeviceScaleOnlyChange) { | 382 TEST_F(DisplayManagerTest, TestDeviceScaleOnlyChange) { |
382 if (!SupportsHostWindowResize()) | 383 if (!SupportsHostWindowResize()) |
383 return; | 384 return; |
384 | 385 |
385 UpdateDisplay("1000x600"); | 386 UpdateDisplay("1000x600"); |
386 aura::WindowTreeHost* host = Shell::GetPrimaryRootWindow()->GetHost(); | 387 aura::WindowTreeHost* host = Shell::GetPrimaryRootWindow()->GetHost(); |
387 EXPECT_EQ(1, host->compositor()->device_scale_factor()); | 388 EXPECT_EQ(1, host->compositor()->device_scale_factor()); |
388 EXPECT_EQ("1000x600", | 389 EXPECT_EQ("1000x600", |
389 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); | 390 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); |
| 391 EXPECT_EQ("1 0 0", GetCountSummary()); |
| 392 |
390 UpdateDisplay("1000x600*2"); | 393 UpdateDisplay("1000x600*2"); |
391 EXPECT_EQ(2, host->compositor()->device_scale_factor()); | 394 EXPECT_EQ(2, host->compositor()->device_scale_factor()); |
| 395 EXPECT_EQ("2 0 0", GetCountSummary()); |
392 EXPECT_EQ("500x300", | 396 EXPECT_EQ("500x300", |
393 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); | 397 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); |
394 } | 398 } |
395 | 399 |
396 DisplayInfo CreateDisplayInfo(int64 id, const gfx::Rect& bounds) { | 400 DisplayInfo CreateDisplayInfo(int64 id, const gfx::Rect& bounds) { |
397 DisplayInfo info(id, ToDisplayName(id), false); | 401 DisplayInfo info(id, ToDisplayName(id), false); |
398 info.SetBounds(bounds); | 402 info.SetBounds(bounds); |
399 return info; | 403 return info; |
400 } | 404 } |
401 | 405 |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 EXPECT_EQ("1,201 300x400", | 843 EXPECT_EQ("1,201 300x400", |
840 GetDisplayInfoAt(1).bounds_in_native().ToString()); | 844 GetDisplayInfoAt(1).bounds_in_native().ToString()); |
841 EXPECT_EQ("300x400", | 845 EXPECT_EQ("300x400", |
842 GetDisplayInfoAt(1).size_in_pixel().ToString()); | 846 GetDisplayInfoAt(1).size_in_pixel().ToString()); |
843 | 847 |
844 // Just Rotating display will change the bounds on both display. | 848 // Just Rotating display will change the bounds on both display. |
845 UpdateDisplay("100x200/l,300x400"); | 849 UpdateDisplay("100x200/l,300x400"); |
846 EXPECT_EQ("2 0 0", GetCountSummary()); | 850 EXPECT_EQ("2 0 0", GetCountSummary()); |
847 reset(); | 851 reset(); |
848 | 852 |
849 // Updating tothe same configuration should report no changes. | 853 // Updating to the same configuration should report no changes. |
850 UpdateDisplay("100x200/l,300x400"); | 854 UpdateDisplay("100x200/l,300x400"); |
851 EXPECT_EQ("0 0 0", GetCountSummary()); | 855 EXPECT_EQ("0 0 0", GetCountSummary()); |
852 reset(); | 856 reset(); |
853 | 857 |
854 UpdateDisplay("100x200/l,300x400"); | 858 // Rotating 180 degrees should report one change. |
855 EXPECT_EQ("0 0 0", GetCountSummary()); | 859 UpdateDisplay("100x200/r,300x400"); |
| 860 EXPECT_EQ("1 0 0", GetCountSummary()); |
856 reset(); | 861 reset(); |
857 | 862 |
858 UpdateDisplay("200x200"); | 863 UpdateDisplay("200x200"); |
859 EXPECT_EQ("1 0 1", GetCountSummary()); | 864 EXPECT_EQ("1 0 1", GetCountSummary()); |
860 reset(); | 865 reset(); |
861 | 866 |
| 867 // Rotating 180 degrees should report one change. |
| 868 UpdateDisplay("200x200/u"); |
| 869 EXPECT_EQ("1 0 0", GetCountSummary()); |
| 870 reset(); |
| 871 |
862 UpdateDisplay("200x200/l"); | 872 UpdateDisplay("200x200/l"); |
863 EXPECT_EQ("1 0 0", GetCountSummary()); | 873 EXPECT_EQ("1 0 0", GetCountSummary()); |
864 } | 874 } |
865 | 875 |
866 TEST_F(DisplayManagerTest, UIScale) { | 876 TEST_F(DisplayManagerTest, UIScale) { |
867 UpdateDisplay("1280x800"); | 877 UpdateDisplay("1280x800"); |
868 int64 display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); | 878 int64 display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); |
869 display_manager()->SetDisplayUIScale(display_id, 1.125f); | 879 display_manager()->SetDisplayUIScale(display_id, 1.125f); |
870 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale()); | 880 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale()); |
871 display_manager()->SetDisplayUIScale(display_id, 0.8f); | 881 display_manager()->SetDisplayUIScale(display_id, 0.8f); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 UpdateDisplay("600x400,400x200*2@1.5"); | 1050 UpdateDisplay("600x400,400x200*2@1.5"); |
1041 EXPECT_EQ("750,75", env->last_mouse_location().ToString()); | 1051 EXPECT_EQ("750,75", env->last_mouse_location().ToString()); |
1042 } | 1052 } |
1043 | 1053 |
1044 class TestDisplayObserver : public gfx::DisplayObserver { | 1054 class TestDisplayObserver : public gfx::DisplayObserver { |
1045 public: | 1055 public: |
1046 TestDisplayObserver() : changed_(false) {} | 1056 TestDisplayObserver() : changed_(false) {} |
1047 virtual ~TestDisplayObserver() {} | 1057 virtual ~TestDisplayObserver() {} |
1048 | 1058 |
1049 // gfx::DisplayObserver overrides: | 1059 // gfx::DisplayObserver overrides: |
1050 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE { | 1060 virtual void OnDisplayMetricsChanged(const gfx::Display&,uint32_t) OVERRIDE {} |
1051 } | |
1052 virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE { | 1061 virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE { |
1053 // Mirror window should already be delete before restoring | 1062 // Mirror window should already be delete before restoring |
1054 // the external display. | 1063 // the external display. |
1055 EXPECT_FALSE(test_api.GetHost()); | 1064 EXPECT_FALSE(test_api.GetHost()); |
1056 changed_ = true; | 1065 changed_ = true; |
1057 } | 1066 } |
1058 virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE { | 1067 virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE { |
1059 // Mirror window should not be created until the external display | 1068 // Mirror window should not be created until the external display |
1060 // is removed. | 1069 // is removed. |
1061 EXPECT_FALSE(test_api.GetHost()); | 1070 EXPECT_FALSE(test_api.GetHost()); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 DISALLOW_COPY_AND_ASSIGN(ScreenShutdownTest); | 1271 DISALLOW_COPY_AND_ASSIGN(ScreenShutdownTest); |
1263 }; | 1272 }; |
1264 | 1273 |
1265 TEST_F(ScreenShutdownTest, ScreenAfterShutdown) { | 1274 TEST_F(ScreenShutdownTest, ScreenAfterShutdown) { |
1266 if (!SupportsMultipleDisplays()) | 1275 if (!SupportsMultipleDisplays()) |
1267 return; | 1276 return; |
1268 UpdateDisplay("500x300,800x400"); | 1277 UpdateDisplay("500x300,800x400"); |
1269 } | 1278 } |
1270 | 1279 |
1271 } // namespace ash | 1280 } // namespace ash |
OLD | NEW |