OLD | NEW |
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/CompositorAnimationPlayer.h" | 9 #include "platform/animation/CompositorAnimationPlayer.h" |
10 #include "platform/testing/CompositorTest.h" | 10 #include "platform/testing/CompositorTest.h" |
11 #include "platform/testing/WebLayerTreeViewImplForTesting.h" | 11 #include "platform/testing/WebLayerTreeViewImplForTesting.h" |
12 #include "wtf/PtrUtil.h" | |
13 #include <memory> | |
14 | 12 |
15 namespace blink { | 13 namespace blink { |
16 | 14 |
17 class CompositorAnimationTimelineTest : public CompositorTest { | 15 class CompositorAnimationTimelineTest : public CompositorTest { |
18 }; | 16 }; |
19 | 17 |
20 TEST_F(CompositorAnimationTimelineTest, CompositorTimelineDeletionDetachesFromAn
imationHost) | 18 TEST_F(CompositorAnimationTimelineTest, CompositorTimelineDeletionDetachesFromAn
imationHost) |
21 { | 19 { |
22 std::unique_ptr<CompositorAnimationTimeline> timeline = CompositorAnimationT
imeline::create(); | 20 OwnPtr<CompositorAnimationTimeline> timeline = CompositorAnimationTimeline::
create(); |
23 | 21 |
24 scoped_refptr<cc::AnimationTimeline> ccTimeline = timeline->animationTimelin
e(); | 22 scoped_refptr<cc::AnimationTimeline> ccTimeline = timeline->animationTimelin
e(); |
25 EXPECT_FALSE(ccTimeline->animation_host()); | 23 EXPECT_FALSE(ccTimeline->animation_host()); |
26 | 24 |
27 std::unique_ptr<WebLayerTreeView> layerTreeHost = wrapUnique(new WebLayerTre
eViewImplForTesting); | 25 OwnPtr<WebLayerTreeView> layerTreeHost = adoptPtr(new WebLayerTreeViewImplFo
rTesting); |
28 DCHECK(layerTreeHost); | 26 DCHECK(layerTreeHost); |
29 | 27 |
30 layerTreeHost->attachCompositorAnimationTimeline(timeline->animationTimeline
()); | 28 layerTreeHost->attachCompositorAnimationTimeline(timeline->animationTimeline
()); |
31 cc::AnimationHost* animationHost = ccTimeline->animation_host(); | 29 cc::AnimationHost* animationHost = ccTimeline->animation_host(); |
32 EXPECT_TRUE(animationHost); | 30 EXPECT_TRUE(animationHost); |
33 EXPECT_TRUE(animationHost->GetTimelineById(ccTimeline->id())); | 31 EXPECT_TRUE(animationHost->GetTimelineById(ccTimeline->id())); |
34 | 32 |
35 // Delete CompositorAnimationTimeline while attached to host. | 33 // Delete CompositorAnimationTimeline while attached to host. |
36 timeline = nullptr; | 34 timeline = nullptr; |
37 | 35 |
38 EXPECT_FALSE(ccTimeline->animation_host()); | 36 EXPECT_FALSE(ccTimeline->animation_host()); |
39 EXPECT_FALSE(animationHost->GetTimelineById(ccTimeline->id())); | 37 EXPECT_FALSE(animationHost->GetTimelineById(ccTimeline->id())); |
40 } | 38 } |
41 | 39 |
42 } // namespace blink | 40 } // namespace blink |
OLD | NEW |