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