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/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/display/display_controller.h" | 8 #include "ash/display/display_controller.h" |
9 #include "ash/display/display_info.h" | 9 #include "ash/display/display_info.h" |
10 #include "ash/display/display_layout_store.h" | 10 #include "ash/display/display_layout_store.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 } // namespace | 43 } // namespace |
44 | 44 |
45 class DisplayManagerTest : public test::AshTestBase, | 45 class DisplayManagerTest : public test::AshTestBase, |
46 public gfx::DisplayObserver, | 46 public gfx::DisplayObserver, |
47 public aura::WindowObserver { | 47 public aura::WindowObserver { |
48 public: | 48 public: |
49 DisplayManagerTest() | 49 DisplayManagerTest() |
50 : removed_count_(0U), | 50 : removed_count_(0U), |
51 root_window_destroyed_(false) { | 51 root_window_destroyed_(false) { |
52 } | 52 } |
53 virtual ~DisplayManagerTest() {} | 53 ~DisplayManagerTest() override {} |
54 | 54 |
55 virtual void SetUp() override { | 55 void SetUp() override { |
56 AshTestBase::SetUp(); | 56 AshTestBase::SetUp(); |
57 Shell::GetScreen()->AddObserver(this); | 57 Shell::GetScreen()->AddObserver(this); |
58 Shell::GetPrimaryRootWindow()->AddObserver(this); | 58 Shell::GetPrimaryRootWindow()->AddObserver(this); |
59 } | 59 } |
60 virtual void TearDown() override { | 60 void TearDown() override { |
61 Shell::GetPrimaryRootWindow()->RemoveObserver(this); | 61 Shell::GetPrimaryRootWindow()->RemoveObserver(this); |
62 Shell::GetScreen()->RemoveObserver(this); | 62 Shell::GetScreen()->RemoveObserver(this); |
63 AshTestBase::TearDown(); | 63 AshTestBase::TearDown(); |
64 } | 64 } |
65 | 65 |
66 DisplayManager* display_manager() { | 66 DisplayManager* display_manager() { |
67 return Shell::GetInstance()->display_manager(); | 67 return Shell::GetInstance()->display_manager(); |
68 } | 68 } |
69 const vector<gfx::Display>& changed() const { return changed_; } | 69 const vector<gfx::Display>& changed() const { return changed_; } |
70 const vector<gfx::Display>& added() const { return added_; } | 70 const vector<gfx::Display>& added() const { return added_; } |
(...skipping 24 matching lines...) Expand all Loading... |
95 | 95 |
96 const gfx::Display& GetDisplayForId(int64 id) { | 96 const gfx::Display& GetDisplayForId(int64 id) { |
97 return display_manager()->GetDisplayForId(id); | 97 return display_manager()->GetDisplayForId(id); |
98 } | 98 } |
99 | 99 |
100 const DisplayInfo& GetDisplayInfoForId(int64 id) { | 100 const DisplayInfo& GetDisplayInfoForId(int64 id) { |
101 return GetDisplayInfo(display_manager()->GetDisplayForId(id)); | 101 return GetDisplayInfo(display_manager()->GetDisplayForId(id)); |
102 } | 102 } |
103 | 103 |
104 // aura::DisplayObserver overrides: | 104 // aura::DisplayObserver overrides: |
105 virtual void OnDisplayMetricsChanged(const gfx::Display& display, | 105 void OnDisplayMetricsChanged(const gfx::Display& display, uint32_t) override { |
106 uint32_t) override { | |
107 changed_.push_back(display); | 106 changed_.push_back(display); |
108 } | 107 } |
109 virtual void OnDisplayAdded(const gfx::Display& new_display) override { | 108 void OnDisplayAdded(const gfx::Display& new_display) override { |
110 added_.push_back(new_display); | 109 added_.push_back(new_display); |
111 } | 110 } |
112 virtual void OnDisplayRemoved(const gfx::Display& old_display) override { | 111 void OnDisplayRemoved(const gfx::Display& old_display) override { |
113 ++removed_count_; | 112 ++removed_count_; |
114 } | 113 } |
115 | 114 |
116 // aura::WindowObserver overrides: | 115 // aura::WindowObserver overrides: |
117 virtual void OnWindowDestroying(aura::Window* window) override { | 116 void OnWindowDestroying(aura::Window* window) override { |
118 ASSERT_EQ(Shell::GetPrimaryRootWindow(), window); | 117 ASSERT_EQ(Shell::GetPrimaryRootWindow(), window); |
119 root_window_destroyed_ = true; | 118 root_window_destroyed_ = true; |
120 } | 119 } |
121 | 120 |
122 private: | 121 private: |
123 vector<gfx::Display> changed_; | 122 vector<gfx::Display> changed_; |
124 vector<gfx::Display> added_; | 123 vector<gfx::Display> added_; |
125 size_t removed_count_; | 124 size_t removed_count_; |
126 bool root_window_destroyed_; | 125 bool root_window_destroyed_; |
127 | 126 |
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 | 1174 |
1176 // The native location is now outside, so move to the | 1175 // The native location is now outside, so move to the |
1177 // center of closest display. | 1176 // center of closest display. |
1178 UpdateDisplay("600x400,400x200*2@1.5"); | 1177 UpdateDisplay("600x400,400x200*2@1.5"); |
1179 EXPECT_EQ("750,75", env->last_mouse_location().ToString()); | 1178 EXPECT_EQ("750,75", env->last_mouse_location().ToString()); |
1180 } | 1179 } |
1181 | 1180 |
1182 class TestDisplayObserver : public gfx::DisplayObserver { | 1181 class TestDisplayObserver : public gfx::DisplayObserver { |
1183 public: | 1182 public: |
1184 TestDisplayObserver() : changed_(false) {} | 1183 TestDisplayObserver() : changed_(false) {} |
1185 virtual ~TestDisplayObserver() {} | 1184 ~TestDisplayObserver() override {} |
1186 | 1185 |
1187 // gfx::DisplayObserver overrides: | 1186 // gfx::DisplayObserver overrides: |
1188 virtual void OnDisplayMetricsChanged(const gfx::Display&,uint32_t) override {} | 1187 void OnDisplayMetricsChanged(const gfx::Display&, uint32_t) override {} |
1189 virtual void OnDisplayAdded(const gfx::Display& new_display) override { | 1188 void OnDisplayAdded(const gfx::Display& new_display) override { |
1190 // Mirror window should already be delete before restoring | 1189 // Mirror window should already be delete before restoring |
1191 // the external display. | 1190 // the external display. |
1192 EXPECT_FALSE(test_api.GetHost()); | 1191 EXPECT_FALSE(test_api.GetHost()); |
1193 changed_ = true; | 1192 changed_ = true; |
1194 } | 1193 } |
1195 virtual void OnDisplayRemoved(const gfx::Display& old_display) override { | 1194 void OnDisplayRemoved(const gfx::Display& old_display) override { |
1196 // Mirror window should not be created until the external display | 1195 // Mirror window should not be created until the external display |
1197 // is removed. | 1196 // is removed. |
1198 EXPECT_FALSE(test_api.GetHost()); | 1197 EXPECT_FALSE(test_api.GetHost()); |
1199 changed_ = true; | 1198 changed_ = true; |
1200 } | 1199 } |
1201 | 1200 |
1202 bool changed_and_reset() { | 1201 bool changed_and_reset() { |
1203 bool changed = changed_; | 1202 bool changed = changed_; |
1204 changed_ = false; | 1203 changed_ = false; |
1205 return changed; | 1204 return changed; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1410 EXPECT_EQ("100x200", host0->GetBounds().size().ToString()); | 1409 EXPECT_EQ("100x200", host0->GetBounds().size().ToString()); |
1411 EXPECT_EQ("300,500", host1->GetBounds().origin().ToString()); | 1410 EXPECT_EQ("300,500", host1->GetBounds().origin().ToString()); |
1412 EXPECT_EQ("200x300", host1->GetBounds().size().ToString()); | 1411 EXPECT_EQ("200x300", host1->GetBounds().size().ToString()); |
1413 } | 1412 } |
1414 | 1413 |
1415 | 1414 |
1416 class ScreenShutdownTest : public test::AshTestBase { | 1415 class ScreenShutdownTest : public test::AshTestBase { |
1417 public: | 1416 public: |
1418 ScreenShutdownTest() { | 1417 ScreenShutdownTest() { |
1419 } | 1418 } |
1420 virtual ~ScreenShutdownTest() {} | 1419 ~ScreenShutdownTest() override {} |
1421 | 1420 |
1422 virtual void TearDown() override { | 1421 void TearDown() override { |
1423 gfx::Screen* orig_screen = | 1422 gfx::Screen* orig_screen = |
1424 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); | 1423 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); |
1425 AshTestBase::TearDown(); | 1424 AshTestBase::TearDown(); |
1426 if (!SupportsMultipleDisplays()) | 1425 if (!SupportsMultipleDisplays()) |
1427 return; | 1426 return; |
1428 gfx::Screen* screen = | 1427 gfx::Screen* screen = |
1429 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); | 1428 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); |
1430 EXPECT_NE(orig_screen, screen); | 1429 EXPECT_NE(orig_screen, screen); |
1431 EXPECT_EQ(2, screen->GetNumDisplays()); | 1430 EXPECT_EQ(2, screen->GetNumDisplays()); |
1432 EXPECT_EQ("500x300", screen->GetPrimaryDisplay().size().ToString()); | 1431 EXPECT_EQ("500x300", screen->GetPrimaryDisplay().size().ToString()); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1541 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL); | 1540 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL); |
1542 ASSERT_DOUBLE_EQ( | 1541 ASSERT_DOUBLE_EQ( |
1543 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 1542 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
1544 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); | 1543 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); |
1545 DisplayInfo::SetUse125DSFForUIScaling(false); | 1544 DisplayInfo::SetUse125DSFForUIScaling(false); |
1546 } | 1545 } |
1547 | 1546 |
1548 #endif // OS_CHROMEOS | 1547 #endif // OS_CHROMEOS |
1549 | 1548 |
1550 } // namespace ash | 1549 } // namespace ash |
OLD | NEW |