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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 ui::LayerAnimator* animator_; | 57 ui::LayerAnimator* animator_; |
58 base::TimeDelta duration_; | 58 base::TimeDelta duration_; |
59 | 59 |
60 DISALLOW_COPY_AND_ASSIGN(MinimizeAnimationObserver); | 60 DISALLOW_COPY_AND_ASSIGN(MinimizeAnimationObserver); |
61 }; | 61 }; |
62 | 62 |
63 TEST_F(WindowAnimationsTest, HideShowBrightnessGrayscaleAnimation) { | 63 TEST_F(WindowAnimationsTest, HideShowBrightnessGrayscaleAnimation) { |
64 ui::ScopedAnimationDurationScaleMode test_duration_mode( | 64 ui::ScopedAnimationDurationScaleMode test_duration_mode( |
65 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | 65 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
66 | 66 |
67 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); | 67 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); |
68 window->Show(); | 68 window->Show(); |
69 EXPECT_TRUE(window->layer()->visible()); | 69 EXPECT_TRUE(window->layer()->visible()); |
70 | 70 |
71 // Hiding. | 71 // Hiding. |
72 ::wm::SetWindowVisibilityAnimationType( | 72 ::wm::SetWindowVisibilityAnimationType( |
73 window.get(), | 73 window.get(), |
74 WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE); | 74 WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE); |
75 AnimateOnChildWindowVisibilityChanged(window.get(), false); | 75 AnimateOnChildWindowVisibilityChanged(window.get(), false); |
76 EXPECT_EQ(0.0f, window->layer()->GetTargetOpacity()); | 76 EXPECT_EQ(0.0f, window->layer()->GetTargetOpacity()); |
77 EXPECT_FALSE(window->layer()->GetTargetVisibility()); | 77 EXPECT_FALSE(window->layer()->GetTargetVisibility()); |
(...skipping 10 matching lines...) Expand all Loading... |
88 | 88 |
89 // Stays shown. | 89 // Stays shown. |
90 window->layer()->GetAnimator()->Step(base::TimeTicks::Now() + | 90 window->layer()->GetAnimator()->Step(base::TimeTicks::Now() + |
91 base::TimeDelta::FromSeconds(5)); | 91 base::TimeDelta::FromSeconds(5)); |
92 EXPECT_EQ(0.0f, window->layer()->GetTargetBrightness()); | 92 EXPECT_EQ(0.0f, window->layer()->GetTargetBrightness()); |
93 EXPECT_EQ(0.0f, window->layer()->GetTargetGrayscale()); | 93 EXPECT_EQ(0.0f, window->layer()->GetTargetGrayscale()); |
94 EXPECT_TRUE(window->layer()->visible()); | 94 EXPECT_TRUE(window->layer()->visible()); |
95 } | 95 } |
96 | 96 |
97 TEST_F(WindowAnimationsTest, LayerTargetVisibility) { | 97 TEST_F(WindowAnimationsTest, LayerTargetVisibility) { |
98 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); | 98 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithId(0)); |
99 | 99 |
100 // Layer target visibility changes according to Show/Hide. | 100 // Layer target visibility changes according to Show/Hide. |
101 window->Show(); | 101 window->Show(); |
102 EXPECT_TRUE(window->layer()->GetTargetVisibility()); | 102 EXPECT_TRUE(window->layer()->GetTargetVisibility()); |
103 window->Hide(); | 103 window->Hide(); |
104 EXPECT_FALSE(window->layer()->GetTargetVisibility()); | 104 EXPECT_FALSE(window->layer()->GetTargetVisibility()); |
105 window->Show(); | 105 window->Show(); |
106 EXPECT_TRUE(window->layer()->GetTargetVisibility()); | 106 EXPECT_TRUE(window->layer()->GetTargetVisibility()); |
107 } | 107 } |
108 | 108 |
109 namespace wm { | 109 namespace wm { |
110 | 110 |
111 TEST_F(WindowAnimationsTest, CrossFadeToBounds) { | 111 TEST_F(WindowAnimationsTest, CrossFadeToBounds) { |
112 ui::ScopedAnimationDurationScaleMode test_duration_mode( | 112 ui::ScopedAnimationDurationScaleMode test_duration_mode( |
113 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | 113 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
114 | 114 |
115 scoped_ptr<Window> window(CreateTestWindowInShellWithId(0)); | 115 std::unique_ptr<Window> window(CreateTestWindowInShellWithId(0)); |
116 window->SetBounds(gfx::Rect(5, 10, 320, 240)); | 116 window->SetBounds(gfx::Rect(5, 10, 320, 240)); |
117 window->Show(); | 117 window->Show(); |
118 | 118 |
119 Layer* old_layer = window->layer(); | 119 Layer* old_layer = window->layer(); |
120 EXPECT_EQ(1.0f, old_layer->GetTargetOpacity()); | 120 EXPECT_EQ(1.0f, old_layer->GetTargetOpacity()); |
121 | 121 |
122 // Cross fade to a larger size, as in a maximize animation. | 122 // Cross fade to a larger size, as in a maximize animation. |
123 GetWindowState(window.get())->SetBoundsDirectCrossFade( | 123 GetWindowState(window.get())->SetBoundsDirectCrossFade( |
124 gfx::Rect(0, 0, 640, 480)); | 124 gfx::Rect(0, 0, 640, 480)); |
125 // Window's layer has been replaced. | 125 // Window's layer has been replaced. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 base::TimeDelta::FromSeconds(1)); | 164 base::TimeDelta::FromSeconds(1)); |
165 } | 165 } |
166 | 166 |
167 // Tests that when crossfading from a window which has a transform that the | 167 // Tests that when crossfading from a window which has a transform that the |
168 // crossfade starts from this transformed size rather than snapping the window | 168 // crossfade starts from this transformed size rather than snapping the window |
169 // to an identity transform and crossfading from there. | 169 // to an identity transform and crossfading from there. |
170 TEST_F(WindowAnimationsTest, CrossFadeToBoundsFromTransform) { | 170 TEST_F(WindowAnimationsTest, CrossFadeToBoundsFromTransform) { |
171 ui::ScopedAnimationDurationScaleMode test_duration_mode( | 171 ui::ScopedAnimationDurationScaleMode test_duration_mode( |
172 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | 172 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
173 | 173 |
174 scoped_ptr<Window> window(CreateTestWindowInShellWithId(0)); | 174 std::unique_ptr<Window> window(CreateTestWindowInShellWithId(0)); |
175 window->SetBounds(gfx::Rect(10, 10, 320, 240)); | 175 window->SetBounds(gfx::Rect(10, 10, 320, 240)); |
176 gfx::Transform half_size; | 176 gfx::Transform half_size; |
177 half_size.Translate(10, 10); | 177 half_size.Translate(10, 10); |
178 half_size.Scale(0.5f, 0.5f); | 178 half_size.Scale(0.5f, 0.5f); |
179 window->SetTransform(half_size); | 179 window->SetTransform(half_size); |
180 window->Show(); | 180 window->Show(); |
181 | 181 |
182 Layer* old_layer = window->layer(); | 182 Layer* old_layer = window->layer(); |
183 EXPECT_EQ(1.0f, old_layer->GetTargetOpacity()); | 183 EXPECT_EQ(1.0f, old_layer->GetTargetOpacity()); |
184 | 184 |
(...skipping 18 matching lines...) Expand all Loading... |
203 EXPECT_EQ(quarter_size_shifted, window->layer()->transform()); | 203 EXPECT_EQ(quarter_size_shifted, window->layer()->transform()); |
204 EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform()); | 204 EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform()); |
205 } | 205 } |
206 | 206 |
207 } // namespace wm | 207 } // namespace wm |
208 | 208 |
209 TEST_F(WindowAnimationsTest, LockAnimationDuration) { | 209 TEST_F(WindowAnimationsTest, LockAnimationDuration) { |
210 ui::ScopedAnimationDurationScaleMode test_duration_mode( | 210 ui::ScopedAnimationDurationScaleMode test_duration_mode( |
211 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | 211 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
212 | 212 |
213 scoped_ptr<Window> window(CreateTestWindowInShellWithId(0)); | 213 std::unique_ptr<Window> window(CreateTestWindowInShellWithId(0)); |
214 Layer* layer = window->layer(); | 214 Layer* layer = window->layer(); |
215 window->SetBounds(gfx::Rect(5, 10, 320, 240)); | 215 window->SetBounds(gfx::Rect(5, 10, 320, 240)); |
216 window->Show(); | 216 window->Show(); |
217 | 217 |
218 // Test that it is possible to override transition duration when it is not | 218 // Test that it is possible to override transition duration when it is not |
219 // locked. | 219 // locked. |
220 { | 220 { |
221 ui::ScopedLayerAnimationSettings settings1(layer->GetAnimator()); | 221 ui::ScopedLayerAnimationSettings settings1(layer->GetAnimator()); |
222 settings1.SetTransitionDuration(base::TimeDelta::FromMilliseconds(1000)); | 222 settings1.SetTransitionDuration(base::TimeDelta::FromMilliseconds(1000)); |
223 { | 223 { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 EXPECT_TRUE(layer->GetAnimator()->is_animating()); | 276 EXPECT_TRUE(layer->GetAnimator()->is_animating()); |
277 // Expect default duration (200ms for stock ash minimizing animation). | 277 // Expect default duration (200ms for stock ash minimizing animation). |
278 EXPECT_EQ(default_duration.InMilliseconds(), | 278 EXPECT_EQ(default_duration.InMilliseconds(), |
279 layer->GetAnimator()->GetTransitionDuration().InMilliseconds()); | 279 layer->GetAnimator()->GetTransitionDuration().InMilliseconds()); |
280 window->Show(); | 280 window->Show(); |
281 layer->GetAnimator()->StopAnimating(); | 281 layer->GetAnimator()->StopAnimating(); |
282 } | 282 } |
283 } | 283 } |
284 | 284 |
285 } // namespace ash | 285 } // namespace ash |
OLD | NEW |