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

Side by Side Diff: Source/core/animation/CompositorAnimationsTestHelper.h

Issue 470443002: Revert of Rename WebAnimation to WebCompositorAnimation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
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 29 matching lines...) Expand all
40 40
41 template<typename T> 41 template<typename T>
42 PassOwnPtr<T> CloneToPassOwnPtr(T& o) 42 PassOwnPtr<T> CloneToPassOwnPtr(T& o)
43 { 43 {
44 return adoptPtr(new T(o)); 44 return adoptPtr(new T(o));
45 } 45 }
46 46
47 } // namespace testing 47 } // namespace testing
48 48
49 49
50 // Test helpers and mocks for Web* types 50 // Test helpers and mocks for blink::Web* types
51 // ----------------------------------------------------------------------- 51 // -----------------------------------------------------------------------
52 namespace blink { 52 namespace blink {
53 53
54 // WebFloatKeyframe is a plain struct, so we just create an == operator 54 // blink::WebFloatKeyframe is a plain struct, so we just create an == operator
55 // for it. 55 // for it.
56 inline bool operator==(const WebFloatKeyframe& a, const WebFloatKeyframe& b) 56 inline bool operator==(const WebFloatKeyframe& a, const WebFloatKeyframe& b)
57 { 57 {
58 return a.time == b.time && a.value == b.value; 58 return a.time == b.time && a.value == b.value;
59 } 59 }
60 60
61 inline void PrintTo(const WebFloatKeyframe& frame, ::std::ostream* os) 61 inline void PrintTo(const WebFloatKeyframe& frame, ::std::ostream* os)
62 { 62 {
63 *os << "WebFloatKeyframe@" << &frame << "(" << frame.time << ", " << frame.v alue << ")"; 63 *os << "WebFloatKeyframe@" << &frame << "(" << frame.time << ", " << frame.v alue << ")";
64 } 64 }
65 65
66 // ----------------------------------------------------------------------- 66 // -----------------------------------------------------------------------
67 67
68 class WebCompositorAnimationMock : public WebCompositorAnimation { 68 class WebAnimationMock : public blink::WebAnimation {
69 private: 69 private:
70 WebCompositorAnimation::TargetProperty m_property; 70 blink::WebAnimation::TargetProperty m_property;
71 71
72 public: 72 public:
73 // Target Property is set through the constructor. 73 // Target Property is set through the constructor.
74 WebCompositorAnimationMock(WebCompositorAnimation::TargetProperty p) : m_pro perty(p) { } 74 WebAnimationMock(blink::WebAnimation::TargetProperty p) : m_property(p) { }
75 virtual WebCompositorAnimation::TargetProperty targetProperty() const { retu rn m_property; }; 75 virtual blink::WebAnimation::TargetProperty targetProperty() const { return m_property; };
76 76
77 MOCK_METHOD0(id, int()); 77 MOCK_METHOD0(id, int());
78 78
79 MOCK_CONST_METHOD0(iterations, int()); 79 MOCK_CONST_METHOD0(iterations, int());
80 MOCK_METHOD1(setIterations, void(int)); 80 MOCK_METHOD1(setIterations, void(int));
81 81
82 MOCK_CONST_METHOD0(startTime, double()); 82 MOCK_CONST_METHOD0(startTime, double());
83 MOCK_METHOD1(setStartTime, void(double)); 83 MOCK_METHOD1(setStartTime, void(double));
84 84
85 MOCK_CONST_METHOD0(timeOffset, double()); 85 MOCK_CONST_METHOD0(timeOffset, double());
86 MOCK_METHOD1(setTimeOffset, void(double)); 86 MOCK_METHOD1(setTimeOffset, void(double));
87 87
88 MOCK_CONST_METHOD0(alternatesDirection, bool()); 88 MOCK_CONST_METHOD0(alternatesDirection, bool());
89 MOCK_METHOD1(setAlternatesDirection, void(bool)); 89 MOCK_METHOD1(setAlternatesDirection, void(bool));
90 90
91 MOCK_METHOD0(delete_, void()); 91 MOCK_METHOD0(delete_, void());
92 ~WebCompositorAnimationMock() { delete_(); } 92 ~WebAnimationMock() { delete_(); }
93 }; 93 };
94 94
95 template<typename CurveType, WebCompositorAnimationCurve::AnimationCurveType Cur veId, typename KeyframeType> 95 template<typename CurveType, blink::WebAnimationCurve::AnimationCurveType CurveI d, typename KeyframeType>
96 class WebCompositorAnimationCurveMock : public CurveType { 96 class WebAnimationCurveMock : public CurveType {
97 public: 97 public:
98 MOCK_METHOD1_T(add, void(const KeyframeType&)); 98 MOCK_METHOD1_T(add, void(const KeyframeType&));
99 MOCK_METHOD2_T(add, void(const KeyframeType&, WebCompositorAnimationCurve::T imingFunctionType)); 99 MOCK_METHOD2_T(add, void(const KeyframeType&, blink::WebAnimationCurve::Timi ngFunctionType));
100 MOCK_METHOD5_T(add, void(const KeyframeType&, double, double, double, double )); 100 MOCK_METHOD5_T(add, void(const KeyframeType&, double, double, double, double ));
101 101
102 MOCK_CONST_METHOD1_T(getValue, float(double)); // Only on WebFloatAnimationC urve, but can't hurt to have here. 102 MOCK_CONST_METHOD1_T(getValue, float(double)); // Only on WebFloatAnimationC urve, but can't hurt to have here.
103 103
104 virtual WebCompositorAnimationCurve::AnimationCurveType type() const { retur n CurveId; }; 104 virtual blink::WebAnimationCurve::AnimationCurveType type() const { return C urveId; };
105 105
106 MOCK_METHOD0(delete_, void()); 106 MOCK_METHOD0(delete_, void());
107 ~WebCompositorAnimationCurveMock() { delete_(); } 107 ~WebAnimationCurveMock() { delete_(); }
108 }; 108 };
109 109
110 typedef WebCompositorAnimationCurveMock<WebFloatAnimationCurve, WebCompositorAni mationCurve::AnimationCurveTypeFloat, WebFloatKeyframe> WebFloatAnimationCurveMo ck; 110 typedef WebAnimationCurveMock<blink::WebFloatAnimationCurve, blink::WebAnimation Curve::AnimationCurveTypeFloat, blink::WebFloatKeyframe> WebFloatAnimationCurveM ock;
111 111
112 } // namespace blink 112 } // namespace blink
113 113
114 namespace blink { 114 namespace blink {
115 115
116 class AnimationCompositorAnimationsTestBase : public ::testing::Test { 116 class AnimationCompositorAnimationsTestBase : public ::testing::Test {
117 public: 117 public:
118 AnimationCompositorAnimationsTestBase() : m_proxyPlatform(&m_mockCompositor) { }; 118 AnimationCompositorAnimationsTestBase() : m_proxyPlatform(&m_mockCompositor) { };
119 119
120 class WebCompositorSupportMock : public WebCompositorSupport { 120 class WebCompositorSupportMock : public blink::WebCompositorSupport {
121 public: 121 public:
122 MOCK_METHOD3(createAnimation, WebCompositorAnimation*(const WebComposito rAnimationCurve& curve, WebCompositorAnimation::TargetProperty target, int anima tionId)); 122 MOCK_METHOD3(createAnimation, blink::WebAnimation*(const blink::WebAnima tionCurve& curve, blink::WebAnimation::TargetProperty target, int animationId));
123 MOCK_METHOD0(createFloatAnimationCurve, WebFloatAnimationCurve*()); 123 MOCK_METHOD0(createFloatAnimationCurve, blink::WebFloatAnimationCurve*() );
124 }; 124 };
125 125
126 private: 126 private:
127 class PlatformProxy : public Platform { 127 class PlatformProxy : public blink::Platform {
128 public: 128 public:
129 PlatformProxy(WebCompositorSupportMock** compositor) : m_compositor(comp ositor) { } 129 PlatformProxy(WebCompositorSupportMock** compositor) : m_compositor(comp ositor) { }
130 130
131 virtual void cryptographicallyRandomValues(unsigned char* buffer, size_t length) { ASSERT_NOT_REACHED(); } 131 virtual void cryptographicallyRandomValues(unsigned char* buffer, size_t length) { ASSERT_NOT_REACHED(); }
132 private: 132 private:
133 WebCompositorSupportMock** m_compositor; 133 WebCompositorSupportMock** m_compositor;
134 virtual WebCompositorSupport* compositorSupport() OVERRIDE { return *m_c ompositor; } 134 virtual blink::WebCompositorSupport* compositorSupport() OVERRIDE { retu rn *m_compositor; }
135 }; 135 };
136 136
137 WebCompositorSupportMock* m_mockCompositor; 137 WebCompositorSupportMock* m_mockCompositor;
138 PlatformProxy m_proxyPlatform; 138 PlatformProxy m_proxyPlatform;
139 139
140 protected: 140 protected:
141 Platform* m_platform; 141 blink::Platform* m_platform;
142 142
143 virtual void SetUp() 143 virtual void SetUp()
144 { 144 {
145 m_mockCompositor = 0; 145 m_mockCompositor = 0;
146 m_platform = Platform::current(); 146 m_platform = blink::Platform::current();
147 Platform::initialize(&m_proxyPlatform); 147 blink::Platform::initialize(&m_proxyPlatform);
148 } 148 }
149 149
150 virtual void TearDown() 150 virtual void TearDown()
151 { 151 {
152 Platform::initialize(m_platform); 152 blink::Platform::initialize(m_platform);
153 } 153 }
154 154
155 void setCompositorForTesting(WebCompositorSupportMock& mock) 155 void setCompositorForTesting(WebCompositorSupportMock& mock)
156 { 156 {
157 ASSERT(!m_mockCompositor); 157 ASSERT(!m_mockCompositor);
158 m_mockCompositor = &mock; 158 m_mockCompositor = &mock;
159 } 159 }
160 }; 160 };
161 161
162 } 162 }
163 163
164 #endif 164 #endif
OLDNEW
« no previous file with comments | « Source/core/animation/CompositorAnimationsTest.cpp ('k') | Source/platform/graphics/GraphicsLayer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698