| 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/window_sizer.h" | 5 #include "chrome/browser/ui/window_sizer/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/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // it. | 58 // it. |
| 59 class TestBrowserWindowAura : public TestBrowserWindow { | 59 class TestBrowserWindowAura : public TestBrowserWindow { |
| 60 public: | 60 public: |
| 61 explicit TestBrowserWindowAura(aura::Window* native_window); | 61 explicit TestBrowserWindowAura(aura::Window* native_window); |
| 62 virtual ~TestBrowserWindowAura(); | 62 virtual ~TestBrowserWindowAura(); |
| 63 | 63 |
| 64 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE { | 64 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE { |
| 65 return native_window_; | 65 return native_window_; |
| 66 } | 66 } |
| 67 | 67 |
| 68 virtual gfx::Rect GetBounds() const { |
| 69 return native_window_->bounds(); |
| 70 } |
| 71 |
| 68 private: | 72 private: |
| 69 gfx::NativeWindow native_window_; | 73 gfx::NativeWindow native_window_; |
| 70 | 74 |
| 71 DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowAura); | 75 DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowAura); |
| 72 }; | 76 }; |
| 73 | 77 |
| 74 } // namespace | 78 } // namespace |
| 75 | 79 |
| 76 TestBrowserWindowAura::TestBrowserWindowAura(aura::Window *native_window) | 80 TestBrowserWindowAura::TestBrowserWindowAura(aura::Window *native_window) |
| 77 : native_window_(native_window) { | 81 : native_window_(native_window) { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 TEST_F(WindowSizerTest, LastWindowBoundsCase) { | 216 TEST_F(WindowSizerTest, LastWindowBoundsCase) { |
| 213 { // normal, in the middle of the screen somewhere. | 217 { // normal, in the middle of the screen somewhere. |
| 214 gfx::Rect window_bounds; | 218 gfx::Rect window_bounds; |
| 215 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 219 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 216 gfx::Rect(WindowSizer::kDesktopBorderSize, | 220 gfx::Rect(WindowSizer::kDesktopBorderSize, |
| 217 WindowSizer::kDesktopBorderSize, 500, 400), | 221 WindowSizer::kDesktopBorderSize, 500, 400), |
| 218 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL, | 222 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL, |
| 219 gfx::Rect()); | 223 gfx::Rect()); |
| 220 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 224 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
| 221 kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 225 kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
| 222 500, 400), | 226 500, 400).ToString(), |
| 223 window_bounds); | 227 window_bounds.ToString()); |
| 224 } | 228 } |
| 225 | 229 |
| 226 { // taskbar on top. | 230 { // taskbar on top. |
| 227 gfx::Rect window_bounds; | 231 gfx::Rect window_bounds; |
| 228 GetWindowBounds(tentwentyfour, taskbar_top_work_area, gfx::Rect(), | 232 GetWindowBounds(tentwentyfour, taskbar_top_work_area, gfx::Rect(), |
| 229 gfx::Rect(WindowSizer::kDesktopBorderSize, | 233 gfx::Rect(WindowSizer::kDesktopBorderSize, |
| 230 WindowSizer::kDesktopBorderSize, 500, 400), | 234 WindowSizer::kDesktopBorderSize, 500, 400), |
| 231 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL, | 235 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL, |
| 232 gfx::Rect()); | 236 gfx::Rect()); |
| 233 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 237 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
| 234 std::max(kWindowTilePixels + | 238 std::max(kWindowTilePixels + |
| 235 WindowSizer::kDesktopBorderSize, | 239 WindowSizer::kDesktopBorderSize, |
| 236 34 /* toolbar height */), | 240 34 /* toolbar height */), |
| 237 500, 400), window_bounds); | 241 500, 400).ToString(), window_bounds.ToString()); |
| 238 } | 242 } |
| 239 | 243 |
| 240 { // Too small to satisify the minimum visibility condition. | 244 { // Too small to satisify the minimum visibility condition. |
| 241 gfx::Rect window_bounds; | 245 gfx::Rect window_bounds; |
| 242 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 246 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 243 gfx::Rect(WindowSizer::kDesktopBorderSize, | 247 gfx::Rect(WindowSizer::kDesktopBorderSize, |
| 244 WindowSizer::kDesktopBorderSize, 29, 29), | 248 WindowSizer::kDesktopBorderSize, 29, 29), |
| 245 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL, | 249 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL, |
| 246 gfx::Rect()); | 250 gfx::Rect()); |
| 247 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 251 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
| 248 kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 252 kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
| 249 30 /* not 29 */, | 253 30 /* not 29 */, |
| 250 30 /* not 29 */), | 254 30 /* not 29 */).ToString(), |
| 251 window_bounds); | 255 window_bounds.ToString()); |
| 252 } | 256 } |
| 253 | 257 |
| 254 | 258 |
| 255 { // Normal. | 259 { // Normal. |
| 256 gfx::Rect window_bounds; | 260 gfx::Rect window_bounds; |
| 257 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 261 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 258 gfx::Rect(WindowSizer::kDesktopBorderSize, | 262 gfx::Rect(WindowSizer::kDesktopBorderSize, |
| 259 WindowSizer::kDesktopBorderSize, 500, 400), | 263 WindowSizer::kDesktopBorderSize, 500, 400), |
| 260 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL, | 264 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL, |
| 261 gfx::Rect()); | 265 gfx::Rect()); |
| 262 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 266 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
| 263 kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 267 kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
| 264 500, 400), | 268 500, 400).ToString(), |
| 265 window_bounds); | 269 window_bounds.ToString()); |
| 266 } | 270 } |
| 267 } | 271 } |
| 268 | 272 |
| 269 // Test that the window opened is sized appropriately given persisted sizes. | 273 // Test that the window opened is sized appropriately given persisted sizes. |
| 270 TEST_F(WindowSizerTest, PersistedBoundsCase) { | 274 TEST_F(WindowSizerTest, PersistedBoundsCase) { |
| 271 { // normal, in the middle of the screen somewhere. | 275 { // normal, in the middle of the screen somewhere. |
| 272 gfx::Rect initial_bounds(WindowSizer::kDesktopBorderSize, | 276 gfx::Rect initial_bounds(WindowSizer::kDesktopBorderSize, |
| 273 WindowSizer::kDesktopBorderSize, 500, 400); | 277 WindowSizer::kDesktopBorderSize, 500, 400); |
| 274 | 278 |
| 275 gfx::Rect window_bounds; | 279 gfx::Rect window_bounds; |
| 276 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), initial_bounds, | 280 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), initial_bounds, |
| 277 gfx::Rect(), PERSISTED, &window_bounds, NULL, gfx::Rect()); | 281 gfx::Rect(), PERSISTED, &window_bounds, NULL, gfx::Rect()); |
| 278 EXPECT_EQ(initial_bounds, window_bounds); | 282 EXPECT_EQ(initial_bounds.ToString(), window_bounds.ToString()); |
| 279 } | 283 } |
| 280 | 284 |
| 281 { // Normal. | 285 { // Normal. |
| 282 gfx::Rect initial_bounds(0, 0, 1024, 768); | 286 gfx::Rect initial_bounds(0, 0, 1024, 768); |
| 283 | 287 |
| 284 gfx::Rect window_bounds; | 288 gfx::Rect window_bounds; |
| 285 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), initial_bounds, | 289 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), initial_bounds, |
| 286 gfx::Rect(), PERSISTED, &window_bounds, NULL, gfx::Rect()); | 290 gfx::Rect(), PERSISTED, &window_bounds, NULL, gfx::Rect()); |
| 287 EXPECT_EQ(initial_bounds, window_bounds); | 291 EXPECT_EQ(initial_bounds.ToString(), window_bounds.ToString()); |
| 288 } | 292 } |
| 289 | 293 |
| 290 { // normal, on non-primary monitor in negative coords. | 294 { // normal, on non-primary monitor in negative coords. |
| 291 gfx::Rect initial_bounds(-600, 10, 500, 400); | 295 gfx::Rect initial_bounds(-600, 10, 500, 400); |
| 292 | 296 |
| 293 gfx::Rect window_bounds; | 297 gfx::Rect window_bounds; |
| 294 GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary, | 298 GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary, |
| 295 initial_bounds, gfx::Rect(), PERSISTED, &window_bounds, | 299 initial_bounds, gfx::Rect(), PERSISTED, &window_bounds, |
| 296 NULL, gfx::Rect()); | 300 NULL, gfx::Rect()); |
| 297 EXPECT_EQ(initial_bounds, window_bounds); | 301 EXPECT_EQ(initial_bounds.ToString(), window_bounds.ToString()); |
| 298 } | 302 } |
| 299 | 303 |
| 300 { // normal, on non-primary monitor in negative coords. | 304 { // normal, on non-primary monitor in negative coords. |
| 301 gfx::Rect initial_bounds(-1024, 0, 1024, 768); | 305 gfx::Rect initial_bounds(-1024, 0, 1024, 768); |
| 302 | 306 |
| 303 gfx::Rect window_bounds; | 307 gfx::Rect window_bounds; |
| 304 GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary, | 308 GetWindowBounds(tentwentyfour, tentwentyfour, left_nonprimary, |
| 305 initial_bounds, gfx::Rect(), PERSISTED, &window_bounds, | 309 initial_bounds, gfx::Rect(), PERSISTED, &window_bounds, |
| 306 NULL, gfx::Rect()); | 310 NULL, gfx::Rect()); |
| 307 EXPECT_EQ(initial_bounds, window_bounds); | 311 EXPECT_EQ(initial_bounds.ToString(), window_bounds.ToString()); |
| 308 } | 312 } |
| 309 | 313 |
| 310 { // Non-primary monitor resoultion has changed, but the monitor still | 314 { // Non-primary monitor resoultion has changed, but the monitor still |
| 311 // completely contains the window. | 315 // completely contains the window. |
| 312 | 316 |
| 313 gfx::Rect initial_bounds(1074, 50, 600, 500); | 317 gfx::Rect initial_bounds(1074, 50, 600, 500); |
| 314 | 318 |
| 315 gfx::Rect window_bounds; | 319 gfx::Rect window_bounds; |
| 316 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600), | 320 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600), |
| 317 initial_bounds, right_nonprimary, PERSISTED, | 321 initial_bounds, right_nonprimary, PERSISTED, |
| 318 &window_bounds, NULL, gfx::Rect()); | 322 &window_bounds, NULL, gfx::Rect()); |
| 319 EXPECT_EQ(initial_bounds, window_bounds); | 323 EXPECT_EQ(initial_bounds.ToString(), window_bounds.ToString()); |
| 320 } | 324 } |
| 321 | 325 |
| 322 { // Non-primary monitor resoultion has changed, and the window is partially | 326 { // Non-primary monitor resoultion has changed, and the window is partially |
| 323 // off-screen. | 327 // off-screen. |
| 324 | 328 |
| 325 gfx::Rect initial_bounds(1274, 50, 600, 500); | 329 gfx::Rect initial_bounds(1274, 50, 600, 500); |
| 326 | 330 |
| 327 gfx::Rect window_bounds; | 331 gfx::Rect window_bounds; |
| 328 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600), | 332 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600), |
| 329 initial_bounds, right_nonprimary, PERSISTED, | 333 initial_bounds, right_nonprimary, PERSISTED, |
| 330 &window_bounds, NULL, gfx::Rect()); | 334 &window_bounds, NULL, gfx::Rect()); |
| 331 EXPECT_EQ(gfx::Rect(1224, 50, 600, 500), window_bounds); | 335 EXPECT_EQ("1224,50 600x500", window_bounds.ToString()); |
| 332 } | 336 } |
| 333 | 337 |
| 334 { // Non-primary monitor resoultion has changed, and the window is now too | 338 { // Non-primary monitor resoultion has changed, and the window is now too |
| 335 // large for the monitor. | 339 // large for the monitor. |
| 336 | 340 |
| 337 gfx::Rect initial_bounds(1274, 50, 900, 700); | 341 gfx::Rect initial_bounds(1274, 50, 900, 700); |
| 338 | 342 |
| 339 gfx::Rect window_bounds; | 343 gfx::Rect window_bounds; |
| 340 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600), | 344 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(1024, 0, 800, 600), |
| 341 initial_bounds, right_nonprimary, PERSISTED, | 345 initial_bounds, right_nonprimary, PERSISTED, |
| 342 &window_bounds, NULL, gfx::Rect()); | 346 &window_bounds, NULL, gfx::Rect()); |
| 343 EXPECT_EQ(gfx::Rect(1024, 0, 800, 600), window_bounds); | 347 EXPECT_EQ("1024,0 800x600", window_bounds.ToString()); |
| 344 } | 348 } |
| 345 | 349 |
| 346 { // width and height too small | 350 { // width and height too small |
| 347 gfx::Rect window_bounds; | 351 gfx::Rect window_bounds; |
| 348 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 352 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 349 gfx::Rect(WindowSizer::kDesktopBorderSize, | 353 gfx::Rect(WindowSizer::kDesktopBorderSize, |
| 350 WindowSizer::kDesktopBorderSize, 29, 29), | 354 WindowSizer::kDesktopBorderSize, 29, 29), |
| 351 gfx::Rect(), PERSISTED, &window_bounds, NULL, gfx::Rect()); | 355 gfx::Rect(), PERSISTED, &window_bounds, NULL, gfx::Rect()); |
| 352 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, | 356 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, |
| 353 WindowSizer::kDesktopBorderSize, | 357 WindowSizer::kDesktopBorderSize, |
| 354 30 /* not 29 */, 30 /* not 29 */), | 358 30 /* not 29 */, 30 /* not 29 */).ToString(), |
| 355 window_bounds); | 359 window_bounds.ToString()); |
| 356 } | 360 } |
| 357 } | 361 } |
| 358 | 362 |
| 359 ////////////////////////////////////////////////////////////////////////////// | 363 ////////////////////////////////////////////////////////////////////////////// |
| 360 // The following unittests have different results on Mac/non-Mac because we | 364 // The following unittests have different results on Mac/non-Mac because we |
| 361 // reposition windows aggressively on Mac. The *WithAggressiveReposition tests | 365 // reposition windows aggressively on Mac. The *WithAggressiveReposition tests |
| 362 // are run on Mac, and the *WithNonAggressiveRepositioning tests are run on | 366 // are run on Mac, and the *WithNonAggressiveRepositioning tests are run on |
| 363 // other platforms. | 367 // other platforms. |
| 364 | 368 |
| 365 TEST_F(WindowSizerTest, LastWindowOffscreenWithNonAggressiveRepositioning) { | 369 TEST_F(WindowSizerTest, LastWindowOffscreenWithNonAggressiveRepositioning) { |
| 366 { // taskbar on left. | 370 { // taskbar on left. |
| 367 gfx::Rect window_bounds; | 371 gfx::Rect window_bounds; |
| 368 GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(), | 372 GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(), |
| 369 gfx::Rect(WindowSizer::kDesktopBorderSize, | 373 gfx::Rect(WindowSizer::kDesktopBorderSize, |
| 370 WindowSizer::kDesktopBorderSize, 500, 400), | 374 WindowSizer::kDesktopBorderSize, 500, 400), |
| 371 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL, | 375 gfx::Rect(), LAST_ACTIVE, &window_bounds, NULL, |
| 372 gfx::Rect()); | 376 gfx::Rect()); |
| 373 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 377 EXPECT_EQ(gfx::Rect(kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
| 374 kWindowTilePixels + WindowSizer::kDesktopBorderSize, | 378 kWindowTilePixels + WindowSizer::kDesktopBorderSize, |
| 375 500, 400), | 379 500, 400).ToString(), |
| 376 window_bounds); | 380 window_bounds.ToString()); |
| 377 } | 381 } |
| 378 | 382 |
| 379 { // offset would put the new window offscreen at the bottom but the minimum | 383 { // offset would put the new window offscreen at the bottom but the minimum |
| 380 // visibility condition is barely satisfied without relocation. | 384 // visibility condition is barely satisfied without relocation. |
| 381 gfx::Rect window_bounds; | 385 gfx::Rect window_bounds; |
| 382 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 386 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 383 gfx::Rect(10, 728, 500, 400), gfx::Rect(), LAST_ACTIVE, | 387 gfx::Rect(10, 728, 500, 400), gfx::Rect(), LAST_ACTIVE, |
| 384 &window_bounds, NULL, gfx::Rect()); | 388 &window_bounds, NULL, gfx::Rect()); |
| 385 EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 738, | 389 EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 738, 500, 400).ToString(), |
| 386 500, 400), window_bounds); | 390 window_bounds.ToString()); |
| 387 } | 391 } |
| 388 | 392 |
| 389 { // offset would put the new window offscreen at the bottom and the minimum | 393 { // offset would put the new window offscreen at the bottom and the minimum |
| 390 // visibility condition is satisified by relocation. | 394 // visibility condition is satisified by relocation. |
| 391 gfx::Rect window_bounds; | 395 gfx::Rect window_bounds; |
| 392 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 396 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 393 gfx::Rect(10, 729, 500, 400), gfx::Rect(), LAST_ACTIVE, | 397 gfx::Rect(10, 729, 500, 400), gfx::Rect(), LAST_ACTIVE, |
| 394 &window_bounds, NULL, gfx::Rect()); | 398 &window_bounds, NULL, gfx::Rect()); |
| 395 EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 738 /* not 739 */, 500, 400), | 399 EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, |
| 396 window_bounds); | 400 738 /* not 739 */, |
| 401 500, |
| 402 400).ToString(), |
| 403 window_bounds.ToString()); |
| 397 } | 404 } |
| 398 | 405 |
| 399 { // offset would put the new window offscreen at the right but the minimum | 406 { // offset would put the new window offscreen at the right but the minimum |
| 400 // visibility condition is barely satisfied without relocation. | 407 // visibility condition is barely satisfied without relocation. |
| 401 gfx::Rect window_bounds; | 408 gfx::Rect window_bounds; |
| 402 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 409 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 403 gfx::Rect(984, 10, 500, 400), gfx::Rect(), LAST_ACTIVE, | 410 gfx::Rect(984, 10, 500, 400), gfx::Rect(), LAST_ACTIVE, |
| 404 &window_bounds, NULL, gfx::Rect()); | 411 &window_bounds, NULL, gfx::Rect()); |
| 405 EXPECT_EQ(gfx::Rect(994, 10 + kWindowTilePixels, 500, 400), window_bounds); | 412 EXPECT_EQ(gfx::Rect(994, 10 + kWindowTilePixels, 500, 400).ToString(), |
| 413 window_bounds.ToString()); |
| 406 } | 414 } |
| 407 | 415 |
| 408 { // offset would put the new window offscreen at the right and the minimum | 416 { // offset would put the new window offscreen at the right and the minimum |
| 409 // visibility condition is satisified by relocation. | 417 // visibility condition is satisified by relocation. |
| 410 gfx::Rect window_bounds; | 418 gfx::Rect window_bounds; |
| 411 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 419 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 412 gfx::Rect(985, 10, 500, 400), gfx::Rect(), LAST_ACTIVE, | 420 gfx::Rect(985, 10, 500, 400), gfx::Rect(), LAST_ACTIVE, |
| 413 &window_bounds, NULL, gfx::Rect()); | 421 &window_bounds, NULL, gfx::Rect()); |
| 414 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 10 + kWindowTilePixels, | 422 EXPECT_EQ(gfx::Rect(994 /* not 995 */, |
| 415 500, 400), window_bounds); | 423 10 + kWindowTilePixels, |
| 424 500, |
| 425 400).ToString(), |
| 426 window_bounds.ToString()); |
| 416 } | 427 } |
| 417 | 428 |
| 418 { // offset would put the new window offscreen at the bottom right and the | 429 { // offset would put the new window offscreen at the bottom right and the |
| 419 // minimum visibility condition is satisified by relocation. | 430 // minimum visibility condition is satisified by relocation. |
| 420 gfx::Rect window_bounds; | 431 gfx::Rect window_bounds; |
| 421 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 432 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 422 gfx::Rect(985, 729, 500, 400), gfx::Rect(), LAST_ACTIVE, | 433 gfx::Rect(985, 729, 500, 400), gfx::Rect(), LAST_ACTIVE, |
| 423 &window_bounds, NULL, gfx::Rect()); | 434 &window_bounds, NULL, gfx::Rect()); |
| 424 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 738 /* not 739 */, 500, 400), | 435 EXPECT_EQ(gfx::Rect(994 /* not 995 */, |
| 425 window_bounds); | 436 738 /* not 739 */, |
| 437 500, |
| 438 400).ToString(), |
| 439 window_bounds.ToString()); |
| 426 } | 440 } |
| 427 } | 441 } |
| 428 | 442 |
| 429 TEST_F(WindowSizerTest, | 443 TEST_F(WindowSizerTest, |
| 430 PersistedWindowOffscreenWithNonAggressiveRepositioning) { | 444 PersistedWindowOffscreenWithNonAggressiveRepositioning) { |
| 431 { // off the left but the minimum visibility condition is barely satisfied | 445 { // off the left but the minimum visibility condition is barely satisfied |
| 432 // without relocaiton. | 446 // without relocaiton. |
| 433 gfx::Rect initial_bounds(-470, 50, 500, 400); | 447 gfx::Rect initial_bounds(-470, 50, 500, 400); |
| 434 | 448 |
| 435 gfx::Rect window_bounds; | 449 gfx::Rect window_bounds; |
| 436 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 450 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 437 initial_bounds, gfx::Rect(), PERSISTED, | 451 initial_bounds, gfx::Rect(), PERSISTED, |
| 438 &window_bounds, NULL, gfx::Rect()); | 452 &window_bounds, NULL, gfx::Rect()); |
| 439 EXPECT_EQ(initial_bounds, window_bounds); | 453 EXPECT_EQ(initial_bounds.ToString(), window_bounds.ToString()); |
| 440 } | 454 } |
| 441 | 455 |
| 442 { // off the left and the minimum visibility condition is satisfied by | 456 { // off the left and the minimum visibility condition is satisfied by |
| 443 // relocation. | 457 // relocation. |
| 444 gfx::Rect window_bounds; | 458 gfx::Rect window_bounds; |
| 445 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 459 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 446 gfx::Rect(-471, 50, 500, 400), gfx::Rect(), PERSISTED, | 460 gfx::Rect(-471, 50, 500, 400), gfx::Rect(), PERSISTED, |
| 447 &window_bounds, NULL, gfx::Rect()); | 461 &window_bounds, NULL, gfx::Rect()); |
| 448 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 50, 500, 400), window_bounds); | 462 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 50, 500, 400).ToString(), |
| 463 window_bounds.ToString()); |
| 449 } | 464 } |
| 450 | 465 |
| 451 { // off the top | 466 { // off the top |
| 452 gfx::Rect initial_bounds(50, -370, 500, 400); | 467 gfx::Rect initial_bounds(50, -370, 500, 400); |
| 453 | 468 |
| 454 gfx::Rect window_bounds; | 469 gfx::Rect window_bounds; |
| 455 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 470 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 456 gfx::Rect(50, -370, 500, 400), gfx::Rect(), PERSISTED, | 471 gfx::Rect(50, -370, 500, 400), gfx::Rect(), PERSISTED, |
| 457 &window_bounds, NULL, gfx::Rect()); | 472 &window_bounds, NULL, gfx::Rect()); |
| 458 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); | 473 EXPECT_EQ("50,0 500x400", window_bounds.ToString()); |
| 459 } | 474 } |
| 460 | 475 |
| 461 { // off the right but the minimum visibility condition is barely satisified | 476 { // off the right but the minimum visibility condition is barely satisified |
| 462 // without relocation. | 477 // without relocation. |
| 463 gfx::Rect initial_bounds(994, 50, 500, 400); | 478 gfx::Rect initial_bounds(994, 50, 500, 400); |
| 464 | 479 |
| 465 gfx::Rect window_bounds; | 480 gfx::Rect window_bounds; |
| 466 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 481 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 467 initial_bounds, gfx::Rect(), PERSISTED, | 482 initial_bounds, gfx::Rect(), PERSISTED, |
| 468 &window_bounds, NULL, gfx::Rect()); | 483 &window_bounds, NULL, gfx::Rect()); |
| 469 EXPECT_EQ(initial_bounds, window_bounds); | 484 EXPECT_EQ(initial_bounds.ToString(), window_bounds.ToString()); |
| 470 } | 485 } |
| 471 | 486 |
| 472 { // off the right and the minimum visibility condition is satisified by | 487 { // off the right and the minimum visibility condition is satisified by |
| 473 // relocation. | 488 // relocation. |
| 474 gfx::Rect window_bounds; | 489 gfx::Rect window_bounds; |
| 475 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 490 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 476 gfx::Rect(995, 50, 500, 400), gfx::Rect(), PERSISTED, | 491 gfx::Rect(995, 50, 500, 400), gfx::Rect(), PERSISTED, |
| 477 &window_bounds, NULL, gfx::Rect()); | 492 &window_bounds, NULL, gfx::Rect()); |
| 478 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 50, 500, 400), window_bounds); | 493 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 50, 500, 400).ToString(), |
| 494 window_bounds.ToString()); |
| 479 } | 495 } |
| 480 | 496 |
| 481 { // off the bottom but the minimum visibility condition is barely satisified | 497 { // off the bottom but the minimum visibility condition is barely satisified |
| 482 // without relocation. | 498 // without relocation. |
| 483 gfx::Rect initial_bounds(50, 738, 500, 400); | 499 gfx::Rect initial_bounds(50, 738, 500, 400); |
| 484 | 500 |
| 485 gfx::Rect window_bounds; | 501 gfx::Rect window_bounds; |
| 486 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 502 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 487 initial_bounds, gfx::Rect(), PERSISTED, | 503 initial_bounds, gfx::Rect(), PERSISTED, |
| 488 &window_bounds, NULL, gfx::Rect()); | 504 &window_bounds, NULL, gfx::Rect()); |
| 489 EXPECT_EQ(initial_bounds, window_bounds); | 505 EXPECT_EQ(initial_bounds.ToString(), window_bounds.ToString()); |
| 490 } | 506 } |
| 491 | 507 |
| 492 { // off the bottom and the minimum visibility condition is satisified by | 508 { // off the bottom and the minimum visibility condition is satisified by |
| 493 // relocation. | 509 // relocation. |
| 494 gfx::Rect window_bounds; | 510 gfx::Rect window_bounds; |
| 495 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 511 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 496 gfx::Rect(50, 739, 500, 400), gfx::Rect(), PERSISTED, | 512 gfx::Rect(50, 739, 500, 400), gfx::Rect(), PERSISTED, |
| 497 &window_bounds, NULL, gfx::Rect()); | 513 &window_bounds, NULL, gfx::Rect()); |
| 498 EXPECT_EQ(gfx::Rect(50, 738 /* not 739 */, 500, 400), window_bounds); | 514 EXPECT_EQ(gfx::Rect(50, 738 /* not 739 */, 500, 400).ToString(), |
| 515 window_bounds.ToString()); |
| 499 } | 516 } |
| 500 | 517 |
| 501 { // off the topleft | 518 { // off the topleft |
| 502 gfx::Rect window_bounds; | 519 gfx::Rect window_bounds; |
| 503 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 520 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 504 gfx::Rect(-471, -371, 500, 400), gfx::Rect(), PERSISTED, | 521 gfx::Rect(-471, -371, 500, 400), gfx::Rect(), PERSISTED, |
| 505 &window_bounds, NULL, gfx::Rect()); | 522 &window_bounds, NULL, gfx::Rect()); |
| 506 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 0, 500, 400), | 523 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 0, 500, 400).ToString(), |
| 507 window_bounds); | 524 window_bounds.ToString()); |
| 508 } | 525 } |
| 509 | 526 |
| 510 { // off the topright and the minimum visibility condition is satisified by | 527 { // off the topright and the minimum visibility condition is satisified by |
| 511 // relocation. | 528 // relocation. |
| 512 gfx::Rect window_bounds; | 529 gfx::Rect window_bounds; |
| 513 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 530 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 514 gfx::Rect(995, -371, 500, 400), gfx::Rect(), PERSISTED, | 531 gfx::Rect(995, -371, 500, 400), gfx::Rect(), PERSISTED, |
| 515 &window_bounds, NULL, gfx::Rect()); | 532 &window_bounds, NULL, gfx::Rect()); |
| 516 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 0, 500, 400), | 533 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 0, 500, 400).ToString(), |
| 517 window_bounds); | 534 window_bounds.ToString()); |
| 518 } | 535 } |
| 519 | 536 |
| 520 { // off the bottomleft and the minimum visibility condition is satisified by | 537 { // off the bottomleft and the minimum visibility condition is satisified by |
| 521 // relocation. | 538 // relocation. |
| 522 gfx::Rect window_bounds; | 539 gfx::Rect window_bounds; |
| 523 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 540 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 524 gfx::Rect(-471, 739, 500, 400), gfx::Rect(), PERSISTED, | 541 gfx::Rect(-471, 739, 500, 400), gfx::Rect(), PERSISTED, |
| 525 &window_bounds, NULL, gfx::Rect()); | 542 &window_bounds, NULL, gfx::Rect()); |
| 526 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, 738 /* not 739 */, 500, 400), | 543 EXPECT_EQ(gfx::Rect(-470 /* not -471 */, |
| 527 window_bounds); | 544 738 /* not 739 */, |
| 545 500, |
| 546 400).ToString(), |
| 547 window_bounds.ToString()); |
| 528 } | 548 } |
| 529 | 549 |
| 530 { // off the bottomright and the minimum visibility condition is satisified by | 550 { // off the bottomright and the minimum visibility condition is satisified by |
| 531 // relocation. | 551 // relocation. |
| 532 gfx::Rect window_bounds; | 552 gfx::Rect window_bounds; |
| 533 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 553 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 534 gfx::Rect(995, 739, 500, 400), gfx::Rect(), PERSISTED, | 554 gfx::Rect(995, 739, 500, 400), gfx::Rect(), PERSISTED, |
| 535 &window_bounds, NULL, gfx::Rect()); | 555 &window_bounds, NULL, gfx::Rect()); |
| 536 EXPECT_EQ(gfx::Rect(994 /* not 995 */, 738 /* not 739 */, 500, 400), | 556 EXPECT_EQ(gfx::Rect(994 /* not 995 */, |
| 537 window_bounds); | 557 738 /* not 739 */, |
| 558 500, |
| 559 400).ToString(), |
| 560 window_bounds.ToString()); |
| 538 } | 561 } |
| 539 | 562 |
| 540 { // entirely off left | 563 { // entirely off left |
| 541 gfx::Rect window_bounds; | 564 gfx::Rect window_bounds; |
| 542 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 565 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 543 gfx::Rect(-700, 50, 500, 400), gfx::Rect(), PERSISTED, | 566 gfx::Rect(-700, 50, 500, 400), gfx::Rect(), PERSISTED, |
| 544 &window_bounds, NULL, gfx::Rect()); | 567 &window_bounds, NULL, gfx::Rect()); |
| 545 EXPECT_EQ(gfx::Rect(-470 /* not -700 */, 50, 500, 400), window_bounds); | 568 EXPECT_EQ(gfx::Rect(-470 /* not -700 */, 50, 500, 400).ToString(), |
| 569 window_bounds.ToString()); |
| 546 } | 570 } |
| 547 | 571 |
| 548 { // entirely off left (monitor was detached since last run) | 572 { // entirely off left (monitor was detached since last run) |
| 549 gfx::Rect window_bounds; | 573 gfx::Rect window_bounds; |
| 550 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 574 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 551 gfx::Rect(-700, 50, 500, 400), left_nonprimary, PERSISTED, | 575 gfx::Rect(-700, 50, 500, 400), left_nonprimary, PERSISTED, |
| 552 &window_bounds, NULL, gfx::Rect()); | 576 &window_bounds, NULL, gfx::Rect()); |
| 553 EXPECT_EQ(gfx::Rect(0, 50, 500, 400), window_bounds); | 577 EXPECT_EQ("0,50 500x400", window_bounds.ToString()); |
| 554 } | 578 } |
| 555 | 579 |
| 556 { // entirely off top | 580 { // entirely off top |
| 557 gfx::Rect window_bounds; | 581 gfx::Rect window_bounds; |
| 558 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 582 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 559 gfx::Rect(50, -500, 500, 400), gfx::Rect(), PERSISTED, | 583 gfx::Rect(50, -500, 500, 400), gfx::Rect(), PERSISTED, |
| 560 &window_bounds, NULL, gfx::Rect()); | 584 &window_bounds, NULL, gfx::Rect()); |
| 561 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); | 585 EXPECT_EQ("50,0 500x400", window_bounds.ToString()); |
| 562 } | 586 } |
| 563 | 587 |
| 564 { // entirely off top (monitor was detached since last run) | 588 { // entirely off top (monitor was detached since last run) |
| 565 gfx::Rect window_bounds; | 589 gfx::Rect window_bounds; |
| 566 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 590 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 567 gfx::Rect(50, -500, 500, 400), top_nonprimary, | 591 gfx::Rect(50, -500, 500, 400), top_nonprimary, |
| 568 PERSISTED, &window_bounds, NULL, gfx::Rect()); | 592 PERSISTED, &window_bounds, NULL, gfx::Rect()); |
| 569 EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds); | 593 EXPECT_EQ("50,0 500x400", window_bounds.ToString()); |
| 570 } | 594 } |
| 571 | 595 |
| 572 { // entirely off right | 596 { // entirely off right |
| 573 gfx::Rect window_bounds; | 597 gfx::Rect window_bounds; |
| 574 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 598 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 575 gfx::Rect(1200, 50, 500, 400), gfx::Rect(), PERSISTED, | 599 gfx::Rect(1200, 50, 500, 400), gfx::Rect(), PERSISTED, |
| 576 &window_bounds, NULL, gfx::Rect()); | 600 &window_bounds, NULL, gfx::Rect()); |
| 577 EXPECT_EQ(gfx::Rect(994 /* not 1200 */, 50, 500, 400), window_bounds); | 601 EXPECT_EQ(gfx::Rect(994 /* not 1200 */, 50, 500, 400).ToString(), |
| 602 window_bounds.ToString()); |
| 578 } | 603 } |
| 579 | 604 |
| 580 { // entirely off right (monitor was detached since last run) | 605 { // entirely off right (monitor was detached since last run) |
| 581 gfx::Rect window_bounds; | 606 gfx::Rect window_bounds; |
| 582 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 607 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 583 gfx::Rect(1200, 50, 500, 400), right_nonprimary, | 608 gfx::Rect(1200, 50, 500, 400), right_nonprimary, |
| 584 PERSISTED, &window_bounds, NULL, gfx::Rect()); | 609 PERSISTED, &window_bounds, NULL, gfx::Rect()); |
| 585 EXPECT_EQ(gfx::Rect(524, 50, 500, 400), window_bounds); | 610 EXPECT_EQ("524,50 500x400", window_bounds.ToString()); |
| 586 } | 611 } |
| 587 | 612 |
| 588 { // entirely off bottom | 613 { // entirely off bottom |
| 589 gfx::Rect window_bounds; | 614 gfx::Rect window_bounds; |
| 590 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 615 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 591 gfx::Rect(50, 800, 500, 400), gfx::Rect(), PERSISTED, | 616 gfx::Rect(50, 800, 500, 400), gfx::Rect(), PERSISTED, |
| 592 &window_bounds, NULL, gfx::Rect()); | 617 &window_bounds, NULL, gfx::Rect()); |
| 593 EXPECT_EQ(gfx::Rect(50, 738 /* not 800 */, 500, 400), window_bounds); | 618 EXPECT_EQ(gfx::Rect(50, 738 /* not 800 */, 500, 400).ToString(), |
| 619 window_bounds.ToString()); |
| 594 } | 620 } |
| 595 | 621 |
| 596 { // entirely off bottom (monitor was detached since last run) | 622 { // entirely off bottom (monitor was detached since last run) |
| 597 gfx::Rect window_bounds; | 623 gfx::Rect window_bounds; |
| 598 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 624 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 599 gfx::Rect(50, 800, 500, 400), bottom_nonprimary, | 625 gfx::Rect(50, 800, 500, 400), bottom_nonprimary, |
| 600 PERSISTED, &window_bounds, NULL, gfx::Rect()); | 626 PERSISTED, &window_bounds, NULL, gfx::Rect()); |
| 601 EXPECT_EQ(gfx::Rect(50, 368, 500, 400), window_bounds); | 627 EXPECT_EQ("50,368 500x400", window_bounds.ToString()); |
| 602 } | 628 } |
| 603 } | 629 } |
| 604 | 630 |
| 605 // Test that a newly created window gets positioned over a previously created | 631 // Test the placement of newly created windows. |
| 606 // window. | 632 TEST_F(WindowSizerTestWithBrowser, PlaceNewWindows) { |
| 607 TEST_F(WindowSizerTestWithBrowser, PlaceNewWindowOverOldWindow) { | |
| 608 // Create a dummy window. | 633 // Create a dummy window. |
| 609 scoped_ptr<aura::Window> window( | 634 scoped_ptr<aura::Window> window( |
| 610 aura::test::CreateTestWindowWithId(0, NULL)); | 635 aura::test::CreateTestWindowWithId(0, NULL)); |
| 611 window->SetBounds(gfx::Rect(16, 32, 640, 320)); | 636 window->SetBounds(gfx::Rect(16, 32, 640, 320)); |
| 612 | 637 |
| 613 scoped_ptr<aura::Window> popup( | 638 scoped_ptr<aura::Window> popup( |
| 614 aura::test::CreateTestWindowWithId(1, NULL)); | 639 aura::test::CreateTestWindowWithId(1, NULL)); |
| 615 popup->SetBounds(gfx::Rect(16, 32, 128, 256)); | 640 popup->SetBounds(gfx::Rect(16, 32, 128, 256)); |
| 616 | 641 |
| 617 scoped_ptr<aura::Window> panel( | 642 scoped_ptr<aura::Window> panel( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 647 Browser::CreateParams panel_params(Browser::TYPE_POPUP, profile.get()); | 672 Browser::CreateParams panel_params(Browser::TYPE_POPUP, profile.get()); |
| 648 panel_params.window = browser_panel.get(); | 673 panel_params.window = browser_panel.get(); |
| 649 scoped_ptr<Browser> panel_owning_browser(new Browser(panel_params)); | 674 scoped_ptr<Browser> panel_owning_browser(new Browser(panel_params)); |
| 650 | 675 |
| 651 window->Show(); | 676 window->Show(); |
| 652 { // With a shown window it's size should get returned. | 677 { // With a shown window it's size should get returned. |
| 653 gfx::Rect window_bounds; | 678 gfx::Rect window_bounds; |
| 654 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 679 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 655 gfx::Rect(50, 100, 300, 150), bottom_nonprimary, | 680 gfx::Rect(50, 100, 300, 150), bottom_nonprimary, |
| 656 PERSISTED, &window_bounds, browser.get(), gfx::Rect()); | 681 PERSISTED, &window_bounds, browser.get(), gfx::Rect()); |
| 657 EXPECT_EQ(gfx::Rect(16, 32, 640, 320), window_bounds); | 682 // The position should be right flush. |
| 683 EXPECT_EQ("384,32 640x320", window_bounds.ToString()); |
| 684 // In addition the other window should have moved left flush. |
| 685 EXPECT_EQ("0,32 640x320", window->bounds().ToString()); |
| 686 } |
| 687 |
| 688 { // With the window shown - but more on the right side then on the left |
| 689 // side (and partially out of the screen), it should default to the other |
| 690 // side and inside the screen. |
| 691 window->SetBounds(gfx::Rect(350, 600, 640, 320)); |
| 692 gfx::Rect window_bounds; |
| 693 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 694 gfx::Rect(50, 100, 300, 150), bottom_nonprimary, |
| 695 PERSISTED, &window_bounds, browser.get(), gfx::Rect()); |
| 696 // The position should be left & bottom flush. |
| 697 EXPECT_EQ("0,448 640x320", window_bounds.ToString()); |
| 698 // In addition the other window should have moved right flush. |
| 699 EXPECT_EQ("384,600 640x320", window->bounds().ToString()); |
| 700 } |
| 701 |
| 702 { // If the second windows right side is already over the right side of the |
| 703 // screen, it will not move back into the screen. |
| 704 window->SetBounds(gfx::Rect(1000, 600, 640, 320)); |
| 705 gfx::Rect window_bounds; |
| 706 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 707 gfx::Rect(50, 100, 300, 150), bottom_nonprimary, |
| 708 PERSISTED, &window_bounds, browser.get(), gfx::Rect()); |
| 709 // The position should be left & bottom flush. |
| 710 EXPECT_EQ("0,448 640x320", window_bounds.ToString()); |
| 711 // If the other window was already beyond the point to get right flush |
| 712 // it will remain where it is. |
| 713 EXPECT_EQ("1000,600 640x320", window->bounds().ToString()); |
| 658 } | 714 } |
| 659 | 715 |
| 660 { // Make sure that popups do not get changed. | 716 { // Make sure that popups do not get changed. |
| 661 gfx::Rect window_bounds; | 717 gfx::Rect window_bounds; |
| 662 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 718 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 663 gfx::Rect(50, 100, 300, 150), bottom_nonprimary, | 719 gfx::Rect(50, 100, 300, 150), bottom_nonprimary, |
| 664 PERSISTED, &window_bounds, popup_owning_browser.get(), | 720 PERSISTED, &window_bounds, popup_owning_browser.get(), |
| 665 gfx::Rect()); | 721 gfx::Rect()); |
| 666 EXPECT_EQ(gfx::Rect(50, 100, 300, 150), window_bounds); | 722 EXPECT_EQ("50,100 300x150", window_bounds.ToString()); |
| 667 } | 723 } |
| 668 | 724 |
| 669 window->SetBounds(gfx::Rect(816, 720, 640, 320)); | 725 window->Hide(); |
| 670 // Verifies newly created windows appear on screen. | 726 { // If a window is there but not shown the persisted default should be used. |
| 671 { | |
| 672 gfx::Rect window_bounds; | 727 gfx::Rect window_bounds; |
| 673 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 728 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 674 gfx::Rect(50, 100, 300, 150), bottom_nonprimary, | 729 gfx::Rect(50, 100, 300, 150), bottom_nonprimary, |
| 675 PERSISTED, &window_bounds, browser.get(), gfx::Rect()); | 730 PERSISTED, &window_bounds, browser.get(), gfx::Rect()); |
| 676 EXPECT_EQ("384,448 640x320", window_bounds.ToString()); | 731 EXPECT_EQ("50,100 300x150", window_bounds.ToString()); |
| 677 } | 732 } |
| 678 | 733 |
| 679 window->Hide(); | |
| 680 { // If a window is there but not shown the default should be returned. | 734 { // If a window is there but not shown the default should be returned. |
| 681 // The existing popup should not have any impact as well. | |
| 682 gfx::Rect window_bounds; | 735 gfx::Rect window_bounds; |
| 683 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), | 736 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |
| 684 gfx::Rect(50, 100, 300, 150), bottom_nonprimary, | 737 gfx::Rect(), bottom_nonprimary, |
| 685 PERSISTED, &window_bounds, browser.get(), gfx::Rect()); | 738 DEFAULT, &window_bounds, browser.get(), gfx::Rect()); |
| 686 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, | 739 EXPECT_EQ(gfx::Rect(WindowSizer::kDesktopBorderSize, |
| 687 WindowSizer::kDesktopBorderSize, | 740 WindowSizer::kDesktopBorderSize, |
| 688 1024 - 2 * WindowSizer::kDesktopBorderSize, | 741 1024 - 2 * WindowSizer::kDesktopBorderSize, |
| 689 768 - WindowSizer::kDesktopBorderSize), | 742 768 - WindowSizer::kDesktopBorderSize).ToString(), |
| 690 window_bounds); | 743 window_bounds.ToString()); |
| 691 } | 744 } |
| 692 } | 745 } |
| 693 | 746 |
| 694 // Test that the window is sized appropriately for the first run experience | 747 // Test that the window is sized appropriately for the first run experience |
| 695 // where the default window bounds calculation is invoked. | 748 // where the default window bounds calculation is invoked. |
| 696 TEST_F(WindowSizerTest, AdjustFitSize) { | 749 TEST_F(WindowSizerTest, AdjustFitSize) { |
| 697 { // Check that the window gets resized to the screen. | 750 { // Check that the window gets resized to the screen. |
| 698 gfx::Rect window_bounds; | 751 gfx::Rect window_bounds; |
| 699 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(), | 752 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(), |
| 700 gfx::Rect(), DEFAULT, &window_bounds, NULL, | 753 gfx::Rect(), DEFAULT, &window_bounds, NULL, |
| 701 gfx::Rect(-10, -10, 1024 + 20, 768 + 20)); | 754 gfx::Rect(-10, -10, 1024 + 20, 768 + 20)); |
| 702 EXPECT_EQ(gfx::Rect(0, 0, 1024, 768), window_bounds); | 755 EXPECT_EQ("0,0 1024x768", window_bounds.ToString()); |
| 703 } | 756 } |
| 704 | 757 |
| 705 { // Check that a window which hangs out of the screen get moved back in. | 758 { // Check that a window which hangs out of the screen get moved back in. |
| 706 gfx::Rect window_bounds; | 759 gfx::Rect window_bounds; |
| 707 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(), | 760 GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), gfx::Rect(), |
| 708 gfx::Rect(), DEFAULT, &window_bounds, NULL, | 761 gfx::Rect(), DEFAULT, &window_bounds, NULL, |
| 709 gfx::Rect(1020, 700, 100, 100)); | 762 gfx::Rect(1020, 700, 100, 100)); |
| 710 EXPECT_EQ(gfx::Rect(924, 668, 100, 100), window_bounds); | 763 EXPECT_EQ("924,668 100x100", window_bounds.ToString()); |
| 711 } | 764 } |
| 712 } | 765 } |
| OLD | NEW |