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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/GraphicsLayerTest.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from Kent; merge. Created 4 years, 6 months 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 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 24 matching lines...) Expand all
35 #include "platform/testing/FakeGraphicsLayerClient.h" 35 #include "platform/testing/FakeGraphicsLayerClient.h"
36 #include "platform/testing/WebLayerTreeViewImplForTesting.h" 36 #include "platform/testing/WebLayerTreeViewImplForTesting.h"
37 #include "platform/transforms/Matrix3DTransformOperation.h" 37 #include "platform/transforms/Matrix3DTransformOperation.h"
38 #include "platform/transforms/RotateTransformOperation.h" 38 #include "platform/transforms/RotateTransformOperation.h"
39 #include "platform/transforms/TranslateTransformOperation.h" 39 #include "platform/transforms/TranslateTransformOperation.h"
40 #include "public/platform/Platform.h" 40 #include "public/platform/Platform.h"
41 #include "public/platform/WebCompositorSupport.h" 41 #include "public/platform/WebCompositorSupport.h"
42 #include "public/platform/WebLayer.h" 42 #include "public/platform/WebLayer.h"
43 #include "public/platform/WebLayerTreeView.h" 43 #include "public/platform/WebLayerTreeView.h"
44 #include "testing/gtest/include/gtest/gtest.h" 44 #include "testing/gtest/include/gtest/gtest.h"
45 #include "wtf/PassOwnPtr.h" 45 #include "wtf/PtrUtil.h"
46 #include <memory>
46 47
47 namespace blink { 48 namespace blink {
48 49
49 class GraphicsLayerTest : public testing::Test { 50 class GraphicsLayerTest : public testing::Test {
50 public: 51 public:
51 GraphicsLayerTest() 52 GraphicsLayerTest()
52 { 53 {
53 m_clipLayer = adoptPtr(new FakeGraphicsLayer(&m_client)); 54 m_clipLayer = wrapUnique(new FakeGraphicsLayer(&m_client));
54 m_scrollElasticityLayer = adoptPtr(new FakeGraphicsLayer(&m_client)); 55 m_scrollElasticityLayer = wrapUnique(new FakeGraphicsLayer(&m_client));
55 m_graphicsLayer = adoptPtr(new FakeGraphicsLayer(&m_client)); 56 m_graphicsLayer = wrapUnique(new FakeGraphicsLayer(&m_client));
56 m_clipLayer->addChild(m_scrollElasticityLayer.get()); 57 m_clipLayer->addChild(m_scrollElasticityLayer.get());
57 m_scrollElasticityLayer->addChild(m_graphicsLayer.get()); 58 m_scrollElasticityLayer->addChild(m_graphicsLayer.get());
58 m_graphicsLayer->platformLayer()->setScrollClipLayer( 59 m_graphicsLayer->platformLayer()->setScrollClipLayer(
59 m_clipLayer->platformLayer()); 60 m_clipLayer->platformLayer());
60 m_platformLayer = m_graphicsLayer->platformLayer(); 61 m_platformLayer = m_graphicsLayer->platformLayer();
61 m_layerTreeView = adoptPtr(new WebLayerTreeViewImplForTesting); 62 m_layerTreeView = wrapUnique(new WebLayerTreeViewImplForTesting);
62 ASSERT(m_layerTreeView); 63 ASSERT(m_layerTreeView);
63 m_layerTreeView->setRootLayer(*m_clipLayer->platformLayer()); 64 m_layerTreeView->setRootLayer(*m_clipLayer->platformLayer());
64 m_layerTreeView->registerViewportLayers( 65 m_layerTreeView->registerViewportLayers(
65 m_scrollElasticityLayer->platformLayer(), m_clipLayer->platformLayer (), m_graphicsLayer->platformLayer(), 0); 66 m_scrollElasticityLayer->platformLayer(), m_clipLayer->platformLayer (), m_graphicsLayer->platformLayer(), 0);
66 m_layerTreeView->setViewportSize(WebSize(1, 1)); 67 m_layerTreeView->setViewportSize(WebSize(1, 1));
67 } 68 }
68 69
69 ~GraphicsLayerTest() override 70 ~GraphicsLayerTest() override
70 { 71 {
71 m_graphicsLayer.reset(); 72 m_graphicsLayer.reset();
72 m_layerTreeView.reset(); 73 m_layerTreeView.reset();
73 } 74 }
74 75
75 WebLayerTreeView* layerTreeView() { return m_layerTreeView.get(); } 76 WebLayerTreeView* layerTreeView() { return m_layerTreeView.get(); }
76 77
77 protected: 78 protected:
78 WebLayer* m_platformLayer; 79 WebLayer* m_platformLayer;
79 OwnPtr<FakeGraphicsLayer> m_graphicsLayer; 80 std::unique_ptr<FakeGraphicsLayer> m_graphicsLayer;
80 OwnPtr<FakeGraphicsLayer> m_scrollElasticityLayer; 81 std::unique_ptr<FakeGraphicsLayer> m_scrollElasticityLayer;
81 OwnPtr<FakeGraphicsLayer> m_clipLayer; 82 std::unique_ptr<FakeGraphicsLayer> m_clipLayer;
82 83
83 private: 84 private:
84 OwnPtr<WebLayerTreeView> m_layerTreeView; 85 std::unique_ptr<WebLayerTreeView> m_layerTreeView;
85 FakeGraphicsLayerClient m_client; 86 FakeGraphicsLayerClient m_client;
86 }; 87 };
87 88
88 class AnimationPlayerForTesting : public CompositorAnimationPlayerClient { 89 class AnimationPlayerForTesting : public CompositorAnimationPlayerClient {
89 public: 90 public:
90 AnimationPlayerForTesting() 91 AnimationPlayerForTesting()
91 { 92 {
92 m_compositorPlayer = adoptPtr(CompositorFactory::current().createAnimati onPlayer()); 93 m_compositorPlayer = wrapUnique(CompositorFactory::current().createAnima tionPlayer());
93 } 94 }
94 95
95 CompositorAnimationPlayer* compositorPlayer() const override 96 CompositorAnimationPlayer* compositorPlayer() const override
96 { 97 {
97 return m_compositorPlayer.get(); 98 return m_compositorPlayer.get();
98 } 99 }
99 100
100 OwnPtr<CompositorAnimationPlayer> m_compositorPlayer; 101 std::unique_ptr<CompositorAnimationPlayer> m_compositorPlayer;
101 }; 102 };
102 103
103 TEST_F(GraphicsLayerTest, updateLayerShouldFlattenTransformWithAnimations) 104 TEST_F(GraphicsLayerTest, updateLayerShouldFlattenTransformWithAnimations)
104 { 105 {
105 ASSERT_FALSE(m_platformLayer->hasActiveAnimationForTesting()); 106 ASSERT_FALSE(m_platformLayer->hasActiveAnimationForTesting());
106 107
107 OwnPtr<CompositorFloatAnimationCurve> curve = adoptPtr(CompositorFactory::cu rrent().createFloatAnimationCurve()); 108 std::unique_ptr<CompositorFloatAnimationCurve> curve = wrapUnique(Compositor Factory::current().createFloatAnimationCurve());
108 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(0.0, 0.0), CubicBezier TimingFunction::EaseType::EASE); 109 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(0.0, 0.0), CubicBezier TimingFunction::EaseType::EASE);
109 OwnPtr<CompositorAnimation> floatAnimation(adoptPtr(CompositorFactory::curre nt().createAnimation(*curve, CompositorTargetProperty::OPACITY))); 110 std::unique_ptr<CompositorAnimation> floatAnimation(wrapUnique(CompositorFac tory::current().createAnimation(*curve, CompositorTargetProperty::OPACITY)));
110 int animationId = floatAnimation->id(); 111 int animationId = floatAnimation->id();
111 112
112 OwnPtr<CompositorAnimationTimeline> compositorTimeline = adoptPtr(Compositor Factory::current().createAnimationTimeline()); 113 std::unique_ptr<CompositorAnimationTimeline> compositorTimeline = wrapUnique (CompositorFactory::current().createAnimationTimeline());
113 AnimationPlayerForTesting player; 114 AnimationPlayerForTesting player;
114 115
115 layerTreeView()->attachCompositorAnimationTimeline(compositorTimeline->anima tionTimeline()); 116 layerTreeView()->attachCompositorAnimationTimeline(compositorTimeline->anima tionTimeline());
116 compositorTimeline->playerAttached(player); 117 compositorTimeline->playerAttached(player);
117 118
118 player.compositorPlayer()->attachLayer(m_platformLayer); 119 player.compositorPlayer()->attachLayer(m_platformLayer);
119 ASSERT_TRUE(player.compositorPlayer()->isLayerAttached()); 120 ASSERT_TRUE(player.compositorPlayer()->isLayerAttached());
120 121
121 player.compositorPlayer()->addAnimation(floatAnimation.leakPtr()); 122 player.compositorPlayer()->addAnimation(floatAnimation.release());
122 123
123 ASSERT_TRUE(m_platformLayer->hasActiveAnimationForTesting()); 124 ASSERT_TRUE(m_platformLayer->hasActiveAnimationForTesting());
124 125
125 m_graphicsLayer->setShouldFlattenTransform(false); 126 m_graphicsLayer->setShouldFlattenTransform(false);
126 127
127 m_platformLayer = m_graphicsLayer->platformLayer(); 128 m_platformLayer = m_graphicsLayer->platformLayer();
128 ASSERT_TRUE(m_platformLayer); 129 ASSERT_TRUE(m_platformLayer);
129 130
130 ASSERT_TRUE(m_platformLayer->hasActiveAnimationForTesting()); 131 ASSERT_TRUE(m_platformLayer->hasActiveAnimationForTesting());
131 player.compositorPlayer()->removeAnimation(animationId); 132 player.compositorPlayer()->removeAnimation(animationId);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 194
194 WebDoublePoint scrollPosition(7, 9); 195 WebDoublePoint scrollPosition(7, 9);
195 m_platformLayer->setScrollPositionDouble(scrollPosition); 196 m_platformLayer->setScrollPositionDouble(scrollPosition);
196 m_graphicsLayer->didScroll(); 197 m_graphicsLayer->didScroll();
197 198
198 EXPECT_FLOAT_EQ(scrollPosition.x, scrollableArea->scrollPositionDouble().x() ); 199 EXPECT_FLOAT_EQ(scrollPosition.x, scrollableArea->scrollPositionDouble().x() );
199 EXPECT_FLOAT_EQ(scrollPosition.y, scrollableArea->scrollPositionDouble().y() ); 200 EXPECT_FLOAT_EQ(scrollPosition.y, scrollableArea->scrollPositionDouble().y() );
200 } 201 }
201 202
202 } // namespace blink 203 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698