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_ash.h" | 8 #include "ash/screen_ash.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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 private: | 81 private: |
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 Shell::RootWindowList root_windows = |
91 Shell::GetInstance()->GetAllRootWindows(); | 91 Shell::GetInstance()->GetAllRootWindows(); |
92 EXPECT_EQ("100,100", | 92 EXPECT_EQ("100,100", root_windows[0]->GetHostOrigin().ToString()); |
93 root_windows[0]->GetDispatcher()->GetHostOrigin().ToString()); | 93 EXPECT_EQ("200x200", root_windows[0]->GetHostSize().ToString()); |
94 EXPECT_EQ("200x200", | 94 EXPECT_EQ("100,500", root_windows[1]->GetHostOrigin().ToString()); |
95 root_windows[0]->GetDispatcher()->GetHostSize().ToString()); | 95 EXPECT_EQ("200x200", root_windows[1]->GetHostSize().ToString()); |
96 EXPECT_EQ("100,500", | |
97 root_windows[1]->GetDispatcher()->GetHostOrigin().ToString()); | |
98 EXPECT_EQ("200x200", | |
99 root_windows[1]->GetDispatcher()->GetHostSize().ToString()); | |
100 | 96 |
101 const gfx::Point window_pos(100, 100); | 97 const gfx::Point window_pos(100, 100); |
102 window_->SetBoundsInScreen( | 98 window_->SetBoundsInScreen( |
103 gfx::Rect(window_pos, gfx::Size(100, 100)), | 99 gfx::Rect(window_pos, gfx::Size(100, 100)), |
104 Shell::GetScreen()->GetDisplayNearestPoint(window_pos)); | 100 Shell::GetScreen()->GetDisplayNearestPoint(window_pos)); |
105 SetSecondaryDisplayLayout(DisplayLayout::RIGHT); | 101 SetSecondaryDisplayLayout(DisplayLayout::RIGHT); |
106 // The point is on the primary root window. | 102 // The point is on the primary root window. |
107 EXPECT_EQ("50,50", ConvertHostPointToScreen(50, 50)); | 103 EXPECT_EQ("50,50", ConvertHostPointToScreen(50, 50)); |
108 // The point is out of the all root windows. | 104 // The point is out of the all root windows. |
109 EXPECT_EQ("250,250", ConvertHostPointToScreen(250, 250)); | 105 EXPECT_EQ("250,250", ConvertHostPointToScreen(250, 250)); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 EXPECT_EQ("50,-150", ConvertHostPointToScreen(50, 50)); | 164 EXPECT_EQ("50,-150", ConvertHostPointToScreen(50, 50)); |
169 // The point is out of the all root windows. | 165 // The point is out of the all root windows. |
170 EXPECT_EQ("250,50", ConvertHostPointToScreen(250, 250)); | 166 EXPECT_EQ("250,50", ConvertHostPointToScreen(250, 250)); |
171 // The point is on the primary root window. | 167 // The point is on the primary root window. |
172 EXPECT_EQ("50,0", ConvertHostPointToScreen(50, -400)); | 168 EXPECT_EQ("50,0", ConvertHostPointToScreen(50, -400)); |
173 } | 169 } |
174 | 170 |
175 TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreenHiDPI) { | 171 TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreenHiDPI) { |
176 UpdateDisplay("100+100-200x200*2,100+500-200x200"); | 172 UpdateDisplay("100+100-200x200*2,100+500-200x200"); |
177 | 173 |
178 aura::Window::Windows root_windows = | 174 Shell::RootWindowList root_windows = |
179 Shell::GetInstance()->GetAllRootWindows(); | 175 Shell::GetInstance()->GetAllRootWindows(); |
180 EXPECT_EQ("100,100", | 176 EXPECT_EQ("100,100", root_windows[0]->GetHostOrigin().ToString()); |
181 root_windows[0]->GetDispatcher()->GetHostOrigin().ToString()); | 177 EXPECT_EQ("200x200", root_windows[0]->GetHostSize().ToString()); |
182 EXPECT_EQ("200x200", | 178 EXPECT_EQ("100,500", root_windows[1]->GetHostOrigin().ToString()); |
183 root_windows[0]->GetDispatcher()->GetHostSize().ToString()); | 179 EXPECT_EQ("200x200", root_windows[1]->GetHostSize().ToString()); |
184 EXPECT_EQ("100,500", | |
185 root_windows[1]->GetDispatcher()->GetHostOrigin().ToString()); | |
186 EXPECT_EQ("200x200", | |
187 root_windows[1]->GetDispatcher()->GetHostSize().ToString()); | |
188 | 180 |
189 // Put |window_| to the primary 2x display. | 181 // Put |window_| to the primary 2x display. |
190 window_->SetBoundsInScreen(gfx::Rect(20, 20, 50, 50), | 182 window_->SetBoundsInScreen(gfx::Rect(20, 20, 50, 50), |
191 Shell::GetScreen()->GetPrimaryDisplay()); | 183 Shell::GetScreen()->GetPrimaryDisplay()); |
192 // (30, 30) means the host coordinate, so the point is still on the primary | 184 // (30, 30) means the host coordinate, so the point is still on the primary |
193 // root window. Since it's 2x, the specified native point was halved. | 185 // root window. Since it's 2x, the specified native point was halved. |
194 EXPECT_EQ("15,15", ConvertHostPointToScreen(30, 30)); | 186 EXPECT_EQ("15,15", ConvertHostPointToScreen(30, 30)); |
195 // Similar to above but the point is out of the all root windows. | 187 // Similar to above but the point is out of the all root windows. |
196 EXPECT_EQ("200,200", ConvertHostPointToScreen(400, 400)); | 188 EXPECT_EQ("200,200", ConvertHostPointToScreen(400, 400)); |
197 // Similar to above but the point is on the secondary display. | 189 // Similar to above but the point is on the secondary display. |
(...skipping 22 matching lines...) Expand all Loading... |
220 EXPECT_EQ("70,149", ConvertHostPointToScreen(50, 70)); | 212 EXPECT_EQ("70,149", ConvertHostPointToScreen(50, 70)); |
221 // The point is out of the host windows. | 213 // The point is out of the host windows. |
222 EXPECT_EQ("250,-51", ConvertHostPointToScreen(250, 250)); | 214 EXPECT_EQ("250,-51", ConvertHostPointToScreen(250, 250)); |
223 // The point is on the 2nd host. Point on 2nd host (30,150) - | 215 // The point is on the 2nd host. Point on 2nd host (30,150) - |
224 // rotate 270 clockwise -> (149, 30) - layout [+(200,0)] -> (349,30). | 216 // rotate 270 clockwise -> (149, 30) - layout [+(200,0)] -> (349,30). |
225 EXPECT_EQ("349,30", ConvertHostPointToScreen(30, 450)); | 217 EXPECT_EQ("349,30", ConvertHostPointToScreen(30, 450)); |
226 | 218 |
227 // Move |window_| to the 2nd. | 219 // Move |window_| to the 2nd. |
228 window_->SetBoundsInScreen(gfx::Rect(300, 20, 50, 50), | 220 window_->SetBoundsInScreen(gfx::Rect(300, 20, 50, 50), |
229 ScreenAsh::GetSecondaryDisplay()); | 221 ScreenAsh::GetSecondaryDisplay()); |
230 aura::Window::Windows root_windows = | 222 Shell::RootWindowList root_windows = |
231 Shell::GetInstance()->GetAllRootWindows(); | 223 Shell::GetInstance()->GetAllRootWindows(); |
232 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | 224 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
233 | 225 |
234 // The point is on the 2nd host. (50,70) on 2n host - | 226 // The point is on the 2nd host. (50,70) on 2n host - |
235 // roatate 270 clockwise -> (129,50) -layout [+(200,0)] -> (329,50) | 227 // roatate 270 clockwise -> (129,50) -layout [+(200,0)] -> (329,50) |
236 EXPECT_EQ("329,50", ConvertHostPointToScreen(50, 70)); | 228 EXPECT_EQ("329,50", ConvertHostPointToScreen(50, 70)); |
237 // The point is out of the host windows. | 229 // The point is out of the host windows. |
238 EXPECT_EQ("449,50", ConvertHostPointToScreen(50, -50)); | 230 EXPECT_EQ("449,50", ConvertHostPointToScreen(50, -50)); |
239 // The point is on the 2nd host. Point on 2nd host (50,50) - | 231 // The point is on the 2nd host. Point on 2nd host (50,50) - |
240 // rotate 90 clockwise -> (50, 149) | 232 // rotate 90 clockwise -> (50, 149) |
(...skipping 11 matching lines...) Expand all Loading... |
252 EXPECT_EQ("45,45", ConvertHostPointToScreen(60, 60)); | 244 EXPECT_EQ("45,45", ConvertHostPointToScreen(60, 60)); |
253 // The point is out of the host windows. | 245 // The point is out of the host windows. |
254 EXPECT_EQ("45,225", ConvertHostPointToScreen(60, 300)); | 246 EXPECT_EQ("45,225", ConvertHostPointToScreen(60, 300)); |
255 // The point is on the 2nd host. Point on 2nd host (60,150) - | 247 // The point is on the 2nd host. Point on 2nd host (60,150) - |
256 // - screen [+(150,0)] | 248 // - screen [+(150,0)] |
257 EXPECT_EQ("210,49", ConvertHostPointToScreen(60, 450)); | 249 EXPECT_EQ("210,49", ConvertHostPointToScreen(60, 450)); |
258 | 250 |
259 // Move |window_| to the 2nd. | 251 // Move |window_| to the 2nd. |
260 window_->SetBoundsInScreen(gfx::Rect(300, 20, 50, 50), | 252 window_->SetBoundsInScreen(gfx::Rect(300, 20, 50, 50), |
261 ScreenAsh::GetSecondaryDisplay()); | 253 ScreenAsh::GetSecondaryDisplay()); |
262 aura::Window::Windows root_windows = | 254 Shell::RootWindowList root_windows = |
263 Shell::GetInstance()->GetAllRootWindows(); | 255 Shell::GetInstance()->GetAllRootWindows(); |
264 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | 256 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
265 | 257 |
266 // The point is on the 2nd host. (50,70) - ro | 258 // The point is on the 2nd host. (50,70) - ro |
267 EXPECT_EQ("210,70", ConvertHostPointToScreen(60, 70)); | 259 EXPECT_EQ("210,70", ConvertHostPointToScreen(60, 70)); |
268 // The point is out of the host windows. | 260 // The point is out of the host windows. |
269 EXPECT_EQ("210,-50", ConvertHostPointToScreen(60, -50)); | 261 EXPECT_EQ("210,-50", ConvertHostPointToScreen(60, -50)); |
270 // The point is on the 2nd host. Point on 1nd host (60, 60) | 262 // The point is on the 2nd host. Point on 1nd host (60, 60) |
271 // 1/2 * 1.5 = (45,45) | 263 // 1/2 * 1.5 = (45,45) |
272 EXPECT_EQ("45,45", ConvertHostPointToScreen(60, -340)); | 264 EXPECT_EQ("45,45", ConvertHostPointToScreen(60, -340)); |
273 } | 265 } |
274 | 266 |
275 } // namespace test | 267 } // namespace test |
276 } // namespace ash | 268 } // namespace ash |
OLD | NEW |