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

Side by Side Diff: chrome/browser/ui/window_sizer_unittest.cc

Issue 8584001: Remove unused "maximized" parameter from WindowSizer::GetBrowserWindowBounds(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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
« no previous file with comments | « chrome/browser/ui/window_sizer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 std::vector<gfx::Rect> monitor_bounds_; 90 std::vector<gfx::Rect> monitor_bounds_;
91 91
92 DISALLOW_COPY_AND_ASSIGN(TestMonitorInfoProvider); 92 DISALLOW_COPY_AND_ASSIGN(TestMonitorInfoProvider);
93 }; 93 };
94 94
95 // Testing implementation of WindowSizer::StateProvider that we use to fake 95 // Testing implementation of WindowSizer::StateProvider that we use to fake
96 // persistent storage and existing windows. 96 // persistent storage and existing windows.
97 class TestStateProvider : public WindowSizer::StateProvider { 97 class TestStateProvider : public WindowSizer::StateProvider {
98 public: 98 public:
99 TestStateProvider() 99 TestStateProvider()
100 : persistent_maximized_(false), 100 : has_persistent_data_(false),
101 has_persistent_data_(false),
102 has_last_active_data_(false) { 101 has_last_active_data_(false) {
103 } 102 }
104 virtual ~TestStateProvider() {} 103 virtual ~TestStateProvider() {}
105 104
106 void SetPersistentState(const gfx::Rect& bounds, 105 void SetPersistentState(const gfx::Rect& bounds,
107 bool maximized,
108 const gfx::Rect& work_area, 106 const gfx::Rect& work_area,
109 bool has_persistent_data) { 107 bool has_persistent_data) {
110 persistent_bounds_ = bounds; 108 persistent_bounds_ = bounds;
111 persistent_maximized_ = maximized;
112 persistent_work_area_ = work_area; 109 persistent_work_area_ = work_area;
113 has_persistent_data_ = has_persistent_data; 110 has_persistent_data_ = has_persistent_data;
114 } 111 }
115 112
116 void SetLastActiveState(const gfx::Rect& bounds, bool has_last_active_data) { 113 void SetLastActiveState(const gfx::Rect& bounds, bool has_last_active_data) {
117 last_active_bounds_ = bounds; 114 last_active_bounds_ = bounds;
118 has_last_active_data_ = has_last_active_data; 115 has_last_active_data_ = has_last_active_data;
119 } 116 }
120 117
121 // Overridden from WindowSizer::StateProvider: 118 // Overridden from WindowSizer::StateProvider:
122 virtual bool GetPersistentState(gfx::Rect* bounds, 119 virtual bool GetPersistentState(gfx::Rect* bounds,
123 bool* maximized,
124 gfx::Rect* saved_work_area) const { 120 gfx::Rect* saved_work_area) const {
125 *bounds = persistent_bounds_; 121 *bounds = persistent_bounds_;
126 *maximized = persistent_maximized_;
127 *saved_work_area = persistent_work_area_; 122 *saved_work_area = persistent_work_area_;
128 return has_persistent_data_; 123 return has_persistent_data_;
129 } 124 }
130 125
131 virtual bool GetLastActiveWindowState(gfx::Rect* bounds) const { 126 virtual bool GetLastActiveWindowState(gfx::Rect* bounds) const {
132 *bounds = last_active_bounds_; 127 *bounds = last_active_bounds_;
133 return has_last_active_data_; 128 return has_last_active_data_;
134 } 129 }
135 130
136 private: 131 private:
137 gfx::Rect persistent_bounds_; 132 gfx::Rect persistent_bounds_;
138 bool persistent_maximized_;
139 gfx::Rect persistent_work_area_; 133 gfx::Rect persistent_work_area_;
140 bool has_persistent_data_; 134 bool has_persistent_data_;
141 135
142 gfx::Rect last_active_bounds_; 136 gfx::Rect last_active_bounds_;
143 bool has_last_active_data_; 137 bool has_last_active_data_;
144 138
145 DISALLOW_COPY_AND_ASSIGN(TestStateProvider); 139 DISALLOW_COPY_AND_ASSIGN(TestStateProvider);
146 }; 140 };
147 141
148 // A convenience function to read the window bounds from the window sizer 142 // A convenience function to read the window bounds from the window sizer
149 // according to the specified configuration. 143 // according to the specified configuration.
150 enum Source { DEFAULT, LAST_ACTIVE, PERSISTED }; 144 enum Source { DEFAULT, LAST_ACTIVE, PERSISTED };
151 static void GetWindowBounds(const gfx::Rect& monitor1_bounds, 145 static void GetWindowBounds(const gfx::Rect& monitor1_bounds,
152 const gfx::Rect& monitor1_work_area, 146 const gfx::Rect& monitor1_work_area,
153 const gfx::Rect& monitor2_bounds, 147 const gfx::Rect& monitor2_bounds,
154 const gfx::Rect& state, 148 const gfx::Rect& state,
155 bool maximized,
156 const gfx::Rect& work_area, 149 const gfx::Rect& work_area,
157 Source source, 150 Source source,
158 gfx::Rect* out_bounds, 151 gfx::Rect* out_bounds) {
159 bool* out_maximized) {
160 TestMonitorInfoProvider* mip = new TestMonitorInfoProvider; 152 TestMonitorInfoProvider* mip = new TestMonitorInfoProvider;
161 mip->AddMonitor(monitor1_bounds, monitor1_work_area); 153 mip->AddMonitor(monitor1_bounds, monitor1_work_area);
162 if (!monitor2_bounds.IsEmpty()) 154 if (!monitor2_bounds.IsEmpty())
163 mip->AddMonitor(monitor2_bounds, monitor2_bounds); 155 mip->AddMonitor(monitor2_bounds, monitor2_bounds);
164 TestStateProvider* sp = new TestStateProvider; 156 TestStateProvider* sp = new TestStateProvider;
165 if (source == PERSISTED) 157 if (source == PERSISTED)
166 sp->SetPersistentState(state, maximized, work_area, true); 158 sp->SetPersistentState(state, work_area, true);
167 else if (source == LAST_ACTIVE) 159 else if (source == LAST_ACTIVE)
168 sp->SetLastActiveState(state, true); 160 sp->SetLastActiveState(state, true);
169 WindowSizer sizer(sp, mip); 161 WindowSizer sizer(sp, mip);
170 sizer.DetermineWindowBounds(gfx::Rect(), out_bounds, out_maximized); 162 sizer.DetermineWindowBounds(gfx::Rect(), out_bounds);
171 } 163 }
172 164
173 // Test that the window is sized appropriately for the first run experience 165 // Test that the window is sized appropriately for the first run experience
174 // where the default window bounds calculation is invoked. 166 // where the default window bounds calculation is invoked.
175 TEST(WindowSizerTest, DefaultSizeCase) { 167 TEST(WindowSizerTest, DefaultSizeCase) {
176 { // 4:3 monitor case, 1024x768, no taskbar 168 { // 4:3 monitor case, 1024x768, no taskbar
177 gfx::Rect window_bounds; 169 gfx::Rect window_bounds;
178 bool maximized;
179 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(), 170 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(),
180 false, gfx::Rect(), DEFAULT, &window_bounds, &maximized); 171 gfx::Rect(), DEFAULT, &window_bounds);
181 EXPECT_FALSE(maximized);
182 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, 172 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels,
183 1024 - kWindowTilePixels * 2, 173 1024 - kWindowTilePixels * 2,
184 768 - kWindowTilePixels * 2), 174 768 - kWindowTilePixels * 2),
185 window_bounds); 175 window_bounds);
186 } 176 }
187 177
188 { // 4:3 monitor case, 1024x768, taskbar on bottom 178 { // 4:3 monitor case, 1024x768, taskbar on bottom
189 gfx::Rect window_bounds; 179 gfx::Rect window_bounds;
190 bool maximized;
191 GetWindowBounds(tentwentyfour, taskbar_bottom_work_area, gfx::Rect(), 180 GetWindowBounds(tentwentyfour, taskbar_bottom_work_area, gfx::Rect(),
192 gfx::Rect(), false, gfx::Rect(), DEFAULT, &window_bounds, 181 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds);
193 &maximized);
194 EXPECT_FALSE(maximized);
195 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, 182 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels,
196 1024 - kWindowTilePixels * 2, 183 1024 - kWindowTilePixels * 2,
197 (taskbar_bottom_work_area.height() - 184 (taskbar_bottom_work_area.height() -
198 kWindowTilePixels * 2)), 185 kWindowTilePixels * 2)),
199 window_bounds); 186 window_bounds);
200 } 187 }
201 188
202 { // 4:3 monitor case, 1024x768, taskbar on right 189 { // 4:3 monitor case, 1024x768, taskbar on right
203 gfx::Rect window_bounds; 190 gfx::Rect window_bounds;
204 bool maximized;
205 GetWindowBounds(tentwentyfour, taskbar_right_work_area, gfx::Rect(), 191 GetWindowBounds(tentwentyfour, taskbar_right_work_area, gfx::Rect(),
206 gfx::Rect(), false, gfx::Rect(), DEFAULT, &window_bounds, 192 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds);
207 &maximized);
208 EXPECT_FALSE(maximized);
209 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, 193 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels,
210 taskbar_right_work_area.width() - kWindowTilePixels*2, 194 taskbar_right_work_area.width() - kWindowTilePixels*2,
211 768 - kWindowTilePixels * 2), 195 768 - kWindowTilePixels * 2),
212 window_bounds); 196 window_bounds);
213 } 197 }
214 198
215 { // 4:3 monitor case, 1024x768, taskbar on left 199 { // 4:3 monitor case, 1024x768, taskbar on left
216 gfx::Rect window_bounds; 200 gfx::Rect window_bounds;
217 bool maximized;
218 GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(), 201 GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(),
219 gfx::Rect(), false, gfx::Rect(), DEFAULT, &window_bounds, 202 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds);
220 &maximized);
221 EXPECT_FALSE(maximized);
222 EXPECT_EQ(gfx::Rect(taskbar_left_work_area.x() + kWindowTilePixels, 203 EXPECT_EQ(gfx::Rect(taskbar_left_work_area.x() + kWindowTilePixels,
223 kWindowTilePixels, 204 kWindowTilePixels,
224 taskbar_left_work_area.width() - kWindowTilePixels * 2, 205 taskbar_left_work_area.width() - kWindowTilePixels * 2,
225 (taskbar_left_work_area.height() - 206 (taskbar_left_work_area.height() -
226 kWindowTilePixels * 2)), 207 kWindowTilePixels * 2)),
227 window_bounds); 208 window_bounds);
228 } 209 }
229 210
230 { // 4:3 monitor case, 1024x768, taskbar on top 211 { // 4:3 monitor case, 1024x768, taskbar on top
231 gfx::Rect window_bounds; 212 gfx::Rect window_bounds;
232 bool maximized;
233 GetWindowBounds(tentwentyfour, taskbar_top_work_area, gfx::Rect(), 213 GetWindowBounds(tentwentyfour, taskbar_top_work_area, gfx::Rect(),
234 gfx::Rect(), false, gfx::Rect(), DEFAULT, &window_bounds, 214 gfx::Rect(), gfx::Rect(), DEFAULT, &window_bounds);
235 &maximized);
236 EXPECT_FALSE(maximized);
237 EXPECT_EQ(gfx::Rect(kWindowTilePixels, 215 EXPECT_EQ(gfx::Rect(kWindowTilePixels,
238 taskbar_top_work_area.y() + kWindowTilePixels, 216 taskbar_top_work_area.y() + kWindowTilePixels,
239 1024 - kWindowTilePixels * 2, 217 1024 - kWindowTilePixels * 2,
240 taskbar_top_work_area.height() - kWindowTilePixels * 2), 218 taskbar_top_work_area.height() - kWindowTilePixels * 2),
241 window_bounds); 219 window_bounds);
242 } 220 }
243 221
244 { // 4:3 monitor case, 1280x1024 222 { // 4:3 monitor case, 1280x1024
245 gfx::Rect window_bounds; 223 gfx::Rect window_bounds;
246 bool maximized;
247 GetWindowBounds(twelveeighty, twelveeighty, gfx::Rect(), gfx::Rect(), 224 GetWindowBounds(twelveeighty, twelveeighty, gfx::Rect(), gfx::Rect(),
248 false, gfx::Rect(), DEFAULT, &window_bounds, &maximized); 225 gfx::Rect(), DEFAULT, &window_bounds);
249 EXPECT_FALSE(maximized);
250 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, 226 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels,
251 1050, 227 1050,
252 1024 - kWindowTilePixels * 2), 228 1024 - kWindowTilePixels * 2),
253 window_bounds); 229 window_bounds);
254 } 230 }
255 231
256 { // 4:3 monitor case, 1600x1200 232 { // 4:3 monitor case, 1600x1200
257 gfx::Rect window_bounds; 233 gfx::Rect window_bounds;
258 bool maximized;
259 GetWindowBounds(sixteenhundred, sixteenhundred, gfx::Rect(), gfx::Rect(), 234 GetWindowBounds(sixteenhundred, sixteenhundred, gfx::Rect(), gfx::Rect(),
260 false, gfx::Rect(), DEFAULT, &window_bounds, &maximized); 235 gfx::Rect(), DEFAULT, &window_bounds);
261 EXPECT_FALSE(maximized);
262 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, 236 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels,
263 1050, 237 1050,
264 1200 - kWindowTilePixels * 2), 238 1200 - kWindowTilePixels * 2),
265 window_bounds); 239 window_bounds);
266 } 240 }
267 241
268 { // 16:10 monitor case, 1680x1050 242 { // 16:10 monitor case, 1680x1050
269 gfx::Rect window_bounds; 243 gfx::Rect window_bounds;
270 bool maximized;
271 GetWindowBounds(sixteeneighty, sixteeneighty, gfx::Rect(), gfx::Rect(), 244 GetWindowBounds(sixteeneighty, sixteeneighty, gfx::Rect(), gfx::Rect(),
272 false, gfx::Rect(), DEFAULT, &window_bounds, &maximized); 245 gfx::Rect(), DEFAULT, &window_bounds);
273 EXPECT_FALSE(maximized);
274 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, 246 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels,
275 840 - static_cast<int>(kWindowTilePixels * 1.5), 247 840 - static_cast<int>(kWindowTilePixels * 1.5),
276 1050 - kWindowTilePixels * 2), 248 1050 - kWindowTilePixels * 2),
277 window_bounds); 249 window_bounds);
278 } 250 }
279 251
280 { // 16:10 monitor case, 1920x1200 252 { // 16:10 monitor case, 1920x1200
281 gfx::Rect window_bounds; 253 gfx::Rect window_bounds;
282 bool maximized;
283 GetWindowBounds(nineteentwenty, nineteentwenty, gfx::Rect(), gfx::Rect(), 254 GetWindowBounds(nineteentwenty, nineteentwenty, gfx::Rect(), gfx::Rect(),
284 false, gfx::Rect(), DEFAULT, &window_bounds, &maximized); 255 gfx::Rect(), DEFAULT, &window_bounds);
285 EXPECT_FALSE(maximized);
286 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, 256 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels,
287 960 - static_cast<int>(kWindowTilePixels * 1.5), 257 960 - static_cast<int>(kWindowTilePixels * 1.5),
288 1200 - kWindowTilePixels * 2), 258 1200 - kWindowTilePixels * 2),
289 window_bounds); 259 window_bounds);
290 } 260 }
291 } 261 }
292 262
293 // Test that the next opened window is positioned appropriately given the 263 // Test that the next opened window is positioned appropriately given the
294 // bounds of an existing window of the same type. 264 // bounds of an existing window of the same type.
295 TEST(WindowSizerTest, LastWindowBoundsCase) { 265 TEST(WindowSizerTest, LastWindowBoundsCase) {
296 { // normal, in the middle of the screen somewhere. 266 { // normal, in the middle of the screen somewhere.
297 gfx::Rect window_bounds; 267 gfx::Rect window_bounds;
298 bool maximized = false;
299 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 268 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
300 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400), 269 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400),
301 false, gfx::Rect(), LAST_ACTIVE, 270 gfx::Rect(), LAST_ACTIVE, &window_bounds);
302 &window_bounds, &maximized);
303 EXPECT_FALSE(maximized);
304 EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2, 271 EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2,
305 kWindowTilePixels * 2, 500, 400), window_bounds); 272 kWindowTilePixels * 2, 500, 400), window_bounds);
306 } 273 }
307 274
308 { // taskbar on top. 275 { // taskbar on top.
309 gfx::Rect window_bounds; 276 gfx::Rect window_bounds;
310 bool maximized = false;
311 GetWindowBounds(tentwentyfour, taskbar_top_work_area, gfx::Rect(), 277 GetWindowBounds(tentwentyfour, taskbar_top_work_area, gfx::Rect(),
312 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400), 278 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400),
313 false, gfx::Rect(), LAST_ACTIVE, 279 gfx::Rect(), LAST_ACTIVE, &window_bounds);
314 &window_bounds, &maximized);
315 EXPECT_FALSE(maximized);
316 EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2, 280 EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2,
317 std::max(kWindowTilePixels * 2, 281 std::max(kWindowTilePixels * 2,
318 34 /* toolbar height */), 282 34 /* toolbar height */),
319 500, 400), window_bounds); 283 500, 400), window_bounds);
320 } 284 }
321 285
322 { // too small to satisify the minimum visibility condition. 286 { // Too small to satisify the minimum visibility condition.
323 gfx::Rect window_bounds; 287 gfx::Rect window_bounds;
324 bool maximized = false;
325 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 288 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
326 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 29, 29), 289 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 29, 29),
327 false, gfx::Rect(), LAST_ACTIVE, 290 gfx::Rect(), LAST_ACTIVE, &window_bounds);
328 &window_bounds, &maximized);
329 EXPECT_FALSE(maximized);
330 EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2, 291 EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2,
331 kWindowTilePixels * 2, 292 kWindowTilePixels * 2,
332 30 /* not 29 */, 293 30 /* not 29 */,
333 30 /* not 29 */), 294 30 /* not 29 */),
334 window_bounds); 295 window_bounds);
335 } 296 }
336 297
337 298
338 { // normal, but maximized 299 { // Normal.
339 gfx::Rect window_bounds; 300 gfx::Rect window_bounds;
340 bool maximized = false;
341 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 301 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
342 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400), 302 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400),
343 true, gfx::Rect(), LAST_ACTIVE, 303 gfx::Rect(), LAST_ACTIVE, &window_bounds);
344 &window_bounds, &maximized);
345 EXPECT_FALSE(maximized);
346 EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2, 304 EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2,
347 kWindowTilePixels * 2, 500, 400), window_bounds); 305 kWindowTilePixels * 2, 500, 400), window_bounds);
348 } 306 }
349 } 307 }
350 308
351 // Test that the window opened is sized appropriately given persisted sizes. 309 // Test that the window opened is sized appropriately given persisted sizes.
352 TEST(WindowSizerTest, PersistedBoundsCase) { 310 TEST(WindowSizerTest, PersistedBoundsCase) {
353 { // normal, in the middle of the screen somewhere. 311 { // normal, in the middle of the screen somewhere.
354 gfx::Rect initial_bounds(kWindowTilePixels, kWindowTilePixels, 500, 400); 312 gfx::Rect initial_bounds(kWindowTilePixels, kWindowTilePixels, 500, 400);
355 313
356 gfx::Rect window_bounds; 314 gfx::Rect window_bounds;
357 bool maximized;
358 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), initial_bounds, 315 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), initial_bounds,
359 false, gfx::Rect(), PERSISTED, &window_bounds, &maximized); 316 gfx::Rect(), PERSISTED, &window_bounds);
360 EXPECT_FALSE(maximized);
361 EXPECT_EQ(initial_bounds, window_bounds); 317 EXPECT_EQ(initial_bounds, window_bounds);
362 } 318 }
363 319
364 { // normal, maximized. 320 { // Normal.
365 gfx::Rect initial_bounds(0, 0, 1024, 768); 321 gfx::Rect initial_bounds(0, 0, 1024, 768);
366 322
367 gfx::Rect window_bounds; 323 gfx::Rect window_bounds;
368 bool maximized;
369 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), initial_bounds, 324 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), initial_bounds,
370 true, gfx::Rect(), PERSISTED, &window_bounds, &maximized); 325 gfx::Rect(), PERSISTED, &window_bounds);
371 EXPECT_TRUE(maximized);
372 EXPECT_EQ(initial_bounds, window_bounds); 326 EXPECT_EQ(initial_bounds, window_bounds);
373 } 327 }
374 328
375 { // normal, on non-primary monitor in negative coords. 329 { // normal, on non-primary monitor in negative coords.
376 gfx::Rect initial_bounds(-600, 10, 500, 400); 330 gfx::Rect initial_bounds(-600, 10, 500, 400);
377 331
378 gfx::Rect window_bounds; 332 gfx::Rect window_bounds;
379 bool maximized;
380 GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary, 333 GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary,
381 initial_bounds, false, gfx::Rect(), PERSISTED, 334 initial_bounds, gfx::Rect(), PERSISTED, &window_bounds);
382 &window_bounds, &maximized);
383 EXPECT_FALSE(maximized);
384 EXPECT_EQ(initial_bounds, window_bounds); 335 EXPECT_EQ(initial_bounds, window_bounds);
385 } 336 }
386 337
387 { // normal, on non-primary monitor in negative coords, maximized. 338 { // normal, on non-primary monitor in negative coords.
388 gfx::Rect initial_bounds(-1024, 0, 1024, 768); 339 gfx::Rect initial_bounds(-1024, 0, 1024, 768);
389 340
390 gfx::Rect window_bounds; 341 gfx::Rect window_bounds;
391 bool maximized;
392 GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary, 342 GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary,
393 initial_bounds, true, gfx::Rect(), PERSISTED, 343 initial_bounds, gfx::Rect(), PERSISTED, &window_bounds);
394 &window_bounds, &maximized);
395 EXPECT_TRUE(maximized);
396 EXPECT_EQ(initial_bounds, window_bounds); 344 EXPECT_EQ(initial_bounds, window_bounds);
397 } 345 }
398 346
399 { // Non-primary monitor resoultion has changed, but the monitor still 347 { // Non-primary monitor resoultion has changed, but the monitor still
400 // completely contains the window. 348 // completely contains the window.
401 349
402 gfx::Rect initial_bounds(1074, 50, 600, 500); 350 gfx::Rect initial_bounds(1074, 50, 600, 500);
403 351
404 gfx::Rect window_bounds; 352 gfx::Rect window_bounds;
405 bool maximized;
406 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600), 353 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600),
407 initial_bounds, false, right_nonprimary, 354 initial_bounds, right_nonprimary, PERSISTED,
408 PERSISTED, &window_bounds, &maximized); 355 &window_bounds);
409 EXPECT_FALSE(maximized);
410 EXPECT_EQ(initial_bounds, window_bounds); 356 EXPECT_EQ(initial_bounds, window_bounds);
411 } 357 }
412 358
413 { // Non-primary monitor resoultion has changed, and the window is partially 359 { // Non-primary monitor resoultion has changed, and the window is partially
414 // off-screen. 360 // off-screen.
415 361
416 gfx::Rect initial_bounds(1274, 50, 600, 500); 362 gfx::Rect initial_bounds(1274, 50, 600, 500);
417 363
418 gfx::Rect window_bounds; 364 gfx::Rect window_bounds;
419 bool maximized;
420 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600), 365 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600),
421 initial_bounds, false, right_nonprimary, 366 initial_bounds, right_nonprimary, PERSISTED,
422 PERSISTED, &window_bounds, &maximized); 367 &window_bounds);
423 EXPECT_FALSE(maximized);
424 EXPECT_EQ(gfx::Rect(1224, 50, 600, 500), window_bounds); 368 EXPECT_EQ(gfx::Rect(1224, 50, 600, 500), window_bounds);
425 } 369 }
426 370
427 { // Non-primary monitor resoultion has changed, and the window is now too 371 { // Non-primary monitor resoultion has changed, and the window is now too
428 // large for the monitor. 372 // large for the monitor.
429 373
430 gfx::Rect initial_bounds(1274, 50, 900, 700); 374 gfx::Rect initial_bounds(1274, 50, 900, 700);
431 375
432 gfx::Rect window_bounds; 376 gfx::Rect window_bounds;
433 bool maximized;
434 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600), 377 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600),
435 initial_bounds, false, right_nonprimary, 378 initial_bounds, right_nonprimary, PERSISTED,
436 PERSISTED, &window_bounds, &maximized); 379 &window_bounds);
437 EXPECT_FALSE(maximized);
438 EXPECT_EQ(gfx::Rect(1024, 0, 800, 600), window_bounds); 380 EXPECT_EQ(gfx::Rect(1024, 0, 800, 600), window_bounds);
439 } 381 }
440 382
441 { // width and height too small 383 { // width and height too small
442 gfx::Rect window_bounds; 384 gfx::Rect window_bounds;
443 bool maximized;
444 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 385 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
445 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 29, 29), 386 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 29, 29),
446 false, gfx::Rect(), PERSISTED, 387 gfx::Rect(), PERSISTED, &window_bounds);
447 &window_bounds, &maximized);
448 EXPECT_FALSE(maximized);
449 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels, 388 EXPECT_EQ(gfx::Rect(kWindowTilePixels, kWindowTilePixels,
450 30 /* not 29 */, 30 /* not 29 */), 389 30 /* not 29 */, 30 /* not 29 */),
451 window_bounds); 390 window_bounds);
452 } 391 }
453 392
454 #if defined(OS_MACOSX) 393 #if defined(OS_MACOSX)
455 { // Saved state is too tall to possibly be resized. Mac resizers 394 { // Saved state is too tall to possibly be resized. Mac resizers
456 // are at the bottom of the window, and no piece of a window can 395 // are at the bottom of the window, and no piece of a window can
457 // be moved higher than the menubar. (Perhaps the user changed 396 // be moved higher than the menubar. (Perhaps the user changed
458 // resolution to something smaller before relaunching Chrome?) 397 // resolution to something smaller before relaunching Chrome?)
459 gfx::Rect window_bounds; 398 gfx::Rect window_bounds;
460 bool maximized;
461 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 399 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
462 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 30, 5000), 400 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 30, 5000),
463 false, gfx::Rect(), PERSISTED, 401 gfx::Rect(), PERSISTED, &window_bounds);
464 &window_bounds, &maximized);
465 EXPECT_FALSE(maximized);
466 EXPECT_EQ(tentwentyfour.height(), window_bounds.height()); 402 EXPECT_EQ(tentwentyfour.height(), window_bounds.height());
467 } 403 }
468 #endif // defined(OS_MACOSX) 404 #endif // defined(OS_MACOSX)
469 } 405 }
470 406
471 ////////////////////////////////////////////////////////////////////////////// 407 //////////////////////////////////////////////////////////////////////////////
472 // The following unittests have different results on Mac/non-Mac because we 408 // The following unittests have different results on Mac/non-Mac because we
473 // reposition windows aggressively on Mac. The *WithAggressiveReposition tests 409 // reposition windows aggressively on Mac. The *WithAggressiveReposition tests
474 // are run on Mac, and the *WithNonAggressiveRepositioning tests are run on 410 // are run on Mac, and the *WithNonAggressiveRepositioning tests are run on
475 // other platforms. 411 // other platforms.
476 412
477 #if defined(OS_MACOSX) 413 #if defined(OS_MACOSX)
478 TEST(WindowSizerTest, LastWindowOffscreenWithAggressiveRepositioning) { 414 TEST(WindowSizerTest, LastWindowOffscreenWithAggressiveRepositioning) {
479 { // taskbar on left. The new window overlaps slightly with the taskbar, so 415 { // taskbar on left. The new window overlaps slightly with the taskbar, so
480 // it is moved to be flush with the left edge of the work area. 416 // it is moved to be flush with the left edge of the work area.
481 gfx::Rect window_bounds; 417 gfx::Rect window_bounds;
482 bool maximized = false;
483 GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(), 418 GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(),
484 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400), 419 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400),
485 false, gfx::Rect(), LAST_ACTIVE, 420 gfx::Rect(), LAST_ACTIVE, &window_bounds);
486 &window_bounds, &maximized);
487 EXPECT_FALSE(maximized);
488 EXPECT_EQ(gfx::Rect(taskbar_left_work_area.x(), 421 EXPECT_EQ(gfx::Rect(taskbar_left_work_area.x(),
489 kWindowTilePixels * 2, 500, 400), window_bounds); 422 kWindowTilePixels * 2, 500, 400), window_bounds);
490 } 423 }
491 424
492 { // offset would put the new window offscreen at the bottom 425 { // offset would put the new window offscreen at the bottom
493 gfx::Rect window_bounds; 426 gfx::Rect window_bounds;
494 bool maximized = false;
495 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 427 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
496 gfx::Rect(10, 729, 500, 400), false, gfx::Rect(), 428 gfx::Rect(10, 729, 500, 400), gfx::Rect(), LAST_ACTIVE,
497 LAST_ACTIVE, &window_bounds, &maximized); 429 &window_bounds);
498 EXPECT_FALSE(maximized);
499 EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 430 EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels,
500 0 /* not 729 + kWindowTilePixels */, 431 0 /* not 729 + kWindowTilePixels */,
501 500, 400), 432 500, 400),
502 window_bounds); 433 window_bounds);
503 } 434 }
504 435
505 { // offset would put the new window offscreen at the right 436 { // offset would put the new window offscreen at the right
506 gfx::Rect window_bounds; 437 gfx::Rect window_bounds;
507 bool maximized = false;
508 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 438 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
509 gfx::Rect(985, 10, 500, 400), false, gfx::Rect(), 439 gfx::Rect(985, 10, 500, 400), gfx::Rect(), LAST_ACTIVE,
510 LAST_ACTIVE, &window_bounds, &maximized); 440 &window_bounds);
511 EXPECT_FALSE(maximized);
512 EXPECT_EQ(gfx::Rect(0 /* not 985 + kWindowTilePixels*/, 441 EXPECT_EQ(gfx::Rect(0 /* not 985 + kWindowTilePixels*/,
513 10 + kWindowTilePixels, 442 10 + kWindowTilePixels,
514 500, 400), 443 500, 400),
515 window_bounds); 444 window_bounds);
516 } 445 }
517 446
518 { // offset would put the new window offscreen at the bottom right 447 { // offset would put the new window offscreen at the bottom right
519 gfx::Rect window_bounds; 448 gfx::Rect window_bounds;
520 bool maximized = false;
521 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 449 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
522 gfx::Rect(985, 729, 500, 400), false, gfx::Rect(), 450 gfx::Rect(985, 729, 500, 400), gfx::Rect(), LAST_ACTIVE,
523 LAST_ACTIVE, &window_bounds, &maximized); 451 &window_bounds);
524 EXPECT_FALSE(maximized);
525 EXPECT_EQ(gfx::Rect(0 /* not 985 + kWindowTilePixels*/, 452 EXPECT_EQ(gfx::Rect(0 /* not 985 + kWindowTilePixels*/,
526 0 /* not 729 + kWindowTilePixels*/, 453 0 /* not 729 + kWindowTilePixels*/,
527 500, 400), 454 500, 400),
528 window_bounds); 455 window_bounds);
529 } 456 }
530 } 457 }
531 458
532 TEST(WindowSizerTest, PersistedWindowOffscreenWithAggressiveRepositioning) { 459 TEST(WindowSizerTest, PersistedWindowOffscreenWithAggressiveRepositioning) {
533 { // off the left 460 { // off the left
534 gfx::Rect window_bounds; 461 gfx::Rect window_bounds;
535 bool maximized;
536 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 462 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
537 gfx::Rect(-471, 50, 500, 400), false, gfx::Rect(), 463 gfx::Rect(-471, 50, 500, 400), gfx::Rect(), PERSISTED,
538 PERSISTED, &window_bounds, &maximized); 464 &window_bounds);
539 EXPECT_FALSE(maximized);
540 EXPECT_EQ(gfx::Rect(0 /* not -471 */, 50, 500, 400), window_bounds); 465 EXPECT_EQ(gfx::Rect(0 /* not -471 */, 50, 500, 400), window_bounds);
541 } 466 }
542 467
543 { // off the top 468 { // off the top
544 gfx::Rect window_bounds; 469 gfx::Rect window_bounds;
545 bool maximized;
546 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 470 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
547 gfx::Rect(50, -370, 500, 400), false, gfx::Rect(), 471 gfx::Rect(50, -370, 500, 400), gfx::Rect(), PERSISTED,
548 PERSISTED, &window_bounds, &maximized); 472 &window_bounds);
549 EXPECT_FALSE(maximized);
550 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); 473 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds);
551 } 474 }
552 475
553 { // off the right 476 { // off the right
554 gfx::Rect window_bounds; 477 gfx::Rect window_bounds;
555 bool maximized;
556 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 478 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
557 gfx::Rect(995, 50, 500, 400), false, gfx::Rect(), 479 gfx::Rect(995, 50, 500, 400), gfx::Rect(), PERSISTED,
558 PERSISTED, &window_bounds, &maximized); 480 &window_bounds);
559 EXPECT_FALSE(maximized);
560 EXPECT_EQ(gfx::Rect(0 /* not 995 */, 50, 500, 400), window_bounds); 481 EXPECT_EQ(gfx::Rect(0 /* not 995 */, 50, 500, 400), window_bounds);
561 } 482 }
562 483
563 { // off the bottom 484 { // off the bottom
564 gfx::Rect window_bounds; 485 gfx::Rect window_bounds;
565 bool maximized;
566 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 486 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
567 gfx::Rect(50, 739, 500, 400), false, gfx::Rect(), PERSISTED, 487 gfx::Rect(50, 739, 500, 400), gfx::Rect(), PERSISTED,
568 &window_bounds, &maximized); 488 &window_bounds);
569 EXPECT_FALSE(maximized);
570 EXPECT_EQ(gfx::Rect(50, 0 /* not 739 */, 500, 400), window_bounds); 489 EXPECT_EQ(gfx::Rect(50, 0 /* not 739 */, 500, 400), window_bounds);
571 } 490 }
572 491
573 { // off the topleft 492 { // off the topleft
574 gfx::Rect window_bounds; 493 gfx::Rect window_bounds;
575 bool maximized;
576 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 494 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
577 gfx::Rect(-471, -371, 500, 400), false, gfx::Rect(), 495 gfx::Rect(-471, -371, 500, 400), gfx::Rect(), PERSISTED,
578 PERSISTED, &window_bounds, &maximized); 496 &window_bounds);
579 EXPECT_FALSE(maximized);
580 EXPECT_EQ(gfx::Rect(0 /* not -471 */, 0 /* not -371 */, 500, 400), 497 EXPECT_EQ(gfx::Rect(0 /* not -471 */, 0 /* not -371 */, 500, 400),
581 window_bounds); 498 window_bounds);
582 } 499 }
583 500
584 { // off the topright 501 { // off the topright
585 gfx::Rect window_bounds; 502 gfx::Rect window_bounds;
586 bool maximized;
587 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 503 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
588 gfx::Rect(995, -371, 500, 400), false, gfx::Rect(), 504 gfx::Rect(995, -371, 500, 400), gfx::Rect(), PERSISTED,
589 PERSISTED, &window_bounds, &maximized); 505 &window_bounds);
590 EXPECT_FALSE(maximized);
591 EXPECT_EQ(gfx::Rect(0 /* not 995 */, 0 /* not -371 */, 500, 400), 506 EXPECT_EQ(gfx::Rect(0 /* not 995 */, 0 /* not -371 */, 500, 400),
592 window_bounds); 507 window_bounds);
593 } 508 }
594 509
595 { // off the bottomleft 510 { // off the bottomleft
596 gfx::Rect window_bounds; 511 gfx::Rect window_bounds;
597 bool maximized;
598 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 512 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
599 gfx::Rect(-471, 739, 500, 400), false, gfx::Rect(), 513 gfx::Rect(-471, 739, 500, 400), gfx::Rect(), PERSISTED,
600 PERSISTED, &window_bounds, &maximized); 514 &window_bounds);
601 EXPECT_FALSE(maximized);
602 EXPECT_EQ(gfx::Rect(0 /* not -471 */, 0 /* not 739 */, 500, 400), 515 EXPECT_EQ(gfx::Rect(0 /* not -471 */, 0 /* not 739 */, 500, 400),
603 window_bounds); 516 window_bounds);
604 } 517 }
605 518
606 { // off the bottomright 519 { // off the bottomright
607 gfx::Rect window_bounds; 520 gfx::Rect window_bounds;
608 bool maximized;
609 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 521 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
610 gfx::Rect(995, 739, 500, 400), false, gfx::Rect(), 522 gfx::Rect(995, 739, 500, 400), gfx::Rect(), PERSISTED,
611 PERSISTED, &window_bounds, &maximized); 523 &window_bounds);
612 EXPECT_FALSE(maximized);
613 EXPECT_EQ(gfx::Rect(0 /* not 995 */, 0 /* not 739 */, 500, 400), 524 EXPECT_EQ(gfx::Rect(0 /* not 995 */, 0 /* not 739 */, 500, 400),
614 window_bounds); 525 window_bounds);
615 } 526 }
616 527
617 { // entirely off left 528 { // entirely off left
618 gfx::Rect window_bounds; 529 gfx::Rect window_bounds;
619 bool maximized;
620 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 530 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
621 gfx::Rect(-700, 50, 500, 400), false, gfx::Rect(), 531 gfx::Rect(-700, 50, 500, 400), gfx::Rect(), PERSISTED,
622 PERSISTED, &window_bounds, &maximized); 532 &window_bounds);
623 EXPECT_FALSE(maximized);
624 EXPECT_EQ(gfx::Rect(0 /* not -700 */, 50, 500, 400), window_bounds); 533 EXPECT_EQ(gfx::Rect(0 /* not -700 */, 50, 500, 400), window_bounds);
625 } 534 }
626 535
627 { // entirely off left (monitor was detached since last run) 536 { // entirely off left (monitor was detached since last run)
628 gfx::Rect window_bounds; 537 gfx::Rect window_bounds;
629 bool maximized;
630 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 538 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
631 gfx::Rect(-700, 50, 500, 400), false, left_nonprimary, 539 gfx::Rect(-700, 50, 500, 400), left_nonprimary,
632 PERSISTED, &window_bounds, &maximized); 540 PERSISTED, &window_bounds);
633 EXPECT_FALSE(maximized);
634 EXPECT_EQ(gfx::Rect(0, 50, 500, 400), window_bounds); 541 EXPECT_EQ(gfx::Rect(0, 50, 500, 400), window_bounds);
635 } 542 }
636 543
637 { // entirely off top 544 { // entirely off top
638 gfx::Rect window_bounds; 545 gfx::Rect window_bounds;
639 bool maximized;
640 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 546 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
641 gfx::Rect(50, -500, 500, 400), false, gfx::Rect(), 547 gfx::Rect(50, -500, 500, 400), gfx::Rect(), PERSISTED,
642 PERSISTED, &window_bounds, &maximized); 548 &window_bounds);
643 EXPECT_FALSE(maximized);
644 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); 549 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds);
645 } 550 }
646 551
647 { // entirely off top (monitor was detached since last run) 552 { // entirely off top (monitor was detached since last run)
648 gfx::Rect window_bounds; 553 gfx::Rect window_bounds;
649 bool maximized;
650 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 554 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
651 gfx::Rect(50, -500, 500, 400), false, top_nonprimary, 555 gfx::Rect(50, -500, 500, 400), top_nonprimary, PERSISTED,
652 PERSISTED, &window_bounds, &maximized); 556 &window_bounds);
653 EXPECT_FALSE(maximized);
654 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); 557 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds);
655 } 558 }
656 559
657 { // entirely off right 560 { // entirely off right
658 gfx::Rect window_bounds; 561 gfx::Rect window_bounds;
659 bool maximized;
660 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 562 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
661 gfx::Rect(1200, 50, 500, 400), false, gfx::Rect(), 563 gfx::Rect(1200, 50, 500, 400), gfx::Rect(), PERSISTED,
662 PERSISTED, &window_bounds, &maximized); 564 &window_bounds);
663 EXPECT_FALSE(maximized);
664 EXPECT_EQ(gfx::Rect(0 /* not 1200 */, 50, 500, 400), window_bounds); 565 EXPECT_EQ(gfx::Rect(0 /* not 1200 */, 50, 500, 400), window_bounds);
665 } 566 }
666 567
667 { // entirely off right (monitor was detached since last run) 568 { // entirely off right (monitor was detached since last run)
668 gfx::Rect window_bounds; 569 gfx::Rect window_bounds;
669 bool maximized;
670 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 570 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
671 gfx::Rect(1200, 50, 500, 400), false, right_nonprimary, 571 gfx::Rect(1200, 50, 500, 400), right_nonprimary, PERSISTED,
672 PERSISTED, &window_bounds, &maximized); 572 &window_bounds);
673 EXPECT_FALSE(maximized);
674 EXPECT_EQ(gfx::Rect(524 /* not 1200 */, 50, 500, 400), window_bounds); 573 EXPECT_EQ(gfx::Rect(524 /* not 1200 */, 50, 500, 400), window_bounds);
675 } 574 }
676 575
677 { // entirely off bottom 576 { // entirely off bottom
678 gfx::Rect window_bounds; 577 gfx::Rect window_bounds;
679 bool maximized;
680 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 578 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
681 gfx::Rect(50, 800, 500, 400), false, gfx::Rect(), PERSISTED, 579 gfx::Rect(50, 800, 500, 400), gfx::Rect(), PERSISTED,
682 &window_bounds, &maximized); 580 &window_bounds);
683 EXPECT_FALSE(maximized);
684 EXPECT_EQ(gfx::Rect(50, 0 /* not 800 */, 500, 400), window_bounds); 581 EXPECT_EQ(gfx::Rect(50, 0 /* not 800 */, 500, 400), window_bounds);
685 } 582 }
686 583
687 { // entirely off bottom (monitor was detached since last run) 584 { // entirely off bottom (monitor was detached since last run)
688 gfx::Rect window_bounds; 585 gfx::Rect window_bounds;
689 bool maximized;
690 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 586 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
691 gfx::Rect(50, 800, 500, 400), false, bottom_nonprimary, 587 gfx::Rect(50, 800, 500, 400), bottom_nonprimary,
692 PERSISTED, &window_bounds, &maximized); 588 PERSISTED, &window_bounds);
693 EXPECT_FALSE(maximized);
694 EXPECT_EQ(gfx::Rect(50, 368 /* not 800 */, 500, 400), window_bounds); 589 EXPECT_EQ(gfx::Rect(50, 368 /* not 800 */, 500, 400), window_bounds);
695 } 590 }
696 591
697 { // wider than the screen. off both the left and right 592 { // wider than the screen. off both the left and right
698 gfx::Rect window_bounds; 593 gfx::Rect window_bounds;
699 bool maximized;
700 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 594 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
701 gfx::Rect(-100, 50, 2000, 400), false, gfx::Rect(), 595 gfx::Rect(-100, 50, 2000, 400), gfx::Rect(), PERSISTED,
702 PERSISTED, &window_bounds, &maximized); 596 &window_bounds);
703 EXPECT_FALSE(maximized);
704 EXPECT_EQ(gfx::Rect(0 /* not -100 */, 50, 2000, 400), window_bounds); 597 EXPECT_EQ(gfx::Rect(0 /* not -100 */, 50, 2000, 400), window_bounds);
705 } 598 }
706 } 599 }
707 #else 600 #else
708 TEST(WindowSizerTest, LastWindowOffscreenWithNonAggressiveRepositioning) { 601 TEST(WindowSizerTest, LastWindowOffscreenWithNonAggressiveRepositioning) {
709 { // taskbar on left. 602 { // taskbar on left.
710 gfx::Rect window_bounds; 603 gfx::Rect window_bounds;
711 bool maximized = false;
712 GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(), 604 GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(),
713 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400), 605 gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400),
714 false, gfx::Rect(), LAST_ACTIVE, 606 gfx::Rect(), LAST_ACTIVE, &window_bounds);
715 &window_bounds, &maximized);
716 EXPECT_FALSE(maximized);
717 EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2, 607 EXPECT_EQ(gfx::Rect(kWindowTilePixels * 2,
718 kWindowTilePixels * 2, 500, 400), window_bounds); 608 kWindowTilePixels * 2, 500, 400), window_bounds);
719 } 609 }
720 610
721 // Linux does not tile windows, so tile adjustment tests don't make sense. 611 // Linux does not tile windows, so tile adjustment tests don't make sense.
722 #if !defined(OS_POSIX) || defined(OS_MACOSX) 612 #if !defined(OS_POSIX) || defined(OS_MACOSX)
723 { // offset would put the new window offscreen at the bottom but the minimum 613 { // offset would put the new window offscreen at the bottom but the minimum
724 // visibility condition is barely satisfied without relocation. 614 // visibility condition is barely satisfied without relocation.
725 gfx::Rect window_bounds; 615 gfx::Rect window_bounds;
726 bool maximized = false;
727 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 616 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
728 gfx::Rect(10, 728, 500, 400), false, gfx::Rect(), 617 gfx::Rect(10, 728, 500, 400), gfx::Rect(), LAST_ACTIVE,
729 LAST_ACTIVE, &window_bounds, &maximized); 618 &window_bounds);
730 EXPECT_FALSE(maximized);
731 EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 738, 619 EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 738,
732 500, 400), window_bounds); 620 500, 400), window_bounds);
733 } 621 }
734 622
735 { // offset would put the new window offscreen at the bottom and the minimum 623 { // offset would put the new window offscreen at the bottom and the minimum
736 // visibility condition is satisified by relocation. 624 // visibility condition is satisified by relocation.
737 gfx::Rect window_bounds; 625 gfx::Rect window_bounds;
738 bool maximized = false;
739 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 626 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
740 gfx::Rect(10, 729, 500, 400), false, gfx::Rect(), 627 gfx::Rect(10, 729, 500, 400), gfx::Rect(), LAST_ACTIVE,
741 LAST_ACTIVE, &window_bounds, &maximized); 628 &window_bounds);
742 EXPECT_FALSE(maximized);
743 EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 738 /* not 739 */, 500, 400), 629 EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 738 /* not 739 */, 500, 400),
744 window_bounds); 630 window_bounds);
745 } 631 }
746 632
747 { // offset would put the new window offscreen at the right but the minimum 633 { // offset would put the new window offscreen at the right but the minimum
748 // visibility condition is barely satisfied without relocation. 634 // visibility condition is barely satisfied without relocation.
749 gfx::Rect window_bounds; 635 gfx::Rect window_bounds;
750 bool maximized = false;
751 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 636 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
752 gfx::Rect(984, 10, 500, 400), false, gfx::Rect(), 637 gfx::Rect(984, 10, 500, 400), gfx::Rect(), LAST_ACTIVE,
753 LAST_ACTIVE, &window_bounds, &maximized); 638 &window_bounds);
754 EXPECT_FALSE(maximized);
755 EXPECT_EQ(gfx::Rect(994, 10 + kWindowTilePixels, 500, 400), window_bounds); 639 EXPECT_EQ(gfx::Rect(994, 10 + kWindowTilePixels, 500, 400), window_bounds);
756 } 640 }
757 641
758 { // offset would put the new window offscreen at the right and the minimum 642 { // offset would put the new window offscreen at the right and the minimum
759 // visibility condition is satisified by relocation. 643 // visibility condition is satisified by relocation.
760 gfx::Rect window_bounds; 644 gfx::Rect window_bounds;
761 bool maximized = false;
762 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 645 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
763 gfx::Rect(985, 10, 500, 400), false, gfx::Rect(), 646 gfx::Rect(985, 10, 500, 400), gfx::Rect(), LAST_ACTIVE,
764 LAST_ACTIVE, &window_bounds, &maximized); 647 &window_bounds);
765 EXPECT_FALSE(maximized);
766 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 10 + kWindowTilePixels, 648 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 10 + kWindowTilePixels,
767 500, 400), window_bounds); 649 500, 400), window_bounds);
768 } 650 }
769 651
770 { // offset would put the new window offscreen at the bottom right and the 652 { // offset would put the new window offscreen at the bottom right and the
771 // minimum visibility condition is satisified by relocation. 653 // minimum visibility condition is satisified by relocation.
772 gfx::Rect window_bounds; 654 gfx::Rect window_bounds;
773 bool maximized = false;
774 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 655 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
775 gfx::Rect(985, 729, 500, 400), false, gfx::Rect(), 656 gfx::Rect(985, 729, 500, 400), gfx::Rect(), LAST_ACTIVE,
776 LAST_ACTIVE, &window_bounds, &maximized); 657 &window_bounds);
777 EXPECT_FALSE(maximized);
778 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 738 /* not 739 */, 500, 400), 658 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 738 /* not 739 */, 500, 400),
779 window_bounds); 659 window_bounds);
780 } 660 }
781 #endif // !defined(OS_POSIX) || defined(OS_MACOSX) 661 #endif // !defined(OS_POSIX) || defined(OS_MACOSX)
782 } 662 }
783 663
784 TEST(WindowSizerTest, PersistedWindowOffscreenWithNonAggressiveRepositioning) { 664 TEST(WindowSizerTest, PersistedWindowOffscreenWithNonAggressiveRepositioning) {
785 { // off the left but the minimum visibility condition is barely satisfied 665 { // off the left but the minimum visibility condition is barely satisfied
786 // without relocaiton. 666 // without relocaiton.
787 gfx::Rect initial_bounds(-470, 50, 500, 400); 667 gfx::Rect initial_bounds(-470, 50, 500, 400);
788 668
789 gfx::Rect window_bounds; 669 gfx::Rect window_bounds;
790 bool maximized;
791 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 670 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
792 initial_bounds, false, gfx::Rect(), PERSISTED, 671 initial_bounds, gfx::Rect(), PERSISTED,
793 &window_bounds, &maximized); 672 &window_bounds);
794 EXPECT_FALSE(maximized);
795 EXPECT_EQ(initial_bounds, window_bounds); 673 EXPECT_EQ(initial_bounds, window_bounds);
796 } 674 }
797 675
798 { // off the left and the minimum visibility condition is satisfied by 676 { // off the left and the minimum visibility condition is satisfied by
799 // relocation. 677 // relocation.
800 gfx::Rect window_bounds; 678 gfx::Rect window_bounds;
801 bool maximized;
802 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 679 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
803 gfx::Rect(-471, 50, 500, 400), false, gfx::Rect(), 680 gfx::Rect(-471, 50, 500, 400), gfx::Rect(), PERSISTED,
804 PERSISTED, &window_bounds, &maximized); 681 &window_bounds);
805 EXPECT_FALSE(maximized);
806 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 50, 500, 400), window_bounds); 682 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 50, 500, 400), window_bounds);
807 } 683 }
808 684
809 { // off the top 685 { // off the top
810 gfx::Rect initial_bounds(50, -370, 500, 400); 686 gfx::Rect initial_bounds(50, -370, 500, 400);
811 687
812 gfx::Rect window_bounds; 688 gfx::Rect window_bounds;
813 bool maximized;
814 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 689 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
815 gfx::Rect(50, -370, 500, 400), false, gfx::Rect(), 690 gfx::Rect(50, -370, 500, 400), gfx::Rect(), PERSISTED,
816 PERSISTED, &window_bounds, &maximized); 691 &window_bounds);
817 EXPECT_FALSE(maximized);
818 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); 692 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds);
819 } 693 }
820 694
821 { // off the right but the minimum visibility condition is barely satisified 695 { // off the right but the minimum visibility condition is barely satisified
822 // without relocation. 696 // without relocation.
823 gfx::Rect initial_bounds(994, 50, 500, 400); 697 gfx::Rect initial_bounds(994, 50, 500, 400);
824 698
825 gfx::Rect window_bounds; 699 gfx::Rect window_bounds;
826 bool maximized;
827 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 700 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
828 initial_bounds, false, gfx::Rect(), PERSISTED, 701 initial_bounds, gfx::Rect(), PERSISTED,
829 &window_bounds, &maximized); 702 &window_bounds);
830 EXPECT_FALSE(maximized);
831 EXPECT_EQ(initial_bounds, window_bounds); 703 EXPECT_EQ(initial_bounds, window_bounds);
832 } 704 }
833 705
834 { // off the right and the minimum visibility condition is satisified by 706 { // off the right and the minimum visibility condition is satisified by
835 // relocation. 707 // relocation.
836 gfx::Rect window_bounds; 708 gfx::Rect window_bounds;
837 bool maximized;
838 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 709 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
839 gfx::Rect(995, 50, 500, 400), false, gfx::Rect(), 710 gfx::Rect(995, 50, 500, 400), gfx::Rect(), PERSISTED,
840 PERSISTED, &window_bounds, &maximized); 711 &window_bounds);
841 EXPECT_FALSE(maximized);
842 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 50, 500, 400), window_bounds); 712 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 50, 500, 400), window_bounds);
843 } 713 }
844 714
845 { // off the bottom but the minimum visibility condition is barely satisified 715 { // off the bottom but the minimum visibility condition is barely satisified
846 // without relocation. 716 // without relocation.
847 gfx::Rect initial_bounds(50, 738, 500, 400); 717 gfx::Rect initial_bounds(50, 738, 500, 400);
848 718
849 gfx::Rect window_bounds; 719 gfx::Rect window_bounds;
850 bool maximized;
851 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 720 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
852 initial_bounds, false, gfx::Rect(), PERSISTED, 721 initial_bounds, gfx::Rect(), PERSISTED,
853 &window_bounds, &maximized); 722 &window_bounds);
854 EXPECT_FALSE(maximized);
855 EXPECT_EQ(initial_bounds, window_bounds); 723 EXPECT_EQ(initial_bounds, window_bounds);
856 } 724 }
857 725
858 { // off the bottom and the minimum visibility condition is satisified by 726 { // off the bottom and the minimum visibility condition is satisified by
859 // relocation. 727 // relocation.
860 gfx::Rect window_bounds; 728 gfx::Rect window_bounds;
861 bool maximized;
862 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 729 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
863 gfx::Rect(50, 739, 500, 400), false, gfx::Rect(), PERSISTED, 730 gfx::Rect(50, 739, 500, 400), gfx::Rect(), PERSISTED,
864 &window_bounds, &maximized); 731 &window_bounds);
865 EXPECT_FALSE(maximized);
866 EXPECT_EQ(gfx::Rect(50, 738 /* not 739 */, 500, 400), window_bounds); 732 EXPECT_EQ(gfx::Rect(50, 738 /* not 739 */, 500, 400), window_bounds);
867 } 733 }
868 734
869 { // off the topleft 735 { // off the topleft
870 gfx::Rect window_bounds; 736 gfx::Rect window_bounds;
871 bool maximized;
872 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 737 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
873 gfx::Rect(-471, -371, 500, 400), false, gfx::Rect(), 738 gfx::Rect(-471, -371, 500, 400), gfx::Rect(), PERSISTED,
874 PERSISTED, &window_bounds, &maximized); 739 &window_bounds);
875 EXPECT_FALSE(maximized);
876 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 0, 500, 400), 740 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 0, 500, 400),
877 window_bounds); 741 window_bounds);
878 } 742 }
879 743
880 { // off the topright and the minimum visibility condition is satisified by 744 { // off the topright and the minimum visibility condition is satisified by
881 // relocation. 745 // relocation.
882 gfx::Rect window_bounds; 746 gfx::Rect window_bounds;
883 bool maximized;
884 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 747 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
885 gfx::Rect(995, -371, 500, 400), false, gfx::Rect(), 748 gfx::Rect(995, -371, 500, 400), gfx::Rect(), PERSISTED,
886 PERSISTED, &window_bounds, &maximized); 749 &window_bounds);
887 EXPECT_FALSE(maximized);
888 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 0, 500, 400), 750 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 0, 500, 400),
889 window_bounds); 751 window_bounds);
890 } 752 }
891 753
892 { // off the bottomleft and the minimum visibility condition is satisified by 754 { // off the bottomleft and the minimum visibility condition is satisified by
893 // relocation. 755 // relocation.
894 gfx::Rect window_bounds; 756 gfx::Rect window_bounds;
895 bool maximized;
896 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 757 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
897 gfx::Rect(-471, 739, 500, 400), false, gfx::Rect(), 758 gfx::Rect(-471, 739, 500, 400), gfx::Rect(), PERSISTED,
898 PERSISTED, &window_bounds, &maximized); 759 &window_bounds);
899 EXPECT_FALSE(maximized);
900 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 738 /* not 739 */, 500, 400), 760 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 738 /* not 739 */, 500, 400),
901 window_bounds); 761 window_bounds);
902 } 762 }
903 763
904 { // off the bottomright and the minimum visibility condition is satisified by 764 { // off the bottomright and the minimum visibility condition is satisified by
905 // relocation. 765 // relocation.
906 gfx::Rect window_bounds; 766 gfx::Rect window_bounds;
907 bool maximized;
908 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 767 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
909 gfx::Rect(995, 739, 500, 400), false, gfx::Rect(), 768 gfx::Rect(995, 739, 500, 400), gfx::Rect(), PERSISTED,
910 PERSISTED, &window_bounds, &maximized); 769 &window_bounds);
911 EXPECT_FALSE(maximized);
912 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 738 /* not 739 */, 500, 400), 770 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 738 /* not 739 */, 500, 400),
913 window_bounds); 771 window_bounds);
914 } 772 }
915 773
916 { // entirely off left 774 { // entirely off left
917 gfx::Rect window_bounds; 775 gfx::Rect window_bounds;
918 bool maximized;
919 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 776 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
920 gfx::Rect(-700, 50, 500, 400), false, gfx::Rect(), 777 gfx::Rect(-700, 50, 500, 400), gfx::Rect(), PERSISTED,
921 PERSISTED, &window_bounds, &maximized); 778 &window_bounds);
922 EXPECT_FALSE(maximized);
923 EXPECT_EQ(gfx::Rect(-470 /* not -700 */, 50, 500, 400), window_bounds); 779 EXPECT_EQ(gfx::Rect(-470 /* not -700 */, 50, 500, 400), window_bounds);
924 } 780 }
925 781
926 { // entirely off left (monitor was detached since last run) 782 { // entirely off left (monitor was detached since last run)
927 gfx::Rect window_bounds; 783 gfx::Rect window_bounds;
928 bool maximized;
929 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 784 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
930 gfx::Rect(-700, 50, 500, 400), false, left_nonprimary, 785 gfx::Rect(-700, 50, 500, 400), left_nonprimary, PERSISTED,
931 PERSISTED, &window_bounds, &maximized); 786 &window_bounds);
932 EXPECT_FALSE(maximized);
933 EXPECT_EQ(gfx::Rect(0, 50, 500, 400), window_bounds); 787 EXPECT_EQ(gfx::Rect(0, 50, 500, 400), window_bounds);
934 } 788 }
935 789
936 { // entirely off top 790 { // entirely off top
937 gfx::Rect window_bounds; 791 gfx::Rect window_bounds;
938 bool maximized;
939 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 792 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
940 gfx::Rect(50, -500, 500, 400), false, gfx::Rect(), 793 gfx::Rect(50, -500, 500, 400), gfx::Rect(), PERSISTED,
941 PERSISTED, &window_bounds, &maximized); 794 &window_bounds);
942 EXPECT_FALSE(maximized);
943 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); 795 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds);
944 } 796 }
945 797
946 { // entirely off top (monitor was detached since last run) 798 { // entirely off top (monitor was detached since last run)
947 gfx::Rect window_bounds; 799 gfx::Rect window_bounds;
948 bool maximized;
949 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 800 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
950 gfx::Rect(50, -500, 500, 400), false, top_nonprimary, 801 gfx::Rect(50, -500, 500, 400), top_nonprimary,
951 PERSISTED, &window_bounds, &maximized); 802 PERSISTED, &window_bounds);
952 EXPECT_FALSE(maximized);
953 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); 803 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds);
954 } 804 }
955 805
956 { // entirely off right 806 { // entirely off right
957 gfx::Rect window_bounds; 807 gfx::Rect window_bounds;
958 bool maximized;
959 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 808 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
960 gfx::Rect(1200, 50, 500, 400), false, gfx::Rect(), 809 gfx::Rect(1200, 50, 500, 400), gfx::Rect(), PERSISTED,
961 PERSISTED, &window_bounds, &maximized); 810 &window_bounds);
962 EXPECT_FALSE(maximized);
963 EXPECT_EQ(gfx::Rect(994 /* not 1200 */, 50, 500, 400), window_bounds); 811 EXPECT_EQ(gfx::Rect(994 /* not 1200 */, 50, 500, 400), window_bounds);
964 } 812 }
965 813
966 { // entirely off right (monitor was detached since last run) 814 { // entirely off right (monitor was detached since last run)
967 gfx::Rect window_bounds; 815 gfx::Rect window_bounds;
968 bool maximized;
969 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 816 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
970 gfx::Rect(1200, 50, 500, 400), false, right_nonprimary, 817 gfx::Rect(1200, 50, 500, 400), right_nonprimary,
971 PERSISTED, &window_bounds, &maximized); 818 PERSISTED, &window_bounds);
972 EXPECT_FALSE(maximized);
973 EXPECT_EQ(gfx::Rect(524, 50, 500, 400), window_bounds); 819 EXPECT_EQ(gfx::Rect(524, 50, 500, 400), window_bounds);
974 } 820 }
975 821
976 { // entirely off bottom 822 { // entirely off bottom
977 gfx::Rect window_bounds; 823 gfx::Rect window_bounds;
978 bool maximized;
979 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 824 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
980 gfx::Rect(50, 800, 500, 400), false, gfx::Rect(), PERSISTED, 825 gfx::Rect(50, 800, 500, 400), gfx::Rect(), PERSISTED,
981 &window_bounds, &maximized); 826 &window_bounds);
982 EXPECT_FALSE(maximized);
983 EXPECT_EQ(gfx::Rect(50, 738 /* not 800 */, 500, 400), window_bounds); 827 EXPECT_EQ(gfx::Rect(50, 738 /* not 800 */, 500, 400), window_bounds);
984 } 828 }
985 829
986 { // entirely off bottom (monitor was detached since last run) 830 { // entirely off bottom (monitor was detached since last run)
987 gfx::Rect window_bounds; 831 gfx::Rect window_bounds;
988 bool maximized;
989 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 832 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
990 gfx::Rect(50, 800, 500, 400), false, bottom_nonprimary, 833 gfx::Rect(50, 800, 500, 400), bottom_nonprimary,
991 PERSISTED, &window_bounds, &maximized); 834 PERSISTED, &window_bounds);
992 EXPECT_FALSE(maximized);
993 EXPECT_EQ(gfx::Rect(50, 368, 500, 400), window_bounds); 835 EXPECT_EQ(gfx::Rect(50, 368, 500, 400), window_bounds);
994 } 836 }
995 } 837 }
996 #endif //defined(OS_MACOSX) 838 #endif //defined(OS_MACOSX)
OLDNEW
« no previous file with comments | « chrome/browser/ui/window_sizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698