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 "ui/wm/core/window_animations.h" | 5 #include "ui/wm/core/window_animations.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/stl_util.h" |
10 #include "base/time/time.h" | 11 #include "base/time/time.h" |
11 #include "ui/aura/test/aura_test_base.h" | 12 #include "ui/aura/test/aura_test_base.h" |
12 #include "ui/aura/test/test_windows.h" | 13 #include "ui/aura/test/test_windows.h" |
13 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
14 #include "ui/compositor/layer.h" | 15 #include "ui/compositor/layer.h" |
15 #include "ui/compositor/layer_animator.h" | 16 #include "ui/compositor/layer_animator.h" |
16 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 17 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
17 #include "ui/gfx/animation/animation_container_element.h" | 18 #include "ui/gfx/animation/animation_container_element.h" |
18 #include "ui/gfx/geometry/vector2d.h" | 19 #include "ui/gfx/geometry/vector2d.h" |
19 #include "ui/wm/core/transient_window_manager.h" | 20 #include "ui/wm/core/transient_window_manager.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 animating_window->Hide(); | 152 animating_window->Hide(); |
152 EXPECT_TRUE(AnimateOnChildWindowVisibilityChanged( | 153 EXPECT_TRUE(AnimateOnChildWindowVisibilityChanged( |
153 animating_window.get(), false)); | 154 animating_window.get(), false)); |
154 EXPECT_TRUE(animating_layer->GetAnimator()->is_animating()); | 155 EXPECT_TRUE(animating_layer->GetAnimator()->is_animating()); |
155 EXPECT_FALSE(animating_layer->delegate()); | 156 EXPECT_FALSE(animating_layer->delegate()); |
156 | 157 |
157 // Make sure the Hide animation create another layer, and both are in | 158 // Make sure the Hide animation create another layer, and both are in |
158 // the parent layer. | 159 // the parent layer. |
159 EXPECT_NE(animating_window->layer(), animating_layer); | 160 EXPECT_NE(animating_window->layer(), animating_layer); |
160 EXPECT_TRUE( | 161 EXPECT_TRUE( |
161 std::find(parent->layer()->children().begin(), | 162 base::ContainsValue(parent->layer()->children(), animating_layer)); |
162 parent->layer()->children().end(), | 163 EXPECT_TRUE(base::ContainsValue(parent->layer()->children(), |
163 animating_layer) != | 164 animating_window->layer())); |
164 parent->layer()->children().end()); | |
165 EXPECT_TRUE( | |
166 std::find(parent->layer()->children().begin(), | |
167 parent->layer()->children().end(), | |
168 animating_window->layer()) != | |
169 parent->layer()->children().end()); | |
170 // Current layer must be already hidden. | 165 // Current layer must be already hidden. |
171 EXPECT_FALSE(animating_window->layer()->visible()); | 166 EXPECT_FALSE(animating_window->layer()->visible()); |
172 | 167 |
173 EXPECT_EQ(1, GetWindowZPosition(animating_window.get())); | 168 EXPECT_EQ(1, GetWindowZPosition(animating_window.get())); |
174 EXPECT_EQ(1, GetLayerZPosition(animating_window->layer())); | 169 EXPECT_EQ(1, GetLayerZPosition(animating_window->layer())); |
175 EXPECT_EQ(2, GetLayerZPosition(animating_layer)); | 170 EXPECT_EQ(2, GetLayerZPosition(animating_layer)); |
176 | 171 |
177 parent->StackChildAtTop(other.get()); | 172 parent->StackChildAtTop(other.get()); |
178 EXPECT_EQ(0, GetWindowZPosition(animating_window.get())); | 173 EXPECT_EQ(0, GetWindowZPosition(animating_window.get())); |
179 EXPECT_EQ(1, GetWindowZPosition(other.get())); | 174 EXPECT_EQ(1, GetWindowZPosition(other.get())); |
180 | 175 |
181 EXPECT_EQ(0, GetLayerZPosition(animating_window->layer())); | 176 EXPECT_EQ(0, GetLayerZPosition(animating_window->layer())); |
182 EXPECT_EQ(1, GetLayerZPosition(other->layer())); | 177 EXPECT_EQ(1, GetLayerZPosition(other->layer())); |
183 // Make sure the animating layer is on top. | 178 // Make sure the animating layer is on top. |
184 EXPECT_EQ(2, GetLayerZPosition(animating_layer)); | 179 EXPECT_EQ(2, GetLayerZPosition(animating_layer)); |
185 | 180 |
186 // Animating layer must be gone | 181 // Animating layer must be gone |
187 animating_layer->GetAnimator()->StopAnimating(); | 182 animating_layer->GetAnimator()->StopAnimating(); |
188 EXPECT_TRUE( | 183 EXPECT_FALSE( |
189 std::find(parent->layer()->children().begin(), | 184 base::ContainsValue(parent->layer()->children(), animating_layer)); |
190 parent->layer()->children().end(), | |
191 animating_layer) == | |
192 parent->layer()->children().end()); | |
193 } | 185 } |
194 } | 186 } |
195 | 187 |
196 TEST_F(WindowAnimationsTest, HideAnimationDetachLayersWithTransientChildren) { | 188 TEST_F(WindowAnimationsTest, HideAnimationDetachLayersWithTransientChildren) { |
197 TransientWindowStackingClient transient_stacking_client; | 189 TransientWindowStackingClient transient_stacking_client; |
198 | 190 |
199 std::unique_ptr<aura::Window> parent( | 191 std::unique_ptr<aura::Window> parent( |
200 aura::test::CreateTestWindowWithId(0, NULL)); | 192 aura::test::CreateTestWindowWithId(0, NULL)); |
201 | 193 |
202 std::unique_ptr<aura::Window> other( | 194 std::unique_ptr<aura::Window> other( |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 wm::SetWindowVisibilityAnimationType(window.get(), | 313 wm::SetWindowVisibilityAnimationType(window.get(), |
322 WINDOW_VISIBILITY_ANIMATION_TYPE_ROTATE); | 314 WINDOW_VISIBILITY_ANIMATION_TYPE_ROTATE); |
323 AnimateOnChildWindowVisibilityChanged(window.get(), true); | 315 AnimateOnChildWindowVisibilityChanged(window.get(), true); |
324 window->layer()->GetAnimator()->Step(base::TimeTicks::Now() + | 316 window->layer()->GetAnimator()->Step(base::TimeTicks::Now() + |
325 base::TimeDelta::FromSeconds(5)); | 317 base::TimeDelta::FromSeconds(5)); |
326 AnimateOnChildWindowVisibilityChanged(window.get(), false); | 318 AnimateOnChildWindowVisibilityChanged(window.get(), false); |
327 animating_layer->GetAnimator()->StopAnimating(); | 319 animating_layer->GetAnimator()->StopAnimating(); |
328 } | 320 } |
329 | 321 |
330 } // namespace wm | 322 } // namespace wm |
OLD | NEW |