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

Side by Side Diff: third_party/WebKit/Source/platform/animation/CompositorAnimationTimelineTest.cpp

Issue 2559273003: Blink Compositor Animation: Introduce CompositorAnimationHost correctly. (Closed)
Patch Set: Allocate on stack in unit tests. 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "platform/animation/CompositorAnimationTimeline.h" 5 #include "platform/animation/CompositorAnimationTimeline.h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "cc/animation/animation_host.h" 8 #include "cc/animation/animation_host.h"
9 #include "platform/animation/CompositorAnimationHost.h"
9 #include "platform/animation/CompositorAnimationPlayer.h" 10 #include "platform/animation/CompositorAnimationPlayer.h"
10 #include "platform/testing/CompositorTest.h" 11 #include "platform/testing/CompositorTest.h"
11 #include "platform/testing/WebLayerTreeViewImplForTesting.h" 12 #include "platform/testing/WebLayerTreeViewImplForTesting.h"
12 #include "wtf/PtrUtil.h"
13 #include <memory> 13 #include <memory>
14 14
15 namespace blink { 15 namespace blink {
16 16
17 class CompositorAnimationTimelineTest : public CompositorTest {}; 17 class CompositorAnimationTimelineTest : public CompositorTest {};
18 18
19 TEST_F(CompositorAnimationTimelineTest, 19 TEST_F(CompositorAnimationTimelineTest,
20 CompositorTimelineDeletionDetachesFromAnimationHost) { 20 CompositorTimelineDeletionDetachesFromAnimationHost) {
21 std::unique_ptr<CompositorAnimationTimeline> timeline = 21 std::unique_ptr<CompositorAnimationTimeline> timeline =
22 CompositorAnimationTimeline::create(); 22 CompositorAnimationTimeline::create();
23 23
24 scoped_refptr<cc::AnimationTimeline> ccTimeline = 24 scoped_refptr<cc::AnimationTimeline> ccTimeline =
25 timeline->animationTimeline(); 25 timeline->animationTimeline();
26 EXPECT_FALSE(ccTimeline->animation_host()); 26 EXPECT_FALSE(ccTimeline->animation_host());
27 27
28 std::unique_ptr<WebLayerTreeView> layerTreeHost = 28 WebLayerTreeViewImplForTesting layerTreeView;
29 WTF::wrapUnique(new WebLayerTreeViewImplForTesting); 29 CompositorAnimationHost compositorAnimationHost(
30 DCHECK(layerTreeHost); 30 layerTreeView.compositorAnimationHost());
31 31
32 layerTreeHost->attachCompositorAnimationTimeline( 32 compositorAnimationHost.addTimeline(*timeline);
33 timeline->animationTimeline());
34 cc::AnimationHost* animationHost = ccTimeline->animation_host(); 33 cc::AnimationHost* animationHost = ccTimeline->animation_host();
35 EXPECT_TRUE(animationHost); 34 EXPECT_TRUE(animationHost);
36 EXPECT_TRUE(animationHost->GetTimelineById(ccTimeline->id())); 35 EXPECT_TRUE(animationHost->GetTimelineById(ccTimeline->id()));
37 36
38 // Delete CompositorAnimationTimeline while attached to host. 37 // Delete CompositorAnimationTimeline while attached to host.
39 timeline = nullptr; 38 timeline = nullptr;
40 39
41 EXPECT_FALSE(ccTimeline->animation_host()); 40 EXPECT_FALSE(ccTimeline->animation_host());
42 EXPECT_FALSE(animationHost->GetTimelineById(ccTimeline->id())); 41 EXPECT_FALSE(animationHost->GetTimelineById(ccTimeline->id()));
43 } 42 }
44 43
45 } // namespace blink 44 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698