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

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

Issue 115180: Change the window bounds adjusting algorithm to restore... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <vector> 5 #include <vector>
6 6
7 #include "chrome/browser/window_sizer.h" 7 #include "chrome/browser/window_sizer.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 GetWindowBounds(nineteentwenty, nineteentwenty, gfx::Rect(), gfx::Rect(), 245 GetWindowBounds(nineteentwenty, nineteentwenty, gfx::Rect(), gfx::Rect(),
246 false, DEFAULT, &window_bounds, &maximized); 246 false, DEFAULT, &window_bounds, &maximized);
247 EXPECT_FALSE(maximized); 247 EXPECT_FALSE(maximized);
248 EXPECT_EQ(gfx::Rect(10, 10, 930, 1180), window_bounds); 248 EXPECT_EQ(gfx::Rect(10, 10, 930, 1180), window_bounds);
249 } 249 }
250 } 250 }
251 251
252 // Test that the next opened window is positioned appropriately given the 252 // Test that the next opened window is positioned appropriately given the
253 // bounds of an existing window of the same type. 253 // bounds of an existing window of the same type.
254 TEST(WindowSizerTest, LastWindowBoundsCase) { 254 TEST(WindowSizerTest, LastWindowBoundsCase) {
255
256 { // normal, in the middle of the screen somewhere. 255 { // normal, in the middle of the screen somewhere.
257 gfx::Rect window_bounds; 256 gfx::Rect window_bounds;
258 bool maximized = false; 257 bool maximized = false;
259 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 258 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
260 gfx::Rect(10, 10, 500, 400), false, LAST_ACTIVE, 259 gfx::Rect(10, 10, 500, 400), false, LAST_ACTIVE,
261 &window_bounds, &maximized); 260 &window_bounds, &maximized);
262 EXPECT_FALSE(maximized); 261 EXPECT_FALSE(maximized);
263 EXPECT_EQ(gfx::Rect(20, 20, 500, 400), window_bounds); 262 EXPECT_EQ(gfx::Rect(20, 20, 500, 400), window_bounds);
264 } 263 }
265 264
265 { // too small to satisify the minimum visibility condition.
266 gfx::Rect window_bounds;
267 bool maximized = false;
268 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
269 gfx::Rect(10, 10, 29, 29), false, LAST_ACTIVE,
270 &window_bounds, &maximized);
271 EXPECT_FALSE(maximized);
272 EXPECT_EQ(gfx::Rect(20, 20, 30 /* not 29 */, 30 /* not 29 */),
273 window_bounds);
274 }
275
276
266 { // normal, but maximized 277 { // normal, but maximized
267 gfx::Rect window_bounds; 278 gfx::Rect window_bounds;
268 bool maximized = false; 279 bool maximized = false;
269 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 280 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
270 gfx::Rect(10, 10, 500, 400), true, LAST_ACTIVE, 281 gfx::Rect(10, 10, 500, 400), true, LAST_ACTIVE,
271 &window_bounds, &maximized); 282 &window_bounds, &maximized);
272 EXPECT_FALSE(maximized); 283 EXPECT_FALSE(maximized);
273 EXPECT_EQ(gfx::Rect(20, 20, 500, 400), window_bounds); 284 EXPECT_EQ(gfx::Rect(20, 20, 500, 400), window_bounds);
274 } 285 }
275 286
276 { // offset would put the new window offscreen at the bottom 287 { // offset would put the new window offscreen at the bottom but the minimum
288 // visibility condition is barely satisfied without relocation.
277 gfx::Rect window_bounds; 289 gfx::Rect window_bounds;
278 bool maximized = false; 290 bool maximized = false;
279 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 291 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
280 gfx::Rect(10, 360, 500, 400), false, LAST_ACTIVE, 292 gfx::Rect(10, 728, 500, 400), false, LAST_ACTIVE,
281 &window_bounds, &maximized); 293 &window_bounds, &maximized);
282 EXPECT_FALSE(maximized); 294 EXPECT_FALSE(maximized);
283 EXPECT_EQ(gfx::Rect(20, 358, 500, 400), window_bounds); 295 EXPECT_EQ(gfx::Rect(20, 738, 500, 400), window_bounds);
284 } 296 }
285 297
286 { // offset would put the new window offscreen at the right 298 { // offset would put the new window offscreen at the bottom and the minimum
299 // visibility condition is satisified by relocation.
287 gfx::Rect window_bounds; 300 gfx::Rect window_bounds;
288 bool maximized = false; 301 bool maximized = false;
289 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 302 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
290 gfx::Rect(520, 10, 500, 400), false, LAST_ACTIVE, 303 gfx::Rect(10, 729, 500, 400), false, LAST_ACTIVE,
291 &window_bounds, &maximized); 304 &window_bounds, &maximized);
292 EXPECT_FALSE(maximized); 305 EXPECT_FALSE(maximized);
293 EXPECT_EQ(gfx::Rect(514, 20, 500, 400), window_bounds); 306 EXPECT_EQ(gfx::Rect(20, 738 /* not 739 */, 500, 400), window_bounds);
294 } 307 }
295 308
296 { // offset would put the new window offscreen at the bottom right 309 { // offset would put the new window offscreen at the right but the minimum
310 // visibility condition is barely satisfied without relocation.
297 gfx::Rect window_bounds; 311 gfx::Rect window_bounds;
298 bool maximized = false; 312 bool maximized = false;
299 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 313 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
300 gfx::Rect(520, 360, 500, 400), false, LAST_ACTIVE, 314 gfx::Rect(984, 10, 500, 400), false, LAST_ACTIVE,
301 &window_bounds, &maximized); 315 &window_bounds, &maximized);
302 EXPECT_FALSE(maximized); 316 EXPECT_FALSE(maximized);
303 EXPECT_EQ(gfx::Rect(514, 358, 500, 400), window_bounds); 317 EXPECT_EQ(gfx::Rect(994, 20, 500, 400), window_bounds);
318 }
319
320 { // offset would put the new window offscreen at the right and the minimum
321 // visibility condition is satisified by relocation.
322 gfx::Rect window_bounds;
323 bool maximized = false;
324 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
325 gfx::Rect(985, 10, 500, 400), false, LAST_ACTIVE,
326 &window_bounds, &maximized);
327 EXPECT_FALSE(maximized);
328 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 20, 500, 400), window_bounds);
329 }
330
331 { // offset would put the new window offscreen at the bottom right and the
332 // minimum visibility condition is satisified by relocation.
333 gfx::Rect window_bounds;
334 bool maximized = false;
335 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
336 gfx::Rect(985, 729, 500, 400), false, LAST_ACTIVE,
337 &window_bounds, &maximized);
338 EXPECT_FALSE(maximized);
339 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 738 /* not 739 */, 500, 400),
340 window_bounds);
304 } 341 }
305 } 342 }
306 343
307 // Test that the window opened is sized appropriately given persisted sizes. 344 // Test that the window opened is sized appropriately given persisted sizes.
308 TEST(WindowSizerTest, PersistedBoundsCase) { 345 TEST(WindowSizerTest, PersistedBoundsCase) {
309 346
310 { // normal, in the middle of the screen somewhere. 347 { // normal, in the middle of the screen somewhere.
311 gfx::Rect initial_bounds(10, 10, 500, 400); 348 gfx::Rect initial_bounds(10, 10, 500, 400);
312 349
313 gfx::Rect window_bounds; 350 gfx::Rect window_bounds;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 383
347 gfx::Rect window_bounds; 384 gfx::Rect window_bounds;
348 bool maximized; 385 bool maximized;
349 GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary, 386 GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary,
350 initial_bounds, true, PERSISTED, &window_bounds, 387 initial_bounds, true, PERSISTED, &window_bounds,
351 &maximized); 388 &maximized);
352 EXPECT_TRUE(maximized); 389 EXPECT_TRUE(maximized);
353 EXPECT_EQ(initial_bounds, window_bounds); 390 EXPECT_EQ(initial_bounds, window_bounds);
354 } 391 }
355 392
356 { // a little off the left 393 { // off the left but the minimum visibility condition is barely satisfied
394 // without relocaiton.
395 gfx::Rect initial_bounds(-470, 50, 500, 400);
396
357 gfx::Rect window_bounds; 397 gfx::Rect window_bounds;
358 bool maximized; 398 bool maximized;
359 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 399 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
360 gfx::Rect(-10, 50, 500, 400), false, PERSISTED, 400 initial_bounds, false, PERSISTED,
361 &window_bounds, &maximized); 401 &window_bounds, &maximized);
362 EXPECT_FALSE(maximized); 402 EXPECT_FALSE(maximized);
363 EXPECT_EQ(gfx::Rect(10, 50, 500, 400), window_bounds);
364 }
365
366 { // a little off the top
367 gfx::Rect window_bounds;
368 bool maximized;
369 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
370 gfx::Rect(50, -10, 500, 400), false, PERSISTED,
371 &window_bounds, &maximized);
372 EXPECT_FALSE(maximized);
373 EXPECT_EQ(gfx::Rect(50, 10, 500, 400), window_bounds);
374 }
375
376 { // a little off the right
377 gfx::Rect window_bounds;
378 bool maximized;
379 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
380 gfx::Rect(534, 50, 500, 400), false, PERSISTED,
381 &window_bounds, &maximized);
382 EXPECT_FALSE(maximized);
383 EXPECT_EQ(gfx::Rect(514, 50, 500, 400), window_bounds);
384 }
385
386 { // a little off the bottom
387 gfx::Rect window_bounds;
388 bool maximized;
389 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
390 gfx::Rect(50, 378, 500, 400), false, PERSISTED,
391 &window_bounds, &maximized);
392 EXPECT_FALSE(maximized);
393 EXPECT_EQ(gfx::Rect(50, 358, 500, 400), window_bounds);
394 }
395
396 { // a little off the topleft
397 gfx::Rect window_bounds;
398 bool maximized;
399 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
400 gfx::Rect(-10, -10, 500, 400), false, PERSISTED,
401 &window_bounds, &maximized);
402 EXPECT_FALSE(maximized);
403 EXPECT_EQ(gfx::Rect(10, 10, 500, 400), window_bounds);
404 }
405
406 { // a little off the topright
407 gfx::Rect window_bounds;
408 bool maximized;
409 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
410 gfx::Rect(534, -10, 500, 400), false, PERSISTED,
411 &window_bounds, &maximized);
412 EXPECT_FALSE(maximized);
413 EXPECT_EQ(gfx::Rect(514, 10, 500, 400), window_bounds);
414 }
415
416 { // a little off the bottomleft
417 gfx::Rect window_bounds;
418 bool maximized;
419 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
420 gfx::Rect(-10, 378, 500, 400), false, PERSISTED,
421 &window_bounds, &maximized);
422 EXPECT_FALSE(maximized);
423 EXPECT_EQ(gfx::Rect(10, 358, 500, 400), window_bounds);
424 }
425
426 { // a little off the bottomright
427 gfx::Rect window_bounds;
428 bool maximized;
429 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
430 gfx::Rect(534, 378, 500, 400), false, PERSISTED,
431 &window_bounds, &maximized);
432 EXPECT_FALSE(maximized);
433 EXPECT_EQ(gfx::Rect(514, 358, 500, 400), window_bounds);
434 }
435
436 { // split across two, bias right
437 gfx::Rect initial_bounds(-50, 50, 500, 400);
438 gfx::Rect window_bounds;
439 bool maximized;
440 GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary,
441 initial_bounds, false, PERSISTED, &window_bounds,
442 &maximized);
443 EXPECT_FALSE(maximized);
444 EXPECT_EQ(initial_bounds, window_bounds);
445
446 initial_bounds.Offset(tentwentyfour.width(), 0);
447 GetWindowBounds(tentwentyfour, tentwentyfour, right_nonprimary,
448 initial_bounds, false, PERSISTED, &window_bounds,
449 &maximized);
450 EXPECT_FALSE(maximized);
451 EXPECT_EQ(initial_bounds, window_bounds); 403 EXPECT_EQ(initial_bounds, window_bounds);
452 } 404 }
453 405
454 { // split across two, bias left 406 { // off the left and the minimum visibility condition is satisfied by
455 gfx::Rect initial_bounds(-450, 50, 500, 400); 407 // relocation.
456 gfx::Rect window_bounds; 408 gfx::Rect window_bounds;
457 bool maximized; 409 bool maximized;
458 GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary, 410 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
459 initial_bounds, false, PERSISTED, &window_bounds, 411 gfx::Rect(-471, 50, 500, 400), false, PERSISTED,
460 &maximized); 412 &window_bounds, &maximized);
461 EXPECT_FALSE(maximized); 413 EXPECT_FALSE(maximized);
462 EXPECT_EQ(initial_bounds, window_bounds); 414 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 50, 500, 400), window_bounds);
415 }
463 416
464 initial_bounds.Offset(tentwentyfour.width(), 0); 417 { // off the top but the minimum visibility condition is barely satisified
465 GetWindowBounds(tentwentyfour, tentwentyfour, right_nonprimary, 418 // without relocation.
466 initial_bounds, false, PERSISTED, &window_bounds, 419 gfx::Rect initial_bounds(50, -370, 500, 400);
467 &maximized); 420
421 gfx::Rect window_bounds;
422 bool maximized;
423 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
424 initial_bounds, false, PERSISTED,
425 &window_bounds, &maximized);
468 EXPECT_FALSE(maximized); 426 EXPECT_FALSE(maximized);
469 EXPECT_EQ(initial_bounds, window_bounds); 427 EXPECT_EQ(initial_bounds, window_bounds);
470 } 428 }
471 429
472 { // split across two, a little off left 430 { // off the top and the minimum visibility condition is satisified by
431 // relocation.
473 gfx::Rect window_bounds; 432 gfx::Rect window_bounds;
474 bool maximized; 433 bool maximized;
475 GetWindowBounds(tentwentyfour, tentwentyfour, top_nonprimary, 434 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
476 gfx::Rect(-50, -50, 500, 400), false, PERSISTED, 435 gfx::Rect(50, -371, 500, 400), false, PERSISTED,
477 &window_bounds, &maximized); 436 &window_bounds, &maximized);
478 EXPECT_FALSE(maximized); 437 EXPECT_FALSE(maximized);
479 EXPECT_EQ(gfx::Rect(10, -50, 500, 400), window_bounds); 438 EXPECT_EQ(gfx::Rect(50, -370 /* not -371 */, 500, 400), window_bounds);
480 } 439 }
481 440
482 { // split across two, a little off right 441 { // off the right but the minimum visibility condition is barely satisified
442 // without relocation.
443 gfx::Rect initial_bounds(994, 50, 500, 400);
444
483 gfx::Rect window_bounds; 445 gfx::Rect window_bounds;
484 bool maximized; 446 bool maximized;
485 GetWindowBounds(tentwentyfour, tentwentyfour, top_nonprimary, 447 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
486 gfx::Rect(534, -50, 500, 400), false, PERSISTED, 448 initial_bounds, false, PERSISTED,
487 &window_bounds, &maximized); 449 &window_bounds, &maximized);
488 EXPECT_FALSE(maximized); 450 EXPECT_FALSE(maximized);
489 EXPECT_EQ(gfx::Rect(514, -50, 500, 400), window_bounds); 451 EXPECT_EQ(initial_bounds, window_bounds);
490 } 452 }
491 453
492 { // split across two, a little off top 454 { // off the right and the minimum visibility condition is satisified by
455 // relocation.
493 gfx::Rect window_bounds; 456 gfx::Rect window_bounds;
494 bool maximized; 457 bool maximized;
495 GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary, 458 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
496 gfx::Rect(-50, -50, 500, 400), false, PERSISTED, 459 gfx::Rect(995, 50, 500, 400), false, PERSISTED,
497 &window_bounds, &maximized); 460 &window_bounds, &maximized);
498 EXPECT_FALSE(maximized); 461 EXPECT_FALSE(maximized);
499 EXPECT_EQ(gfx::Rect(-50, 10, 500, 400), window_bounds); 462 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 50, 500, 400), window_bounds);
500 } 463 }
501 464
502 { // split across two, a little off bottom 465 { // off the bottom but the minimum visibility condition is barely satisified
466 // without relocation.
467 gfx::Rect initial_bounds(50, 738, 500, 400);
468
503 gfx::Rect window_bounds; 469 gfx::Rect window_bounds;
504 bool maximized; 470 bool maximized;
505 GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary, 471 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
506 gfx::Rect(-50, 378, 500, 400), false, PERSISTED, 472 initial_bounds, false, PERSISTED,
507 &window_bounds, &maximized); 473 &window_bounds, &maximized);
508 EXPECT_FALSE(maximized); 474 EXPECT_FALSE(maximized);
509 EXPECT_EQ(gfx::Rect(-50, 358, 500, 400), window_bounds); 475 EXPECT_EQ(initial_bounds, window_bounds);
476 }
477
478 { // off the bottom and the minimum visibility condition is satisified by
479 // relocation.
480 gfx::Rect window_bounds;
481 bool maximized;
482 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
483 gfx::Rect(50, 739, 500, 400), false, PERSISTED,
484 &window_bounds, &maximized);
485 EXPECT_FALSE(maximized);
486 EXPECT_EQ(gfx::Rect(50, 738 /* not 739 */, 500, 400), window_bounds);
487 }
488
489 { // off the topleft and the minimum visibility condition is satisified by
490 // relocation.
491 gfx::Rect window_bounds;
492 bool maximized;
493 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
494 gfx::Rect(-471, -371, 500, 400), false, PERSISTED,
495 &window_bounds, &maximized);
496 EXPECT_FALSE(maximized);
497 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, -370 /* not -371 */, 500, 400),
498 window_bounds);
499 }
500
501 { // off the topright and the minimum visibility condition is satisified by
502 // relocation.
503 gfx::Rect window_bounds;
504 bool maximized;
505 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
506 gfx::Rect(995, -371, 500, 400), false, PERSISTED,
507 &window_bounds, &maximized);
508 EXPECT_FALSE(maximized);
509 EXPECT_EQ(gfx::Rect(994 /* not 995 */, -370 /* not -371 */, 500, 400),
510 window_bounds);
511 }
512
513 { // off the bottomleft and the minimum visibility condition is satisified by
514 // relocation.
515 gfx::Rect window_bounds;
516 bool maximized;
517 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
518 gfx::Rect(-471, 739, 500, 400), false, PERSISTED,
519 &window_bounds, &maximized);
520 EXPECT_FALSE(maximized);
521 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 738 /* not 739 */, 500, 400),
522 window_bounds);
523 }
524
525 { // off the bottomright and the minimum visibility condition is satisified by
526 // relocation.
527 gfx::Rect window_bounds;
528 bool maximized;
529 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
530 gfx::Rect(995, 739, 500, 400), false, PERSISTED,
531 &window_bounds, &maximized);
532 EXPECT_FALSE(maximized);
533 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 738 /* not 739 */, 500, 400),
534 window_bounds);
510 } 535 }
511 536
512 { // entirely off left (monitor was detached since last run) 537 { // entirely off left (monitor was detached since last run)
513 gfx::Rect window_bounds; 538 gfx::Rect window_bounds;
514 bool maximized; 539 bool maximized;
515 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 540 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
516 gfx::Rect(-700, 50, 500, 400), false, PERSISTED, 541 gfx::Rect(-700, 50, 500, 400), false, PERSISTED,
517 &window_bounds, &maximized); 542 &window_bounds, &maximized);
518 EXPECT_FALSE(maximized); 543 EXPECT_FALSE(maximized);
519 EXPECT_EQ(gfx::Rect(10, 50, 500, 400), window_bounds); 544 EXPECT_EQ(gfx::Rect(-470 /* not -700 */, 50, 500, 400), window_bounds);
520 } 545 }
521 546
522 { // entirely off top (monitor was detached since last run) 547 { // entirely off top (monitor was detached since last run)
523 gfx::Rect window_bounds; 548 gfx::Rect window_bounds;
524 bool maximized; 549 bool maximized;
525 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 550 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
526 gfx::Rect(50, -500, 500, 400), false, PERSISTED, 551 gfx::Rect(50, -500, 500, 400), false, PERSISTED,
527 &window_bounds, &maximized); 552 &window_bounds, &maximized);
528 EXPECT_FALSE(maximized); 553 EXPECT_FALSE(maximized);
529 EXPECT_EQ(gfx::Rect(50, 10, 500, 400), window_bounds); 554 EXPECT_EQ(gfx::Rect(50, -370 /* not -500 */, 500, 400), window_bounds);
530 } 555 }
531 556
532 { // entirely off right (monitor was detached since last run) 557 { // entirely off right (monitor was detached since last run)
533 gfx::Rect window_bounds; 558 gfx::Rect window_bounds;
534 bool maximized; 559 bool maximized;
535 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 560 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
536 gfx::Rect(1200, 50, 500, 400), false, PERSISTED, 561 gfx::Rect(1200, 50, 500, 400), false, PERSISTED,
537 &window_bounds, &maximized); 562 &window_bounds, &maximized);
538 EXPECT_FALSE(maximized); 563 EXPECT_FALSE(maximized);
539 EXPECT_EQ(gfx::Rect(514, 50, 500, 400), window_bounds); 564 EXPECT_EQ(gfx::Rect(994 /* not 1200 */, 50, 500, 400), window_bounds);
540 } 565 }
541 566
542 { // entirely off bottom (monitor was detached since last run) 567 { // entirely off bottom (monitor was detached since last run)
543 gfx::Rect window_bounds; 568 gfx::Rect window_bounds;
544 bool maximized; 569 bool maximized;
545 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 570 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
546 gfx::Rect(50, 800, 500, 400), false, PERSISTED, 571 gfx::Rect(50, 800, 500, 400), false, PERSISTED,
547 &window_bounds, &maximized); 572 &window_bounds, &maximized);
548 EXPECT_FALSE(maximized); 573 EXPECT_FALSE(maximized);
549 EXPECT_EQ(gfx::Rect(50, 358, 500, 400), window_bounds); 574 EXPECT_EQ(gfx::Rect(50, 738 /* not 800 */, 500, 400), window_bounds);
550 } 575 }
551 576
552 { // width and height too large (monitor screen resolution changed since last 577 { // width and height too small
553 // run)
554 gfx::Rect window_bounds; 578 gfx::Rect window_bounds;
555 bool maximized; 579 bool maximized;
556 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), 580 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(),
557 gfx::Rect(10, 10, 1200, 900), false, PERSISTED, 581 gfx::Rect(10, 10, 29, 29), false, PERSISTED,
558 &window_bounds, &maximized); 582 &window_bounds, &maximized);
559 EXPECT_FALSE(maximized); 583 EXPECT_FALSE(maximized);
560 EXPECT_EQ(gfx::Rect(10, 10, 1004, 748), window_bounds); 584 EXPECT_EQ(gfx::Rect(10, 10, 30 /* not 29 */, 30 /* not 29 */),
561 } 585 window_bounds);
562
563 { // Handles taskbar offset on the top.
564 gfx::Rect initial_bounds(10, 10, 500, 400);
565
566 gfx::Rect window_bounds;
567 bool maximized;
568 GetWindowBounds(tentwentyfour, taskbar_top_work_area, gfx::Rect(),
569 initial_bounds, false, PERSISTED, &window_bounds,
570 &maximized);
571 EXPECT_FALSE(maximized);
572 initial_bounds.Offset(taskbar_top_work_area.x(), taskbar_top_work_area.y());
573 EXPECT_EQ(initial_bounds, window_bounds);
574 }
575
576 { // Handles taskbar offset on the left.
577 gfx::Rect initial_bounds(10, 10, 500, 400);
578
579 gfx::Rect window_bounds;
580 bool maximized;
581 GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(),
582 initial_bounds, false, PERSISTED, &window_bounds,
583 &maximized);
584 EXPECT_FALSE(maximized);
585 initial_bounds.Offset(taskbar_left_work_area.x(),
586 taskbar_left_work_area.y());
587 EXPECT_EQ(initial_bounds, window_bounds);
588 } 586 }
589 } 587 }
OLDNEW
« no previous file with comments | « chrome/browser/window_sizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698