Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(816)

Side by Side Diff: ash/display/screen_position_controller_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698