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/wm/window_animations.h" | 5 #include "ash/wm/window_animations.h" |
6 | 6 |
7 #include "ash/shell_window_ids.h" | 7 #include "ash/shell_window_ids.h" |
8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
9 #include "ash/wm/window_state.h" | 9 #include "ash/wm/window_state.h" |
10 #include "ash/wm/workspace_controller.h" | 10 #include "ash/wm/workspace_controller.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // New layer animates in to the identity transform. | 161 // New layer animates in to the identity transform. |
162 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity()); | 162 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity()); |
163 EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform()); | 163 EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform()); |
164 | 164 |
165 old_layer->GetAnimator()->Step(base::TimeTicks::Now() + | 165 old_layer->GetAnimator()->Step(base::TimeTicks::Now() + |
166 base::TimeDelta::FromSeconds(1)); | 166 base::TimeDelta::FromSeconds(1)); |
167 window->layer()->GetAnimator()->Step(base::TimeTicks::Now() + | 167 window->layer()->GetAnimator()->Step(base::TimeTicks::Now() + |
168 base::TimeDelta::FromSeconds(1)); | 168 base::TimeDelta::FromSeconds(1)); |
169 } | 169 } |
170 | 170 |
| 171 // Tests that when crossfading from a window which has a transform that the |
| 172 // crossfade starts from this transformed size rather than snapping the window |
| 173 // to an identity transform and crossfading from there. |
| 174 TEST_F(WindowAnimationsTest, CrossFadeToBoundsFromTransform) { |
| 175 ui::ScopedAnimationDurationScaleMode test_duration_mode( |
| 176 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
| 177 |
| 178 scoped_ptr<Window> window(CreateTestWindowInShellWithId(0)); |
| 179 window->SetBounds(gfx::Rect(10, 10, 320, 240)); |
| 180 gfx::Transform half_size; |
| 181 half_size.Translate(10, 10); |
| 182 half_size.Scale(0.5f, 0.5f); |
| 183 window->SetTransform(half_size); |
| 184 window->Show(); |
| 185 |
| 186 Layer* old_layer = window->layer(); |
| 187 EXPECT_EQ(1.0f, old_layer->GetTargetOpacity()); |
| 188 |
| 189 // Cross fade to a larger size, as in a maximize animation. |
| 190 GetWindowState(window.get())->SetBoundsDirectCrossFade( |
| 191 gfx::Rect(0, 0, 640, 480)); |
| 192 // Window's layer has been replaced. |
| 193 EXPECT_NE(old_layer, window->layer()); |
| 194 // Original layer stays opaque and stretches to new size. |
| 195 EXPECT_EQ(1.0f, old_layer->GetTargetOpacity()); |
| 196 EXPECT_EQ("10,10 320x240", old_layer->bounds().ToString()); |
| 197 EXPECT_EQ(half_size, old_layer->transform()); |
| 198 |
| 199 // New layer animates in from the old window's transformed size to the |
| 200 // identity transform. |
| 201 EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity()); |
| 202 // Set up the transform necessary to start at the old windows transformed |
| 203 // position. |
| 204 gfx::Transform quarter_size_shifted; |
| 205 quarter_size_shifted.Translate(20, 20); |
| 206 quarter_size_shifted.Scale(0.25f, 0.25f); |
| 207 EXPECT_EQ(quarter_size_shifted, window->layer()->transform()); |
| 208 EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform()); |
| 209 } |
| 210 |
171 } // namespace wm | 211 } // namespace wm |
172 | 212 |
173 TEST_F(WindowAnimationsTest, LockAnimationDuration) { | 213 TEST_F(WindowAnimationsTest, LockAnimationDuration) { |
174 ui::ScopedAnimationDurationScaleMode test_duration_mode( | 214 ui::ScopedAnimationDurationScaleMode test_duration_mode( |
175 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | 215 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
176 | 216 |
177 scoped_ptr<Window> window(CreateTestWindowInShellWithId(0)); | 217 scoped_ptr<Window> window(CreateTestWindowInShellWithId(0)); |
178 Layer* layer = window->layer(); | 218 Layer* layer = window->layer(); |
179 window->SetBounds(gfx::Rect(5, 10, 320, 240)); | 219 window->SetBounds(gfx::Rect(5, 10, 320, 240)); |
180 window->Show(); | 220 window->Show(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 EXPECT_TRUE(layer->GetAnimator()->is_animating()); | 280 EXPECT_TRUE(layer->GetAnimator()->is_animating()); |
241 // Expect default duration (200ms for stock ash minimizing animation). | 281 // Expect default duration (200ms for stock ash minimizing animation). |
242 EXPECT_EQ(default_duration.InMilliseconds(), | 282 EXPECT_EQ(default_duration.InMilliseconds(), |
243 layer->GetAnimator()->GetTransitionDuration().InMilliseconds()); | 283 layer->GetAnimator()->GetTransitionDuration().InMilliseconds()); |
244 window->Show(); | 284 window->Show(); |
245 layer->GetAnimator()->StopAnimating(); | 285 layer->GetAnimator()->StopAnimating(); |
246 } | 286 } |
247 } | 287 } |
248 | 288 |
249 } // namespace ash | 289 } // namespace ash |
OLD | NEW |