OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "cc/animation/element_animations.h" | 5 #include "cc/animation/element_animations.h" |
6 | 6 |
7 #include "cc/animation/animation_delegate.h" | 7 #include "cc/animation/animation_delegate.h" |
8 #include "cc/animation/animation_host.h" | 8 #include "cc/animation/animation_host.h" |
9 #include "cc/animation/animation_id_provider.h" | 9 #include "cc/animation/animation_id_provider.h" |
10 #include "cc/animation/animation_player.h" | 10 #include "cc/animation/animation_player.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 timeline_->AttachPlayer(player_); | 54 timeline_->AttachPlayer(player_); |
55 player_->AttachElement(element_id_); | 55 player_->AttachElement(element_id_); |
56 | 56 |
57 scoped_refptr<ElementAnimations> element_animations = | 57 scoped_refptr<ElementAnimations> element_animations = |
58 player_->element_animations(); | 58 player_->element_animations(); |
59 EXPECT_TRUE(element_animations); | 59 EXPECT_TRUE(element_animations); |
60 | 60 |
61 EXPECT_TRUE(element_animations->has_element_in_active_list()); | 61 EXPECT_TRUE(element_animations->has_element_in_active_list()); |
62 EXPECT_FALSE(element_animations->has_element_in_pending_list()); | 62 EXPECT_FALSE(element_animations->has_element_in_pending_list()); |
63 | 63 |
64 host_->PushPropertiesTo(host_impl_); | 64 host_->PushPropertiesTo(host_impl_, base::TimeTicks()); |
65 | 65 |
66 GetImplTimelineAndPlayerByID(); | 66 GetImplTimelineAndPlayerByID(); |
67 | 67 |
68 scoped_refptr<ElementAnimations> element_animations_impl = | 68 scoped_refptr<ElementAnimations> element_animations_impl = |
69 player_impl_->element_animations(); | 69 player_impl_->element_animations(); |
70 EXPECT_TRUE(element_animations_impl); | 70 EXPECT_TRUE(element_animations_impl); |
71 | 71 |
72 EXPECT_FALSE(element_animations_impl->has_element_in_active_list()); | 72 EXPECT_FALSE(element_animations_impl->has_element_in_active_list()); |
73 EXPECT_TRUE(element_animations_impl->has_element_in_pending_list()); | 73 EXPECT_TRUE(element_animations_impl->has_element_in_pending_list()); |
74 | 74 |
75 // Create the layer in the impl active tree. | 75 // Create the layer in the impl active tree. |
76 client_impl_.RegisterElement(element_id_, ElementListType::ACTIVE); | 76 client_impl_.RegisterElement(element_id_, ElementListType::ACTIVE); |
77 EXPECT_TRUE(element_animations_impl->has_element_in_active_list()); | 77 EXPECT_TRUE(element_animations_impl->has_element_in_active_list()); |
78 EXPECT_TRUE(element_animations_impl->has_element_in_pending_list()); | 78 EXPECT_TRUE(element_animations_impl->has_element_in_pending_list()); |
79 | 79 |
80 EXPECT_TRUE( | 80 EXPECT_TRUE( |
81 client_impl_.IsElementInList(element_id_, ElementListType::ACTIVE)); | 81 client_impl_.IsElementInList(element_id_, ElementListType::ACTIVE)); |
82 EXPECT_TRUE( | 82 EXPECT_TRUE( |
83 client_impl_.IsElementInList(element_id_, ElementListType::PENDING)); | 83 client_impl_.IsElementInList(element_id_, ElementListType::PENDING)); |
84 | 84 |
85 // kill layer on main thread. | 85 // kill layer on main thread. |
86 client_.UnregisterElement(element_id_, ElementListType::ACTIVE); | 86 client_.UnregisterElement(element_id_, ElementListType::ACTIVE); |
87 EXPECT_EQ(element_animations, player_->element_animations()); | 87 EXPECT_EQ(element_animations, player_->element_animations()); |
88 EXPECT_FALSE(element_animations->has_element_in_active_list()); | 88 EXPECT_FALSE(element_animations->has_element_in_active_list()); |
89 EXPECT_FALSE(element_animations->has_element_in_pending_list()); | 89 EXPECT_FALSE(element_animations->has_element_in_pending_list()); |
90 | 90 |
91 // Sync doesn't detach LayerImpl. | 91 // Sync doesn't detach LayerImpl. |
92 host_->PushPropertiesTo(host_impl_); | 92 host_->PushPropertiesTo(host_impl_, base::TimeTicks()); |
93 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); | 93 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); |
94 EXPECT_TRUE(element_animations_impl->has_element_in_active_list()); | 94 EXPECT_TRUE(element_animations_impl->has_element_in_active_list()); |
95 EXPECT_TRUE(element_animations_impl->has_element_in_pending_list()); | 95 EXPECT_TRUE(element_animations_impl->has_element_in_pending_list()); |
96 | 96 |
97 // Kill layer on impl thread in pending tree. | 97 // Kill layer on impl thread in pending tree. |
98 client_impl_.UnregisterElement(element_id_, ElementListType::PENDING); | 98 client_impl_.UnregisterElement(element_id_, ElementListType::PENDING); |
99 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); | 99 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); |
100 EXPECT_TRUE(element_animations_impl->has_element_in_active_list()); | 100 EXPECT_TRUE(element_animations_impl->has_element_in_active_list()); |
101 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list()); | 101 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list()); |
102 | 102 |
103 // Kill layer on impl thread in active tree. | 103 // Kill layer on impl thread in active tree. |
104 client_impl_.UnregisterElement(element_id_, ElementListType::ACTIVE); | 104 client_impl_.UnregisterElement(element_id_, ElementListType::ACTIVE); |
105 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); | 105 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); |
106 EXPECT_FALSE(element_animations_impl->has_element_in_active_list()); | 106 EXPECT_FALSE(element_animations_impl->has_element_in_active_list()); |
107 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list()); | 107 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list()); |
108 | 108 |
109 // Sync doesn't change anything. | 109 // Sync doesn't change anything. |
110 host_->PushPropertiesTo(host_impl_); | 110 host_->PushPropertiesTo(host_impl_, base::TimeTicks()); |
111 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); | 111 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); |
112 EXPECT_FALSE(element_animations_impl->has_element_in_active_list()); | 112 EXPECT_FALSE(element_animations_impl->has_element_in_active_list()); |
113 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list()); | 113 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list()); |
114 | 114 |
115 player_->DetachElement(); | 115 player_->DetachElement(); |
116 EXPECT_FALSE(player_->element_animations()); | 116 EXPECT_FALSE(player_->element_animations()); |
117 | 117 |
118 // Release ptrs now to test the order of destruction. | 118 // Release ptrs now to test the order of destruction. |
119 ReleaseRefPtrs(); | 119 ReleaseRefPtrs(); |
120 } | 120 } |
121 | 121 |
122 TEST_F(ElementAnimationsTest, AttachToNotYetCreatedLayer) { | 122 TEST_F(ElementAnimationsTest, AttachToNotYetCreatedLayer) { |
123 host_->AddAnimationTimeline(timeline_); | 123 host_->AddAnimationTimeline(timeline_); |
124 timeline_->AttachPlayer(player_); | 124 timeline_->AttachPlayer(player_); |
125 | 125 |
126 host_->PushPropertiesTo(host_impl_); | 126 host_->PushPropertiesTo(host_impl_, base::TimeTicks()); |
127 | 127 |
128 GetImplTimelineAndPlayerByID(); | 128 GetImplTimelineAndPlayerByID(); |
129 | 129 |
130 player_->AttachElement(element_id_); | 130 player_->AttachElement(element_id_); |
131 | 131 |
132 scoped_refptr<ElementAnimations> element_animations = | 132 scoped_refptr<ElementAnimations> element_animations = |
133 player_->element_animations(); | 133 player_->element_animations(); |
134 EXPECT_TRUE(element_animations); | 134 EXPECT_TRUE(element_animations); |
135 | 135 |
136 EXPECT_FALSE(element_animations->has_element_in_active_list()); | 136 EXPECT_FALSE(element_animations->has_element_in_active_list()); |
137 EXPECT_FALSE(element_animations->has_element_in_pending_list()); | 137 EXPECT_FALSE(element_animations->has_element_in_pending_list()); |
138 | 138 |
139 host_->PushPropertiesTo(host_impl_); | 139 host_->PushPropertiesTo(host_impl_, base::TimeTicks()); |
140 | 140 |
141 scoped_refptr<ElementAnimations> element_animations_impl = | 141 scoped_refptr<ElementAnimations> element_animations_impl = |
142 player_impl_->element_animations(); | 142 player_impl_->element_animations(); |
143 EXPECT_TRUE(element_animations_impl); | 143 EXPECT_TRUE(element_animations_impl); |
144 | 144 |
145 EXPECT_FALSE(element_animations_impl->has_element_in_active_list()); | 145 EXPECT_FALSE(element_animations_impl->has_element_in_active_list()); |
146 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list()); | 146 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list()); |
147 | 147 |
148 // Create layer. | 148 // Create layer. |
149 client_.RegisterElement(element_id_, ElementListType::ACTIVE); | 149 client_.RegisterElement(element_id_, ElementListType::ACTIVE); |
(...skipping 26 matching lines...) Expand all Loading... |
176 timeline_->AttachPlayer(player1); | 176 timeline_->AttachPlayer(player1); |
177 timeline_->AttachPlayer(player2); | 177 timeline_->AttachPlayer(player2); |
178 | 178 |
179 // Attach players to the same layer. | 179 // Attach players to the same layer. |
180 player1->AttachElement(element_id_); | 180 player1->AttachElement(element_id_); |
181 player2->AttachElement(element_id_); | 181 player2->AttachElement(element_id_); |
182 | 182 |
183 EXPECT_EQ(element_animations, player1->element_animations()); | 183 EXPECT_EQ(element_animations, player1->element_animations()); |
184 EXPECT_EQ(element_animations, player2->element_animations()); | 184 EXPECT_EQ(element_animations, player2->element_animations()); |
185 | 185 |
186 host_->PushPropertiesTo(host_impl_); | 186 host_->PushPropertiesTo(host_impl_, base::TimeTicks()); |
187 GetImplTimelineAndPlayerByID(); | 187 GetImplTimelineAndPlayerByID(); |
188 | 188 |
189 scoped_refptr<ElementAnimations> element_animations_impl = | 189 scoped_refptr<ElementAnimations> element_animations_impl = |
190 player_impl_->element_animations(); | 190 player_impl_->element_animations(); |
191 EXPECT_TRUE(element_animations_impl); | 191 EXPECT_TRUE(element_animations_impl); |
192 | 192 |
193 int list_size_before = 0; | 193 int list_size_before = 0; |
194 for (const ElementAnimations::PlayersListNode* node = | 194 for (const ElementAnimations::PlayersListNode* node = |
195 element_animations_impl->players_list().head(); | 195 element_animations_impl->players_list().head(); |
196 node != element_animations_impl->players_list().end(); | 196 node != element_animations_impl->players_list().end(); |
197 node = node->next()) { | 197 node = node->next()) { |
198 const AnimationPlayer* player_impl = node->value(); | 198 const AnimationPlayer* player_impl = node->value(); |
199 EXPECT_TRUE(timeline_->GetPlayerById(player_impl->id())); | 199 EXPECT_TRUE(timeline_->GetPlayerById(player_impl->id())); |
200 ++list_size_before; | 200 ++list_size_before; |
201 } | 201 } |
202 EXPECT_EQ(3, list_size_before); | 202 EXPECT_EQ(3, list_size_before); |
203 | 203 |
204 player2->DetachElement(); | 204 player2->DetachElement(); |
205 EXPECT_FALSE(player2->element_animations()); | 205 EXPECT_FALSE(player2->element_animations()); |
206 EXPECT_EQ(element_animations, player_->element_animations()); | 206 EXPECT_EQ(element_animations, player_->element_animations()); |
207 EXPECT_EQ(element_animations, player1->element_animations()); | 207 EXPECT_EQ(element_animations, player1->element_animations()); |
208 | 208 |
209 host_->PushPropertiesTo(host_impl_); | 209 host_->PushPropertiesTo(host_impl_, base::TimeTicks()); |
210 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); | 210 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); |
211 | 211 |
212 int list_size_after = 0; | 212 int list_size_after = 0; |
213 for (const ElementAnimations::PlayersListNode* node = | 213 for (const ElementAnimations::PlayersListNode* node = |
214 element_animations_impl->players_list().head(); | 214 element_animations_impl->players_list().head(); |
215 node != element_animations_impl->players_list().end(); | 215 node != element_animations_impl->players_list().end(); |
216 node = node->next()) { | 216 node = node->next()) { |
217 const AnimationPlayer* player_impl = node->value(); | 217 const AnimationPlayer* player_impl = node->value(); |
218 EXPECT_TRUE(timeline_->GetPlayerById(player_impl->id())); | 218 EXPECT_TRUE(timeline_->GetPlayerById(player_impl->id())); |
219 ++list_size_after; | 219 ++list_size_after; |
(...skipping 3238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3458 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( | 3458 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( |
3459 TargetProperty::OPACITY, ElementListType::ACTIVE)); | 3459 TargetProperty::OPACITY, ElementListType::ACTIVE)); |
3460 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3460 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( |
3461 TargetProperty::OPACITY, ElementListType::PENDING)); | 3461 TargetProperty::OPACITY, ElementListType::PENDING)); |
3462 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3462 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( |
3463 TargetProperty::OPACITY, ElementListType::ACTIVE)); | 3463 TargetProperty::OPACITY, ElementListType::ACTIVE)); |
3464 } | 3464 } |
3465 | 3465 |
3466 } // namespace | 3466 } // namespace |
3467 } // namespace cc | 3467 } // namespace cc |
OLD | NEW |