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

Side by Side Diff: ash/common/wallpaper/wallpaper_controller_unittest.cc

Issue 2625843002: Folds WmRootWindowController into RootWindowController (Closed)
Patch Set: definition in wm_root_window_controller.cc 2 Created 3 years, 11 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
« no previous file with comments | « ash/common/wallpaper/wallpaper_controller.cc ('k') | ash/common/wallpaper/wallpaper_view.cc » ('j') | 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) 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"
11 #include "ash/common/wallpaper/wallpaper_widget_controller.h" 11 #include "ash/common/wallpaper/wallpaper_widget_controller.h"
12 #include "ash/common/wm_root_window_controller.h"
13 #include "ash/common/wm_shell.h" 12 #include "ash/common/wm_shell.h"
14 #include "ash/common/wm_window.h" 13 #include "ash/common/wm_window.h"
15 #include "ash/public/cpp/shell_window_ids.h" 14 #include "ash/public/cpp/shell_window_ids.h"
15 #include "ash/root_window_controller.h"
16 #include "ash/test/ash_test_base.h" 16 #include "ash/test/ash_test_base.h"
17 #include "ash/test/test_wallpaper_delegate.h" 17 #include "ash/test/test_wallpaper_delegate.h"
18 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
19 #include "base/run_loop.h" 19 #include "base/run_loop.h"
20 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
21 #include "base/threading/sequenced_worker_pool.h" 21 #include "base/threading/sequenced_worker_pool.h"
22 #include "third_party/skia/include/core/SkBitmap.h" 22 #include "third_party/skia/include/core/SkBitmap.h"
23 #include "third_party/skia/include/core/SkColor.h" 23 #include "third_party/skia/include/core/SkColor.h"
24 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 24 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
25 #include "ui/compositor/test/layer_animator_test_controller.h" 25 #include "ui/compositor/test/layer_animator_test_controller.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 class WallpaperControllerTest : public test::AshTestBase { 104 class WallpaperControllerTest : public test::AshTestBase {
105 public: 105 public:
106 WallpaperControllerTest() 106 WallpaperControllerTest()
107 : controller_(nullptr), wallpaper_delegate_(nullptr) {} 107 : controller_(nullptr), wallpaper_delegate_(nullptr) {}
108 ~WallpaperControllerTest() override {} 108 ~WallpaperControllerTest() override {}
109 109
110 void SetUp() override { 110 void SetUp() override {
111 test::AshTestBase::SetUp(); 111 test::AshTestBase::SetUp();
112 // Ash shell initialization creates wallpaper. Reset it so we can manually 112 // Ash shell initialization creates wallpaper. Reset it so we can manually
113 // control wallpaper creation and animation in our tests. 113 // control wallpaper creation and animation in our tests.
114 WmRootWindowController* root_window_controller = 114 RootWindowController* root_window_controller =
115 WmShell::Get()->GetPrimaryRootWindow()->GetRootWindowController(); 115 WmShell::Get()->GetPrimaryRootWindow()->GetRootWindowController();
116 root_window_controller->SetWallpaperWidgetController(nullptr); 116 root_window_controller->SetWallpaperWidgetController(nullptr);
117 root_window_controller->SetAnimatingWallpaperWidgetController(nullptr); 117 root_window_controller->SetAnimatingWallpaperWidgetController(nullptr);
118 controller_ = WmShell::Get()->wallpaper_controller(); 118 controller_ = WmShell::Get()->wallpaper_controller();
119 wallpaper_delegate_ = static_cast<test::TestWallpaperDelegate*>( 119 wallpaper_delegate_ = static_cast<test::TestWallpaperDelegate*>(
120 WmShell::Get()->wallpaper_delegate()); 120 WmShell::Get()->wallpaper_delegate());
121 controller_->set_wallpaper_reload_delay_for_test(0); 121 controller_->set_wallpaper_reload_delay_for_test(0);
122 } 122 }
123 123
124 WallpaperView* wallpaper_view() { 124 WallpaperView* wallpaper_view() {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 TEST_F(WallpaperControllerTest, ControllerOwnership) { 229 TEST_F(WallpaperControllerTest, ControllerOwnership) {
230 // We cannot short-circuit animations for this test. 230 // We cannot short-circuit animations for this test.
231 ui::ScopedAnimationDurationScaleMode test_duration_mode( 231 ui::ScopedAnimationDurationScaleMode test_duration_mode(
232 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); 232 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
233 233
234 // Create the wallpaper and its view. 234 // Create the wallpaper and its view.
235 WallpaperController* controller = WmShell::Get()->wallpaper_controller(); 235 WallpaperController* controller = WmShell::Get()->wallpaper_controller();
236 controller->CreateEmptyWallpaper(); 236 controller->CreateEmptyWallpaper();
237 237
238 // The new wallpaper is ready to animate. 238 // The new wallpaper is ready to animate.
239 WmRootWindowController* root_window_controller = 239 RootWindowController* root_window_controller =
240 WmShell::Get()->GetPrimaryRootWindow()->GetRootWindowController(); 240 WmShell::Get()->GetPrimaryRootWindow()->GetRootWindowController();
241 EXPECT_TRUE(root_window_controller->animating_wallpaper_widget_controller() 241 EXPECT_TRUE(root_window_controller->animating_wallpaper_widget_controller()
242 ->GetController(false)); 242 ->GetController(false));
243 EXPECT_FALSE(root_window_controller->wallpaper_widget_controller()); 243 EXPECT_FALSE(root_window_controller->wallpaper_widget_controller());
244 244
245 // Force the animation to play to completion. 245 // Force the animation to play to completion.
246 RunDesktopControllerAnimation(); 246 RunDesktopControllerAnimation();
247 EXPECT_FALSE(root_window_controller->animating_wallpaper_widget_controller() 247 EXPECT_FALSE(root_window_controller->animating_wallpaper_widget_controller()
248 ->GetController(false)); 248 ->GetController(false));
249 EXPECT_TRUE(root_window_controller->wallpaper_widget_controller()); 249 EXPECT_TRUE(root_window_controller->wallpaper_widget_controller());
(...skipping 15 matching lines...) Expand all
265 265
266 // User locks the screen, which moves the wallpaper forward. 266 // User locks the screen, which moves the wallpaper forward.
267 controller->MoveToLockedContainer(); 267 controller->MoveToLockedContainer();
268 268
269 // Suspend/resume cycle causes wallpaper to refresh, loading a new wallpaper 269 // Suspend/resume cycle causes wallpaper to refresh, loading a new wallpaper
270 // that will animate in on top of the old one. 270 // that will animate in on top of the old one.
271 controller->CreateEmptyWallpaper(); 271 controller->CreateEmptyWallpaper();
272 272
273 // In this state we have two wallpaper views stored in different properties. 273 // In this state we have two wallpaper views stored in different properties.
274 // Both are in the lock screen wallpaper container. 274 // Both are in the lock screen wallpaper container.
275 WmRootWindowController* root_window_controller = 275 RootWindowController* root_window_controller =
276 WmShell::Get()->GetPrimaryRootWindow()->GetRootWindowController(); 276 WmShell::Get()->GetPrimaryRootWindow()->GetRootWindowController();
277 EXPECT_TRUE(root_window_controller->animating_wallpaper_widget_controller() 277 EXPECT_TRUE(root_window_controller->animating_wallpaper_widget_controller()
278 ->GetController(false)); 278 ->GetController(false));
279 EXPECT_TRUE(root_window_controller->wallpaper_widget_controller()); 279 EXPECT_TRUE(root_window_controller->wallpaper_widget_controller());
280 EXPECT_EQ(0, ChildCountForContainer(kWallpaperId)); 280 EXPECT_EQ(0, ChildCountForContainer(kWallpaperId));
281 EXPECT_EQ(2, ChildCountForContainer(kLockScreenWallpaperId)); 281 EXPECT_EQ(2, ChildCountForContainer(kLockScreenWallpaperId));
282 282
283 // Before the wallpaper's animation completes, user unlocks the screen, which 283 // Before the wallpaper's animation completes, user unlocks the screen, which
284 // moves the wallpaper to the back. 284 // moves the wallpaper to the back.
285 controller->MoveToUnlockedContainer(); 285 controller->MoveToUnlockedContainer();
(...skipping 20 matching lines...) Expand all
306 // Reset wallpaper state, see ControllerOwnership above. 306 // Reset wallpaper state, see ControllerOwnership above.
307 WallpaperController* controller = WmShell::Get()->wallpaper_controller(); 307 WallpaperController* controller = WmShell::Get()->wallpaper_controller();
308 controller->CreateEmptyWallpaper(); 308 controller->CreateEmptyWallpaper();
309 309
310 // Run wallpaper show animation to completion. 310 // Run wallpaper show animation to completion.
311 RunDesktopControllerAnimation(); 311 RunDesktopControllerAnimation();
312 312
313 // Change to a new wallpaper. 313 // Change to a new wallpaper.
314 controller->CreateEmptyWallpaper(); 314 controller->CreateEmptyWallpaper();
315 315
316 WmRootWindowController* root_window_controller = 316 RootWindowController* root_window_controller =
317 WmShell::Get()->GetPrimaryRootWindow()->GetRootWindowController(); 317 WmShell::Get()->GetPrimaryRootWindow()->GetRootWindowController();
318 WallpaperWidgetController* animating_controller = 318 WallpaperWidgetController* animating_controller =
319 root_window_controller->animating_wallpaper_widget_controller() 319 root_window_controller->animating_wallpaper_widget_controller()
320 ->GetController(false); 320 ->GetController(false);
321 EXPECT_TRUE(animating_controller); 321 EXPECT_TRUE(animating_controller);
322 EXPECT_TRUE(root_window_controller->wallpaper_widget_controller()); 322 EXPECT_TRUE(root_window_controller->wallpaper_widget_controller());
323 323
324 // Change to another wallpaper before animation finished. 324 // Change to another wallpaper before animation finished.
325 controller->CreateEmptyWallpaper(); 325 controller->CreateEmptyWallpaper();
326 326
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 { 467 {
468 SCOPED_TRACE(base::StringPrintf("1200x600/u@1.5 low resolution")); 468 SCOPED_TRACE(base::StringPrintf("1200x600/u@1.5 low resolution"));
469 controller_->SetWallpaperImage(image_low_res, WALLPAPER_LAYOUT_CENTER); 469 controller_->SetWallpaperImage(image_low_res, WALLPAPER_LAYOUT_CENTER);
470 WallpaperFitToNativeResolution( 470 WallpaperFitToNativeResolution(
471 wallpaper_view(), low_dsf, low_resolution.width(), 471 wallpaper_view(), low_dsf, low_resolution.width(),
472 low_resolution.height(), kCustomWallpaperColor); 472 low_resolution.height(), kCustomWallpaperColor);
473 } 473 }
474 } 474 }
475 475
476 } // namespace ash 476 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wallpaper/wallpaper_controller.cc ('k') | ash/common/wallpaper/wallpaper_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698