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

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

Issue 2559273003: Blink Compositor Animation: Introduce CompositorAnimationHost correctly. (Closed)
Patch Set: Add nullcheck for m_layerTreeView in WebViewImpl 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 "wtf/PtrUtil.h"
13 #include <memory> 14 #include <memory>
14 15
15 namespace blink { 16 namespace blink {
16 17
17 class CompositorAnimationTimelineTest : public CompositorTest {}; 18 class CompositorAnimationTimelineTest : public CompositorTest {};
18 19
19 TEST_F(CompositorAnimationTimelineTest, 20 TEST_F(CompositorAnimationTimelineTest,
20 CompositorTimelineDeletionDetachesFromAnimationHost) { 21 CompositorTimelineDeletionDetachesFromAnimationHost) {
21 std::unique_ptr<CompositorAnimationTimeline> timeline = 22 std::unique_ptr<CompositorAnimationTimeline> timeline =
22 CompositorAnimationTimeline::create(); 23 CompositorAnimationTimeline::create();
23 24
24 scoped_refptr<cc::AnimationTimeline> ccTimeline = 25 scoped_refptr<cc::AnimationTimeline> ccTimeline =
25 timeline->animationTimeline(); 26 timeline->animationTimeline();
26 EXPECT_FALSE(ccTimeline->animation_host()); 27 EXPECT_FALSE(ccTimeline->animation_host());
27 28
28 std::unique_ptr<WebLayerTreeView> layerTreeHost = 29 std::unique_ptr<WebLayerTreeView> layerTreeHost =
29 WTF::wrapUnique(new WebLayerTreeViewImplForTesting); 30 WTF::wrapUnique(new WebLayerTreeViewImplForTesting);
30 DCHECK(layerTreeHost); 31 DCHECK(layerTreeHost);
31 32
32 layerTreeHost->attachCompositorAnimationTimeline( 33 auto compositorAnimationHost = WTF::makeUnique<CompositorAnimationHost>(
33 timeline->animationTimeline()); 34 layerTreeHost->compositorAnimationHost());
35
36 compositorAnimationHost->addTimeline(timeline.get());
34 cc::AnimationHost* animationHost = ccTimeline->animation_host(); 37 cc::AnimationHost* animationHost = ccTimeline->animation_host();
35 EXPECT_TRUE(animationHost); 38 EXPECT_TRUE(animationHost);
36 EXPECT_TRUE(animationHost->GetTimelineById(ccTimeline->id())); 39 EXPECT_TRUE(animationHost->GetTimelineById(ccTimeline->id()));
37 40
38 // Delete CompositorAnimationTimeline while attached to host. 41 // Delete CompositorAnimationTimeline while attached to host.
39 timeline = nullptr; 42 timeline = nullptr;
40 43
41 EXPECT_FALSE(ccTimeline->animation_host()); 44 EXPECT_FALSE(ccTimeline->animation_host());
42 EXPECT_FALSE(animationHost->GetTimelineById(ccTimeline->id())); 45 EXPECT_FALSE(animationHost->GetTimelineById(ccTimeline->id()));
43 } 46 }
44 47
45 } // namespace blink 48 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698