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

Unified Diff: cc/animation/scroll_offset_animation_curve_unittest.cc

Issue 693883004: Make cc::animation::TrimTimeToCurrentIteration,cc::AnimationCurve::Duration use TimeTicks/TimeDelta (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/animation/scroll_offset_animation_curve.cc ('k') | cc/base/time_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/animation/scroll_offset_animation_curve_unittest.cc
diff --git a/cc/animation/scroll_offset_animation_curve_unittest.cc b/cc/animation/scroll_offset_animation_curve_unittest.cc
index d89784a04de9b98ad818481690146a17da9c8616..d57814e794e9470a22b557007a9af4f6885900d3 100644
--- a/cc/animation/scroll_offset_animation_curve_unittest.cc
+++ b/cc/animation/scroll_offset_animation_curve_unittest.cc
@@ -19,39 +19,39 @@ TEST(ScrollOffsetAnimationCurveTest, Duration) {
EaseInOutTimingFunction::Create().Pass()));
curve->SetInitialValue(target_value);
- EXPECT_DOUBLE_EQ(0.0, curve->Duration());
+ EXPECT_DOUBLE_EQ(0.0, curve->Duration().InSecondsF());
// x decreases, y stays the same.
curve->SetInitialValue(gfx::ScrollOffset(136.f, 200.f));
- EXPECT_DOUBLE_EQ(0.1, curve->Duration());
+ EXPECT_DOUBLE_EQ(0.1, curve->Duration().InSecondsF());
// x increases, y stays the same.
curve->SetInitialValue(gfx::ScrollOffset(19.f, 200.f));
- EXPECT_DOUBLE_EQ(0.15, curve->Duration());
+ EXPECT_DOUBLE_EQ(0.15, curve->Duration().InSecondsF());
// x stays the same, y decreases.
curve->SetInitialValue(gfx::ScrollOffset(100.f, 344.f));
- EXPECT_DOUBLE_EQ(0.2, curve->Duration());
+ EXPECT_DOUBLE_EQ(0.2, curve->Duration().InSecondsF());
// x stays the same, y increases.
curve->SetInitialValue(gfx::ScrollOffset(100.f, 191.f));
- EXPECT_DOUBLE_EQ(0.05, curve->Duration());
+ EXPECT_DOUBLE_EQ(0.05, curve->Duration().InSecondsF());
// x decreases, y decreases.
curve->SetInitialValue(gfx::ScrollOffset(32500.f, 500.f));
- EXPECT_DOUBLE_EQ(3.0, curve->Duration());
+ EXPECT_DOUBLE_EQ(3.0, curve->Duration().InSecondsF());
// x decreases, y increases.
curve->SetInitialValue(gfx::ScrollOffset(150.f, 119.f));
- EXPECT_DOUBLE_EQ(0.15, curve->Duration());
+ EXPECT_DOUBLE_EQ(0.15, curve->Duration().InSecondsF());
// x increases, y decreases.
curve->SetInitialValue(gfx::ScrollOffset(0.f, 14600.f));
- EXPECT_DOUBLE_EQ(2.0, curve->Duration());
+ EXPECT_DOUBLE_EQ(2.0, curve->Duration().InSecondsF());
// x increases, y increases.
curve->SetInitialValue(gfx::ScrollOffset(95.f, 191.f));
- EXPECT_DOUBLE_EQ(0.05, curve->Duration());
+ EXPECT_DOUBLE_EQ(0.05, curve->Duration().InSecondsF());
}
TEST(ScrollOffsetAnimationCurveTest, GetValue) {
@@ -63,22 +63,22 @@ TEST(ScrollOffsetAnimationCurveTest, GetValue) {
EaseInOutTimingFunction::Create().Pass()));
curve->SetInitialValue(initial_value);
- double duration = curve->Duration();
- EXPECT_GT(curve->Duration(), 0);
- EXPECT_LT(curve->Duration(), 0.1);
+ double duration_in_seconds = curve->Duration().InSecondsF();
+ EXPECT_GT(curve->Duration().InSecondsF(), 0);
+ EXPECT_LT(curve->Duration().InSecondsF(), 0.1);
EXPECT_EQ(AnimationCurve::ScrollOffset, curve->Type());
- EXPECT_EQ(duration, curve->Duration());
+ EXPECT_EQ(duration_in_seconds, curve->Duration().InSecondsF());
EXPECT_VECTOR2DF_EQ(initial_value, curve->GetValue(-1.0));
EXPECT_VECTOR2DF_EQ(initial_value, curve->GetValue(0.0));
EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(6.f, 30.f),
- curve->GetValue(duration/2.0));
- EXPECT_VECTOR2DF_EQ(target_value, curve->GetValue(duration));
- EXPECT_VECTOR2DF_EQ(target_value, curve->GetValue(duration+1.0));
+ curve->GetValue(duration_in_seconds / 2.0));
+ EXPECT_VECTOR2DF_EQ(target_value, curve->GetValue(duration_in_seconds));
+ EXPECT_VECTOR2DF_EQ(target_value, curve->GetValue(duration_in_seconds + 1.0));
// Verify that GetValue takes the timing function into account.
- gfx::ScrollOffset value = curve->GetValue(duration/4.0);
+ gfx::ScrollOffset value = curve->GetValue(duration_in_seconds / 4.0);
EXPECT_NEAR(3.0333f, value.x(), 0.00015f);
EXPECT_NEAR(37.4168f, value.y(), 0.00015f);
}
@@ -92,30 +92,30 @@ TEST(ScrollOffsetAnimationCurveTest, Clone) {
target_value,
EaseInOutTimingFunction::Create().Pass()));
curve->SetInitialValue(initial_value);
- double duration = curve->Duration();
+ double duration_in_seconds = curve->Duration().InSecondsF();
scoped_ptr<AnimationCurve> clone(curve->Clone().Pass());
EXPECT_EQ(AnimationCurve::ScrollOffset, clone->Type());
- EXPECT_EQ(duration, clone->Duration());
+ EXPECT_EQ(duration_in_seconds, clone->Duration().InSecondsF());
EXPECT_VECTOR2DF_EQ(initial_value,
clone->ToScrollOffsetAnimationCurve()->GetValue(-1.0));
EXPECT_VECTOR2DF_EQ(initial_value,
clone->ToScrollOffsetAnimationCurve()->GetValue(0.0));
- EXPECT_VECTOR2DF_EQ(
- gfx::ScrollOffset(6.f, 30.f),
- clone->ToScrollOffsetAnimationCurve()->GetValue(duration / 2.0));
- EXPECT_VECTOR2DF_EQ(
- target_value,
- clone->ToScrollOffsetAnimationCurve()->GetValue(duration));
+ EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(6.f, 30.f),
+ clone->ToScrollOffsetAnimationCurve()->GetValue(
+ duration_in_seconds / 2.0));
EXPECT_VECTOR2DF_EQ(
target_value,
- clone->ToScrollOffsetAnimationCurve()->GetValue(duration + 1.0));
+ clone->ToScrollOffsetAnimationCurve()->GetValue(duration_in_seconds));
+ EXPECT_VECTOR2DF_EQ(target_value,
+ clone->ToScrollOffsetAnimationCurve()->GetValue(
+ duration_in_seconds + 1.0));
// Verify that the timing function was cloned correctly.
- gfx::ScrollOffset value =
- clone->ToScrollOffsetAnimationCurve()->GetValue(duration / 4.0);
+ gfx::ScrollOffset value = clone->ToScrollOffsetAnimationCurve()->GetValue(
+ duration_in_seconds / 4.0);
EXPECT_NEAR(3.0333f, value.x(), 0.00015f);
EXPECT_NEAR(37.4168f, value.y(), 0.00015f);
}
@@ -127,20 +127,20 @@ TEST(ScrollOffsetAnimationCurveTest, UpdateTarget) {
ScrollOffsetAnimationCurve::Create(
target_value, EaseInOutTimingFunction::Create().Pass()));
curve->SetInitialValue(initial_value);
- EXPECT_EQ(1.0, curve->Duration());
+ EXPECT_EQ(1.0, curve->Duration().InSecondsF());
EXPECT_EQ(1800.0, curve->GetValue(0.5).y());
EXPECT_EQ(3600.0, curve->GetValue(1.0).y());
curve->UpdateTarget(0.5, gfx::ScrollOffset(0.0, 9900.0));
- EXPECT_EQ(2.0, curve->Duration());
+ EXPECT_EQ(2.0, curve->Duration().InSecondsF());
EXPECT_EQ(1800.0, curve->GetValue(0.5).y());
EXPECT_NEAR(5566.49, curve->GetValue(1.0).y(), 0.01);
EXPECT_EQ(9900.0, curve->GetValue(2.0).y());
curve->UpdateTarget(1.0, gfx::ScrollOffset(0.0, 7200.0));
- EXPECT_NEAR(1.674, curve->Duration(), 0.01);
+ EXPECT_NEAR(1.674, curve->Duration().InSecondsF(), 0.01);
EXPECT_NEAR(5566.49, curve->GetValue(1.0).y(), 0.01);
EXPECT_EQ(7200.0, curve->GetValue(1.674).y());
}
« no previous file with comments | « cc/animation/scroll_offset_animation_curve.cc ('k') | cc/base/time_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698