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