Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: cc/animation/animation_player_unittest.cc

Issue 1922833002: CC Animation: Start replacing int layer_id with ElementId element_id. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/animation/animation_player.cc ('k') | cc/animation/element_animations.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "cc/animation/element_animations.h" 11 #include "cc/animation/element_animations.h"
12 #include "cc/test/animation_test_common.h" 12 #include "cc/test/animation_test_common.h"
13 #include "cc/test/animation_timelines_test_common.h" 13 #include "cc/test/animation_timelines_test_common.h"
14 14
15 namespace cc { 15 namespace cc {
16 namespace { 16 namespace {
17 17
18 class AnimationPlayerTest : public AnimationTimelinesTest { 18 class AnimationPlayerTest : public AnimationTimelinesTest {
19 public: 19 public:
20 AnimationPlayerTest() {} 20 AnimationPlayerTest() {}
21 ~AnimationPlayerTest() override {} 21 ~AnimationPlayerTest() override {}
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_->layer_id()); 30 EXPECT_FALSE(player_->element_id());
31 31
32 host_->PushPropertiesTo(host_impl_); 32 host_->PushPropertiesTo(host_impl_);
33 33
34 EXPECT_FALSE(GetImplPlayerForLayerId(layer_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_->layer_id()); 39 EXPECT_FALSE(player_impl_->element_id());
40 40
41 player_->AttachLayer(layer_id_); 41 player_->AttachLayer(element_id_);
42 EXPECT_EQ(player_, GetPlayerForLayerId(layer_id_)); 42 EXPECT_EQ(player_, GetPlayerForLayerId(element_id_));
43 EXPECT_TRUE(player_->element_animations()); 43 EXPECT_TRUE(player_->element_animations());
44 EXPECT_EQ(player_->layer_id(), layer_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(layer_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_->layer_id(), layer_id_); 50 EXPECT_EQ(player_impl_->element_id(), element_id_);
51 51
52 player_->DetachLayer(); 52 player_->DetachLayer();
53 EXPECT_FALSE(GetPlayerForLayerId(layer_id_)); 53 EXPECT_FALSE(GetPlayerForLayerId(element_id_));
54 EXPECT_FALSE(player_->element_animations()); 54 EXPECT_FALSE(player_->element_animations());
55 EXPECT_FALSE(player_->layer_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(layer_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_->layer_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_->layer_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_->layer_id()); 73 EXPECT_FALSE(player_->element_id());
74 74
75 player_->AttachLayer(layer_id_); 75 player_->AttachLayer(element_id_);
76 EXPECT_FALSE(player_->animation_timeline()); 76 EXPECT_FALSE(player_->animation_timeline());
77 EXPECT_FALSE(GetPlayerForLayerId(layer_id_)); 77 EXPECT_FALSE(GetPlayerForLayerId(element_id_));
78 EXPECT_FALSE(player_->element_animations()); 78 EXPECT_FALSE(player_->element_animations());
79 EXPECT_EQ(player_->layer_id(), layer_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(layer_id_)); 83 EXPECT_EQ(player_, GetPlayerForLayerId(element_id_));
84 EXPECT_TRUE(player_->element_animations()); 84 EXPECT_TRUE(player_->element_animations());
85 EXPECT_EQ(player_->layer_id(), layer_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(layer_id_)); 90 EXPECT_FALSE(GetPlayerForLayerId(element_id_));
91 EXPECT_FALSE(player_->element_animations()); 91 EXPECT_FALSE(player_->element_animations());
92 EXPECT_FALSE(player_->layer_id()); 92 EXPECT_FALSE(player_->element_id());
93 } 93 }
94 94
95 TEST_F(AnimationPlayerTest, PropertiesMutate) { 95 TEST_F(AnimationPlayerTest, PropertiesMutate) {
96 client_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); 96 client_.RegisterLayer(element_id_, LayerTreeType::ACTIVE);
97 client_impl_.RegisterLayer(layer_id_, LayerTreeType::PENDING); 97 client_impl_.RegisterLayer(element_id_, LayerTreeType::PENDING);
98 client_impl_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); 98 client_impl_.RegisterLayer(element_id_, LayerTreeType::ACTIVE);
99 99
100 host_->AddAnimationTimeline(timeline_); 100 host_->AddAnimationTimeline(timeline_);
101 timeline_->AttachPlayer(player_); 101 timeline_->AttachPlayer(player_);
102 player_->AttachLayer(layer_id_); 102 player_->AttachLayer(element_id_);
103 103
104 const float start_opacity = .7f; 104 const float start_opacity = .7f;
105 const float end_opacity = .3f; 105 const float end_opacity = .3f;
106 106
107 const float start_brightness = .6f; 107 const float start_brightness = .6f;
108 const float end_brightness = .4f; 108 const float end_brightness = .4f;
109 109
110 const int transform_x = 10; 110 const int transform_x = 10;
111 const int transform_y = 20; 111 const int transform_y = 20;
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_);
123 123
124 EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 124 EXPECT_FALSE(client_.IsPropertyMutated(element_id_, LayerTreeType::ACTIVE,
125 TargetProperty::OPACITY)); 125 TargetProperty::OPACITY));
126 EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 126 EXPECT_FALSE(client_.IsPropertyMutated(element_id_, LayerTreeType::ACTIVE,
127 TargetProperty::TRANSFORM)); 127 TargetProperty::TRANSFORM));
128 EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 128 EXPECT_FALSE(client_.IsPropertyMutated(element_id_, LayerTreeType::ACTIVE,
129 TargetProperty::FILTER)); 129 TargetProperty::FILTER));
130 130
131 EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 131 EXPECT_FALSE(client_impl_.IsPropertyMutated(
132 TargetProperty::OPACITY)); 132 element_id_, LayerTreeType::ACTIVE, TargetProperty::OPACITY));
133 EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 133 EXPECT_FALSE(client_impl_.IsPropertyMutated(
134 TargetProperty::TRANSFORM)); 134 element_id_, LayerTreeType::ACTIVE, TargetProperty::TRANSFORM));
135 EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 135 EXPECT_FALSE(client_impl_.IsPropertyMutated(
136 TargetProperty::FILTER)); 136 element_id_, LayerTreeType::ACTIVE, TargetProperty::FILTER));
137 137
138 host_impl_->ActivateAnimations(); 138 host_impl_->ActivateAnimations();
139 139
140 base::TimeTicks time; 140 base::TimeTicks time;
141 time += base::TimeDelta::FromSecondsD(0.1); 141 time += base::TimeDelta::FromSecondsD(0.1);
142 AnimateLayersTransferEvents(time, 3u); 142 AnimateLayersTransferEvents(time, 3u);
143 143
144 time += base::TimeDelta::FromSecondsD(duration); 144 time += base::TimeDelta::FromSecondsD(duration);
145 AnimateLayersTransferEvents(time, 3u); 145 AnimateLayersTransferEvents(time, 3u);
146 146
147 client_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 147 client_.ExpectOpacityPropertyMutated(element_id_, LayerTreeType::ACTIVE,
148 end_opacity); 148 end_opacity);
149 client_.ExpectTransformPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 149 client_.ExpectTransformPropertyMutated(element_id_, LayerTreeType::ACTIVE,
150 transform_x, transform_y); 150 transform_x, transform_y);
151 client_.ExpectFilterPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 151 client_.ExpectFilterPropertyMutated(element_id_, LayerTreeType::ACTIVE,
152 end_brightness); 152 end_brightness);
153 153
154 client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 154 client_impl_.ExpectOpacityPropertyMutated(element_id_, LayerTreeType::ACTIVE,
155 end_opacity); 155 end_opacity);
156 client_impl_.ExpectTransformPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 156 client_impl_.ExpectTransformPropertyMutated(
157 transform_x, transform_y); 157 element_id_, LayerTreeType::ACTIVE, transform_x, transform_y);
158 client_impl_.ExpectFilterPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 158 client_impl_.ExpectFilterPropertyMutated(element_id_, LayerTreeType::ACTIVE,
159 end_brightness); 159 end_brightness);
160 160
161 client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::PENDING, 161 client_impl_.ExpectOpacityPropertyMutated(element_id_, LayerTreeType::PENDING,
162 end_opacity); 162 end_opacity);
163 client_impl_.ExpectTransformPropertyMutated(layer_id_, LayerTreeType::PENDING, 163 client_impl_.ExpectTransformPropertyMutated(
164 transform_x, transform_y); 164 element_id_, LayerTreeType::PENDING, transform_x, transform_y);
165 client_impl_.ExpectFilterPropertyMutated(layer_id_, LayerTreeType::PENDING, 165 client_impl_.ExpectFilterPropertyMutated(element_id_, LayerTreeType::PENDING,
166 end_brightness); 166 end_brightness);
167 } 167 }
168 168
169 TEST_F(AnimationPlayerTest, AttachTwoPlayersToOneLayer) { 169 TEST_F(AnimationPlayerTest, AttachTwoPlayersToOneLayer) {
170 TestAnimationDelegate delegate1; 170 TestAnimationDelegate delegate1;
171 TestAnimationDelegate delegate2; 171 TestAnimationDelegate delegate2;
172 172
173 client_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); 173 client_.RegisterLayer(element_id_, LayerTreeType::ACTIVE);
174 client_impl_.RegisterLayer(layer_id_, LayerTreeType::PENDING); 174 client_impl_.RegisterLayer(element_id_, LayerTreeType::PENDING);
175 client_impl_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); 175 client_impl_.RegisterLayer(element_id_, LayerTreeType::ACTIVE);
176 176
177 scoped_refptr<AnimationPlayer> player1 = 177 scoped_refptr<AnimationPlayer> player1 =
178 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); 178 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId());
179 scoped_refptr<AnimationPlayer> player2 = 179 scoped_refptr<AnimationPlayer> player2 =
180 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); 180 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId());
181 181
182 host_->AddAnimationTimeline(timeline_); 182 host_->AddAnimationTimeline(timeline_);
183 timeline_->AttachPlayer(player1); 183 timeline_->AttachPlayer(player1);
184 timeline_->AttachPlayer(player2); 184 timeline_->AttachPlayer(player2);
185 185
186 player1->set_layer_animation_delegate(&delegate1); 186 player1->set_layer_animation_delegate(&delegate1);
187 player2->set_layer_animation_delegate(&delegate2); 187 player2->set_layer_animation_delegate(&delegate2);
188 188
189 // Attach players to the same layer. 189 // Attach players to the same layer.
190 player1->AttachLayer(layer_id_); 190 player1->AttachLayer(element_id_);
191 player2->AttachLayer(layer_id_); 191 player2->AttachLayer(element_id_);
192 192
193 const float start_opacity = .7f; 193 const float start_opacity = .7f;
194 const float end_opacity = .3f; 194 const float end_opacity = .3f;
195 195
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,
(...skipping 19 matching lines...) Expand all
221 221
222 EXPECT_TRUE(delegate2.started()); 222 EXPECT_TRUE(delegate2.started());
223 EXPECT_FALSE(delegate2.finished()); 223 EXPECT_FALSE(delegate2.finished());
224 224
225 time += base::TimeDelta::FromSecondsD(duration); 225 time += base::TimeDelta::FromSecondsD(duration);
226 AnimateLayersTransferEvents(time, 2u); 226 AnimateLayersTransferEvents(time, 2u);
227 227
228 EXPECT_TRUE(delegate1.finished()); 228 EXPECT_TRUE(delegate1.finished());
229 EXPECT_TRUE(delegate2.finished()); 229 EXPECT_TRUE(delegate2.finished());
230 230
231 client_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 231 client_.ExpectOpacityPropertyMutated(element_id_, LayerTreeType::ACTIVE,
232 end_opacity); 232 end_opacity);
233 client_.ExpectTransformPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 233 client_.ExpectTransformPropertyMutated(element_id_, LayerTreeType::ACTIVE,
234 transform_x, transform_y); 234 transform_x, transform_y);
235 235
236 client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 236 client_impl_.ExpectOpacityPropertyMutated(element_id_, LayerTreeType::ACTIVE,
237 end_opacity); 237 end_opacity);
238 client_impl_.ExpectTransformPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 238 client_impl_.ExpectTransformPropertyMutated(
239 transform_x, transform_y); 239 element_id_, LayerTreeType::ACTIVE, transform_x, transform_y);
240 240
241 client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::PENDING, 241 client_impl_.ExpectOpacityPropertyMutated(element_id_, LayerTreeType::PENDING,
242 end_opacity); 242 end_opacity);
243 client_impl_.ExpectTransformPropertyMutated(layer_id_, LayerTreeType::PENDING, 243 client_impl_.ExpectTransformPropertyMutated(
244 transform_x, transform_y); 244 element_id_, LayerTreeType::PENDING, transform_x, transform_y);
245 } 245 }
246 246
247 TEST_F(AnimationPlayerTest, AddRemoveAnimationToNonAttachedPlayer) { 247 TEST_F(AnimationPlayerTest, AddRemoveAnimationToNonAttachedPlayer) {
248 client_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); 248 client_.RegisterLayer(element_id_, LayerTreeType::ACTIVE);
249 client_impl_.RegisterLayer(layer_id_, LayerTreeType::PENDING); 249 client_impl_.RegisterLayer(element_id_, LayerTreeType::PENDING);
250 client_impl_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); 250 client_impl_.RegisterLayer(element_id_, LayerTreeType::ACTIVE);
251 251
252 const double duration = 1.; 252 const double duration = 1.;
253 const float start_opacity = .7f; 253 const float start_opacity = .7f;
254 const float end_opacity = .3f; 254 const float end_opacity = .3f;
255 255
256 const int filter_id = 256 const int filter_id =
257 AddAnimatedFilterToPlayer(player_.get(), duration, 0.1f, 0.9f); 257 AddAnimatedFilterToPlayer(player_.get(), duration, 0.1f, 0.9f);
258 const int opacity_id = AddOpacityTransitionToPlayer( 258 const int opacity_id = AddOpacityTransitionToPlayer(
259 player_.get(), duration, start_opacity, end_opacity, false); 259 player_.get(), duration, start_opacity, end_opacity, false);
260 260
261 host_->AddAnimationTimeline(timeline_); 261 host_->AddAnimationTimeline(timeline_);
262 timeline_->AttachPlayer(player_); 262 timeline_->AttachPlayer(player_);
263 263
264 EXPECT_FALSE(player_->element_animations()); 264 EXPECT_FALSE(player_->element_animations());
265 player_->RemoveAnimation(filter_id); 265 player_->RemoveAnimation(filter_id);
266 266
267 player_->AttachLayer(layer_id_); 267 player_->AttachLayer(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_);
276 276
277 EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 277 EXPECT_FALSE(client_.IsPropertyMutated(element_id_, LayerTreeType::ACTIVE,
278 TargetProperty::OPACITY)); 278 TargetProperty::OPACITY));
279 EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 279 EXPECT_FALSE(client_impl_.IsPropertyMutated(
280 TargetProperty::OPACITY)); 280 element_id_, LayerTreeType::ACTIVE, TargetProperty::OPACITY));
281 281
282 EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 282 EXPECT_FALSE(client_.IsPropertyMutated(element_id_, LayerTreeType::ACTIVE,
283 TargetProperty::FILTER)); 283 TargetProperty::FILTER));
284 EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 284 EXPECT_FALSE(client_impl_.IsPropertyMutated(
285 TargetProperty::FILTER)); 285 element_id_, LayerTreeType::ACTIVE, TargetProperty::FILTER));
286 286
287 host_impl_->ActivateAnimations(); 287 host_impl_->ActivateAnimations();
288 288
289 base::TimeTicks time; 289 base::TimeTicks time;
290 time += base::TimeDelta::FromSecondsD(0.1); 290 time += base::TimeDelta::FromSecondsD(0.1);
291 AnimateLayersTransferEvents(time, 1u); 291 AnimateLayersTransferEvents(time, 1u);
292 292
293 time += base::TimeDelta::FromSecondsD(duration); 293 time += base::TimeDelta::FromSecondsD(duration);
294 AnimateLayersTransferEvents(time, 1u); 294 AnimateLayersTransferEvents(time, 1u);
295 295
296 client_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 296 client_.ExpectOpacityPropertyMutated(element_id_, LayerTreeType::ACTIVE,
297 end_opacity); 297 end_opacity);
298 client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 298 client_impl_.ExpectOpacityPropertyMutated(element_id_, LayerTreeType::ACTIVE,
299 end_opacity); 299 end_opacity);
300 client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::PENDING, 300 client_impl_.ExpectOpacityPropertyMutated(element_id_, LayerTreeType::PENDING,
301 end_opacity); 301 end_opacity);
302 302
303 EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 303 EXPECT_FALSE(client_.IsPropertyMutated(element_id_, LayerTreeType::ACTIVE,
304 TargetProperty::FILTER)); 304 TargetProperty::FILTER));
305 EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, 305 EXPECT_FALSE(client_impl_.IsPropertyMutated(
306 TargetProperty::FILTER)); 306 element_id_, LayerTreeType::ACTIVE, TargetProperty::FILTER));
307 } 307 }
308 308
309 TEST_F(AnimationPlayerTest, AddRemoveAnimationCausesSetNeedsCommit) { 309 TEST_F(AnimationPlayerTest, AddRemoveAnimationCausesSetNeedsCommit) {
310 client_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); 310 client_.RegisterLayer(element_id_, LayerTreeType::ACTIVE);
311 host_->AddAnimationTimeline(timeline_); 311 host_->AddAnimationTimeline(timeline_);
312 timeline_->AttachPlayer(player_); 312 timeline_->AttachPlayer(player_);
313 player_->AttachLayer(layer_id_); 313 player_->AttachLayer(element_id_);
314 314
315 EXPECT_FALSE(client_.mutators_need_commit()); 315 EXPECT_FALSE(client_.mutators_need_commit());
316 316
317 const int animation_id = 317 const int animation_id =
318 AddOpacityTransitionToPlayer(player_.get(), 1., .7f, .3f, false); 318 AddOpacityTransitionToPlayer(player_.get(), 1., .7f, .3f, false);
319 319
320 EXPECT_TRUE(client_.mutators_need_commit()); 320 EXPECT_TRUE(client_.mutators_need_commit());
321 client_.set_mutators_need_commit(false); 321 client_.set_mutators_need_commit(false);
322 322
323 player_->PauseAnimation(animation_id, 1.); 323 player_->PauseAnimation(animation_id, 1.);
324 EXPECT_TRUE(client_.mutators_need_commit()); 324 EXPECT_TRUE(client_.mutators_need_commit());
325 client_.set_mutators_need_commit(false); 325 client_.set_mutators_need_commit(false);
326 326
327 player_->RemoveAnimation(animation_id); 327 player_->RemoveAnimation(animation_id);
328 EXPECT_TRUE(client_.mutators_need_commit()); 328 EXPECT_TRUE(client_.mutators_need_commit());
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_->AttachLayer(layer_id_); 337 player_->AttachLayer(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(layer_id_)); 343 EXPECT_EQ(player_, GetPlayerForLayerId(element_id_));
344 EXPECT_TRUE(player_->element_animations()); 344 EXPECT_TRUE(player_->element_animations());
345 EXPECT_EQ(player_->layer_id(), layer_id_); 345 EXPECT_EQ(player_->element_id(), element_id_);
346 346
347 EXPECT_EQ(player_impl_, GetImplPlayerForLayerId(layer_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_->layer_id(), layer_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_->DetachLayer(); 352 player_->DetachLayer();
353 player_->AttachLayer(new_layer_id); 353 player_->AttachLayer(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_->layer_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_);
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_->layer_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
OLDNEW
« no previous file with comments | « cc/animation/animation_player.cc ('k') | cc/animation/element_animations.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698