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

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

Issue 1608053002: Remove now-unnecessary wrappers around gfx::Screen::GetScreen() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@metro-mode-5
Patch Set: . Created 4 years, 11 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
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/wm/window_positioner.h" 5 #include "ash/wm/window_positioner.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
oshima 2016/01/20 06:40:12 remove this?
scottmg 2016/01/26 20:46:35 Done.
10 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
11 #include "ash/test/test_shell_delegate.h" 11 #include "ash/test/test_shell_delegate.h"
12 #include "ash/wm/window_resizer.h" 12 #include "ash/wm/window_resizer.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/host_desktop.h" 17 #include "chrome/browser/ui/host_desktop.h"
18 #include "chrome/test/base/test_browser_window_aura.h" 18 #include "chrome/test/base/test_browser_window_aura.h"
19 #include "chrome/test/base/testing_profile.h" 19 #include "chrome/test/base/testing_profile.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 97 }
98 98
99 int AlignToGridRoundDown(int location, int grid_size) { 99 int AlignToGridRoundDown(int location, int grid_size) {
100 if (grid_size <= 1 || location % grid_size == 0) 100 if (grid_size <= 1 || location % grid_size == 0)
101 return location; 101 return location;
102 return location / grid_size * grid_size; 102 return location / grid_size * grid_size;
103 } 103 }
104 104
105 TEST_F(WindowPositionerTest, cascading) { 105 TEST_F(WindowPositionerTest, cascading) {
106 const gfx::Rect work_area = 106 const gfx::Rect work_area =
107 Shell::GetScreen()->GetPrimaryDisplay().work_area(); 107 gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area();
108 108
109 // First see that the window will cascade down when there is no space. 109 // First see that the window will cascade down when there is no space.
110 window()->SetBounds(work_area); 110 window()->SetBounds(work_area);
111 window()->Show(); 111 window()->Show();
112 112
113 gfx::Rect popup_position(0, 0, 200, 200); 113 gfx::Rect popup_position(0, 0, 200, 200);
114 // Check that it gets cascaded. 114 // Check that it gets cascaded.
115 gfx::Rect cascade_1 = window_positioner()->GetPopupPosition(popup_position); 115 gfx::Rect cascade_1 = window_positioner()->GetPopupPosition(popup_position);
116 EXPECT_EQ(gfx::Rect(work_area.x() + grid_size_, work_area.y() + grid_size_, 116 EXPECT_EQ(gfx::Rect(work_area.x() + grid_size_, work_area.y() + grid_size_,
117 popup_position.width(), popup_position.height()), 117 popup_position.width(), popup_position.height()),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 gfx::Rect cascade_5 = 158 gfx::Rect cascade_5 =
159 window_positioner()->GetPopupPosition(popup_position_5); 159 window_positioner()->GetPopupPosition(popup_position_5);
160 EXPECT_EQ(gfx::Rect(work_area.x() + grid_size_, 160 EXPECT_EQ(gfx::Rect(work_area.x() + grid_size_,
161 work_area.y() + grid_size_, 161 work_area.y() + grid_size_,
162 popup_position_5.width(), popup_position_5.height()), 162 popup_position_5.width(), popup_position_5.height()),
163 cascade_5); 163 cascade_5);
164 } 164 }
165 165
166 TEST_F(WindowPositionerTest, filling) { 166 TEST_F(WindowPositionerTest, filling) {
167 const gfx::Rect work_area = 167 const gfx::Rect work_area =
168 Shell::GetScreen()->GetPrimaryDisplay().work_area(); 168 gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area();
169 gfx::Rect popup_position(0, 0, 256, 128); 169 gfx::Rect popup_position(0, 0, 256, 128);
170 // Leave space on the left and the right and see if we fill top to bottom. 170 // Leave space on the left and the right and see if we fill top to bottom.
171 window()->SetBounds(gfx::Rect(work_area.x() + popup_position.width(), 171 window()->SetBounds(gfx::Rect(work_area.x() + popup_position.width(),
172 work_area.y(), 172 work_area.y(),
173 work_area.width() - 2 * popup_position.width(), 173 work_area.width() - 2 * popup_position.width(),
174 work_area.height())); 174 work_area.height()));
175 window()->Show(); 175 window()->Show();
176 // Check that we are positioned in the top left corner. 176 // Check that we are positioned in the top left corner.
177 gfx::Rect top_left = window_positioner()->GetPopupPosition(popup_position); 177 gfx::Rect top_left = window_positioner()->GetPopupPosition(popup_position);
178 EXPECT_EQ(gfx::Rect(work_area.x(), work_area.y(), 178 EXPECT_EQ(gfx::Rect(work_area.x(), work_area.y(),
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 popup_position); 213 popup_position);
214 EXPECT_EQ(gfx::Rect(AlignToGridRoundDown(work_area.right() - 214 EXPECT_EQ(gfx::Rect(AlignToGridRoundDown(work_area.right() -
215 popup_position.width(), grid_size_), 215 popup_position.width(), grid_size_),
216 work_area.y(), 216 work_area.y(),
217 popup_position.width(), popup_position.height()), 217 popup_position.width(), popup_position.height()),
218 top_right); 218 top_right);
219 } 219 }
220 220
221 TEST_F(WindowPositionerTest, biggerThenBorder) { 221 TEST_F(WindowPositionerTest, biggerThenBorder) {
222 const gfx::Rect work_area = 222 const gfx::Rect work_area =
223 Shell::GetScreen()->GetPrimaryDisplay().work_area(); 223 gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area();
224 224
225 gfx::Rect pop_position(0, 0, work_area.width(), work_area.height()); 225 gfx::Rect pop_position(0, 0, work_area.width(), work_area.height());
226 226
227 // Check that the popup is placed full screen. 227 // Check that the popup is placed full screen.
228 gfx::Rect full = window_positioner()->GetPopupPosition(pop_position); 228 gfx::Rect full = window_positioner()->GetPopupPosition(pop_position);
229 EXPECT_EQ(gfx::Rect(work_area.x(), work_area.y(), 229 EXPECT_EQ(gfx::Rect(work_area.x(), work_area.y(),
230 pop_position.width(), pop_position.height()), 230 pop_position.width(), pop_position.height()),
231 full); 231 full);
232 } 232 }
233 233
234 } // namespace test 234 } // namespace test
235 } // namespace ash 235 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698