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