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/animation_player.h" | 5 #include "cc/animation/animation_player.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_timeline.h" | 10 #include "cc/animation/animation_timeline.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 }; | 22 }; |
23 | 23 |
24 // See element_animations_unittest.cc for active/pending observers tests. | 24 // See element_animations_unittest.cc for active/pending observers tests. |
25 | 25 |
26 TEST_F(AnimationPlayerTest, AttachDetachLayerIfTimelineAttached) { | 26 TEST_F(AnimationPlayerTest, AttachDetachLayerIfTimelineAttached) { |
27 host_->AddAnimationTimeline(timeline_); | 27 host_->AddAnimationTimeline(timeline_); |
28 timeline_->AttachPlayer(player_); | 28 timeline_->AttachPlayer(player_); |
29 EXPECT_FALSE(player_->element_animations()); | 29 EXPECT_FALSE(player_->element_animations()); |
30 EXPECT_FALSE(player_->element_id()); | 30 EXPECT_FALSE(player_->element_id()); |
31 | 31 |
32 host_->PushPropertiesTo(host_impl_); | 32 host_->PushPropertiesTo(host_impl_, base::TimeTicks()); |
33 | 33 |
34 EXPECT_FALSE(GetImplPlayerForLayerId(element_id_)); | 34 EXPECT_FALSE(GetImplPlayerForLayerId(element_id_)); |
35 | 35 |
36 GetImplTimelineAndPlayerByID(); | 36 GetImplTimelineAndPlayerByID(); |
37 | 37 |
38 EXPECT_FALSE(player_impl_->element_animations()); | 38 EXPECT_FALSE(player_impl_->element_animations()); |
39 EXPECT_FALSE(player_impl_->element_id()); | 39 EXPECT_FALSE(player_impl_->element_id()); |
40 | 40 |
41 player_->AttachElement(element_id_); | 41 player_->AttachElement(element_id_); |
42 EXPECT_EQ(player_, GetPlayerForLayerId(element_id_)); | 42 EXPECT_EQ(player_, GetPlayerForLayerId(element_id_)); |
43 EXPECT_TRUE(player_->element_animations()); | 43 EXPECT_TRUE(player_->element_animations()); |
44 EXPECT_EQ(player_->element_id(), element_id_); | 44 EXPECT_EQ(player_->element_id(), element_id_); |
45 | 45 |
46 host_->PushPropertiesTo(host_impl_); | 46 host_->PushPropertiesTo(host_impl_, base::TimeTicks()); |
47 | 47 |
48 EXPECT_EQ(player_impl_, GetImplPlayerForLayerId(element_id_)); | 48 EXPECT_EQ(player_impl_, GetImplPlayerForLayerId(element_id_)); |
49 EXPECT_TRUE(player_impl_->element_animations()); | 49 EXPECT_TRUE(player_impl_->element_animations()); |
50 EXPECT_EQ(player_impl_->element_id(), element_id_); | 50 EXPECT_EQ(player_impl_->element_id(), element_id_); |
51 | 51 |
52 player_->DetachElement(); | 52 player_->DetachElement(); |
53 EXPECT_FALSE(GetPlayerForLayerId(element_id_)); | 53 EXPECT_FALSE(GetPlayerForLayerId(element_id_)); |
54 EXPECT_FALSE(player_->element_animations()); | 54 EXPECT_FALSE(player_->element_animations()); |
55 EXPECT_FALSE(player_->element_id()); | 55 EXPECT_FALSE(player_->element_id()); |
56 | 56 |
57 host_->PushPropertiesTo(host_impl_); | 57 host_->PushPropertiesTo(host_impl_, base::TimeTicks()); |
58 | 58 |
59 EXPECT_FALSE(GetImplPlayerForLayerId(element_id_)); | 59 EXPECT_FALSE(GetImplPlayerForLayerId(element_id_)); |
60 EXPECT_FALSE(player_impl_->element_animations()); | 60 EXPECT_FALSE(player_impl_->element_animations()); |
61 EXPECT_FALSE(player_impl_->element_id()); | 61 EXPECT_FALSE(player_impl_->element_id()); |
62 | 62 |
63 timeline_->DetachPlayer(player_); | 63 timeline_->DetachPlayer(player_); |
64 EXPECT_FALSE(player_->animation_timeline()); | 64 EXPECT_FALSE(player_->animation_timeline()); |
65 EXPECT_FALSE(player_->element_animations()); | 65 EXPECT_FALSE(player_->element_animations()); |
66 EXPECT_FALSE(player_->element_id()); | 66 EXPECT_FALSE(player_->element_id()); |
67 } | 67 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 const double duration = 1.; | 113 const double duration = 1.; |
114 | 114 |
115 AddOpacityTransitionToPlayer(player_.get(), duration, start_opacity, | 115 AddOpacityTransitionToPlayer(player_.get(), duration, start_opacity, |
116 end_opacity, false); | 116 end_opacity, false); |
117 AddAnimatedTransformToPlayer(player_.get(), duration, transform_x, | 117 AddAnimatedTransformToPlayer(player_.get(), duration, transform_x, |
118 transform_y); | 118 transform_y); |
119 AddAnimatedFilterToPlayer(player_.get(), duration, start_brightness, | 119 AddAnimatedFilterToPlayer(player_.get(), duration, start_brightness, |
120 end_brightness); | 120 end_brightness); |
121 | 121 |
122 host_->PushPropertiesTo(host_impl_); | 122 host_->PushPropertiesTo(host_impl_, base::TimeTicks()); |
123 | 123 |
124 EXPECT_FALSE(client_.IsPropertyMutated(element_id_, ElementListType::ACTIVE, | 124 EXPECT_FALSE(client_.IsPropertyMutated(element_id_, ElementListType::ACTIVE, |
125 TargetProperty::OPACITY)); | 125 TargetProperty::OPACITY)); |
126 EXPECT_FALSE(client_.IsPropertyMutated(element_id_, ElementListType::ACTIVE, | 126 EXPECT_FALSE(client_.IsPropertyMutated(element_id_, ElementListType::ACTIVE, |
127 TargetProperty::TRANSFORM)); | 127 TargetProperty::TRANSFORM)); |
128 EXPECT_FALSE(client_.IsPropertyMutated(element_id_, ElementListType::ACTIVE, | 128 EXPECT_FALSE(client_.IsPropertyMutated(element_id_, ElementListType::ACTIVE, |
129 TargetProperty::FILTER)); | 129 TargetProperty::FILTER)); |
130 | 130 |
131 EXPECT_FALSE(client_impl_.IsPropertyMutated( | 131 EXPECT_FALSE(client_impl_.IsPropertyMutated( |
132 element_id_, ElementListType::ACTIVE, TargetProperty::OPACITY)); | 132 element_id_, ElementListType::ACTIVE, TargetProperty::OPACITY)); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 const int transform_x = 10; | 196 const int transform_x = 10; |
197 const int transform_y = 20; | 197 const int transform_y = 20; |
198 | 198 |
199 const double duration = 1.; | 199 const double duration = 1.; |
200 | 200 |
201 AddOpacityTransitionToPlayer(player1.get(), duration, start_opacity, | 201 AddOpacityTransitionToPlayer(player1.get(), duration, start_opacity, |
202 end_opacity, false); | 202 end_opacity, false); |
203 AddAnimatedTransformToPlayer(player2.get(), duration, transform_x, | 203 AddAnimatedTransformToPlayer(player2.get(), duration, transform_x, |
204 transform_y); | 204 transform_y); |
205 | 205 |
206 host_->PushPropertiesTo(host_impl_); | 206 host_->PushPropertiesTo(host_impl_, base::TimeTicks()); |
207 host_impl_->ActivateAnimations(); | 207 host_impl_->ActivateAnimations(); |
208 | 208 |
209 EXPECT_FALSE(delegate1.started()); | 209 EXPECT_FALSE(delegate1.started()); |
210 EXPECT_FALSE(delegate1.finished()); | 210 EXPECT_FALSE(delegate1.finished()); |
211 | 211 |
212 EXPECT_FALSE(delegate2.started()); | 212 EXPECT_FALSE(delegate2.started()); |
213 EXPECT_FALSE(delegate2.finished()); | 213 EXPECT_FALSE(delegate2.finished()); |
214 | 214 |
215 base::TimeTicks time; | 215 base::TimeTicks time; |
216 time += base::TimeDelta::FromSecondsD(0.1); | 216 time += base::TimeDelta::FromSecondsD(0.1); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 player_->RemoveAnimation(filter_id); | 265 player_->RemoveAnimation(filter_id); |
266 | 266 |
267 player_->AttachElement(element_id_); | 267 player_->AttachElement(element_id_); |
268 | 268 |
269 EXPECT_TRUE(player_->element_animations()); | 269 EXPECT_TRUE(player_->element_animations()); |
270 EXPECT_FALSE(player_->element_animations() | 270 EXPECT_FALSE(player_->element_animations() |
271 ->GetAnimationById(filter_id)); | 271 ->GetAnimationById(filter_id)); |
272 EXPECT_TRUE(player_->element_animations() | 272 EXPECT_TRUE(player_->element_animations() |
273 ->GetAnimationById(opacity_id)); | 273 ->GetAnimationById(opacity_id)); |
274 | 274 |
275 host_->PushPropertiesTo(host_impl_); | 275 host_->PushPropertiesTo(host_impl_, base::TimeTicks()); |
276 | 276 |
277 EXPECT_FALSE(client_.IsPropertyMutated(element_id_, ElementListType::ACTIVE, | 277 EXPECT_FALSE(client_.IsPropertyMutated(element_id_, ElementListType::ACTIVE, |
278 TargetProperty::OPACITY)); | 278 TargetProperty::OPACITY)); |
279 EXPECT_FALSE(client_impl_.IsPropertyMutated( | 279 EXPECT_FALSE(client_impl_.IsPropertyMutated( |
280 element_id_, ElementListType::ACTIVE, TargetProperty::OPACITY)); | 280 element_id_, ElementListType::ACTIVE, TargetProperty::OPACITY)); |
281 | 281 |
282 EXPECT_FALSE(client_.IsPropertyMutated(element_id_, ElementListType::ACTIVE, | 282 EXPECT_FALSE(client_.IsPropertyMutated(element_id_, ElementListType::ACTIVE, |
283 TargetProperty::FILTER)); | 283 TargetProperty::FILTER)); |
284 EXPECT_FALSE(client_impl_.IsPropertyMutated( | 284 EXPECT_FALSE(client_impl_.IsPropertyMutated( |
285 element_id_, ElementListType::ACTIVE, TargetProperty::FILTER)); | 285 element_id_, ElementListType::ACTIVE, TargetProperty::FILTER)); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 client_.set_mutators_need_commit(false); | 329 client_.set_mutators_need_commit(false); |
330 } | 330 } |
331 | 331 |
332 // If main-thread player switches to another layer within one frame then | 332 // If main-thread player switches to another layer within one frame then |
333 // impl-thread player must be switched as well. | 333 // impl-thread player must be switched as well. |
334 TEST_F(AnimationPlayerTest, SwitchToLayer) { | 334 TEST_F(AnimationPlayerTest, SwitchToLayer) { |
335 host_->AddAnimationTimeline(timeline_); | 335 host_->AddAnimationTimeline(timeline_); |
336 timeline_->AttachPlayer(player_); | 336 timeline_->AttachPlayer(player_); |
337 player_->AttachElement(element_id_); | 337 player_->AttachElement(element_id_); |
338 | 338 |
339 host_->PushPropertiesTo(host_impl_); | 339 host_->PushPropertiesTo(host_impl_, base::TimeTicks()); |
340 | 340 |
341 GetImplTimelineAndPlayerByID(); | 341 GetImplTimelineAndPlayerByID(); |
342 | 342 |
343 EXPECT_EQ(player_, GetPlayerForLayerId(element_id_)); | 343 EXPECT_EQ(player_, GetPlayerForLayerId(element_id_)); |
344 EXPECT_TRUE(player_->element_animations()); | 344 EXPECT_TRUE(player_->element_animations()); |
345 EXPECT_EQ(player_->element_id(), element_id_); | 345 EXPECT_EQ(player_->element_id(), element_id_); |
346 | 346 |
347 EXPECT_EQ(player_impl_, GetImplPlayerForLayerId(element_id_)); | 347 EXPECT_EQ(player_impl_, GetImplPlayerForLayerId(element_id_)); |
348 EXPECT_TRUE(player_impl_->element_animations()); | 348 EXPECT_TRUE(player_impl_->element_animations()); |
349 EXPECT_EQ(player_impl_->element_id(), element_id_); | 349 EXPECT_EQ(player_impl_->element_id(), element_id_); |
350 | 350 |
351 const int new_layer_id = NextTestLayerId(); | 351 const int new_layer_id = NextTestLayerId(); |
352 player_->DetachElement(); | 352 player_->DetachElement(); |
353 player_->AttachElement(new_layer_id); | 353 player_->AttachElement(new_layer_id); |
354 | 354 |
355 EXPECT_EQ(player_, GetPlayerForLayerId(new_layer_id)); | 355 EXPECT_EQ(player_, GetPlayerForLayerId(new_layer_id)); |
356 EXPECT_TRUE(player_->element_animations()); | 356 EXPECT_TRUE(player_->element_animations()); |
357 EXPECT_EQ(player_->element_id(), new_layer_id); | 357 EXPECT_EQ(player_->element_id(), new_layer_id); |
358 | 358 |
359 host_->PushPropertiesTo(host_impl_); | 359 host_->PushPropertiesTo(host_impl_, base::TimeTicks()); |
360 | 360 |
361 EXPECT_EQ(player_impl_, GetImplPlayerForLayerId(new_layer_id)); | 361 EXPECT_EQ(player_impl_, GetImplPlayerForLayerId(new_layer_id)); |
362 EXPECT_TRUE(player_impl_->element_animations()); | 362 EXPECT_TRUE(player_impl_->element_animations()); |
363 EXPECT_EQ(player_impl_->element_id(), new_layer_id); | 363 EXPECT_EQ(player_impl_->element_id(), new_layer_id); |
364 } | 364 } |
365 | 365 |
366 } // namespace | 366 } // namespace |
367 } // namespace cc | 367 } // namespace cc |
OLD | NEW |