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 "chrome/browser/ui/window_sizer.h" | 5 #include "chrome/browser/ui/window_sizer.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 TestBrowserWindowAura::~TestBrowserWindowAura() {} | 82 TestBrowserWindowAura::~TestBrowserWindowAura() {} |
83 | 83 |
84 // Test that the window is sized appropriately for the first run experience | 84 // Test that the window is sized appropriately for the first run experience |
85 // where the default window bounds calculation is invoked. | 85 // where the default window bounds calculation is invoked. |
86 TEST_F(WindowSizerTest, DefaultSizeCase) { | 86 TEST_F(WindowSizerTest, DefaultSizeCase) { |
87 int grid = ash::Shell::GetInstance()->GetGridSize(); | 87 int grid = ash::Shell::GetInstance()->GetGridSize(); |
88 EXPECT_EQ(WindowSizer::kDesktopBorderSize, grid); | 88 EXPECT_EQ(WindowSizer::kDesktopBorderSize, grid); |
89 { // 4:3 monitor case, 1024x768, no taskbar | 89 { // 4:3 monitor case, 1024x768, no taskbar |
90 gfx::Rect window_bounds; | 90 gfx::Rect window_bounds; |
91 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(), | 91 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(), |
92 gfx::Rect(), DEFAULT, &window_bounds, NULL); | 92 gfx::Rect(), DEFAULT, &window_bounds, NULL, gfx::Rect()); |
93 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, | 93 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, |
94 WindowSizer::kDesktopBorderSize, | 94 WindowSizer::kDesktopBorderSize, |
95 1024 - WindowSizer::kDesktopBorderSize * 2, | 95 1024 - WindowSizer::kDesktopBorderSize * 2, |
96 768 - WindowSizer::kDesktopBorderSize), | 96 768 - WindowSizer::kDesktopBorderSize), |
97 window_bounds); | 97 window_bounds); |
98 } | 98 } |
99 | 99 |
100 { // 4:3 monitor case, 1024x768, taskbar on bottom | 100 { // 4:3 monitor case, 1024x768, taskbar on bottom |
101 gfx::Rect window_bounds; | 101 gfx::Rect window_bounds; |
102 GetWindowBounds(tentwentyfour, taskbar_bottom_work_area, gfx::Rect(), | 102 GetWindowBounds(tentwentyfour, taskbar_bottom_work_area, gfx::Rect(), |
103 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL); | 103 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL, |
| 104 gfx::Rect()); |
104 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, | 105 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, |
105 WindowSizer::kDesktopBorderSize, | 106 WindowSizer::kDesktopBorderSize, |
106 1024 - WindowSizer::kDesktopBorderSize * 2, | 107 1024 - WindowSizer::kDesktopBorderSize * 2, |
107 ash::WindowResizer::AlignToGridRoundDown( | 108 ash::WindowResizer::AlignToGridRoundDown( |
108 taskbar_bottom_work_area.height() - | 109 taskbar_bottom_work_area.height() - |
109 WindowSizer::kDesktopBorderSize, grid)), | 110 WindowSizer::kDesktopBorderSize, grid)), |
110 window_bounds); | 111 window_bounds); |
111 } | 112 } |
112 | 113 |
113 { // 4:3 monitor case, 1024x768, taskbar on right | 114 { // 4:3 monitor case, 1024x768, taskbar on right |
114 gfx::Rect window_bounds; | 115 gfx::Rect window_bounds; |
115 GetWindowBounds(tentwentyfour, taskbar_right_work_area, gfx::Rect(), | 116 GetWindowBounds(tentwentyfour, taskbar_right_work_area, gfx::Rect(), |
116 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL); | 117 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL, |
| 118 gfx::Rect()); |
117 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, | 119 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, |
118 WindowSizer::kDesktopBorderSize, | 120 WindowSizer::kDesktopBorderSize, |
119 ash::WindowResizer::AlignToGridRoundDown( | 121 ash::WindowResizer::AlignToGridRoundDown( |
120 taskbar_right_work_area.width() - | 122 taskbar_right_work_area.width() - |
121 WindowSizer::kDesktopBorderSize * 2, grid), | 123 WindowSizer::kDesktopBorderSize * 2, grid), |
122 768 - WindowSizer::kDesktopBorderSize), | 124 768 - WindowSizer::kDesktopBorderSize), |
123 window_bounds); | 125 window_bounds); |
124 } | 126 } |
125 | 127 |
126 { // 4:3 monitor case, 1024x768, taskbar on left | 128 { // 4:3 monitor case, 1024x768, taskbar on left |
127 gfx::Rect window_bounds; | 129 gfx::Rect window_bounds; |
128 GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(), | 130 GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(), |
129 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL); | 131 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL, |
| 132 gfx::Rect()); |
130 EXPECT_EQ(gfx::Rect(taskbar_left_work_area.x() + | 133 EXPECT_EQ(gfx::Rect(taskbar_left_work_area.x() + |
131 WindowSizer::kDesktopBorderSize, | 134 WindowSizer::kDesktopBorderSize, |
132 WindowSizer::kDesktopBorderSize, | 135 WindowSizer::kDesktopBorderSize, |
133 ash::WindowResizer::AlignToGridRoundDown( | 136 ash::WindowResizer::AlignToGridRoundDown( |
134 taskbar_left_work_area.width() - | 137 taskbar_left_work_area.width() - |
135 WindowSizer::kDesktopBorderSize * 2, grid), | 138 WindowSizer::kDesktopBorderSize * 2, grid), |
136 ash::WindowResizer::AlignToGridRoundDown( | 139 ash::WindowResizer::AlignToGridRoundDown( |
137 taskbar_left_work_area.height() - | 140 taskbar_left_work_area.height() - |
138 WindowSizer::kDesktopBorderSize, grid)), | 141 WindowSizer::kDesktopBorderSize, grid)), |
139 window_bounds); | 142 window_bounds); |
140 } | 143 } |
141 | 144 |
142 { // 4:3 monitor case, 1024x768, taskbar on top | 145 { // 4:3 monitor case, 1024x768, taskbar on top |
143 gfx::Rect window_bounds; | 146 gfx::Rect window_bounds; |
144 GetWindowBounds(tentwentyfour, taskbar_top_work_area, gfx::Rect(), | 147 GetWindowBounds(tentwentyfour, taskbar_top_work_area, gfx::Rect(), |
145 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL); | 148 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds, NULL, |
| 149 gfx::Rect()); |
146 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, | 150 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, |
147 taskbar_top_work_area.y() + | 151 taskbar_top_work_area.y() + |
148 WindowSizer::kDesktopBorderSize, | 152 WindowSizer::kDesktopBorderSize, |
149 1024 - WindowSizer::kDesktopBorderSize * 2, | 153 1024 - WindowSizer::kDesktopBorderSize * 2, |
150 ash::WindowResizer::AlignToGridRoundDown( | 154 ash::WindowResizer::AlignToGridRoundDown( |
151 taskbar_top_work_area.height() - | 155 taskbar_top_work_area.height() - |
152 WindowSizer::kDesktopBorderSize, grid)), | 156 WindowSizer::kDesktopBorderSize, grid)), |
153 window_bounds); | 157 window_bounds); |
154 } | 158 } |
155 | 159 |
156 { // 4:3 monitor case, 1280x1024 | 160 { // 4:3 monitor case, 1280x1024 |
157 gfx::Rect window_bounds; | 161 gfx::Rect window_bounds; |
158 GetWindowBounds(twelveeighty, twelveeighty, gfx::Rect(), gfx::Rect(), | 162 GetWindowBounds(twelveeighty, twelveeighty, gfx::Rect(), gfx::Rect(), |
159 gfx::Rect(), DEFAULT, &window_bounds, NULL); | 163 gfx::Rect(), DEFAULT, &window_bounds, NULL, gfx::Rect()); |
160 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, | 164 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, |
161 WindowSizer::kDesktopBorderSize, | 165 WindowSizer::kDesktopBorderSize, |
162 1280 - 2 * WindowSizer::kDesktopBorderSize, | 166 1280 - 2 * WindowSizer::kDesktopBorderSize, |
163 1024 - WindowSizer::kDesktopBorderSize), | 167 1024 - WindowSizer::kDesktopBorderSize), |
164 window_bounds); | 168 window_bounds); |
165 } | 169 } |
166 | 170 |
167 { // 4:3 monitor case, 1600x1200 | 171 { // 4:3 monitor case, 1600x1200 |
168 gfx::Rect window_bounds; | 172 gfx::Rect window_bounds; |
169 GetWindowBounds(sixteenhundred, sixteenhundred, gfx::Rect(), gfx::Rect(), | 173 GetWindowBounds(sixteenhundred, sixteenhundred, gfx::Rect(), gfx::Rect(), |
170 gfx::Rect(), DEFAULT, &window_bounds, NULL); | 174 gfx::Rect(), DEFAULT, &window_bounds, NULL, gfx::Rect()); |
171 EXPECT_EQ(gfx::Rect((1600 - 1280) / 2, WindowSizer::kDesktopBorderSize, | 175 EXPECT_EQ(gfx::Rect((1600 - 1280) / 2, WindowSizer::kDesktopBorderSize, |
172 1280, | 176 1280, |
173 1200 - WindowSizer::kDesktopBorderSize), | 177 1200 - WindowSizer::kDesktopBorderSize), |
174 window_bounds); | 178 window_bounds); |
175 } | 179 } |
176 | 180 |
177 { // 16:10 monitor case, 1680x1050 | 181 { // 16:10 monitor case, 1680x1050 |
178 gfx::Rect window_bounds; | 182 gfx::Rect window_bounds; |
179 GetWindowBounds(sixteeneighty, sixteeneighty, gfx::Rect(), gfx::Rect(), | 183 GetWindowBounds(sixteeneighty, sixteeneighty, gfx::Rect(), gfx::Rect(), |
180 gfx::Rect(), DEFAULT, &window_bounds, NULL); | 184 gfx::Rect(), DEFAULT, &window_bounds, NULL, gfx::Rect()); |
181 EXPECT_EQ(gfx::Rect((1680 - 1280) / 2, WindowSizer::kDesktopBorderSize, | 185 EXPECT_EQ(gfx::Rect((1680 - 1280) / 2, WindowSizer::kDesktopBorderSize, |
182 1280, | 186 1280, |
183 ash::WindowResizer::AlignToGridRoundDown( | 187 ash::WindowResizer::AlignToGridRoundDown( |
184 1050 - WindowSizer::kDesktopBorderSize, | 188 1050 - WindowSizer::kDesktopBorderSize, |
185 grid)), | 189 grid)), |
186 window_bounds); | 190 window_bounds); |
187 } | 191 } |
188 | 192 |
189 { // 16:10 monitor case, 1920x1200 | 193 { // 16:10 monitor case, 1920x1200 |
190 gfx::Rect window_bounds; | 194 gfx::Rect window_bounds; |
191 GetWindowBounds(nineteentwenty, nineteentwenty, gfx::Rect(), gfx::Rect(), | 195 GetWindowBounds(nineteentwenty, nineteentwenty, gfx::Rect(), gfx::Rect(), |
192 gfx::Rect(), DEFAULT, &window_bounds, NULL); | 196 gfx::Rect(), DEFAULT, &window_bounds, NULL, gfx::Rect()); |
193 EXPECT_EQ(gfx::Rect((1920 - 1280) / 2, WindowSizer::kDesktopBorderSize, | 197 EXPECT_EQ(gfx::Rect((1920 - 1280) / 2, WindowSizer::kDesktopBorderSize, |
194 1280, | 198 1280, |
195 1200 - WindowSizer::kDesktopBorderSize), | 199 1200 - WindowSizer::kDesktopBorderSize), |
196 window_bounds); | 200 window_bounds); |
197 } | 201 } |
198 } | 202 } |
199 | 203 |
200 // Test that the next opened window is positioned appropriately given the | 204 // Test that the next opened window is positioned appropriately given the |
201 // bounds of an existing window of the same type. | 205 // bounds of an existing window of the same type. |
202 TEST_F(WindowSizerTest, LastWindowBoundsCase) { | 206 TEST_F(WindowSizerTest, LastWindowBoundsCase) { |
203 { // normal, in the middle of the screen somewhere. | 207 { // normal, in the middle of the screen somewhere. |
204 gfx::Rect window_bounds; | 208 gfx::Rect window_bounds; |
205 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 209 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
206 gfx::Rect(WindowSizer::kDesktopBorderSize, | 210 gfx::Rect(WindowSizer::kDesktopBorderSize, |
207 WindowSizer::kDesktopBorderSize, 500, 400), | 211 WindowSizer::kDesktopBorderSize, 500, 400), |
208 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL); | 212 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL, |
| 213 gfx::Rect()); |
209 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 214 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
210 kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 215 kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
211 500, 400), | 216 500, 400), |
212 window_bounds); | 217 window_bounds); |
213 } | 218 } |
214 | 219 |
215 { // taskbar on top. | 220 { // taskbar on top. |
216 gfx::Rect window_bounds; | 221 gfx::Rect window_bounds; |
217 GetWindowBounds(tentwentyfour, taskbar_top_work_area, gfx::Rect(), | 222 GetWindowBounds(tentwentyfour, taskbar_top_work_area, gfx::Rect(), |
218 gfx::Rect(WindowSizer::kDesktopBorderSize, | 223 gfx::Rect(WindowSizer::kDesktopBorderSize, |
219 WindowSizer::kDesktopBorderSize, 500, 400), | 224 WindowSizer::kDesktopBorderSize, 500, 400), |
220 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL); | 225 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL, |
| 226 gfx::Rect()); |
221 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 227 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
222 std::max(kWindowTilePixels + | 228 std::max(kWindowTilePixels + |
223 WindowSizer::kDesktopBorderSize, | 229 WindowSizer::kDesktopBorderSize, |
224 34 /* toolbar height */), | 230 34 /* toolbar height */), |
225 500, 400), window_bounds); | 231 500, 400), window_bounds); |
226 } | 232 } |
227 | 233 |
228 { // Too small to satisify the minimum visibility condition. | 234 { // Too small to satisify the minimum visibility condition. |
229 gfx::Rect window_bounds; | 235 gfx::Rect window_bounds; |
230 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 236 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
231 gfx::Rect(WindowSizer::kDesktopBorderSize, | 237 gfx::Rect(WindowSizer::kDesktopBorderSize, |
232 WindowSizer::kDesktopBorderSize, 29, 29), | 238 WindowSizer::kDesktopBorderSize, 29, 29), |
233 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL); | 239 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL, |
| 240 gfx::Rect()); |
234 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 241 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
235 kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 242 kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
236 30 /* not 29 */, | 243 30 /* not 29 */, |
237 30 /* not 29 */), | 244 30 /* not 29 */), |
238 window_bounds); | 245 window_bounds); |
239 } | 246 } |
240 | 247 |
241 | 248 |
242 { // Normal. | 249 { // Normal. |
243 gfx::Rect window_bounds; | 250 gfx::Rect window_bounds; |
244 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 251 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
245 gfx::Rect(WindowSizer::kDesktopBorderSize, | 252 gfx::Rect(WindowSizer::kDesktopBorderSize, |
246 WindowSizer::kDesktopBorderSize, 500, 400), | 253 WindowSizer::kDesktopBorderSize, 500, 400), |
247 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL); | 254 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL, |
| 255 gfx::Rect()); |
248 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 256 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
249 kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 257 kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
250 500, 400), | 258 500, 400), |
251 window_bounds); | 259 window_bounds); |
252 } | 260 } |
253 } | 261 } |
254 | 262 |
255 // Test that the window opened is sized appropriately given persisted sizes. | 263 // Test that the window opened is sized appropriately given persisted sizes. |
256 TEST_F(WindowSizerTest, PersistedBoundsCase) { | 264 TEST_F(WindowSizerTest, PersistedBoundsCase) { |
257 { // normal, in the middle of the screen somewhere. | 265 { // normal, in the middle of the screen somewhere. |
258 gfx::Rect initial_bounds(WindowSizer::kDesktopBorderSize, | 266 gfx::Rect initial_bounds(WindowSizer::kDesktopBorderSize, |
259 WindowSizer::kDesktopBorderSize, 500, 400); | 267 WindowSizer::kDesktopBorderSize, 500, 400); |
260 | 268 |
261 gfx::Rect window_bounds; | 269 gfx::Rect window_bounds; |
262 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), initial_bounds, | 270 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), initial_bounds, |
263 gfx::Rect(), PERSISTED, &window_bounds, NULL); | 271 gfx::Rect(), PERSISTED, &window_bounds, NULL, gfx::Rect()); |
264 EXPECT_EQ(initial_bounds, window_bounds); | 272 EXPECT_EQ(initial_bounds, window_bounds); |
265 } | 273 } |
266 | 274 |
267 { // Normal. | 275 { // Normal. |
268 gfx::Rect initial_bounds(0, 0, 1024, 768); | 276 gfx::Rect initial_bounds(0, 0, 1024, 768); |
269 | 277 |
270 gfx::Rect window_bounds; | 278 gfx::Rect window_bounds; |
271 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), initial_bounds, | 279 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), initial_bounds, |
272 gfx::Rect(), PERSISTED, &window_bounds, NULL); | 280 gfx::Rect(), PERSISTED, &window_bounds, NULL, gfx::Rect()); |
273 EXPECT_EQ(initial_bounds, window_bounds); | 281 EXPECT_EQ(initial_bounds, window_bounds); |
274 } | 282 } |
275 | 283 |
276 { // normal, on non-primary monitor in negative coords. | 284 { // normal, on non-primary monitor in negative coords. |
277 gfx::Rect initial_bounds(-600, 10, 500, 400); | 285 gfx::Rect initial_bounds(-600, 10, 500, 400); |
278 | 286 |
279 gfx::Rect window_bounds; | 287 gfx::Rect window_bounds; |
280 GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary, | 288 GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary, |
281 initial_bounds, gfx::Rect(), PERSISTED, &window_bounds, | 289 initial_bounds, gfx::Rect(), PERSISTED, &window_bounds, |
282 NULL); | 290 NULL, gfx::Rect()); |
283 EXPECT_EQ(initial_bounds, window_bounds); | 291 EXPECT_EQ(initial_bounds, window_bounds); |
284 } | 292 } |
285 | 293 |
286 { // normal, on non-primary monitor in negative coords. | 294 { // normal, on non-primary monitor in negative coords. |
287 gfx::Rect initial_bounds(-1024, 0, 1024, 768); | 295 gfx::Rect initial_bounds(-1024, 0, 1024, 768); |
288 | 296 |
289 gfx::Rect window_bounds; | 297 gfx::Rect window_bounds; |
290 GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary, | 298 GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary, |
291 initial_bounds, gfx::Rect(), PERSISTED, &window_bounds, | 299 initial_bounds, gfx::Rect(), PERSISTED, &window_bounds, |
292 NULL); | 300 NULL, gfx::Rect()); |
293 EXPECT_EQ(initial_bounds, window_bounds); | 301 EXPECT_EQ(initial_bounds, window_bounds); |
294 } | 302 } |
295 | 303 |
296 { // Non-primary monitor resoultion has changed, but the monitor still | 304 { // Non-primary monitor resoultion has changed, but the monitor still |
297 // completely contains the window. | 305 // completely contains the window. |
298 | 306 |
299 gfx::Rect initial_bounds(1074, 50, 600, 500); | 307 gfx::Rect initial_bounds(1074, 50, 600, 500); |
300 | 308 |
301 gfx::Rect window_bounds; | 309 gfx::Rect window_bounds; |
302 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600), | 310 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600), |
303 initial_bounds, right_nonprimary, PERSISTED, | 311 initial_bounds, right_nonprimary, PERSISTED, |
304 &window_bounds, NULL); | 312 &window_bounds, NULL, gfx::Rect()); |
305 EXPECT_EQ(initial_bounds, window_bounds); | 313 EXPECT_EQ(initial_bounds, window_bounds); |
306 } | 314 } |
307 | 315 |
308 { // Non-primary monitor resoultion has changed, and the window is partially | 316 { // Non-primary monitor resoultion has changed, and the window is partially |
309 // off-screen. | 317 // off-screen. |
310 | 318 |
311 gfx::Rect initial_bounds(1274, 50, 600, 500); | 319 gfx::Rect initial_bounds(1274, 50, 600, 500); |
312 | 320 |
313 gfx::Rect window_bounds; | 321 gfx::Rect window_bounds; |
314 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600), | 322 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600), |
315 initial_bounds, right_nonprimary, PERSISTED, | 323 initial_bounds, right_nonprimary, PERSISTED, |
316 &window_bounds, NULL); | 324 &window_bounds, NULL, gfx::Rect()); |
317 EXPECT_EQ(gfx::Rect(1224, 50, 600, 500), window_bounds); | 325 EXPECT_EQ(gfx::Rect(1224, 50, 600, 500), window_bounds); |
318 } | 326 } |
319 | 327 |
320 { // Non-primary monitor resoultion has changed, and the window is now too | 328 { // Non-primary monitor resoultion has changed, and the window is now too |
321 // large for the monitor. | 329 // large for the monitor. |
322 | 330 |
323 gfx::Rect initial_bounds(1274, 50, 900, 700); | 331 gfx::Rect initial_bounds(1274, 50, 900, 700); |
324 | 332 |
325 gfx::Rect window_bounds; | 333 gfx::Rect window_bounds; |
326 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600), | 334 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600), |
327 initial_bounds, right_nonprimary, PERSISTED, | 335 initial_bounds, right_nonprimary, PERSISTED, |
328 &window_bounds, NULL); | 336 &window_bounds, NULL, gfx::Rect()); |
329 EXPECT_EQ(gfx::Rect(1024, 0, 800, 600), window_bounds); | 337 EXPECT_EQ(gfx::Rect(1024, 0, 800, 600), window_bounds); |
330 } | 338 } |
331 | 339 |
332 { // width and height too small | 340 { // width and height too small |
333 gfx::Rect window_bounds; | 341 gfx::Rect window_bounds; |
334 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 342 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
335 gfx::Rect(WindowSizer::kDesktopBorderSize, | 343 gfx::Rect(WindowSizer::kDesktopBorderSize, |
336 WindowSizer::kDesktopBorderSize, 29, 29), | 344 WindowSizer::kDesktopBorderSize, 29, 29), |
337 gfx::Rect(), PERSISTED, &window_bounds, NULL); | 345 gfx::Rect(), PERSISTED, &window_bounds, NULL, gfx::Rect()); |
338 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, | 346 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, |
339 WindowSizer::kDesktopBorderSize, | 347 WindowSizer::kDesktopBorderSize, |
340 30 /* not 29 */, 30 /* not 29 */), | 348 30 /* not 29 */, 30 /* not 29 */), |
341 window_bounds); | 349 window_bounds); |
342 } | 350 } |
343 } | 351 } |
344 | 352 |
345 ////////////////////////////////////////////////////////////////////////////// | 353 ////////////////////////////////////////////////////////////////////////////// |
346 // The following unittests have different results on Mac/non-Mac because we | 354 // The following unittests have different results on Mac/non-Mac because we |
347 // reposition windows aggressively on Mac. The *WithAggressiveReposition tests | 355 // reposition windows aggressively on Mac. The *WithAggressiveReposition tests |
348 // are run on Mac, and the *WithNonAggressiveRepositioning tests are run on | 356 // are run on Mac, and the *WithNonAggressiveRepositioning tests are run on |
349 // other platforms. | 357 // other platforms. |
350 | 358 |
351 TEST_F(WindowSizerTest, LastWindowOffscreenWithNonAggressiveRepositioning) { | 359 TEST_F(WindowSizerTest, LastWindowOffscreenWithNonAggressiveRepositioning) { |
352 { // taskbar on left. | 360 { // taskbar on left. |
353 gfx::Rect window_bounds; | 361 gfx::Rect window_bounds; |
354 GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(), | 362 GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(), |
355 gfx::Rect(WindowSizer::kDesktopBorderSize, | 363 gfx::Rect(WindowSizer::kDesktopBorderSize, |
356 WindowSizer::kDesktopBorderSize, 500, 400), | 364 WindowSizer::kDesktopBorderSize, 500, 400), |
357 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL); | 365 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL, |
| 366 gfx::Rect()); |
358 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 367 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
359 kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 368 kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
360 500, 400), | 369 500, 400), |
361 window_bounds); | 370 window_bounds); |
362 } | 371 } |
363 | 372 |
364 { // offset would put the new window offscreen at the bottom but the minimum | 373 { // offset would put the new window offscreen at the bottom but the minimum |
365 // visibility condition is barely satisfied without relocation. | 374 // visibility condition is barely satisfied without relocation. |
366 gfx::Rect window_bounds; | 375 gfx::Rect window_bounds; |
367 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 376 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
368 gfx::Rect(10, 728, 500, 400), gfx::Rect(), LAST_ACTIVE, | 377 gfx::Rect(10, 728, 500, 400), gfx::Rect(), LAST_ACTIVE, |
369 &window_bounds, NULL); | 378 &window_bounds, NULL, gfx::Rect()); |
370 EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 738, | 379 EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 738, |
371 500, 400), window_bounds); | 380 500, 400), window_bounds); |
372 } | 381 } |
373 | 382 |
374 { // offset would put the new window offscreen at the bottom and the minimum | 383 { // offset would put the new window offscreen at the bottom and the minimum |
375 // visibility condition is satisified by relocation. | 384 // visibility condition is satisified by relocation. |
376 gfx::Rect window_bounds; | 385 gfx::Rect window_bounds; |
377 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 386 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
378 gfx::Rect(10, 729, 500, 400), gfx::Rect(), LAST_ACTIVE, | 387 gfx::Rect(10, 729, 500, 400), gfx::Rect(), LAST_ACTIVE, |
379 &window_bounds, NULL); | 388 &window_bounds, NULL, gfx::Rect()); |
380 EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 738 /* not 739 */, 500, 400), | 389 EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 738 /* not 739 */, 500, 400), |
381 window_bounds); | 390 window_bounds); |
382 } | 391 } |
383 | 392 |
384 { // offset would put the new window offscreen at the right but the minimum | 393 { // offset would put the new window offscreen at the right but the minimum |
385 // visibility condition is barely satisfied without relocation. | 394 // visibility condition is barely satisfied without relocation. |
386 gfx::Rect window_bounds; | 395 gfx::Rect window_bounds; |
387 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 396 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
388 gfx::Rect(984, 10, 500, 400), gfx::Rect(), LAST_ACTIVE, | 397 gfx::Rect(984, 10, 500, 400), gfx::Rect(), LAST_ACTIVE, |
389 &window_bounds, NULL); | 398 &window_bounds, NULL, gfx::Rect()); |
390 EXPECT_EQ(gfx::Rect(994, 10 + kWindowTilePixels, 500, 400), window_bounds); | 399 EXPECT_EQ(gfx::Rect(994, 10 + kWindowTilePixels, 500, 400), window_bounds); |
391 } | 400 } |
392 | 401 |
393 { // offset would put the new window offscreen at the right and the minimum | 402 { // offset would put the new window offscreen at the right and the minimum |
394 // visibility condition is satisified by relocation. | 403 // visibility condition is satisified by relocation. |
395 gfx::Rect window_bounds; | 404 gfx::Rect window_bounds; |
396 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 405 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
397 gfx::Rect(985, 10, 500, 400), gfx::Rect(), LAST_ACTIVE, | 406 gfx::Rect(985, 10, 500, 400), gfx::Rect(), LAST_ACTIVE, |
398 &window_bounds, NULL); | 407 &window_bounds, NULL, gfx::Rect()); |
399 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 10 + kWindowTilePixels, | 408 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 10 + kWindowTilePixels, |
400 500, 400), window_bounds); | 409 500, 400), window_bounds); |
401 } | 410 } |
402 | 411 |
403 { // offset would put the new window offscreen at the bottom right and the | 412 { // offset would put the new window offscreen at the bottom right and the |
404 // minimum visibility condition is satisified by relocation. | 413 // minimum visibility condition is satisified by relocation. |
405 gfx::Rect window_bounds; | 414 gfx::Rect window_bounds; |
406 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 415 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
407 gfx::Rect(985, 729, 500, 400), gfx::Rect(), LAST_ACTIVE, | 416 gfx::Rect(985, 729, 500, 400), gfx::Rect(), LAST_ACTIVE, |
408 &window_bounds, NULL); | 417 &window_bounds, NULL, gfx::Rect()); |
409 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 738 /* not 739 */, 500, 400), | 418 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 738 /* not 739 */, 500, 400), |
410 window_bounds); | 419 window_bounds); |
411 } | 420 } |
412 } | 421 } |
413 | 422 |
414 TEST_F(WindowSizerTest, | 423 TEST_F(WindowSizerTest, |
415 PersistedWindowOffscreenWithNonAggressiveRepositioning) { | 424 PersistedWindowOffscreenWithNonAggressiveRepositioning) { |
416 { // off the left but the minimum visibility condition is barely satisfied | 425 { // off the left but the minimum visibility condition is barely satisfied |
417 // without relocaiton. | 426 // without relocaiton. |
418 gfx::Rect initial_bounds(-470, 50, 500, 400); | 427 gfx::Rect initial_bounds(-470, 50, 500, 400); |
419 | 428 |
420 gfx::Rect window_bounds; | 429 gfx::Rect window_bounds; |
421 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 430 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
422 initial_bounds, gfx::Rect(), PERSISTED, | 431 initial_bounds, gfx::Rect(), PERSISTED, |
423 &window_bounds, NULL); | 432 &window_bounds, NULL, gfx::Rect()); |
424 EXPECT_EQ(initial_bounds, window_bounds); | 433 EXPECT_EQ(initial_bounds, window_bounds); |
425 } | 434 } |
426 | 435 |
427 { // off the left and the minimum visibility condition is satisfied by | 436 { // off the left and the minimum visibility condition is satisfied by |
428 // relocation. | 437 // relocation. |
429 gfx::Rect window_bounds; | 438 gfx::Rect window_bounds; |
430 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 439 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
431 gfx::Rect(-471, 50, 500, 400), gfx::Rect(), PERSISTED, | 440 gfx::Rect(-471, 50, 500, 400), gfx::Rect(), PERSISTED, |
432 &window_bounds, NULL); | 441 &window_bounds, NULL, gfx::Rect()); |
433 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 50, 500, 400), window_bounds); | 442 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 50, 500, 400), window_bounds); |
434 } | 443 } |
435 | 444 |
436 { // off the top | 445 { // off the top |
437 gfx::Rect initial_bounds(50, -370, 500, 400); | 446 gfx::Rect initial_bounds(50, -370, 500, 400); |
438 | 447 |
439 gfx::Rect window_bounds; | 448 gfx::Rect window_bounds; |
440 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 449 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
441 gfx::Rect(50, -370, 500, 400), gfx::Rect(), PERSISTED, | 450 gfx::Rect(50, -370, 500, 400), gfx::Rect(), PERSISTED, |
442 &window_bounds, NULL); | 451 &window_bounds, NULL, gfx::Rect()); |
443 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); | 452 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); |
444 } | 453 } |
445 | 454 |
446 { // off the right but the minimum visibility condition is barely satisified | 455 { // off the right but the minimum visibility condition is barely satisified |
447 // without relocation. | 456 // without relocation. |
448 gfx::Rect initial_bounds(994, 50, 500, 400); | 457 gfx::Rect initial_bounds(994, 50, 500, 400); |
449 | 458 |
450 gfx::Rect window_bounds; | 459 gfx::Rect window_bounds; |
451 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 460 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
452 initial_bounds, gfx::Rect(), PERSISTED, | 461 initial_bounds, gfx::Rect(), PERSISTED, |
453 &window_bounds, NULL); | 462 &window_bounds, NULL, gfx::Rect()); |
454 EXPECT_EQ(initial_bounds, window_bounds); | 463 EXPECT_EQ(initial_bounds, window_bounds); |
455 } | 464 } |
456 | 465 |
457 { // off the right and the minimum visibility condition is satisified by | 466 { // off the right and the minimum visibility condition is satisified by |
458 // relocation. | 467 // relocation. |
459 gfx::Rect window_bounds; | 468 gfx::Rect window_bounds; |
460 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 469 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
461 gfx::Rect(995, 50, 500, 400), gfx::Rect(), PERSISTED, | 470 gfx::Rect(995, 50, 500, 400), gfx::Rect(), PERSISTED, |
462 &window_bounds, NULL); | 471 &window_bounds, NULL, gfx::Rect()); |
463 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 50, 500, 400), window_bounds); | 472 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 50, 500, 400), window_bounds); |
464 } | 473 } |
465 | 474 |
466 { // off the bottom but the minimum visibility condition is barely satisified | 475 { // off the bottom but the minimum visibility condition is barely satisified |
467 // without relocation. | 476 // without relocation. |
468 gfx::Rect initial_bounds(50, 738, 500, 400); | 477 gfx::Rect initial_bounds(50, 738, 500, 400); |
469 | 478 |
470 gfx::Rect window_bounds; | 479 gfx::Rect window_bounds; |
471 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 480 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
472 initial_bounds, gfx::Rect(), PERSISTED, | 481 initial_bounds, gfx::Rect(), PERSISTED, |
473 &window_bounds, NULL); | 482 &window_bounds, NULL, gfx::Rect()); |
474 EXPECT_EQ(initial_bounds, window_bounds); | 483 EXPECT_EQ(initial_bounds, window_bounds); |
475 } | 484 } |
476 | 485 |
477 { // off the bottom and the minimum visibility condition is satisified by | 486 { // off the bottom and the minimum visibility condition is satisified by |
478 // relocation. | 487 // relocation. |
479 gfx::Rect window_bounds; | 488 gfx::Rect window_bounds; |
480 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 489 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
481 gfx::Rect(50, 739, 500, 400), gfx::Rect(), PERSISTED, | 490 gfx::Rect(50, 739, 500, 400), gfx::Rect(), PERSISTED, |
482 &window_bounds, NULL); | 491 &window_bounds, NULL, gfx::Rect()); |
483 EXPECT_EQ(gfx::Rect(50, 738 /* not 739 */, 500, 400), window_bounds); | 492 EXPECT_EQ(gfx::Rect(50, 738 /* not 739 */, 500, 400), window_bounds); |
484 } | 493 } |
485 | 494 |
486 { // off the topleft | 495 { // off the topleft |
487 gfx::Rect window_bounds; | 496 gfx::Rect window_bounds; |
488 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 497 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
489 gfx::Rect(-471, -371, 500, 400), gfx::Rect(), PERSISTED, | 498 gfx::Rect(-471, -371, 500, 400), gfx::Rect(), PERSISTED, |
490 &window_bounds, NULL); | 499 &window_bounds, NULL, gfx::Rect()); |
491 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 0, 500, 400), | 500 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 0, 500, 400), |
492 window_bounds); | 501 window_bounds); |
493 } | 502 } |
494 | 503 |
495 { // off the topright and the minimum visibility condition is satisified by | 504 { // off the topright and the minimum visibility condition is satisified by |
496 // relocation. | 505 // relocation. |
497 gfx::Rect window_bounds; | 506 gfx::Rect window_bounds; |
498 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 507 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
499 gfx::Rect(995, -371, 500, 400), gfx::Rect(), PERSISTED, | 508 gfx::Rect(995, -371, 500, 400), gfx::Rect(), PERSISTED, |
500 &window_bounds, NULL); | 509 &window_bounds, NULL, gfx::Rect()); |
501 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 0, 500, 400), | 510 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 0, 500, 400), |
502 window_bounds); | 511 window_bounds); |
503 } | 512 } |
504 | 513 |
505 { // off the bottomleft and the minimum visibility condition is satisified by | 514 { // off the bottomleft and the minimum visibility condition is satisified by |
506 // relocation. | 515 // relocation. |
507 gfx::Rect window_bounds; | 516 gfx::Rect window_bounds; |
508 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 517 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
509 gfx::Rect(-471, 739, 500, 400), gfx::Rect(), PERSISTED, | 518 gfx::Rect(-471, 739, 500, 400), gfx::Rect(), PERSISTED, |
510 &window_bounds, NULL); | 519 &window_bounds, NULL, gfx::Rect()); |
511 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 738 /* not 739 */, 500, 400), | 520 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 738 /* not 739 */, 500, 400), |
512 window_bounds); | 521 window_bounds); |
513 } | 522 } |
514 | 523 |
515 { // off the bottomright and the minimum visibility condition is satisified by | 524 { // off the bottomright and the minimum visibility condition is satisified by |
516 // relocation. | 525 // relocation. |
517 gfx::Rect window_bounds; | 526 gfx::Rect window_bounds; |
518 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 527 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
519 gfx::Rect(995, 739, 500, 400), gfx::Rect(), PERSISTED, | 528 gfx::Rect(995, 739, 500, 400), gfx::Rect(), PERSISTED, |
520 &window_bounds, NULL); | 529 &window_bounds, NULL, gfx::Rect()); |
521 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 738 /* not 739 */, 500, 400), | 530 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 738 /* not 739 */, 500, 400), |
522 window_bounds); | 531 window_bounds); |
523 } | 532 } |
524 | 533 |
525 { // entirely off left | 534 { // entirely off left |
526 gfx::Rect window_bounds; | 535 gfx::Rect window_bounds; |
527 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 536 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
528 gfx::Rect(-700, 50, 500, 400), gfx::Rect(), PERSISTED, | 537 gfx::Rect(-700, 50, 500, 400), gfx::Rect(), PERSISTED, |
529 &window_bounds, NULL); | 538 &window_bounds, NULL, gfx::Rect()); |
530 EXPECT_EQ(gfx::Rect(-470 /* not -700 */, 50, 500, 400), window_bounds); | 539 EXPECT_EQ(gfx::Rect(-470 /* not -700 */, 50, 500, 400), window_bounds); |
531 } | 540 } |
532 | 541 |
533 { // entirely off left (monitor was detached since last run) | 542 { // entirely off left (monitor was detached since last run) |
534 gfx::Rect window_bounds; | 543 gfx::Rect window_bounds; |
535 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 544 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
536 gfx::Rect(-700, 50, 500, 400), left_nonprimary, PERSISTED, | 545 gfx::Rect(-700, 50, 500, 400), left_nonprimary, PERSISTED, |
537 &window_bounds, NULL); | 546 &window_bounds, NULL, gfx::Rect()); |
538 EXPECT_EQ(gfx::Rect(0, 50, 500, 400), window_bounds); | 547 EXPECT_EQ(gfx::Rect(0, 50, 500, 400), window_bounds); |
539 } | 548 } |
540 | 549 |
541 { // entirely off top | 550 { // entirely off top |
542 gfx::Rect window_bounds; | 551 gfx::Rect window_bounds; |
543 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 552 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
544 gfx::Rect(50, -500, 500, 400), gfx::Rect(), PERSISTED, | 553 gfx::Rect(50, -500, 500, 400), gfx::Rect(), PERSISTED, |
545 &window_bounds, NULL); | 554 &window_bounds, NULL, gfx::Rect()); |
546 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); | 555 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); |
547 } | 556 } |
548 | 557 |
549 { // entirely off top (monitor was detached since last run) | 558 { // entirely off top (monitor was detached since last run) |
550 gfx::Rect window_bounds; | 559 gfx::Rect window_bounds; |
551 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 560 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
552 gfx::Rect(50, -500, 500, 400), top_nonprimary, | 561 gfx::Rect(50, -500, 500, 400), top_nonprimary, |
553 PERSISTED, &window_bounds, NULL); | 562 PERSISTED, &window_bounds, NULL, gfx::Rect()); |
554 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); | 563 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); |
555 } | 564 } |
556 | 565 |
557 { // entirely off right | 566 { // entirely off right |
558 gfx::Rect window_bounds; | 567 gfx::Rect window_bounds; |
559 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 568 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
560 gfx::Rect(1200, 50, 500, 400), gfx::Rect(), PERSISTED, | 569 gfx::Rect(1200, 50, 500, 400), gfx::Rect(), PERSISTED, |
561 &window_bounds, NULL); | 570 &window_bounds, NULL, gfx::Rect()); |
562 EXPECT_EQ(gfx::Rect(994 /* not 1200 */, 50, 500, 400), window_bounds); | 571 EXPECT_EQ(gfx::Rect(994 /* not 1200 */, 50, 500, 400), window_bounds); |
563 } | 572 } |
564 | 573 |
565 { // entirely off right (monitor was detached since last run) | 574 { // entirely off right (monitor was detached since last run) |
566 gfx::Rect window_bounds; | 575 gfx::Rect window_bounds; |
567 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 576 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
568 gfx::Rect(1200, 50, 500, 400), right_nonprimary, | 577 gfx::Rect(1200, 50, 500, 400), right_nonprimary, |
569 PERSISTED, &window_bounds, NULL); | 578 PERSISTED, &window_bounds, NULL, gfx::Rect()); |
570 EXPECT_EQ(gfx::Rect(524, 50, 500, 400), window_bounds); | 579 EXPECT_EQ(gfx::Rect(524, 50, 500, 400), window_bounds); |
571 } | 580 } |
572 | 581 |
573 { // entirely off bottom | 582 { // entirely off bottom |
574 gfx::Rect window_bounds; | 583 gfx::Rect window_bounds; |
575 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 584 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
576 gfx::Rect(50, 800, 500, 400), gfx::Rect(), PERSISTED, | 585 gfx::Rect(50, 800, 500, 400), gfx::Rect(), PERSISTED, |
577 &window_bounds, NULL); | 586 &window_bounds, NULL, gfx::Rect()); |
578 EXPECT_EQ(gfx::Rect(50, 738 /* not 800 */, 500, 400), window_bounds); | 587 EXPECT_EQ(gfx::Rect(50, 738 /* not 800 */, 500, 400), window_bounds); |
579 } | 588 } |
580 | 589 |
581 { // entirely off bottom (monitor was detached since last run) | 590 { // entirely off bottom (monitor was detached since last run) |
582 gfx::Rect window_bounds; | 591 gfx::Rect window_bounds; |
583 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 592 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
584 gfx::Rect(50, 800, 500, 400), bottom_nonprimary, | 593 gfx::Rect(50, 800, 500, 400), bottom_nonprimary, |
585 PERSISTED, &window_bounds, NULL); | 594 PERSISTED, &window_bounds, NULL, gfx::Rect()); |
586 EXPECT_EQ(gfx::Rect(50, 368, 500, 400), window_bounds); | 595 EXPECT_EQ(gfx::Rect(50, 368, 500, 400), window_bounds); |
587 } | 596 } |
588 } | 597 } |
589 | 598 |
590 // Test that a newly created window gets positioned over a previously created | 599 // Test that a newly created window gets positioned over a previously created |
591 // window. | 600 // window. |
592 TEST_F(WindowSizerTestWithBrowser, PlaceNewWindowOverOldWindow) { | 601 TEST_F(WindowSizerTestWithBrowser, PlaceNewWindowOverOldWindow) { |
593 // Create a dummy window. | 602 // Create a dummy window. |
594 aura::Window* default_container = | 603 aura::Window* default_container = |
595 ash::Shell::GetInstance()->GetContainer( | 604 ash::Shell::GetInstance()->GetContainer( |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 scoped_ptr<BrowserWindow> browser_panel; | 650 scoped_ptr<BrowserWindow> browser_panel; |
642 browser_panel.reset(new TestBrowserWindowAura(panel_owning_browser.get(), | 651 browser_panel.reset(new TestBrowserWindowAura(panel_owning_browser.get(), |
643 panel.get())); | 652 panel.get())); |
644 panel_owning_browser->SetWindowForTesting(browser_panel.get()); | 653 panel_owning_browser->SetWindowForTesting(browser_panel.get()); |
645 | 654 |
646 window->Show(); | 655 window->Show(); |
647 { // With a shown window it's size should get returned. | 656 { // With a shown window it's size should get returned. |
648 gfx::Rect window_bounds; | 657 gfx::Rect window_bounds; |
649 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 658 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
650 gfx::Rect(50, 100, 300, 150), bottom_nonprimary, | 659 gfx::Rect(50, 100, 300, 150), bottom_nonprimary, |
651 PERSISTED, &window_bounds, browser.get()); | 660 PERSISTED, &window_bounds, browser.get(), gfx::Rect()); |
652 EXPECT_EQ(gfx::Rect(16, 32, 640, 320), window_bounds); | 661 EXPECT_EQ(gfx::Rect(16, 32, 640, 320), window_bounds); |
653 } | 662 } |
654 | 663 |
655 { // Make sure that popups do not get changed. | 664 { // Make sure that popups do not get changed. |
656 gfx::Rect window_bounds; | 665 gfx::Rect window_bounds; |
657 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 666 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
658 gfx::Rect(50, 100, 300, 150), bottom_nonprimary, | 667 gfx::Rect(50, 100, 300, 150), bottom_nonprimary, |
659 PERSISTED, &window_bounds, popup_owning_browser.get()); | 668 PERSISTED, &window_bounds, popup_owning_browser.get(), |
| 669 gfx::Rect()); |
660 EXPECT_EQ(gfx::Rect(50, 100, 300, 150), window_bounds); | 670 EXPECT_EQ(gfx::Rect(50, 100, 300, 150), window_bounds); |
661 } | 671 } |
662 | 672 |
663 window->Hide(); | 673 window->Hide(); |
664 { // If a window is there but not shown the default should be returned. | 674 { // If a window is there but not shown the default should be returned. |
665 // The existing popup should not have any impact as well. | 675 // The existing popup should not have any impact as well. |
666 gfx::Rect window_bounds; | 676 gfx::Rect window_bounds; |
667 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 677 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
668 gfx::Rect(50, 100, 300, 150), bottom_nonprimary, | 678 gfx::Rect(50, 100, 300, 150), bottom_nonprimary, |
669 PERSISTED, &window_bounds, browser.get()); | 679 PERSISTED, &window_bounds, browser.get(), gfx::Rect()); |
670 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, | 680 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, |
671 WindowSizer::kDesktopBorderSize, | 681 WindowSizer::kDesktopBorderSize, |
672 1024 - 2 * WindowSizer::kDesktopBorderSize, | 682 1024 - 2 * WindowSizer::kDesktopBorderSize, |
673 768 - WindowSizer::kDesktopBorderSize), | 683 768 - WindowSizer::kDesktopBorderSize), |
674 window_bounds); | 684 window_bounds); |
675 } | 685 } |
676 } | 686 } |
| 687 |
| 688 // Test that the window is sized appropriately for the first run experience |
| 689 // where the default window bounds calculation is invoked. |
| 690 TEST_F(WindowSizerTest, AdjustFitSize) { |
| 691 { // Check that the window gets resized to the screen. |
| 692 gfx::Rect window_bounds; |
| 693 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(), |
| 694 gfx::Rect(), DEFAULT, &window_bounds, NULL, |
| 695 gfx::Rect(-10, -10, 1024 + 20, 768 + 20)); |
| 696 EXPECT_EQ(gfx::Rect(0, 0, 1024, 768), window_bounds); |
| 697 } |
| 698 |
| 699 { // Check that a window which hangs out of the screen get moved back in. |
| 700 gfx::Rect window_bounds; |
| 701 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(), |
| 702 gfx::Rect(), DEFAULT, &window_bounds, NULL, |
| 703 gfx::Rect(1020, 700, 100, 100)); |
| 704 EXPECT_EQ(gfx::Rect(924, 668, 100, 100), window_bounds); |
| 705 } |
| 706 } |
| 707 |
OLD | NEW |