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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 layer->GetAnimator()->Step(step_time + | 61 layer->GetAnimator()->Step(step_time + |
62 base::TimeDelta::FromMilliseconds(1000)); | 62 base::TimeDelta::FromMilliseconds(1000)); |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 } // namespace | 66 } // namespace |
67 | 67 |
68 class DesktopBackgroundControllerTest : public test::AshTestBase { | 68 class DesktopBackgroundControllerTest : public test::AshTestBase { |
69 public: | 69 public: |
70 DesktopBackgroundControllerTest() | 70 DesktopBackgroundControllerTest() |
71 : controller_(NULL), | 71 : controller_(NULL) { |
72 wallpaper_delegate_(NULL) { | |
73 } | 72 } |
74 virtual ~DesktopBackgroundControllerTest() {} | 73 virtual ~DesktopBackgroundControllerTest() {} |
75 | 74 |
76 virtual void SetUp() OVERRIDE { | 75 virtual void SetUp() OVERRIDE { |
77 test::AshTestBase::SetUp(); | 76 test::AshTestBase::SetUp(); |
78 // Ash shell initialization creates wallpaper. Reset it so we can manually | 77 // Ash shell initialization creates wallpaper. Reset it so we can manually |
79 // control wallpaper creation and animation in our tests. | 78 // control wallpaper creation and animation in our tests. |
80 RootWindowController* root_window_controller = | 79 RootWindowController* root_window_controller = |
81 Shell::GetPrimaryRootWindowController(); | 80 Shell::GetPrimaryRootWindowController(); |
82 root_window_controller->SetWallpaperController(NULL); | 81 root_window_controller->SetWallpaperController(NULL); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 EXPECT_TRUE(controller->MoveDesktopToUnlockedContainer()); | 142 EXPECT_TRUE(controller->MoveDesktopToUnlockedContainer()); |
144 EXPECT_FALSE(controller->MoveDesktopToUnlockedContainer()); | 143 EXPECT_FALSE(controller->MoveDesktopToUnlockedContainer()); |
145 | 144 |
146 // One window is moved from lock to desktop container. | 145 // One window is moved from lock to desktop container. |
147 EXPECT_EQ(1, ChildCountForContainer(kDesktopBackgroundId)); | 146 EXPECT_EQ(1, ChildCountForContainer(kDesktopBackgroundId)); |
148 EXPECT_EQ(0, ChildCountForContainer(kLockScreenBackgroundId)); | 147 EXPECT_EQ(0, ChildCountForContainer(kLockScreenBackgroundId)); |
149 } | 148 } |
150 | 149 |
151 TEST_F(DesktopBackgroundControllerTest, ControllerOwnership) { | 150 TEST_F(DesktopBackgroundControllerTest, ControllerOwnership) { |
152 // We cannot short-circuit animations for this test. | 151 // We cannot short-circuit animations for this test. |
153 ui::ScopedAnimationDurationScaleMode test_duration_mode( | 152 ui::ScopedAnimationDurationScaleMode normal_duration_mode( |
154 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | 153 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); |
155 | 154 |
156 // Create wallpaper and background view. | 155 // Create wallpaper and background view. |
157 DesktopBackgroundController* controller = | 156 DesktopBackgroundController* controller = |
158 Shell::GetInstance()->desktop_background_controller(); | 157 Shell::GetInstance()->desktop_background_controller(); |
159 controller->CreateEmptyWallpaper(); | 158 controller->CreateEmptyWallpaper(); |
160 | 159 |
161 // The new wallpaper is ready to start animating. kAnimatingDesktopController | 160 // The new wallpaper is ready to start animating. kAnimatingDesktopController |
162 // holds the widget controller instance. kDesktopController will get it later. | 161 // holds the widget controller instance. kDesktopController will get it later. |
163 RootWindowController* root_window_controller = | 162 RootWindowController* root_window_controller = |
164 Shell::GetPrimaryRootWindowController(); | 163 Shell::GetPrimaryRootWindowController(); |
(...skipping 10 matching lines...) Expand all Loading... |
175 // Ownership has moved from kAnimatingDesktopController to kDesktopController. | 174 // Ownership has moved from kAnimatingDesktopController to kDesktopController. |
176 EXPECT_FALSE(root_window_controller->animating_wallpaper_controller()-> | 175 EXPECT_FALSE(root_window_controller->animating_wallpaper_controller()-> |
177 GetController(false)); | 176 GetController(false)); |
178 EXPECT_TRUE(root_window_controller->wallpaper_controller()); | 177 EXPECT_TRUE(root_window_controller->wallpaper_controller()); |
179 } | 178 } |
180 | 179 |
181 // Test for crbug.com/149043 "Unlock screen, no launcher appears". Ensure we | 180 // Test for crbug.com/149043 "Unlock screen, no launcher appears". Ensure we |
182 // move all desktop views if there are more than one. | 181 // move all desktop views if there are more than one. |
183 TEST_F(DesktopBackgroundControllerTest, BackgroundMovementDuringUnlock) { | 182 TEST_F(DesktopBackgroundControllerTest, BackgroundMovementDuringUnlock) { |
184 // We cannot short-circuit animations for this test. | 183 // We cannot short-circuit animations for this test. |
185 ui::ScopedAnimationDurationScaleMode test_duration_mode( | 184 ui::ScopedAnimationDurationScaleMode normal_duration_mode( |
186 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | 185 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); |
187 | 186 |
188 // Reset wallpaper state, see ControllerOwnership above. | 187 // Reset wallpaper state, see ControllerOwnership above. |
189 DesktopBackgroundController* controller = | 188 DesktopBackgroundController* controller = |
190 Shell::GetInstance()->desktop_background_controller(); | 189 Shell::GetInstance()->desktop_background_controller(); |
191 controller->CreateEmptyWallpaper(); | 190 controller->CreateEmptyWallpaper(); |
192 | 191 |
193 // Run wallpaper show animation to completion. | 192 // Run wallpaper show animation to completion. |
194 RunDesktopControllerAnimation(); | 193 RunDesktopControllerAnimation(); |
195 | 194 |
196 // User locks the screen, which moves the background forward. | 195 // User locks the screen, which moves the background forward. |
(...skipping 26 matching lines...) Expand all Loading... |
223 | 222 |
224 // Now there is one desktop background, in the back. | 223 // Now there is one desktop background, in the back. |
225 EXPECT_EQ(1, ChildCountForContainer(kDesktopBackgroundId)); | 224 EXPECT_EQ(1, ChildCountForContainer(kDesktopBackgroundId)); |
226 EXPECT_EQ(0, ChildCountForContainer(kLockScreenBackgroundId)); | 225 EXPECT_EQ(0, ChildCountForContainer(kLockScreenBackgroundId)); |
227 } | 226 } |
228 | 227 |
229 // Test for crbug.com/156542. Animating wallpaper should immediately finish | 228 // Test for crbug.com/156542. Animating wallpaper should immediately finish |
230 // animation and replace current wallpaper before next animation starts. | 229 // animation and replace current wallpaper before next animation starts. |
231 TEST_F(DesktopBackgroundControllerTest, ChangeWallpaperQuick) { | 230 TEST_F(DesktopBackgroundControllerTest, ChangeWallpaperQuick) { |
232 // We cannot short-circuit animations for this test. | 231 // We cannot short-circuit animations for this test. |
233 ui::ScopedAnimationDurationScaleMode test_duration_mode( | 232 ui::ScopedAnimationDurationScaleMode normal_duration_mode( |
234 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | 233 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); |
235 | 234 |
236 // Reset wallpaper state, see ControllerOwnership above. | 235 // Reset wallpaper state, see ControllerOwnership above. |
237 DesktopBackgroundController* controller = | 236 DesktopBackgroundController* controller = |
238 Shell::GetInstance()->desktop_background_controller(); | 237 Shell::GetInstance()->desktop_background_controller(); |
239 controller->CreateEmptyWallpaper(); | 238 controller->CreateEmptyWallpaper(); |
240 | 239 |
241 // Run wallpaper show animation to completion. | 240 // Run wallpaper show animation to completion. |
242 RunDesktopControllerAnimation(); | 241 RunDesktopControllerAnimation(); |
243 | 242 |
244 // Change to a new wallpaper. | 243 // Change to a new wallpaper. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 | 341 |
343 // Maximum width and height belongs to different displays. | 342 // Maximum width and height belongs to different displays. |
344 UpdateDisplay("400x300,100x500"); | 343 UpdateDisplay("400x300,100x500"); |
345 EXPECT_EQ( | 344 EXPECT_EQ( |
346 "400x500", | 345 "400x500", |
347 DesktopBackgroundController::GetMaxDisplaySizeInNative().ToString()); | 346 DesktopBackgroundController::GetMaxDisplaySizeInNative().ToString()); |
348 } | 347 } |
349 | 348 |
350 | 349 |
351 } // namespace ash | 350 } // namespace ash |
OLD | NEW |