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

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

Issue 1148333002: cc: Make re-added animations get pushed to the compositor thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "cc/animation/layer_animation_controller.h" 5 #include "cc/animation/layer_animation_controller.h"
6 6
7 #include "cc/animation/animation.h" 7 #include "cc/animation/animation.h"
8 #include "cc/animation/animation_curve.h" 8 #include "cc/animation/animation_curve.h"
9 #include "cc/animation/animation_delegate.h" 9 #include "cc/animation/animation_delegate.h"
10 #include "cc/animation/animation_registrar.h" 10 #include "cc/animation/animation_registrar.h"
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 291
292 TEST(LayerAnimationControllerTest, DoNotSyncFinishedAnimation) { 292 TEST(LayerAnimationControllerTest, DoNotSyncFinishedAnimation) {
293 FakeLayerAnimationValueObserver dummy_impl; 293 FakeLayerAnimationValueObserver dummy_impl;
294 scoped_refptr<LayerAnimationController> controller_impl( 294 scoped_refptr<LayerAnimationController> controller_impl(
295 LayerAnimationController::Create(0)); 295 LayerAnimationController::Create(0));
296 controller_impl->AddValueObserver(&dummy_impl); 296 controller_impl->AddValueObserver(&dummy_impl);
297 FakeLayerAnimationValueObserver dummy; 297 FakeLayerAnimationValueObserver dummy;
298 scoped_refptr<LayerAnimationController> controller( 298 scoped_refptr<LayerAnimationController> controller(
299 LayerAnimationController::Create(0)); 299 LayerAnimationController::Create(0));
300 controller->AddValueObserver(&dummy); 300 controller->AddValueObserver(&dummy);
301 scoped_ptr<AnimationEventsVector> events(
302 make_scoped_ptr(new AnimationEventsVector));
301 303
302 EXPECT_FALSE(controller_impl->GetAnimation(Animation::OPACITY)); 304 EXPECT_FALSE(controller_impl->GetAnimation(Animation::OPACITY));
303 305
304 int animation_id = 306 int animation_id =
305 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); 307 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false);
306 int group_id = controller->GetAnimationById(animation_id)->group();
307 308
308 controller->PushAnimationUpdatesTo(controller_impl.get()); 309 controller->PushAnimationUpdatesTo(controller_impl.get());
309 controller_impl->ActivateAnimations(); 310 controller_impl->ActivateAnimations();
310 311
311 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); 312 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id));
312 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, 313 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY,
313 controller_impl->GetAnimationById(animation_id)->run_state()); 314 controller_impl->GetAnimationById(animation_id)->run_state());
314 315
316 events.reset(new AnimationEventsVector);
317 controller_impl->Animate(kInitialTickTime);
318 controller_impl->UpdateState(true, events.get());
319 EXPECT_EQ(1u, events->size());
320 EXPECT_EQ(AnimationEvent::STARTED, (*events)[0].type);
321
315 // Notify main thread controller that the animation has started. 322 // Notify main thread controller that the animation has started.
316 AnimationEvent animation_started_event(AnimationEvent::STARTED, 0, group_id, 323 controller->NotifyAnimationStarted((*events)[0]);
317 Animation::OPACITY, kInitialTickTime);
318 controller->NotifyAnimationStarted(animation_started_event);
319 324
320 // Force animation to complete on impl thread. 325 // Complete animation on impl thread.
321 controller_impl->RemoveAnimation(animation_id); 326 events.reset(new AnimationEventsVector);
327 controller_impl->Animate(kInitialTickTime + TimeDelta::FromSeconds(1));
328 controller_impl->UpdateState(true, events.get());
329 EXPECT_EQ(1u, events->size());
330 EXPECT_EQ(AnimationEvent::FINISHED, (*events)[0].type);
322 331
323 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id)); 332 controller->NotifyAnimationFinished((*events)[0]);
333
334 controller->Animate(kInitialTickTime + TimeDelta::FromSeconds(2));
335 controller->UpdateState(true, nullptr);
324 336
325 controller->PushAnimationUpdatesTo(controller_impl.get()); 337 controller->PushAnimationUpdatesTo(controller_impl.get());
326 controller_impl->ActivateAnimations(); 338 controller_impl->ActivateAnimations();
327 339 EXPECT_FALSE(controller->GetAnimationById(animation_id));
328 // Even though the main thread has a 'new' animation, it should not be pushed
329 // because the animation has already completed on the impl thread.
330 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id)); 340 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id));
331 } 341 }
332 342
333 // Ensure that a finished animation is eventually deleted by both the 343 // Ensure that a finished animation is eventually deleted by both the
334 // main-thread and the impl-thread controllers. 344 // main-thread and the impl-thread controllers.
335 TEST(LayerAnimationControllerTest, AnimationsAreDeleted) { 345 TEST(LayerAnimationControllerTest, AnimationsAreDeleted) {
336 FakeLayerAnimationValueObserver dummy; 346 FakeLayerAnimationValueObserver dummy;
337 FakeLayerAnimationValueObserver dummy_impl; 347 FakeLayerAnimationValueObserver dummy_impl;
338 scoped_ptr<AnimationEventsVector> events( 348 scoped_ptr<AnimationEventsVector> events(
339 make_scoped_ptr(new AnimationEventsVector)); 349 make_scoped_ptr(new AnimationEventsVector));
(...skipping 2105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2445 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::OPACITY)); 2455 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::OPACITY));
2446 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::FILTER)); 2456 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::FILTER));
2447 2457
2448 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); 2458 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
2449 controller->UpdateState(true, nullptr); 2459 controller->UpdateState(true, nullptr);
2450 EXPECT_TRUE(controller->IsAnimatingProperty(Animation::OPACITY)); 2460 EXPECT_TRUE(controller->IsAnimatingProperty(Animation::OPACITY));
2451 } 2461 }
2452 2462
2453 } // namespace 2463 } // namespace
2454 } // namespace cc 2464 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/layer_animation_controller.cc ('k') | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698