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