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

Side by Side Diff: ash/desktop_background/desktop_background_controller_unittest.cc

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
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/common/ash_switches.h" 10 #include "ash/common/ash_switches.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 if (!task_observer.processed()) 102 if (!task_observer.processed())
103 break; 103 break;
104 } 104 }
105 } 105 }
106 106
107 } // namespace 107 } // namespace
108 108
109 class DesktopBackgroundControllerTest : public test::AshTestBase { 109 class DesktopBackgroundControllerTest : public test::AshTestBase {
110 public: 110 public:
111 DesktopBackgroundControllerTest() 111 DesktopBackgroundControllerTest()
112 : controller_(NULL), 112 : controller_(NULL), wallpaper_delegate_(NULL) {}
113 wallpaper_delegate_(NULL) {
114 }
115 ~DesktopBackgroundControllerTest() override {} 113 ~DesktopBackgroundControllerTest() override {}
116 114
117 void SetUp() override { 115 void SetUp() override {
118 test::AshTestBase::SetUp(); 116 test::AshTestBase::SetUp();
119 // Ash shell initialization creates wallpaper. Reset it so we can manually 117 // Ash shell initialization creates wallpaper. Reset it so we can manually
120 // control wallpaper creation and animation in our tests. 118 // control wallpaper creation and animation in our tests.
121 RootWindowController* root_window_controller = 119 RootWindowController* root_window_controller =
122 Shell::GetPrimaryRootWindowController(); 120 Shell::GetPrimaryRootWindowController();
123 root_window_controller->SetWallpaperController(NULL); 121 root_window_controller->SetWallpaperController(NULL);
124 root_window_controller->SetAnimatingWallpaperController(NULL); 122 root_window_controller->SetAnimatingWallpaperController(NULL);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 235
238 // Create wallpaper and background view. 236 // Create wallpaper and background view.
239 DesktopBackgroundController* controller = 237 DesktopBackgroundController* controller =
240 Shell::GetInstance()->desktop_background_controller(); 238 Shell::GetInstance()->desktop_background_controller();
241 controller->CreateEmptyWallpaper(); 239 controller->CreateEmptyWallpaper();
242 240
243 // The new wallpaper is ready to start animating. kAnimatingDesktopController 241 // The new wallpaper is ready to start animating. kAnimatingDesktopController
244 // holds the widget controller instance. kDesktopController will get it later. 242 // holds the widget controller instance. kDesktopController will get it later.
245 RootWindowController* root_window_controller = 243 RootWindowController* root_window_controller =
246 Shell::GetPrimaryRootWindowController(); 244 Shell::GetPrimaryRootWindowController();
247 EXPECT_TRUE(root_window_controller->animating_wallpaper_controller()-> 245 EXPECT_TRUE(
248 GetController(false)); 246 root_window_controller->animating_wallpaper_controller()->GetController(
247 false));
249 248
250 // kDesktopController will receive the widget controller when the animation 249 // kDesktopController will receive the widget controller when the animation
251 // is done. 250 // is done.
252 EXPECT_FALSE(root_window_controller->wallpaper_controller()); 251 EXPECT_FALSE(root_window_controller->wallpaper_controller());
253 252
254 // Force the widget's layer animation to play to completion. 253 // Force the widget's layer animation to play to completion.
255 RunDesktopControllerAnimation(); 254 RunDesktopControllerAnimation();
256 255
257 // Ownership has moved from kAnimatingDesktopController to kDesktopController. 256 // Ownership has moved from kAnimatingDesktopController to kDesktopController.
258 EXPECT_FALSE(root_window_controller->animating_wallpaper_controller()-> 257 EXPECT_FALSE(
259 GetController(false)); 258 root_window_controller->animating_wallpaper_controller()->GetController(
259 false));
260 EXPECT_TRUE(root_window_controller->wallpaper_controller()); 260 EXPECT_TRUE(root_window_controller->wallpaper_controller());
261 } 261 }
262 262
263 // Test for crbug.com/149043 "Unlock screen, no launcher appears". Ensure we 263 // Test for crbug.com/149043 "Unlock screen, no launcher appears". Ensure we
264 // move all desktop views if there are more than one. 264 // move all desktop views if there are more than one.
265 TEST_F(DesktopBackgroundControllerTest, BackgroundMovementDuringUnlock) { 265 TEST_F(DesktopBackgroundControllerTest, BackgroundMovementDuringUnlock) {
266 // We cannot short-circuit animations for this test. 266 // We cannot short-circuit animations for this test.
267 ui::ScopedAnimationDurationScaleMode test_duration_mode( 267 ui::ScopedAnimationDurationScaleMode test_duration_mode(
268 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); 268 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
269 269
270 // Reset wallpaper state, see ControllerOwnership above. 270 // Reset wallpaper state, see ControllerOwnership above.
271 DesktopBackgroundController* controller = 271 DesktopBackgroundController* controller =
272 Shell::GetInstance()->desktop_background_controller(); 272 Shell::GetInstance()->desktop_background_controller();
273 controller->CreateEmptyWallpaper(); 273 controller->CreateEmptyWallpaper();
274 274
275 // Run wallpaper show animation to completion. 275 // Run wallpaper show animation to completion.
276 RunDesktopControllerAnimation(); 276 RunDesktopControllerAnimation();
277 277
278 // User locks the screen, which moves the background forward. 278 // User locks the screen, which moves the background forward.
279 controller->MoveDesktopToLockedContainer(); 279 controller->MoveDesktopToLockedContainer();
280 280
281 // Suspend/resume cycle causes wallpaper to refresh, loading a new desktop 281 // Suspend/resume cycle causes wallpaper to refresh, loading a new desktop
282 // background that will animate in on top of the old one. 282 // background that will animate in on top of the old one.
283 controller->CreateEmptyWallpaper(); 283 controller->CreateEmptyWallpaper();
284 284
285 // In this state we have two desktop background views stored in different 285 // In this state we have two desktop background views stored in different
286 // properties. Both are in the lock screen background container. 286 // properties. Both are in the lock screen background container.
287 RootWindowController* root_window_controller = 287 RootWindowController* root_window_controller =
288 Shell::GetPrimaryRootWindowController(); 288 Shell::GetPrimaryRootWindowController();
289 EXPECT_TRUE(root_window_controller->animating_wallpaper_controller()-> 289 EXPECT_TRUE(
290 GetController(false)); 290 root_window_controller->animating_wallpaper_controller()->GetController(
291 false));
291 EXPECT_TRUE(root_window_controller->wallpaper_controller()); 292 EXPECT_TRUE(root_window_controller->wallpaper_controller());
292 EXPECT_EQ(0, ChildCountForContainer(kDesktopBackgroundId)); 293 EXPECT_EQ(0, ChildCountForContainer(kDesktopBackgroundId));
293 EXPECT_EQ(2, ChildCountForContainer(kLockScreenBackgroundId)); 294 EXPECT_EQ(2, ChildCountForContainer(kLockScreenBackgroundId));
294 295
295 // Before the wallpaper's animation completes, user unlocks the screen, which 296 // Before the wallpaper's animation completes, user unlocks the screen, which
296 // moves the desktop to the back. 297 // moves the desktop to the back.
297 controller->MoveDesktopToUnlockedContainer(); 298 controller->MoveDesktopToUnlockedContainer();
298 299
299 // Ensure both desktop backgrounds have moved. 300 // Ensure both desktop backgrounds have moved.
300 EXPECT_EQ(2, ChildCountForContainer(kDesktopBackgroundId)); 301 EXPECT_EQ(2, ChildCountForContainer(kDesktopBackgroundId));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 EXPECT_TRUE(root_window_controller->wallpaper_controller()); 336 EXPECT_TRUE(root_window_controller->wallpaper_controller());
336 337
337 // Change to another wallpaper before animation finished. 338 // Change to another wallpaper before animation finished.
338 controller->CreateEmptyWallpaper(); 339 controller->CreateEmptyWallpaper();
339 340
340 // The animating controller should immediately move to desktop controller. 341 // The animating controller should immediately move to desktop controller.
341 EXPECT_EQ(animating_controller, 342 EXPECT_EQ(animating_controller,
342 root_window_controller->wallpaper_controller()); 343 root_window_controller->wallpaper_controller());
343 344
344 // Cache the new animating controller. 345 // Cache the new animating controller.
345 animating_controller = root_window_controller-> 346 animating_controller =
346 animating_wallpaper_controller()->GetController(false); 347 root_window_controller->animating_wallpaper_controller()->GetController(
348 false);
347 349
348 // Run wallpaper show animation to completion. 350 // Run wallpaper show animation to completion.
349 ASSERT_NO_FATAL_FAILURE( 351 ASSERT_NO_FATAL_FAILURE(RunAnimationForWidget(
350 RunAnimationForWidget( 352 root_window_controller->animating_wallpaper_controller()
351 root_window_controller->animating_wallpaper_controller()-> 353 ->GetController(false)
352 GetController(false)->widget())); 354 ->widget()));
353 355
354 EXPECT_TRUE(root_window_controller->wallpaper_controller()); 356 EXPECT_TRUE(root_window_controller->wallpaper_controller());
355 EXPECT_FALSE(root_window_controller->animating_wallpaper_controller()-> 357 EXPECT_FALSE(
356 GetController(false)); 358 root_window_controller->animating_wallpaper_controller()->GetController(
359 false));
357 // The desktop controller should be the last created animating controller. 360 // The desktop controller should be the last created animating controller.
358 EXPECT_EQ(animating_controller, 361 EXPECT_EQ(animating_controller,
359 root_window_controller->wallpaper_controller()); 362 root_window_controller->wallpaper_controller());
360 } 363 }
361 364
362 TEST_F(DesktopBackgroundControllerTest, ResizeCustomWallpaper) { 365 TEST_F(DesktopBackgroundControllerTest, ResizeCustomWallpaper) {
363 if (!SupportsMultipleDisplays()) 366 if (!SupportsMultipleDisplays())
364 return; 367 return;
365 368
366 UpdateDisplay("320x200"); 369 UpdateDisplay("320x200");
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 { 494 {
492 SCOPED_TRACE(base::StringPrintf("1200x600/u@1.5 low resolution")); 495 SCOPED_TRACE(base::StringPrintf("1200x600/u@1.5 low resolution"));
493 controller_->SetWallpaperImage(image_low_res, WALLPAPER_LAYOUT_CENTER); 496 controller_->SetWallpaperImage(image_low_res, WALLPAPER_LAYOUT_CENTER);
494 WallpaperFitToNativeResolution( 497 WallpaperFitToNativeResolution(
495 desktop_background_view(), low_dsf, low_resolution.width(), 498 desktop_background_view(), low_dsf, low_resolution.width(),
496 low_resolution.height(), kCustomWallpaperColor); 499 low_resolution.height(), kCustomWallpaperColor);
497 } 500 }
498 } 501 }
499 502
500 } // namespace ash 503 } // namespace ash
OLDNEW
« no previous file with comments | « ash/desktop_background/desktop_background_controller_test_api.cc ('k') | ash/desktop_background/desktop_background_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698