| 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 DisplayObserver::MetricsType) 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 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 EXPECT_EQ("1,201 300x400", | 840 EXPECT_EQ("1,201 300x400", |
| 840 GetDisplayInfoAt(1).bounds_in_native().ToString()); | 841 GetDisplayInfoAt(1).bounds_in_native().ToString()); |
| 841 EXPECT_EQ("300x400", | 842 EXPECT_EQ("300x400", |
| 842 GetDisplayInfoAt(1).size_in_pixel().ToString()); | 843 GetDisplayInfoAt(1).size_in_pixel().ToString()); |
| 843 | 844 |
| 844 // Just Rotating display will change the bounds on both display. | 845 // Just Rotating display will change the bounds on both display. |
| 845 UpdateDisplay("100x200/l,300x400"); | 846 UpdateDisplay("100x200/l,300x400"); |
| 846 EXPECT_EQ("2 0 0", GetCountSummary()); | 847 EXPECT_EQ("2 0 0", GetCountSummary()); |
| 847 reset(); | 848 reset(); |
| 848 | 849 |
| 849 // Updating tothe same configuration should report no changes. | 850 // Updating to the same configuration should report no changes. |
| 850 UpdateDisplay("100x200/l,300x400"); | 851 UpdateDisplay("100x200/l,300x400"); |
| 851 EXPECT_EQ("0 0 0", GetCountSummary()); | 852 EXPECT_EQ("0 0 0", GetCountSummary()); |
| 852 reset(); | 853 reset(); |
| 853 | 854 |
| 854 UpdateDisplay("100x200/l,300x400"); | 855 // Rotating 180 degrees should report one change. |
| 855 EXPECT_EQ("0 0 0", GetCountSummary()); | 856 UpdateDisplay("100x200/r,300x400"); |
| 857 EXPECT_EQ("1 0 0", GetCountSummary()); |
| 856 reset(); | 858 reset(); |
| 857 | 859 |
| 858 UpdateDisplay("200x200"); | 860 UpdateDisplay("200x200"); |
| 859 EXPECT_EQ("1 0 1", GetCountSummary()); | 861 EXPECT_EQ("1 0 1", GetCountSummary()); |
| 860 reset(); | 862 reset(); |
| 861 | 863 |
| 864 // Rotating 180 degrees should report one change. |
| 865 UpdateDisplay("200x200/u"); |
| 866 EXPECT_EQ("1 0 0", GetCountSummary()); |
| 867 reset(); |
| 868 |
| 862 UpdateDisplay("200x200/l"); | 869 UpdateDisplay("200x200/l"); |
| 863 EXPECT_EQ("1 0 0", GetCountSummary()); | 870 EXPECT_EQ("1 0 0", GetCountSummary()); |
| 864 } | 871 } |
| 865 | 872 |
| 866 TEST_F(DisplayManagerTest, UIScale) { | 873 TEST_F(DisplayManagerTest, UIScale) { |
| 867 UpdateDisplay("1280x800"); | 874 UpdateDisplay("1280x800"); |
| 868 int64 display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); | 875 int64 display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); |
| 869 display_manager()->SetDisplayUIScale(display_id, 1.125f); | 876 display_manager()->SetDisplayUIScale(display_id, 1.125f); |
| 870 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale()); | 877 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale()); |
| 871 display_manager()->SetDisplayUIScale(display_id, 0.8f); | 878 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"); | 1047 UpdateDisplay("600x400,400x200*2@1.5"); |
| 1041 EXPECT_EQ("750,75", env->last_mouse_location().ToString()); | 1048 EXPECT_EQ("750,75", env->last_mouse_location().ToString()); |
| 1042 } | 1049 } |
| 1043 | 1050 |
| 1044 class TestDisplayObserver : public gfx::DisplayObserver { | 1051 class TestDisplayObserver : public gfx::DisplayObserver { |
| 1045 public: | 1052 public: |
| 1046 TestDisplayObserver() : changed_(false) {} | 1053 TestDisplayObserver() : changed_(false) {} |
| 1047 virtual ~TestDisplayObserver() {} | 1054 virtual ~TestDisplayObserver() {} |
| 1048 | 1055 |
| 1049 // gfx::DisplayObserver overrides: | 1056 // gfx::DisplayObserver overrides: |
| 1050 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE { | 1057 virtual void OnDisplayMetricsChanged( |
| 1058 const gfx::Display&, DisplayObserver::MetricsType) OVERRIDE { |
| 1051 } | 1059 } |
| 1052 virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE { | 1060 virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE { |
| 1053 // Mirror window should already be delete before restoring | 1061 // Mirror window should already be delete before restoring |
| 1054 // the external display. | 1062 // the external display. |
| 1055 EXPECT_FALSE(test_api.GetHost()); | 1063 EXPECT_FALSE(test_api.GetHost()); |
| 1056 changed_ = true; | 1064 changed_ = true; |
| 1057 } | 1065 } |
| 1058 virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE { | 1066 virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE { |
| 1059 // Mirror window should not be created until the external display | 1067 // Mirror window should not be created until the external display |
| 1060 // is removed. | 1068 // is removed. |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 DISALLOW_COPY_AND_ASSIGN(ScreenShutdownTest); | 1270 DISALLOW_COPY_AND_ASSIGN(ScreenShutdownTest); |
| 1263 }; | 1271 }; |
| 1264 | 1272 |
| 1265 TEST_F(ScreenShutdownTest, ScreenAfterShutdown) { | 1273 TEST_F(ScreenShutdownTest, ScreenAfterShutdown) { |
| 1266 if (!SupportsMultipleDisplays()) | 1274 if (!SupportsMultipleDisplays()) |
| 1267 return; | 1275 return; |
| 1268 UpdateDisplay("500x300,800x400"); | 1276 UpdateDisplay("500x300,800x400"); |
| 1269 } | 1277 } |
| 1270 | 1278 |
| 1271 } // namespace ash | 1279 } // namespace ash |
| OLD | NEW |