Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 |
|
ajuma
2014/02/21 19:05:08
Note that this file has been deleted since you pos
| |
| 5 #include "cc/animation/timing_function.h" | 5 #include "cc/animation/timing_function.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 namespace cc { | 9 namespace cc { |
| 10 namespace { | 10 namespace { |
| 11 | 11 |
| 12 TEST(TimingFunctionTest, CubicBezierTimingFunction) { | 12 TEST(TimingFunctionTest, CubicBezierTimingFunction) { |
| 13 scoped_ptr<CubicBezierTimingFunction> function = | 13 scoped_ptr<CubicBezierTimingFunction> function = |
| 14 CubicBezierTimingFunction::Create(0.25, 0.0, 0.75, 1.0); | 14 CubicBezierTimingFunction::Create(0.25, 0.0, 0.75, 1.0); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 EXPECT_EQ(0.f, min); | 130 EXPECT_EQ(0.f, min); |
| 131 EXPECT_EQ(1.f, max); | 131 EXPECT_EQ(1.f, max); |
| 132 | 132 |
| 133 // Derivative has two roots > 1. | 133 // Derivative has two roots > 1. |
| 134 function = CubicBezierTimingFunction::Create(0.25, 0.367, 0.75, 0.7); | 134 function = CubicBezierTimingFunction::Create(0.25, 0.367, 0.75, 0.7); |
| 135 function->Range(&min, &max); | 135 function->Range(&min, &max); |
| 136 EXPECT_EQ(0.f, min); | 136 EXPECT_EQ(0.f, min); |
| 137 EXPECT_EQ(1.f, max); | 137 EXPECT_EQ(1.f, max); |
| 138 } | 138 } |
| 139 | 139 |
| 140 TEST(TimingFunctionTest, StepsTimingFunction) { | |
| 141 scoped_ptr<StepsTimingFunction> function = | |
| 142 StepsTimingFunction::Create(36, false); | |
| 143 | |
| 144 double epsilon = 0.00015; | |
| 145 | |
| 146 EXPECT_NEAR(function->GetValue(0), 0, epsilon); | |
|
ajuma
2014/02/21 19:05:08
We might be able to just use EXPECT_FLOAT_EQ here,
| |
| 147 EXPECT_NEAR(function->GetValue(0.05), 1.f/36.f, epsilon); | |
| 148 EXPECT_NEAR(function->GetValue(0.1), 3.f/36.f, epsilon); | |
| 149 EXPECT_NEAR(function->GetValue(0.15), 5.f/36.f, epsilon); | |
| 150 EXPECT_NEAR(function->GetValue(0.2), 7.f/36.f, epsilon); | |
| 151 EXPECT_NEAR(function->GetValue(0.25), 9.f/36.f, epsilon); | |
| 152 EXPECT_NEAR(function->GetValue(0.3), 10.f/36.f, epsilon); | |
| 153 EXPECT_NEAR(function->GetValue(0.35), 12.f/36.f, epsilon); | |
| 154 EXPECT_NEAR(function->GetValue(0.4), 14.f/36.f, epsilon); | |
| 155 EXPECT_NEAR(function->GetValue(0.45), 16.f/36.f, epsilon); | |
| 156 EXPECT_NEAR(function->GetValue(0.5), 18.f/36.f, epsilon); | |
| 157 EXPECT_NEAR(function->GetValue(0.6), 21.f/36.f, epsilon); | |
| 158 EXPECT_NEAR(function->GetValue(0.65), 23.f/36.f, epsilon); | |
| 159 EXPECT_NEAR(function->GetValue(0.7), 25.f/36.f, epsilon); | |
| 160 EXPECT_NEAR(function->GetValue(0.75), 27.f/36.f, epsilon); | |
| 161 EXPECT_NEAR(function->GetValue(0.8), 28.f/36.f, epsilon); | |
| 162 EXPECT_NEAR(function->GetValue(0.85), 30.f/36.f, epsilon); | |
| 163 EXPECT_NEAR(function->GetValue(0.9), 32.f/36.f, epsilon); | |
| 164 EXPECT_NEAR(function->GetValue(0.95), 34.f/36.f, epsilon); | |
| 165 EXPECT_NEAR(function->GetValue(1), 1, epsilon); | |
| 166 } | |
| 167 | |
| 168 TEST(TimingFunctionTest, StepsTimingFunctionStepsAtStart) { | |
| 169 return; | |
| 170 scoped_ptr<StepsTimingFunction> function = | |
| 171 StepsTimingFunction::Create(36, true); | |
| 172 | |
| 173 double epsilon = 0.00015; | |
| 174 | |
| 175 EXPECT_NEAR(function->GetValue(0), 1.f/36.f, epsilon); | |
| 176 EXPECT_NEAR(function->GetValue(0.05), 2.f/36.f, epsilon); | |
| 177 EXPECT_NEAR(function->GetValue(0.1), 4.f/36.f, epsilon); | |
| 178 EXPECT_NEAR(function->GetValue(0.15), 6.f/36.f, epsilon); | |
| 179 EXPECT_NEAR(function->GetValue(0.2), 8.f/36.f, epsilon); | |
| 180 EXPECT_NEAR(function->GetValue(0.25), 10.f/36.f, epsilon); | |
| 181 EXPECT_NEAR(function->GetValue(0.3), 11.f/36.f, epsilon); | |
| 182 EXPECT_NEAR(function->GetValue(0.35), 13.f/36.f, epsilon); | |
| 183 EXPECT_NEAR(function->GetValue(0.4), 15.f/36.f, epsilon); | |
| 184 EXPECT_NEAR(function->GetValue(0.45), 17.f/36.f, epsilon); | |
| 185 EXPECT_NEAR(function->GetValue(0.5), 19.f/36.f, epsilon); | |
| 186 EXPECT_NEAR(function->GetValue(0.6), 22.f/36.f, epsilon); | |
| 187 EXPECT_NEAR(function->GetValue(0.65), 24.f/36.f, epsilon); | |
| 188 EXPECT_NEAR(function->GetValue(0.7), 26.f/36.f, epsilon); | |
| 189 EXPECT_NEAR(function->GetValue(0.75), 28.f/36.f, epsilon); | |
| 190 EXPECT_NEAR(function->GetValue(0.8), 29.f/36.f, epsilon); | |
| 191 EXPECT_NEAR(function->GetValue(0.85), 31.f/36.f, epsilon); | |
| 192 EXPECT_NEAR(function->GetValue(0.9), 33.f/36.f, epsilon); | |
| 193 EXPECT_NEAR(function->GetValue(0.95), 35.f/36.f, epsilon); | |
| 194 EXPECT_NEAR(function->GetValue(1), 1, epsilon); | |
| 195 } | |
| 196 | |
| 197 TEST(TimingFunctionTest, StepsTimingFunctionRange) { | |
| 198 double epsilon = 0.00015; | |
| 199 float min, max; | |
| 200 | |
| 201 scoped_ptr<StepsTimingFunction> function = | |
| 202 StepsTimingFunction::Create(36, false); | |
| 203 | |
| 204 function->Range(&min, &max); | |
| 205 EXPECT_EQ(0.f, min); | |
| 206 EXPECT_EQ(1.f, max); | |
| 207 | |
| 208 function = StepsTimingFunction::Create(36, true); | |
| 209 function->Range(&min, &max); | |
| 210 EXPECT_NEAR(min, 1.f/36.f, epsilon); | |
| 211 EXPECT_EQ(1.f, max); | |
| 212 } | |
| 213 | |
| 140 } // namespace | 214 } // namespace |
| 141 } // namespace cc | 215 } // namespace cc |
| OLD | NEW |