| 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 "ash/common/wallpaper/wallpaper_controller.h" | 5 #include "ash/common/wallpaper/wallpaper_controller.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <cstdlib> | 8 #include <cstdlib> |
| 9 | 9 |
| 10 #include "ash/common/wallpaper/wallpaper_view.h" | 10 #include "ash/common/wallpaper/wallpaper_view.h" |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 | 341 |
| 342 EXPECT_TRUE(root_window_controller->wallpaper_widget_controller()); | 342 EXPECT_TRUE(root_window_controller->wallpaper_widget_controller()); |
| 343 EXPECT_FALSE(root_window_controller->animating_wallpaper_widget_controller() | 343 EXPECT_FALSE(root_window_controller->animating_wallpaper_widget_controller() |
| 344 ->GetController(false)); | 344 ->GetController(false)); |
| 345 // The wallpaper controller should be the last created animating controller. | 345 // The wallpaper controller should be the last created animating controller. |
| 346 EXPECT_EQ(animating_controller, | 346 EXPECT_EQ(animating_controller, |
| 347 root_window_controller->wallpaper_widget_controller()); | 347 root_window_controller->wallpaper_widget_controller()); |
| 348 } | 348 } |
| 349 | 349 |
| 350 TEST_F(WallpaperControllerTest, ResizeCustomWallpaper) { | 350 TEST_F(WallpaperControllerTest, ResizeCustomWallpaper) { |
| 351 if (!SupportsMultipleDisplays()) | |
| 352 return; | |
| 353 | |
| 354 UpdateDisplay("320x200"); | 351 UpdateDisplay("320x200"); |
| 355 | 352 |
| 356 gfx::ImageSkia image = CreateImage(640, 480, kCustomWallpaperColor); | 353 gfx::ImageSkia image = CreateImage(640, 480, kCustomWallpaperColor); |
| 357 | 354 |
| 358 // Set the image as custom wallpaper, wait for the resize to finish, and check | 355 // Set the image as custom wallpaper, wait for the resize to finish, and check |
| 359 // that the resized image is the expected size. | 356 // that the resized image is the expected size. |
| 360 controller_->SetWallpaperImage(image, WALLPAPER_LAYOUT_STRETCH); | 357 controller_->SetWallpaperImage(image, WALLPAPER_LAYOUT_STRETCH); |
| 361 EXPECT_TRUE(image.BackedBySameObjectAs(controller_->GetWallpaper())); | 358 EXPECT_TRUE(image.BackedBySameObjectAs(controller_->GetWallpaper())); |
| 362 RunAllBlockingPoolTasksUntilIdle(WmShell::Get()->blocking_pool().get()); | 359 RunAllBlockingPoolTasksUntilIdle(WmShell::Get()->blocking_pool().get()); |
| 363 gfx::ImageSkia resized_image = controller_->GetWallpaper(); | 360 gfx::ImageSkia resized_image = controller_->GetWallpaper(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 381 // Rotated display should return the rotated size. | 378 // Rotated display should return the rotated size. |
| 382 UpdateDisplay("1000x300*2/r"); | 379 UpdateDisplay("1000x300*2/r"); |
| 383 EXPECT_EQ("300x1000", | 380 EXPECT_EQ("300x1000", |
| 384 WallpaperController::GetMaxDisplaySizeInNative().ToString()); | 381 WallpaperController::GetMaxDisplaySizeInNative().ToString()); |
| 385 | 382 |
| 386 // UI Scaling shouldn't affect the native size. | 383 // UI Scaling shouldn't affect the native size. |
| 387 UpdateDisplay("1000x300*2@1.5"); | 384 UpdateDisplay("1000x300*2@1.5"); |
| 388 EXPECT_EQ("1000x300", | 385 EXPECT_EQ("1000x300", |
| 389 WallpaperController::GetMaxDisplaySizeInNative().ToString()); | 386 WallpaperController::GetMaxDisplaySizeInNative().ToString()); |
| 390 | 387 |
| 391 if (!SupportsMultipleDisplays()) | |
| 392 return; | |
| 393 | |
| 394 // First display has maximum size. | 388 // First display has maximum size. |
| 395 UpdateDisplay("400x300,100x100"); | 389 UpdateDisplay("400x300,100x100"); |
| 396 EXPECT_EQ("400x300", | 390 EXPECT_EQ("400x300", |
| 397 WallpaperController::GetMaxDisplaySizeInNative().ToString()); | 391 WallpaperController::GetMaxDisplaySizeInNative().ToString()); |
| 398 | 392 |
| 399 // Second display has maximum size. | 393 // Second display has maximum size. |
| 400 UpdateDisplay("400x300,500x600"); | 394 UpdateDisplay("400x300,500x600"); |
| 401 EXPECT_EQ("500x600", | 395 EXPECT_EQ("500x600", |
| 402 WallpaperController::GetMaxDisplaySizeInNative().ToString()); | 396 WallpaperController::GetMaxDisplaySizeInNative().ToString()); |
| 403 | 397 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 { | 461 { |
| 468 SCOPED_TRACE(base::StringPrintf("1200x600/u@1.5 low resolution")); | 462 SCOPED_TRACE(base::StringPrintf("1200x600/u@1.5 low resolution")); |
| 469 controller_->SetWallpaperImage(image_low_res, WALLPAPER_LAYOUT_CENTER); | 463 controller_->SetWallpaperImage(image_low_res, WALLPAPER_LAYOUT_CENTER); |
| 470 WallpaperFitToNativeResolution( | 464 WallpaperFitToNativeResolution( |
| 471 wallpaper_view(), low_dsf, low_resolution.width(), | 465 wallpaper_view(), low_dsf, low_resolution.width(), |
| 472 low_resolution.height(), kCustomWallpaperColor); | 466 low_resolution.height(), kCustomWallpaperColor); |
| 473 } | 467 } |
| 474 } | 468 } |
| 475 | 469 |
| 476 } // namespace ash | 470 } // namespace ash |
| OLD | NEW |