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 21 matching lines...) Expand all Loading... |
32 host_->PushPropertiesTo(host_impl_); | 32 host_->PushPropertiesTo(host_impl_); |
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_, GetPlayerForElementId(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_); |
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(GetPlayerForElementId(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_); |
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 } |
68 | 68 |
69 TEST_F(AnimationPlayerTest, AttachDetachTimelineIfLayerAttached) { | 69 TEST_F(AnimationPlayerTest, AttachDetachTimelineIfLayerAttached) { |
70 host_->AddAnimationTimeline(timeline_); | 70 host_->AddAnimationTimeline(timeline_); |
71 | 71 |
72 EXPECT_FALSE(player_->element_animations()); | 72 EXPECT_FALSE(player_->element_animations()); |
73 EXPECT_FALSE(player_->element_id()); | 73 EXPECT_FALSE(player_->element_id()); |
74 | 74 |
75 player_->AttachElement(element_id_); | 75 player_->AttachElement(element_id_); |
76 EXPECT_FALSE(player_->animation_timeline()); | 76 EXPECT_FALSE(player_->animation_timeline()); |
77 EXPECT_FALSE(GetPlayerForLayerId(element_id_)); | 77 EXPECT_FALSE(GetPlayerForElementId(element_id_)); |
78 EXPECT_FALSE(player_->element_animations()); | 78 EXPECT_FALSE(player_->element_animations()); |
79 EXPECT_EQ(player_->element_id(), element_id_); | 79 EXPECT_EQ(player_->element_id(), element_id_); |
80 | 80 |
81 timeline_->AttachPlayer(player_); | 81 timeline_->AttachPlayer(player_); |
82 EXPECT_EQ(timeline_, player_->animation_timeline()); | 82 EXPECT_EQ(timeline_, player_->animation_timeline()); |
83 EXPECT_EQ(player_, GetPlayerForLayerId(element_id_)); | 83 EXPECT_EQ(player_, GetPlayerForElementId(element_id_)); |
84 EXPECT_TRUE(player_->element_animations()); | 84 EXPECT_TRUE(player_->element_animations()); |
85 EXPECT_EQ(player_->element_id(), element_id_); | 85 EXPECT_EQ(player_->element_id(), element_id_); |
86 | 86 |
87 // Removing player from timeline detaches layer. | 87 // Removing player from timeline detaches layer. |
88 timeline_->DetachPlayer(player_); | 88 timeline_->DetachPlayer(player_); |
89 EXPECT_FALSE(player_->animation_timeline()); | 89 EXPECT_FALSE(player_->animation_timeline()); |
90 EXPECT_FALSE(GetPlayerForLayerId(element_id_)); | 90 EXPECT_FALSE(GetPlayerForElementId(element_id_)); |
91 EXPECT_FALSE(player_->element_animations()); | 91 EXPECT_FALSE(player_->element_animations()); |
92 EXPECT_FALSE(player_->element_id()); | 92 EXPECT_FALSE(player_->element_id()); |
93 } | 93 } |
94 | 94 |
95 TEST_F(AnimationPlayerTest, PropertiesMutate) { | 95 TEST_F(AnimationPlayerTest, PropertiesMutate) { |
96 client_.RegisterElement(element_id_, ElementListType::ACTIVE); | 96 client_.RegisterElement(element_id_, ElementListType::ACTIVE); |
97 client_impl_.RegisterElement(element_id_, ElementListType::PENDING); | 97 client_impl_.RegisterElement(element_id_, ElementListType::PENDING); |
98 client_impl_.RegisterElement(element_id_, ElementListType::ACTIVE); | 98 client_impl_.RegisterElement(element_id_, ElementListType::ACTIVE); |
99 | 99 |
100 host_->AddAnimationTimeline(timeline_); | 100 host_->AddAnimationTimeline(timeline_); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_); |
340 | 340 |
341 GetImplTimelineAndPlayerByID(); | 341 GetImplTimelineAndPlayerByID(); |
342 | 342 |
343 EXPECT_EQ(player_, GetPlayerForLayerId(element_id_)); | 343 EXPECT_EQ(player_, GetPlayerForElementId(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 ElementId new_element_id(NextTestLayerId(), 0); |
352 player_->DetachElement(); | 352 player_->DetachElement(); |
353 player_->AttachElement(new_layer_id); | 353 player_->AttachElement(new_element_id); |
354 | 354 |
355 EXPECT_EQ(player_, GetPlayerForLayerId(new_layer_id)); | 355 EXPECT_EQ(player_, GetPlayerForElementId(new_element_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_element_id); |
358 | 358 |
359 host_->PushPropertiesTo(host_impl_); | 359 host_->PushPropertiesTo(host_impl_); |
360 | 360 |
361 EXPECT_EQ(player_impl_, GetImplPlayerForLayerId(new_layer_id)); | 361 EXPECT_EQ(player_impl_, GetImplPlayerForLayerId(new_element_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_element_id); |
364 } | 364 } |
365 | 365 |
366 } // namespace | 366 } // namespace |
367 } // namespace cc | 367 } // namespace cc |
OLD | NEW |