OLD | NEW |
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 WebAnimationMock : public blink::WebAnimation { | 68 class WebCompositorAnimationMock : public blink::WebCompositorAnimation { |
69 private: | 69 private: |
70 blink::WebAnimation::TargetProperty m_property; | 70 blink::WebCompositorAnimation::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 WebAnimationMock(blink::WebAnimation::TargetProperty p) : m_property(p) { } | 74 WebCompositorAnimationMock(blink::WebCompositorAnimation::TargetProperty p)
: m_property(p) { } |
75 virtual blink::WebAnimation::TargetProperty targetProperty() const { return
m_property; }; | 75 virtual blink::WebCompositorAnimation::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 ~WebAnimationMock() { delete_(); } | 92 ~WebCompositorAnimationMock() { delete_(); } |
93 }; | 93 }; |
94 | 94 |
95 template<typename CurveType, blink::WebAnimationCurve::AnimationCurveType CurveI
d, typename KeyframeType> | 95 template<typename CurveType, blink::WebCompositorAnimationCurve::AnimationCurveT
ype CurveId, typename KeyframeType> |
96 class WebAnimationCurveMock : public CurveType { | 96 class WebCompositorAnimationCurveMock : 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&, blink::WebAnimationCurve::Timi
ngFunctionType)); | 99 MOCK_METHOD2_T(add, void(const KeyframeType&, blink::WebCompositorAnimationC
urve::TimingFunctionType)); |
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 blink::WebAnimationCurve::AnimationCurveType type() const { return C
urveId; }; | 104 virtual blink::WebCompositorAnimationCurve::AnimationCurveType type() const
{ return CurveId; }; |
105 | 105 |
106 MOCK_METHOD0(delete_, void()); | 106 MOCK_METHOD0(delete_, void()); |
107 ~WebAnimationCurveMock() { delete_(); } | 107 ~WebCompositorAnimationCurveMock() { delete_(); } |
108 }; | 108 }; |
109 | 109 |
110 typedef WebAnimationCurveMock<blink::WebFloatAnimationCurve, blink::WebAnimation
Curve::AnimationCurveTypeFloat, blink::WebFloatKeyframe> WebFloatAnimationCurveM
ock; | 110 typedef WebCompositorAnimationCurveMock<blink::WebFloatAnimationCurve, blink::We
bCompositorAnimationCurve::AnimationCurveTypeFloat, blink::WebFloatKeyframe> Web
FloatAnimationCurveMock; |
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 blink::WebCompositorSupport { | 120 class WebCompositorSupportMock : public blink::WebCompositorSupport { |
121 public: | 121 public: |
122 MOCK_METHOD3(createAnimation, blink::WebAnimation*(const blink::WebAnima
tionCurve& curve, blink::WebAnimation::TargetProperty target, int animationId)); | 122 MOCK_METHOD3(createAnimation, blink::WebCompositorAnimation*(const blink
::WebCompositorAnimationCurve& curve, blink::WebCompositorAnimation::TargetPrope
rty target, int animationId)); |
123 MOCK_METHOD0(createFloatAnimationCurve, blink::WebFloatAnimationCurve*()
); | 123 MOCK_METHOD0(createFloatAnimationCurve, blink::WebFloatAnimationCurve*()
); |
124 }; | 124 }; |
125 | 125 |
126 private: | 126 private: |
127 class PlatformProxy : public blink::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: |
(...skipping 22 matching lines...) Expand all Loading... |
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 |
OLD | NEW |