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

Side by Side Diff: chrome/browser/ui/ash/window_positioner_unittest.cc

Issue 11030017: Add context to gfx::Screen calls in support of simultaneous desktop+ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix other os's Created 8 years, 2 months 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 "chrome/browser/ui/ash/window_positioner.h" 5 #include "chrome/browser/ui/ash/window_positioner.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h" 8 #include "ash/test/ash_test_base.h"
9 #include "ash/test/test_shell_delegate.h" 9 #include "ash/test/test_shell_delegate.h"
10 #include "ash/wm/window_resizer.h" 10 #include "ash/wm/window_resizer.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 window_positioner_ = NULL; 173 window_positioner_ = NULL;
174 } 174 }
175 175
176 int AlignToGridRoundDown(int location, int grid_size) { 176 int AlignToGridRoundDown(int location, int grid_size) {
177 if (grid_size <= 1 || location % grid_size == 0) 177 if (grid_size <= 1 || location % grid_size == 0)
178 return location; 178 return location;
179 return location / grid_size * grid_size; 179 return location / grid_size * grid_size;
180 } 180 }
181 181
182 TEST_F(WindowPositionerTest, cascading) { 182 TEST_F(WindowPositionerTest, cascading) {
183 const gfx::Rect work_area = gfx::Screen::GetPrimaryDisplay().work_area(); 183 const gfx::Rect work_area = gfx::Screen::GetPrimaryDisplay(
184 ash::Shell::GetRootNativeView()).work_area();
184 185
185 // First see that the window will cascade down when there is no space. 186 // First see that the window will cascade down when there is no space.
186 window()->SetBounds(work_area); 187 window()->SetBounds(work_area);
187 window()->Show(); 188 window()->Show();
188 189
189 gfx::Rect popup_position(0, 0, 200, 200); 190 gfx::Rect popup_position(0, 0, 200, 200);
190 // Check that it gets cascaded. 191 // Check that it gets cascaded.
191 gfx::Rect cascade_1 = window_positioner()->GetPopupPosition(popup_position); 192 gfx::Rect cascade_1 = window_positioner()->GetPopupPosition(popup_position);
192 EXPECT_EQ(gfx::Rect(work_area.x() + grid_size_, work_area.y() + grid_size_, 193 EXPECT_EQ(gfx::Rect(work_area.x() + grid_size_, work_area.y() + grid_size_,
193 popup_position.width(), popup_position.height()), 194 popup_position.width(), popup_position.height()),
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 (2 * grid_size_ - work_area.y())); 234 (2 * grid_size_ - work_area.y()));
234 gfx::Rect cascade_5 = 235 gfx::Rect cascade_5 =
235 window_positioner()->GetPopupPosition(popup_position_5); 236 window_positioner()->GetPopupPosition(popup_position_5);
236 EXPECT_EQ(gfx::Rect(work_area.x() + grid_size_, 237 EXPECT_EQ(gfx::Rect(work_area.x() + grid_size_,
237 work_area.y() + grid_size_, 238 work_area.y() + grid_size_,
238 popup_position_5.width(), popup_position_5.height()), 239 popup_position_5.width(), popup_position_5.height()),
239 cascade_5); 240 cascade_5);
240 } 241 }
241 242
242 TEST_F(WindowPositionerTest, filling) { 243 TEST_F(WindowPositionerTest, filling) {
243 const gfx::Rect work_area = gfx::Screen::GetPrimaryDisplay().work_area(); 244 const gfx::Rect work_area = gfx::Screen::GetPrimaryDisplay(
245 ash::Shell::GetRootNativeView()).work_area();
244 gfx::Rect popup_position(0, 0, 256, 128); 246 gfx::Rect popup_position(0, 0, 256, 128);
245 // Leave space on the left and the right and see if we fill top to bottom. 247 // Leave space on the left and the right and see if we fill top to bottom.
246 window()->SetBounds(gfx::Rect(work_area.x() + popup_position.width(), 248 window()->SetBounds(gfx::Rect(work_area.x() + popup_position.width(),
247 work_area.y(), 249 work_area.y(),
248 work_area.width() - 2 * popup_position.width(), 250 work_area.width() - 2 * popup_position.width(),
249 work_area.height())); 251 work_area.height()));
250 window()->Show(); 252 window()->Show();
251 // Check that we are positioned in the top left corner. 253 // Check that we are positioned in the top left corner.
252 gfx::Rect top_left = window_positioner()->GetPopupPosition(popup_position); 254 gfx::Rect top_left = window_positioner()->GetPopupPosition(popup_position);
253 EXPECT_EQ(gfx::Rect(work_area.x(), work_area.y(), 255 EXPECT_EQ(gfx::Rect(work_area.x(), work_area.y(),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 gfx::Rect top_right = window_positioner()->GetPopupPosition( 289 gfx::Rect top_right = window_positioner()->GetPopupPosition(
288 popup_position); 290 popup_position);
289 EXPECT_EQ(gfx::Rect(AlignToGridRoundDown(work_area.right() - 291 EXPECT_EQ(gfx::Rect(AlignToGridRoundDown(work_area.right() -
290 popup_position.width(), grid_size_), 292 popup_position.width(), grid_size_),
291 work_area.y(), 293 work_area.y(),
292 popup_position.width(), popup_position.height()), 294 popup_position.width(), popup_position.height()),
293 top_right); 295 top_right);
294 } 296 }
295 297
296 TEST_F(WindowPositionerTest, blockedByPanel) { 298 TEST_F(WindowPositionerTest, blockedByPanel) {
297 const gfx::Rect work_area = gfx::Screen::GetPrimaryDisplay().work_area(); 299 const gfx::Rect work_area = gfx::Screen::GetPrimaryDisplay(
300 ash::Shell::GetRootNativeView()).work_area();
298 301
299 gfx::Rect pop_position(0, 0, 200, 200); 302 gfx::Rect pop_position(0, 0, 200, 200);
300 // Let the panel cover everything. 303 // Let the panel cover everything.
301 panel()->SetBounds(work_area); 304 panel()->SetBounds(work_area);
302 panel()->Show(); 305 panel()->Show();
303 306
304 // Check that the popup does cascade due to the panel's existence. 307 // Check that the popup does cascade due to the panel's existence.
305 gfx::Rect top_right = window_positioner()->GetPopupPosition(pop_position); 308 gfx::Rect top_right = window_positioner()->GetPopupPosition(pop_position);
306 EXPECT_EQ(gfx::Rect(work_area.x() + grid_size_, work_area.y() + grid_size_, 309 EXPECT_EQ(gfx::Rect(work_area.x() + grid_size_, work_area.y() + grid_size_,
307 pop_position.width(), pop_position.height()), 310 pop_position.width(), pop_position.height()),
308 top_right); 311 top_right);
309 } 312 }
310 313
311 TEST_F(WindowPositionerTest, biggerThenBorder) { 314 TEST_F(WindowPositionerTest, biggerThenBorder) {
312 const gfx::Rect work_area = gfx::Screen::GetPrimaryDisplay().work_area(); 315 const gfx::Rect work_area = gfx::Screen::GetPrimaryDisplay(
316 ash::Shell::GetRootNativeView()).work_area();
313 317
314 gfx::Rect pop_position(0, 0, work_area.width(), work_area.height()); 318 gfx::Rect pop_position(0, 0, work_area.width(), work_area.height());
315 319
316 // Check that the popup is placed full screen. 320 // Check that the popup is placed full screen.
317 gfx::Rect full = window_positioner()->GetPopupPosition(pop_position); 321 gfx::Rect full = window_positioner()->GetPopupPosition(pop_position);
318 EXPECT_EQ(gfx::Rect(work_area.x(), work_area.y(), 322 EXPECT_EQ(gfx::Rect(work_area.x(), work_area.y(),
319 pop_position.width(), pop_position.height()), 323 pop_position.width(), pop_position.height()),
320 full); 324 full);
321 } 325 }
322 326
323 } // namespace test 327 } // namespace test
324 } // namespace ash 328 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698