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

Side by Side Diff: third_party/WebKit/Source/platform/animation/CompositorAnimationHostTest.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/CompositorAnimationHost.h" 5 #include "platform/animation/CompositorAnimationHost.h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "platform/animation/CompositorAnimationTimeline.h" 8 #include "platform/animation/CompositorAnimationTimeline.h"
9 #include "platform/testing/CompositorTest.h" 9 #include "platform/testing/CompositorTest.h"
10 #include "platform/testing/WebLayerTreeViewImplForTesting.h" 10 #include "platform/testing/WebLayerTreeViewImplForTesting.h"
11 #include "wtf/PtrUtil.h"
12 #include <memory> 11 #include <memory>
13 12
14 namespace blink { 13 namespace blink {
15 14
16 class CompositorAnimationHostTest : public CompositorTest {}; 15 class CompositorAnimationHostTest : public CompositorTest {};
17 16
18 TEST_F(CompositorAnimationHostTest, AnimationHostNullWhenTimelineDetached) { 17 TEST_F(CompositorAnimationHostTest, AnimationHostNullWhenTimelineDetached) {
19 std::unique_ptr<CompositorAnimationTimeline> timeline = 18 std::unique_ptr<CompositorAnimationTimeline> timeline =
20 CompositorAnimationTimeline::create(); 19 CompositorAnimationTimeline::create();
21 20
22 scoped_refptr<cc::AnimationTimeline> ccTimeline = 21 scoped_refptr<cc::AnimationTimeline> ccTimeline =
23 timeline->animationTimeline(); 22 timeline->animationTimeline();
24 EXPECT_FALSE(ccTimeline->animation_host()); 23 EXPECT_FALSE(ccTimeline->animation_host());
25 EXPECT_TRUE(timeline->compositorAnimationHost().isNull());
26 24
27 std::unique_ptr<WebLayerTreeView> layerTreeHost = 25 WebLayerTreeViewImplForTesting layerTreeView;
28 WTF::wrapUnique(new WebLayerTreeViewImplForTesting); 26 CompositorAnimationHost compositorAnimationHost(
29 DCHECK(layerTreeHost); 27 layerTreeView.compositorAnimationHost());
30 28
31 layerTreeHost->attachCompositorAnimationTimeline( 29 compositorAnimationHost.addTimeline(*timeline);
32 timeline->animationTimeline()); 30 EXPECT_TRUE(ccTimeline->animation_host());
33 EXPECT_FALSE(timeline->compositorAnimationHost().isNull());
34 31
35 layerTreeHost->detachCompositorAnimationTimeline( 32 compositorAnimationHost.removeTimeline(*timeline);
36 timeline->animationTimeline()); 33 EXPECT_FALSE(ccTimeline->animation_host());
37 EXPECT_TRUE(timeline->compositorAnimationHost().isNull());
38 } 34 }
39 35
40 } // namespace blink 36 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698