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/screen_position_controller.h" | 5 #include "ash/display/screen_position_controller.h" |
6 | 6 |
7 #include "ash/display/display_manager.h" | 7 #include "ash/display/display_manager.h" |
8 #include "ash/screen_util.h" | 8 #include "ash/screen_util.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
(...skipping 71 matching lines...) Loading... |
82 DISALLOW_COPY_AND_ASSIGN(ScreenPositionControllerTest); | 82 DISALLOW_COPY_AND_ASSIGN(ScreenPositionControllerTest); |
83 }; | 83 }; |
84 | 84 |
85 } // namespace | 85 } // namespace |
86 | 86 |
87 TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreen) { | 87 TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreen) { |
88 UpdateDisplay("100+100-200x200,100+500-200x200"); | 88 UpdateDisplay("100+100-200x200,100+500-200x200"); |
89 | 89 |
90 aura::Window::Windows root_windows = | 90 aura::Window::Windows root_windows = |
91 Shell::GetInstance()->GetAllRootWindows(); | 91 Shell::GetInstance()->GetAllRootWindows(); |
92 EXPECT_EQ("100,100", root_windows[0]->GetDispatcher()->host()-> | 92 EXPECT_EQ("100,100", |
93 GetBounds().origin().ToString()); | 93 root_windows[0]->GetHost()->GetBounds().origin().ToString()); |
94 EXPECT_EQ("200x200", root_windows[0]->GetDispatcher()->host()-> | 94 EXPECT_EQ("200x200", |
95 GetBounds().size().ToString()); | 95 root_windows[0]->GetHost()->GetBounds().size().ToString()); |
96 EXPECT_EQ("100,500", root_windows[1]->GetDispatcher()->host()-> | 96 EXPECT_EQ("100,500", |
97 GetBounds().origin().ToString()); | 97 root_windows[1]->GetHost()->GetBounds().origin().ToString()); |
98 EXPECT_EQ("200x200", root_windows[1]->GetDispatcher()->host()-> | 98 EXPECT_EQ("200x200", |
99 GetBounds().size().ToString()); | 99 root_windows[1]->GetHost()->GetBounds().size().ToString()); |
100 | 100 |
101 const gfx::Point window_pos(100, 100); | 101 const gfx::Point window_pos(100, 100); |
102 window_->SetBoundsInScreen( | 102 window_->SetBoundsInScreen( |
103 gfx::Rect(window_pos, gfx::Size(100, 100)), | 103 gfx::Rect(window_pos, gfx::Size(100, 100)), |
104 Shell::GetScreen()->GetDisplayNearestPoint(window_pos)); | 104 Shell::GetScreen()->GetDisplayNearestPoint(window_pos)); |
105 SetSecondaryDisplayLayout(DisplayLayout::RIGHT); | 105 SetSecondaryDisplayLayout(DisplayLayout::RIGHT); |
106 // The point is on the primary root window. | 106 // The point is on the primary root window. |
107 EXPECT_EQ("50,50", ConvertHostPointToScreen(50, 50)); | 107 EXPECT_EQ("50,50", ConvertHostPointToScreen(50, 50)); |
108 // The point is out of the all root windows. | 108 // The point is out of the all root windows. |
109 EXPECT_EQ("250,250", ConvertHostPointToScreen(250, 250)); | 109 EXPECT_EQ("250,250", ConvertHostPointToScreen(250, 250)); |
(...skipping 61 matching lines...) Loading... |
171 // The point is on the primary root window. | 171 // The point is on the primary root window. |
172 EXPECT_EQ("50,0", ConvertHostPointToScreen(50, -400)); | 172 EXPECT_EQ("50,0", ConvertHostPointToScreen(50, -400)); |
173 } | 173 } |
174 | 174 |
175 TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreenHiDPI) { | 175 TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreenHiDPI) { |
176 UpdateDisplay("100+100-200x200*2,100+500-200x200"); | 176 UpdateDisplay("100+100-200x200*2,100+500-200x200"); |
177 | 177 |
178 aura::Window::Windows root_windows = | 178 aura::Window::Windows root_windows = |
179 Shell::GetInstance()->GetAllRootWindows(); | 179 Shell::GetInstance()->GetAllRootWindows(); |
180 EXPECT_EQ("100,100", | 180 EXPECT_EQ("100,100", |
181 root_windows[0]->GetDispatcher()->host()-> | 181 root_windows[0]->GetHost()-> |
182 GetBounds().origin().ToString()); | 182 GetBounds().origin().ToString()); |
183 EXPECT_EQ("200x200", | 183 EXPECT_EQ("200x200", |
184 root_windows[0]->GetDispatcher()->host()-> | 184 root_windows[0]->GetHost()-> |
185 GetBounds().size().ToString()); | 185 GetBounds().size().ToString()); |
186 EXPECT_EQ("100,500", | 186 EXPECT_EQ("100,500", |
187 root_windows[1]->GetDispatcher()->host()-> | 187 root_windows[1]->GetHost()-> |
188 GetBounds().origin().ToString()); | 188 GetBounds().origin().ToString()); |
189 EXPECT_EQ("200x200", | 189 EXPECT_EQ("200x200", |
190 root_windows[1]->GetDispatcher()->host()-> | 190 root_windows[1]->GetHost()-> |
191 GetBounds().size().ToString()); | 191 GetBounds().size().ToString()); |
192 | 192 |
193 // Put |window_| to the primary 2x display. | 193 // Put |window_| to the primary 2x display. |
194 window_->SetBoundsInScreen(gfx::Rect(20, 20, 50, 50), | 194 window_->SetBoundsInScreen(gfx::Rect(20, 20, 50, 50), |
195 Shell::GetScreen()->GetPrimaryDisplay()); | 195 Shell::GetScreen()->GetPrimaryDisplay()); |
196 // (30, 30) means the host coordinate, so the point is still on the primary | 196 // (30, 30) means the host coordinate, so the point is still on the primary |
197 // root window. Since it's 2x, the specified native point was halved. | 197 // root window. Since it's 2x, the specified native point was halved. |
198 EXPECT_EQ("15,15", ConvertHostPointToScreen(30, 30)); | 198 EXPECT_EQ("15,15", ConvertHostPointToScreen(30, 30)); |
199 // Similar to above but the point is out of the all root windows. | 199 // Similar to above but the point is out of the all root windows. |
200 EXPECT_EQ("200,200", ConvertHostPointToScreen(400, 400)); | 200 EXPECT_EQ("200,200", ConvertHostPointToScreen(400, 400)); |
(...skipping 70 matching lines...) Loading... |
271 EXPECT_EQ("210,70", ConvertHostPointToScreen(60, 70)); | 271 EXPECT_EQ("210,70", ConvertHostPointToScreen(60, 70)); |
272 // The point is out of the host windows. | 272 // The point is out of the host windows. |
273 EXPECT_EQ("210,-50", ConvertHostPointToScreen(60, -50)); | 273 EXPECT_EQ("210,-50", ConvertHostPointToScreen(60, -50)); |
274 // The point is on the 2nd host. Point on 1nd host (60, 60) | 274 // The point is on the 2nd host. Point on 1nd host (60, 60) |
275 // 1/2 * 1.5 = (45,45) | 275 // 1/2 * 1.5 = (45,45) |
276 EXPECT_EQ("45,45", ConvertHostPointToScreen(60, -340)); | 276 EXPECT_EQ("45,45", ConvertHostPointToScreen(60, -340)); |
277 } | 277 } |
278 | 278 |
279 } // namespace test | 279 } // namespace test |
280 } // namespace ash | 280 } // namespace ash |
OLD | NEW |