OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions | |
6 * are met: | |
7 * 1. Redistributions of source code must retain the above copyright | |
8 * notice, this list of conditions and the following disclaimer. | |
9 * 2. Redistributions in binary form must reproduce the above copyright | |
10 * notice, this list of conditions and the following disclaimer in the | |
11 * documentation and/or other materials provided with the distribution. | |
12 * | |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y | |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y | |
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N | |
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
23 */ | |
24 | |
25 #ifndef CompositorAnimationsTestHelper_h | |
26 #define CompositorAnimationsTestHelper_h | |
27 | |
28 #include "core/animation/CompositorAnimations.h" | |
29 #include "platform/animation/CompositorAnimationPlayer.h" | |
30 #include "platform/animation/CompositorAnimationTimeline.h" | |
31 #include "platform/animation/CompositorFloatAnimationCurve.h" | |
32 #include "platform/animation/CompositorFloatKeyframe.h" | |
33 #include "platform/graphics/CompositorFactory.h" | |
34 #include "platform/testing/TestingPlatformSupport.h" | |
35 #include "public/platform/WebCompositorSupport.h" | |
36 #include "wtf/PassOwnPtr.h" | |
37 | |
38 #include <gmock/gmock.h> | |
39 #include <gtest/gtest.h> | |
40 | |
41 // Test helpers and mocks for Web* types | |
42 // ----------------------------------------------------------------------- | |
43 namespace blink { | |
44 | |
45 // CompositorFloatKeyframe is a plain struct, so we just create an == operator | |
46 // for it. | |
47 inline bool operator==(const CompositorFloatKeyframe& a, const CompositorFloatKe
yframe& b) | |
48 { | |
49 return a.time == b.time && a.value == b.value; | |
50 } | |
51 | |
52 inline void PrintTo(const CompositorFloatKeyframe& frame, ::std::ostream* os) | |
53 { | |
54 *os << "CompositorFloatKeyframe@" << &frame << "(" << frame.time << ", " <<
frame.value << ")"; | |
55 } | |
56 | |
57 // ----------------------------------------------------------------------- | |
58 | |
59 class WebCompositorAnimationMock : public CompositorAnimation { | |
60 private: | |
61 CompositorTargetProperty::Type m_property; | |
62 | |
63 public: | |
64 // Target Property is set through the constructor. | |
65 WebCompositorAnimationMock(CompositorTargetProperty::Type p) : m_property(p)
{ } | |
66 virtual CompositorTargetProperty::Type targetProperty() const { return m_pro
perty; } | |
67 | |
68 MOCK_METHOD0(id, int()); | |
69 MOCK_METHOD0(group, int()); | |
70 | |
71 MOCK_CONST_METHOD0(iterations, double()); | |
72 MOCK_METHOD1(setIterations, void(double)); | |
73 | |
74 MOCK_CONST_METHOD0(iterationStart, double()); | |
75 MOCK_METHOD1(setIterationStart, void(double)); | |
76 | |
77 MOCK_CONST_METHOD0(startTime, double()); | |
78 MOCK_METHOD1(setStartTime, void(double)); | |
79 | |
80 MOCK_CONST_METHOD0(timeOffset, double()); | |
81 MOCK_METHOD1(setTimeOffset, void(double)); | |
82 | |
83 MOCK_CONST_METHOD0(getDirection, Direction()); | |
84 MOCK_METHOD1(setDirection, void(Direction)); | |
85 | |
86 MOCK_CONST_METHOD0(playbackRate, double()); | |
87 MOCK_METHOD1(setPlaybackRate, void(double)); | |
88 | |
89 MOCK_CONST_METHOD0(getFillMode, FillMode()); | |
90 MOCK_METHOD1(setFillMode, void(FillMode)); | |
91 | |
92 MOCK_METHOD0(delete_, void()); | |
93 ~WebCompositorAnimationMock() { delete_(); } | |
94 }; | |
95 | |
96 template<typename CurveType, typename KeyframeType> | |
97 class WebCompositorAnimationCurveMock : public CurveType { | |
98 public: | |
99 MOCK_METHOD1_T(addLinearKeyframe, void(const KeyframeType&)); | |
100 MOCK_METHOD2_T(addCubicBezierKeyframe, void(const KeyframeType&, CubicBezier
TimingFunction::EaseType)); | |
101 MOCK_METHOD5_T(addCubicBezierKeyframe, void(const KeyframeType&, double, dou
ble, double, double)); | |
102 MOCK_METHOD3_T(addStepsKeyframe, void(const KeyframeType&, int steps, StepsT
imingFunction::StepPosition)); | |
103 | |
104 MOCK_METHOD0(setLinearTimingFunction, void()); | |
105 MOCK_METHOD4(setCubicBezierTimingFunction, void(double, double, double, doub
le)); | |
106 MOCK_METHOD1(setCubicBezierTimingFunction, void(CubicBezierTimingFunction::E
aseType)); | |
107 MOCK_METHOD2(setStepsTimingFunction, void(int, StepsTimingFunction::StepPosi
tion)); | |
108 | |
109 MOCK_CONST_METHOD1_T(getValue, float(double)); // Only on CompositorFloatAni
mationCurve, but can't hurt to have here. | |
110 | |
111 MOCK_METHOD0(delete_, void()); | |
112 ~WebCompositorAnimationCurveMock() override { delete_(); } | |
113 }; | |
114 | |
115 using WebFloatAnimationCurveMock = WebCompositorAnimationCurveMock<CompositorFlo
atAnimationCurve, CompositorFloatKeyframe>; | |
116 | |
117 class WebCompositorAnimationTimelineMock : public CompositorAnimationTimeline { | |
118 public: | |
119 MOCK_METHOD1(playerAttached, void(const CompositorAnimationPlayerClient&)); | |
120 MOCK_METHOD1(playerDestroyed, void(const CompositorAnimationPlayerClient&)); | |
121 }; | |
122 | |
123 } // namespace blink | |
124 | |
125 namespace blink { | |
126 | |
127 class AnimationCompositorAnimationsTestBase : public ::testing::Test { | |
128 public: | |
129 class CompositorFactoryMock : public CompositorFactory { | |
130 public: | |
131 MOCK_METHOD4(createAnimation, CompositorAnimation*(const CompositorAnima
tionCurve& curve, CompositorTargetProperty::Type target, int groupId, int animat
ionId)); | |
132 MOCK_METHOD0(createFloatAnimationCurve, CompositorFloatAnimationCurve*()
); | |
133 MOCK_METHOD0(createAnimationPlayer, CompositorAnimationPlayer*()); | |
134 MOCK_METHOD0(createAnimationTimeline, CompositorAnimationTimeline*()); | |
135 }; | |
136 }; | |
137 | |
138 } // namespace blink | |
139 | |
140 #endif | |
OLD | NEW |