| OLD | NEW |
| 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/CompositorFloatAnimationCurve.h" | 5 #include "platform/animation/CompositorFloatAnimationCurve.h" |
| 6 | 6 |
| 7 #include "cc/animation/timing_function.h" | 7 #include "cc/animation/timing_function.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 using blink::CompositorAnimationCurve; | 12 using blink::CompositorAnimationCurve; |
| 13 using blink::CompositorFloatAnimationCurve; | 13 using blink::CompositorFloatAnimationCurve; |
| 14 using blink::CompositorFloatKeyframe; | 14 using blink::CompositorFloatKeyframe; |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 // Tests that a float animation with one keyframe works as expected. | 18 // Tests that a float animation with one keyframe works as expected. |
| 19 TEST(WebFloatAnimationCurveTest, OneFloatKeyframe) | 19 TEST(WebFloatAnimationCurveTest, OneFloatKeyframe) |
| 20 { | 20 { |
| 21 std::unique_ptr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimat
ionCurve::create(); | 21 OwnPtr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimationCurve:
:create(); |
| 22 curve->addLinearKeyframe(CompositorFloatKeyframe(0, 2)); | 22 curve->addLinearKeyframe(CompositorFloatKeyframe(0, 2)); |
| 23 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); | 23 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); |
| 24 EXPECT_FLOAT_EQ(2, curve->getValue(0)); | 24 EXPECT_FLOAT_EQ(2, curve->getValue(0)); |
| 25 EXPECT_FLOAT_EQ(2, curve->getValue(0.5)); | 25 EXPECT_FLOAT_EQ(2, curve->getValue(0.5)); |
| 26 EXPECT_FLOAT_EQ(2, curve->getValue(1)); | 26 EXPECT_FLOAT_EQ(2, curve->getValue(1)); |
| 27 EXPECT_FLOAT_EQ(2, curve->getValue(2)); | 27 EXPECT_FLOAT_EQ(2, curve->getValue(2)); |
| 28 } | 28 } |
| 29 | 29 |
| 30 // Tests that a float animation with two keyframes works as expected. | 30 // Tests that a float animation with two keyframes works as expected. |
| 31 TEST(WebFloatAnimationCurveTest, TwoFloatKeyframe) | 31 TEST(WebFloatAnimationCurveTest, TwoFloatKeyframe) |
| 32 { | 32 { |
| 33 std::unique_ptr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimat
ionCurve::create(); | 33 OwnPtr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimationCurve:
:create(); |
| 34 curve->addLinearKeyframe(CompositorFloatKeyframe(0, 2)); | 34 curve->addLinearKeyframe(CompositorFloatKeyframe(0, 2)); |
| 35 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 4)); | 35 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 4)); |
| 36 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); | 36 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); |
| 37 EXPECT_FLOAT_EQ(2, curve->getValue(0)); | 37 EXPECT_FLOAT_EQ(2, curve->getValue(0)); |
| 38 EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); | 38 EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); |
| 39 EXPECT_FLOAT_EQ(4, curve->getValue(1)); | 39 EXPECT_FLOAT_EQ(4, curve->getValue(1)); |
| 40 EXPECT_FLOAT_EQ(4, curve->getValue(2)); | 40 EXPECT_FLOAT_EQ(4, curve->getValue(2)); |
| 41 } | 41 } |
| 42 | 42 |
| 43 // Tests that a float animation with three keyframes works as expected. | 43 // Tests that a float animation with three keyframes works as expected. |
| 44 TEST(WebFloatAnimationCurveTest, ThreeFloatKeyframe) | 44 TEST(WebFloatAnimationCurveTest, ThreeFloatKeyframe) |
| 45 { | 45 { |
| 46 std::unique_ptr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimat
ionCurve::create(); | 46 OwnPtr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimationCurve:
:create(); |
| 47 curve->addLinearKeyframe(CompositorFloatKeyframe(0, 2)); | 47 curve->addLinearKeyframe(CompositorFloatKeyframe(0, 2)); |
| 48 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 4)); | 48 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 4)); |
| 49 curve->addLinearKeyframe(CompositorFloatKeyframe(2, 8)); | 49 curve->addLinearKeyframe(CompositorFloatKeyframe(2, 8)); |
| 50 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); | 50 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); |
| 51 EXPECT_FLOAT_EQ(2, curve->getValue(0)); | 51 EXPECT_FLOAT_EQ(2, curve->getValue(0)); |
| 52 EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); | 52 EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); |
| 53 EXPECT_FLOAT_EQ(4, curve->getValue(1)); | 53 EXPECT_FLOAT_EQ(4, curve->getValue(1)); |
| 54 EXPECT_FLOAT_EQ(6, curve->getValue(1.5)); | 54 EXPECT_FLOAT_EQ(6, curve->getValue(1.5)); |
| 55 EXPECT_FLOAT_EQ(8, curve->getValue(2)); | 55 EXPECT_FLOAT_EQ(8, curve->getValue(2)); |
| 56 EXPECT_FLOAT_EQ(8, curve->getValue(3)); | 56 EXPECT_FLOAT_EQ(8, curve->getValue(3)); |
| 57 } | 57 } |
| 58 | 58 |
| 59 // Tests that a float animation with multiple keys at a given time works sanely. | 59 // Tests that a float animation with multiple keys at a given time works sanely. |
| 60 TEST(WebFloatAnimationCurveTest, RepeatedFloatKeyTimes) | 60 TEST(WebFloatAnimationCurveTest, RepeatedFloatKeyTimes) |
| 61 { | 61 { |
| 62 std::unique_ptr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimat
ionCurve::create(); | 62 OwnPtr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimationCurve:
:create(); |
| 63 curve->addLinearKeyframe(CompositorFloatKeyframe(0, 4)); | 63 curve->addLinearKeyframe(CompositorFloatKeyframe(0, 4)); |
| 64 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 4)); | 64 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 4)); |
| 65 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 6)); | 65 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 6)); |
| 66 curve->addLinearKeyframe(CompositorFloatKeyframe(2, 6)); | 66 curve->addLinearKeyframe(CompositorFloatKeyframe(2, 6)); |
| 67 | 67 |
| 68 EXPECT_FLOAT_EQ(4, curve->getValue(-1)); | 68 EXPECT_FLOAT_EQ(4, curve->getValue(-1)); |
| 69 EXPECT_FLOAT_EQ(4, curve->getValue(0)); | 69 EXPECT_FLOAT_EQ(4, curve->getValue(0)); |
| 70 EXPECT_FLOAT_EQ(4, curve->getValue(0.5)); | 70 EXPECT_FLOAT_EQ(4, curve->getValue(0.5)); |
| 71 | 71 |
| 72 // There is a discontinuity at 1. Any value between 4 and 6 is valid. | 72 // There is a discontinuity at 1. Any value between 4 and 6 is valid. |
| 73 float value = curve->getValue(1); | 73 float value = curve->getValue(1); |
| 74 EXPECT_TRUE(value >= 4 && value <= 6); | 74 EXPECT_TRUE(value >= 4 && value <= 6); |
| 75 | 75 |
| 76 EXPECT_FLOAT_EQ(6, curve->getValue(1.5)); | 76 EXPECT_FLOAT_EQ(6, curve->getValue(1.5)); |
| 77 EXPECT_FLOAT_EQ(6, curve->getValue(2)); | 77 EXPECT_FLOAT_EQ(6, curve->getValue(2)); |
| 78 EXPECT_FLOAT_EQ(6, curve->getValue(3)); | 78 EXPECT_FLOAT_EQ(6, curve->getValue(3)); |
| 79 } | 79 } |
| 80 | 80 |
| 81 // Tests that the keyframes may be added out of order. | 81 // Tests that the keyframes may be added out of order. |
| 82 TEST(WebFloatAnimationCurveTest, UnsortedKeyframes) | 82 TEST(WebFloatAnimationCurveTest, UnsortedKeyframes) |
| 83 { | 83 { |
| 84 std::unique_ptr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimat
ionCurve::create(); | 84 OwnPtr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimationCurve:
:create(); |
| 85 curve->addLinearKeyframe(CompositorFloatKeyframe(2, 8)); | 85 curve->addLinearKeyframe(CompositorFloatKeyframe(2, 8)); |
| 86 curve->addLinearKeyframe(CompositorFloatKeyframe(0, 2)); | 86 curve->addLinearKeyframe(CompositorFloatKeyframe(0, 2)); |
| 87 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 4)); | 87 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 4)); |
| 88 | 88 |
| 89 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); | 89 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); |
| 90 EXPECT_FLOAT_EQ(2, curve->getValue(0)); | 90 EXPECT_FLOAT_EQ(2, curve->getValue(0)); |
| 91 EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); | 91 EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); |
| 92 EXPECT_FLOAT_EQ(4, curve->getValue(1)); | 92 EXPECT_FLOAT_EQ(4, curve->getValue(1)); |
| 93 EXPECT_FLOAT_EQ(6, curve->getValue(1.5)); | 93 EXPECT_FLOAT_EQ(6, curve->getValue(1.5)); |
| 94 EXPECT_FLOAT_EQ(8, curve->getValue(2)); | 94 EXPECT_FLOAT_EQ(8, curve->getValue(2)); |
| 95 EXPECT_FLOAT_EQ(8, curve->getValue(3)); | 95 EXPECT_FLOAT_EQ(8, curve->getValue(3)); |
| 96 } | 96 } |
| 97 | 97 |
| 98 // Tests that a cubic bezier timing function works as expected. | 98 // Tests that a cubic bezier timing function works as expected. |
| 99 TEST(WebFloatAnimationCurveTest, CubicBezierTimingFunction) | 99 TEST(WebFloatAnimationCurveTest, CubicBezierTimingFunction) |
| 100 { | 100 { |
| 101 std::unique_ptr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimat
ionCurve::create(); | 101 OwnPtr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimationCurve:
:create(); |
| 102 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(0, 0), 0.25, 0, 0.75,
1); | 102 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(0, 0), 0.25, 0, 0.75,
1); |
| 103 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 1)); | 103 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 1)); |
| 104 | 104 |
| 105 EXPECT_FLOAT_EQ(0, curve->getValue(0)); | 105 EXPECT_FLOAT_EQ(0, curve->getValue(0)); |
| 106 EXPECT_LT(0, curve->getValue(0.25)); | 106 EXPECT_LT(0, curve->getValue(0.25)); |
| 107 EXPECT_GT(0.25, curve->getValue(0.25)); | 107 EXPECT_GT(0.25, curve->getValue(0.25)); |
| 108 EXPECT_NEAR(curve->getValue(0.5), 0.5, 0.00015); | 108 EXPECT_NEAR(curve->getValue(0.5), 0.5, 0.00015); |
| 109 EXPECT_LT(0.75, curve->getValue(0.75)); | 109 EXPECT_LT(0.75, curve->getValue(0.75)); |
| 110 EXPECT_GT(1, curve->getValue(0.75)); | 110 EXPECT_GT(1, curve->getValue(0.75)); |
| 111 EXPECT_FLOAT_EQ(1, curve->getValue(1)); | 111 EXPECT_FLOAT_EQ(1, curve->getValue(1)); |
| 112 } | 112 } |
| 113 | 113 |
| 114 // Tests that an ease timing function works as expected. | 114 // Tests that an ease timing function works as expected. |
| 115 TEST(WebFloatAnimationCurveTest, EaseTimingFunction) | 115 TEST(WebFloatAnimationCurveTest, EaseTimingFunction) |
| 116 { | 116 { |
| 117 std::unique_ptr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimat
ionCurve::create(); | 117 OwnPtr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimationCurve:
:create(); |
| 118 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(0, 0), CubicBezierTimi
ngFunction::EaseType::EASE); | 118 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(0, 0), CubicBezierTimi
ngFunction::EaseType::EASE); |
| 119 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 1)); | 119 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 1)); |
| 120 | 120 |
| 121 std::unique_ptr<cc::TimingFunction> timingFunction( | 121 std::unique_ptr<cc::TimingFunction> timingFunction( |
| 122 cc::CubicBezierTimingFunction::CreatePreset(CubicBezierTimingFunction::E
aseType::EASE)); | 122 cc::CubicBezierTimingFunction::CreatePreset(CubicBezierTimingFunction::E
aseType::EASE)); |
| 123 for (int i = 0; i <= 4; ++i) { | 123 for (int i = 0; i <= 4; ++i) { |
| 124 const double time = i * 0.25; | 124 const double time = i * 0.25; |
| 125 EXPECT_FLOAT_EQ(timingFunction->GetValue(time), curve->getValue(time)); | 125 EXPECT_FLOAT_EQ(timingFunction->GetValue(time), curve->getValue(time)); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 | 128 |
| 129 // Tests using a linear timing function. | 129 // Tests using a linear timing function. |
| 130 TEST(WebFloatAnimationCurveTest, LinearTimingFunction) | 130 TEST(WebFloatAnimationCurveTest, LinearTimingFunction) |
| 131 { | 131 { |
| 132 std::unique_ptr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimat
ionCurve::create(); | 132 OwnPtr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimationCurve:
:create(); |
| 133 curve->addLinearKeyframe(CompositorFloatKeyframe(0, 0)); | 133 curve->addLinearKeyframe(CompositorFloatKeyframe(0, 0)); |
| 134 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 1)); | 134 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 1)); |
| 135 | 135 |
| 136 for (int i = 0; i <= 4; ++i) { | 136 for (int i = 0; i <= 4; ++i) { |
| 137 const double time = i * 0.25; | 137 const double time = i * 0.25; |
| 138 EXPECT_FLOAT_EQ(time, curve->getValue(time)); | 138 EXPECT_FLOAT_EQ(time, curve->getValue(time)); |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 | 141 |
| 142 // Tests that an ease in timing function works as expected. | 142 // Tests that an ease in timing function works as expected. |
| 143 TEST(WebFloatAnimationCurveTest, EaseInTimingFunction) | 143 TEST(WebFloatAnimationCurveTest, EaseInTimingFunction) |
| 144 { | 144 { |
| 145 std::unique_ptr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimat
ionCurve::create(); | 145 OwnPtr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimationCurve:
:create(); |
| 146 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(0, 0), CubicBezierTimi
ngFunction::EaseType::EASE_IN); | 146 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(0, 0), CubicBezierTimi
ngFunction::EaseType::EASE_IN); |
| 147 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 1)); | 147 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 1)); |
| 148 | 148 |
| 149 std::unique_ptr<cc::TimingFunction> timingFunction( | 149 std::unique_ptr<cc::TimingFunction> timingFunction( |
| 150 cc::CubicBezierTimingFunction::CreatePreset(CubicBezierTimingFunction::E
aseType::EASE_IN)); | 150 cc::CubicBezierTimingFunction::CreatePreset(CubicBezierTimingFunction::E
aseType::EASE_IN)); |
| 151 for (int i = 0; i <= 4; ++i) { | 151 for (int i = 0; i <= 4; ++i) { |
| 152 const double time = i * 0.25; | 152 const double time = i * 0.25; |
| 153 EXPECT_FLOAT_EQ(timingFunction->GetValue(time), curve->getValue(time)); | 153 EXPECT_FLOAT_EQ(timingFunction->GetValue(time), curve->getValue(time)); |
| 154 } | 154 } |
| 155 } | 155 } |
| 156 | 156 |
| 157 // Tests that an ease in timing function works as expected. | 157 // Tests that an ease in timing function works as expected. |
| 158 TEST(WebFloatAnimationCurveTest, EaseOutTimingFunction) | 158 TEST(WebFloatAnimationCurveTest, EaseOutTimingFunction) |
| 159 { | 159 { |
| 160 std::unique_ptr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimat
ionCurve::create(); | 160 OwnPtr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimationCurve:
:create(); |
| 161 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(0, 0), CubicBezierTimi
ngFunction::EaseType::EASE_OUT); | 161 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(0, 0), CubicBezierTimi
ngFunction::EaseType::EASE_OUT); |
| 162 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 1)); | 162 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 1)); |
| 163 | 163 |
| 164 std::unique_ptr<cc::TimingFunction> timingFunction( | 164 std::unique_ptr<cc::TimingFunction> timingFunction( |
| 165 cc::CubicBezierTimingFunction::CreatePreset(CubicBezierTimingFunction::E
aseType::EASE_OUT)); | 165 cc::CubicBezierTimingFunction::CreatePreset(CubicBezierTimingFunction::E
aseType::EASE_OUT)); |
| 166 for (int i = 0; i <= 4; ++i) { | 166 for (int i = 0; i <= 4; ++i) { |
| 167 const double time = i * 0.25; | 167 const double time = i * 0.25; |
| 168 EXPECT_FLOAT_EQ(timingFunction->GetValue(time), curve->getValue(time)); | 168 EXPECT_FLOAT_EQ(timingFunction->GetValue(time), curve->getValue(time)); |
| 169 } | 169 } |
| 170 } | 170 } |
| 171 | 171 |
| 172 // Tests that an ease in timing function works as expected. | 172 // Tests that an ease in timing function works as expected. |
| 173 TEST(WebFloatAnimationCurveTest, EaseInOutTimingFunction) | 173 TEST(WebFloatAnimationCurveTest, EaseInOutTimingFunction) |
| 174 { | 174 { |
| 175 std::unique_ptr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimat
ionCurve::create(); | 175 OwnPtr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimationCurve:
:create(); |
| 176 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(0, 0), CubicBezierTimi
ngFunction::EaseType::EASE_IN_OUT); | 176 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(0, 0), CubicBezierTimi
ngFunction::EaseType::EASE_IN_OUT); |
| 177 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 1)); | 177 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 1)); |
| 178 | 178 |
| 179 std::unique_ptr<cc::TimingFunction> timingFunction( | 179 std::unique_ptr<cc::TimingFunction> timingFunction( |
| 180 cc::CubicBezierTimingFunction::CreatePreset(CubicBezierTimingFunction::E
aseType::EASE_IN_OUT)); | 180 cc::CubicBezierTimingFunction::CreatePreset(CubicBezierTimingFunction::E
aseType::EASE_IN_OUT)); |
| 181 for (int i = 0; i <= 4; ++i) { | 181 for (int i = 0; i <= 4; ++i) { |
| 182 const double time = i * 0.25; | 182 const double time = i * 0.25; |
| 183 EXPECT_FLOAT_EQ(timingFunction->GetValue(time), curve->getValue(time)); | 183 EXPECT_FLOAT_EQ(timingFunction->GetValue(time), curve->getValue(time)); |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 | 186 |
| 187 // Tests that an ease in timing function works as expected. | 187 // Tests that an ease in timing function works as expected. |
| 188 TEST(WebFloatAnimationCurveTest, CustomBezierTimingFunction) | 188 TEST(WebFloatAnimationCurveTest, CustomBezierTimingFunction) |
| 189 { | 189 { |
| 190 std::unique_ptr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimat
ionCurve::create(); | 190 OwnPtr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimationCurve:
:create(); |
| 191 double x1 = 0.3; | 191 double x1 = 0.3; |
| 192 double y1 = 0.2; | 192 double y1 = 0.2; |
| 193 double x2 = 0.8; | 193 double x2 = 0.8; |
| 194 double y2 = 0.7; | 194 double y2 = 0.7; |
| 195 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(0, 0), x1, y1, x2, y2)
; | 195 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(0, 0), x1, y1, x2, y2)
; |
| 196 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 1)); | 196 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 1)); |
| 197 | 197 |
| 198 std::unique_ptr<cc::TimingFunction> timingFunction( | 198 std::unique_ptr<cc::TimingFunction> timingFunction( |
| 199 cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2)); | 199 cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2)); |
| 200 for (int i = 0; i <= 4; ++i) { | 200 for (int i = 0; i <= 4; ++i) { |
| 201 const double time = i * 0.25; | 201 const double time = i * 0.25; |
| 202 EXPECT_FLOAT_EQ(timingFunction->GetValue(time), curve->getValue(time)); | 202 EXPECT_FLOAT_EQ(timingFunction->GetValue(time), curve->getValue(time)); |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 | 205 |
| 206 // Tests that the default timing function is indeed ease. | 206 // Tests that the default timing function is indeed ease. |
| 207 TEST(WebFloatAnimationCurveTest, DefaultTimingFunction) | 207 TEST(WebFloatAnimationCurveTest, DefaultTimingFunction) |
| 208 { | 208 { |
| 209 std::unique_ptr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimat
ionCurve::create(); | 209 OwnPtr<CompositorFloatAnimationCurve> curve = CompositorFloatAnimationCurve:
:create(); |
| 210 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(0, 0), CubicBezierTimi
ngFunction::EaseType::EASE); | 210 curve->addCubicBezierKeyframe(CompositorFloatKeyframe(0, 0), CubicBezierTimi
ngFunction::EaseType::EASE); |
| 211 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 1)); | 211 curve->addLinearKeyframe(CompositorFloatKeyframe(1, 1)); |
| 212 | 212 |
| 213 std::unique_ptr<cc::TimingFunction> timingFunction( | 213 std::unique_ptr<cc::TimingFunction> timingFunction( |
| 214 cc::CubicBezierTimingFunction::CreatePreset(CubicBezierTimingFunction::E
aseType::EASE)); | 214 cc::CubicBezierTimingFunction::CreatePreset(CubicBezierTimingFunction::E
aseType::EASE)); |
| 215 for (int i = 0; i <= 4; ++i) { | 215 for (int i = 0; i <= 4; ++i) { |
| 216 const double time = i * 0.25; | 216 const double time = i * 0.25; |
| 217 EXPECT_FLOAT_EQ(timingFunction->GetValue(time), curve->getValue(time)); | 217 EXPECT_FLOAT_EQ(timingFunction->GetValue(time), curve->getValue(time)); |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 | 220 |
| 221 } // namespace blink | 221 } // namespace blink |
| OLD | NEW |