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

Side by Side Diff: ui/compositor/layer_animator_unittest.cc

Issue 2554773002: CC Animation: Rename Active Players to Ticking Players. (Closed)
Patch Set: Rename the argument. Created 4 years 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 | « third_party/WebKit/public/platform/WebLayer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "ui/compositor/layer_animator.h" 5 #include "ui/compositor/layer_animator.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 2614 matching lines...) Expand 10 before | Expand all | Expand 10 after
2625 Layer root_2; 2625 Layer root_2;
2626 compositor_2->SetRootLayer(&root_2); 2626 compositor_2->SetRootLayer(&root_2);
2627 2627
2628 // Verify that neither compositor has active animators. 2628 // Verify that neither compositor has active animators.
2629 EXPECT_FALSE(compositor_1->layer_animator_collection()->HasActiveAnimators()); 2629 EXPECT_FALSE(compositor_1->layer_animator_collection()->HasActiveAnimators());
2630 EXPECT_FALSE(compositor_2->layer_animator_collection()->HasActiveAnimators()); 2630 EXPECT_FALSE(compositor_2->layer_animator_collection()->HasActiveAnimators());
2631 2631
2632 Layer layer; 2632 Layer layer;
2633 root_1.Add(&layer); 2633 root_1.Add(&layer);
2634 LayerAnimator* animator = layer.GetAnimator(); 2634 LayerAnimator* animator = layer.GetAnimator();
2635 EXPECT_FALSE(layer.cc_layer_for_testing()->HasActiveAnimationForTesting()); 2635 EXPECT_FALSE(layer.cc_layer_for_testing()->HasTickingAnimationForTesting());
2636 2636
2637 double target_opacity = 1.0; 2637 double target_opacity = 1.0;
2638 base::TimeDelta time_delta = base::TimeDelta::FromSeconds(1); 2638 base::TimeDelta time_delta = base::TimeDelta::FromSeconds(1);
2639 2639
2640 animator->ScheduleAnimation(new LayerAnimationSequence( 2640 animator->ScheduleAnimation(new LayerAnimationSequence(
2641 LayerAnimationElement::CreateOpacityElement(target_opacity, time_delta))); 2641 LayerAnimationElement::CreateOpacityElement(target_opacity, time_delta)));
2642 EXPECT_TRUE(compositor_1->layer_animator_collection()->HasActiveAnimators()); 2642 EXPECT_TRUE(compositor_1->layer_animator_collection()->HasActiveAnimators());
2643 EXPECT_FALSE(compositor_2->layer_animator_collection()->HasActiveAnimators()); 2643 EXPECT_FALSE(compositor_2->layer_animator_collection()->HasActiveAnimators());
2644 EXPECT_TRUE(layer.cc_layer_for_testing()->HasActiveAnimationForTesting()); 2644 EXPECT_TRUE(layer.cc_layer_for_testing()->HasTickingAnimationForTesting());
2645 2645
2646 root_2.Add(&layer); 2646 root_2.Add(&layer);
2647 EXPECT_FALSE(compositor_1->layer_animator_collection()->HasActiveAnimators()); 2647 EXPECT_FALSE(compositor_1->layer_animator_collection()->HasActiveAnimators());
2648 EXPECT_TRUE(compositor_2->layer_animator_collection()->HasActiveAnimators()); 2648 EXPECT_TRUE(compositor_2->layer_animator_collection()->HasActiveAnimators());
2649 EXPECT_TRUE(layer.cc_layer_for_testing()->HasActiveAnimationForTesting()); 2649 EXPECT_TRUE(layer.cc_layer_for_testing()->HasTickingAnimationForTesting());
2650 2650
2651 host_2.reset(); 2651 host_2.reset();
2652 host_1.reset(); 2652 host_1.reset();
2653 TerminateContextFactoryForTests(); 2653 TerminateContextFactoryForTests();
2654 } 2654 }
2655 2655
2656 TEST(LayerAnimatorTest, ThreadedAnimationSurvivesIfLayerRemovedAdded) { 2656 TEST(LayerAnimatorTest, ThreadedAnimationSurvivesIfLayerRemovedAdded) {
2657 bool enable_pixel_output = false; 2657 bool enable_pixel_output = false;
2658 ui::ContextFactory* context_factory = 2658 ui::ContextFactory* context_factory =
2659 InitializeContextFactoryForTests(enable_pixel_output); 2659 InitializeContextFactoryForTests(enable_pixel_output);
2660 const gfx::Rect bounds(10, 10, 100, 100); 2660 const gfx::Rect bounds(10, 10, 100, 100);
2661 std::unique_ptr<TestCompositorHost> host( 2661 std::unique_ptr<TestCompositorHost> host(
2662 TestCompositorHost::Create(bounds, context_factory)); 2662 TestCompositorHost::Create(bounds, context_factory));
2663 host->Show(); 2663 host->Show();
2664 2664
2665 Compositor* compositor = host->GetCompositor(); 2665 Compositor* compositor = host->GetCompositor();
2666 2666
2667 Layer root; 2667 Layer root;
2668 compositor->SetRootLayer(&root); 2668 compositor->SetRootLayer(&root);
2669 2669
2670 Layer layer; 2670 Layer layer;
2671 root.Add(&layer); 2671 root.Add(&layer);
2672 2672
2673 LayerAnimator* animator = layer.GetAnimator(); 2673 LayerAnimator* animator = layer.GetAnimator();
2674 double target_opacity = 1.0; 2674 double target_opacity = 1.0;
2675 base::TimeDelta time_delta = base::TimeDelta::FromSeconds(1); 2675 base::TimeDelta time_delta = base::TimeDelta::FromSeconds(1);
2676 2676
2677 animator->ScheduleAnimation(new LayerAnimationSequence( 2677 animator->ScheduleAnimation(new LayerAnimationSequence(
2678 LayerAnimationElement::CreateOpacityElement(target_opacity, time_delta))); 2678 LayerAnimationElement::CreateOpacityElement(target_opacity, time_delta)));
2679 EXPECT_TRUE(layer.cc_layer_for_testing()->HasActiveAnimationForTesting()); 2679 EXPECT_TRUE(layer.cc_layer_for_testing()->HasTickingAnimationForTesting());
2680 2680
2681 root.Remove(&layer); 2681 root.Remove(&layer);
2682 EXPECT_FALSE(layer.cc_layer_for_testing()->HasActiveAnimationForTesting()); 2682 EXPECT_FALSE(layer.cc_layer_for_testing()->HasTickingAnimationForTesting());
2683 2683
2684 root.Add(&layer); 2684 root.Add(&layer);
2685 EXPECT_TRUE(layer.cc_layer_for_testing()->HasActiveAnimationForTesting()); 2685 EXPECT_TRUE(layer.cc_layer_for_testing()->HasTickingAnimationForTesting());
2686 2686
2687 host.reset(); 2687 host.reset();
2688 TerminateContextFactoryForTests(); 2688 TerminateContextFactoryForTests();
2689 } 2689 }
2690 2690
2691 class LayerOwnerAnimationObserver : public LayerAnimationObserver { 2691 class LayerOwnerAnimationObserver : public LayerAnimationObserver {
2692 public: 2692 public:
2693 explicit LayerOwnerAnimationObserver(LayerAnimator* animator) 2693 explicit LayerOwnerAnimationObserver(LayerAnimator* animator)
2694 : animator_layer_(new Layer(LAYER_TEXTURED)) { 2694 : animator_layer_(new Layer(LAYER_TEXTURED)) {
2695 animator_layer_->SetAnimator(animator); 2695 animator_layer_->SetAnimator(animator);
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
2945 EXPECT_EQ(observer.last_ended_sequence(), nullptr); 2945 EXPECT_EQ(observer.last_ended_sequence(), nullptr);
2946 EXPECT_EQ(observer.last_detached_sequence(), first_sequence); 2946 EXPECT_EQ(observer.last_detached_sequence(), first_sequence);
2947 2947
2948 EXPECT_TRUE(observer.AbortedEpochIsBeforeDetachedEpoch()); 2948 EXPECT_TRUE(observer.AbortedEpochIsBeforeDetachedEpoch());
2949 EXPECT_TRUE(observer.AbortedEpochIsBeforeStartedEpoch()); 2949 EXPECT_TRUE(observer.AbortedEpochIsBeforeStartedEpoch());
2950 EXPECT_TRUE(observer.AttachedEpochIsBeforeScheduledEpoch()); 2950 EXPECT_TRUE(observer.AttachedEpochIsBeforeScheduledEpoch());
2951 EXPECT_TRUE(observer.ScheduledEpochIsBeforeStartedEpoch()); 2951 EXPECT_TRUE(observer.ScheduledEpochIsBeforeStartedEpoch());
2952 } 2952 }
2953 2953
2954 } // namespace ui 2954 } // namespace ui
OLDNEW
« no previous file with comments | « third_party/WebKit/public/platform/WebLayer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698