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/desktop_background/desktop_background_controller.h" | 5 #include "ash/desktop_background/desktop_background_controller.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <cstdlib> | 8 #include <cstdlib> |
9 | 9 |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 test::DisplayManagerTestApi display_manager_test_api( | 284 test::DisplayManagerTestApi display_manager_test_api( |
285 Shell::GetInstance()->display_manager()); | 285 Shell::GetInstance()->display_manager()); |
286 display_manager_test_api.UpdateDisplay("320x200"); | 286 display_manager_test_api.UpdateDisplay("320x200"); |
287 | 287 |
288 gfx::ImageSkia image = CreateImage(640, 480, kCustomWallpaperColor); | 288 gfx::ImageSkia image = CreateImage(640, 480, kCustomWallpaperColor); |
289 | 289 |
290 // Set the image as custom wallpaper, wait for the resize to finish, and check | 290 // Set the image as custom wallpaper, wait for the resize to finish, and check |
291 // that the resized image is the expected size. | 291 // that the resized image is the expected size. |
292 controller_->SetWallpaperImage(image, WALLPAPER_LAYOUT_STRETCH); | 292 controller_->SetWallpaperImage(image, WALLPAPER_LAYOUT_STRETCH); |
293 EXPECT_TRUE(image.BackedBySameObjectAs(controller_->GetWallpaper())); | 293 EXPECT_TRUE(image.BackedBySameObjectAs(controller_->GetWallpaper())); |
294 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 294 content::RunAllBlockingPoolTasksUntilIdle(); |
295 content::RunAllPendingInMessageLoop(); | |
296 gfx::ImageSkia resized_image = controller_->GetWallpaper(); | 295 gfx::ImageSkia resized_image = controller_->GetWallpaper(); |
297 EXPECT_FALSE(image.BackedBySameObjectAs(resized_image)); | 296 EXPECT_FALSE(image.BackedBySameObjectAs(resized_image)); |
298 EXPECT_EQ(gfx::Size(320, 200).ToString(), resized_image.size().ToString()); | 297 EXPECT_EQ(gfx::Size(320, 200).ToString(), resized_image.size().ToString()); |
299 | 298 |
300 // Load the original wallpaper again and check that we're still using the | 299 // Load the original wallpaper again and check that we're still using the |
301 // previously-resized image instead of doing another resize | 300 // previously-resized image instead of doing another resize |
302 // (http://crbug.com/321402). | 301 // (http://crbug.com/321402). |
303 controller_->SetWallpaperImage(image, WALLPAPER_LAYOUT_STRETCH); | 302 controller_->SetWallpaperImage(image, WALLPAPER_LAYOUT_STRETCH); |
304 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 303 content::RunAllBlockingPoolTasksUntilIdle(); |
305 content::RunAllPendingInMessageLoop(); | |
306 EXPECT_TRUE(resized_image.BackedBySameObjectAs(controller_->GetWallpaper())); | 304 EXPECT_TRUE(resized_image.BackedBySameObjectAs(controller_->GetWallpaper())); |
307 } | 305 } |
308 | 306 |
309 TEST_F(DesktopBackgroundControllerTest, GetMaxDisplaySize) { | 307 TEST_F(DesktopBackgroundControllerTest, GetMaxDisplaySize) { |
310 // Device scale factor shouldn't affect the native size. | 308 // Device scale factor shouldn't affect the native size. |
311 UpdateDisplay("1000x300*2"); | 309 UpdateDisplay("1000x300*2"); |
312 EXPECT_EQ( | 310 EXPECT_EQ( |
313 "1000x300", | 311 "1000x300", |
314 DesktopBackgroundController::GetMaxDisplaySizeInNative().ToString()); | 312 DesktopBackgroundController::GetMaxDisplaySizeInNative().ToString()); |
315 | 313 |
(...skipping 26 matching lines...) Expand all Loading... |
342 | 340 |
343 // Maximum width and height belongs to different displays. | 341 // Maximum width and height belongs to different displays. |
344 UpdateDisplay("400x300,100x500"); | 342 UpdateDisplay("400x300,100x500"); |
345 EXPECT_EQ( | 343 EXPECT_EQ( |
346 "400x500", | 344 "400x500", |
347 DesktopBackgroundController::GetMaxDisplaySizeInNative().ToString()); | 345 DesktopBackgroundController::GetMaxDisplaySizeInNative().ToString()); |
348 } | 346 } |
349 | 347 |
350 | 348 |
351 } // namespace ash | 349 } // namespace ash |
OLD | NEW |