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

Unified Diff: cc/animation/scroll_offset_animation_curve_unittest.cc

Issue 584503005: Make scroll offset type of float in cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: link crbug to TODO Created 6 years, 3 months 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/math_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 1b8fdb5467c0ad4c4fc8a50f2d7c060f38fcaca9..d89784a04de9b98ad818481690146a17da9c8616 100644
--- a/cc/animation/scroll_offset_animation_curve_unittest.cc
+++ b/cc/animation/scroll_offset_animation_curve_unittest.cc
@@ -12,7 +12,7 @@ namespace cc {
namespace {
TEST(ScrollOffsetAnimationCurveTest, Duration) {
- gfx::Vector2dF target_value(100.f, 200.f);
+ gfx::ScrollOffset target_value(100.f, 200.f);
scoped_ptr<ScrollOffsetAnimationCurve> curve(
ScrollOffsetAnimationCurve::Create(
target_value,
@@ -22,41 +22,41 @@ TEST(ScrollOffsetAnimationCurveTest, Duration) {
EXPECT_DOUBLE_EQ(0.0, curve->Duration());
// x decreases, y stays the same.
- curve->SetInitialValue(gfx::Vector2dF(136.f, 200.f));
+ curve->SetInitialValue(gfx::ScrollOffset(136.f, 200.f));
EXPECT_DOUBLE_EQ(0.1, curve->Duration());
// x increases, y stays the same.
- curve->SetInitialValue(gfx::Vector2dF(19.f, 200.f));
+ curve->SetInitialValue(gfx::ScrollOffset(19.f, 200.f));
EXPECT_DOUBLE_EQ(0.15, curve->Duration());
// x stays the same, y decreases.
- curve->SetInitialValue(gfx::Vector2dF(100.f, 344.f));
+ curve->SetInitialValue(gfx::ScrollOffset(100.f, 344.f));
EXPECT_DOUBLE_EQ(0.2, curve->Duration());
// x stays the same, y increases.
- curve->SetInitialValue(gfx::Vector2dF(100.f, 191.f));
+ curve->SetInitialValue(gfx::ScrollOffset(100.f, 191.f));
EXPECT_DOUBLE_EQ(0.05, curve->Duration());
// x decreases, y decreases.
- curve->SetInitialValue(gfx::Vector2dF(32500.f, 500.f));
+ curve->SetInitialValue(gfx::ScrollOffset(32500.f, 500.f));
EXPECT_DOUBLE_EQ(3.0, curve->Duration());
// x decreases, y increases.
- curve->SetInitialValue(gfx::Vector2dF(150.f, 119.f));
+ curve->SetInitialValue(gfx::ScrollOffset(150.f, 119.f));
EXPECT_DOUBLE_EQ(0.15, curve->Duration());
// x increases, y decreases.
- curve->SetInitialValue(gfx::Vector2dF(0.f, 14600.f));
+ curve->SetInitialValue(gfx::ScrollOffset(0.f, 14600.f));
EXPECT_DOUBLE_EQ(2.0, curve->Duration());
// x increases, y increases.
- curve->SetInitialValue(gfx::Vector2dF(95.f, 191.f));
+ curve->SetInitialValue(gfx::ScrollOffset(95.f, 191.f));
EXPECT_DOUBLE_EQ(0.05, curve->Duration());
}
TEST(ScrollOffsetAnimationCurveTest, GetValue) {
- gfx::Vector2dF initial_value(2.f, 40.f);
- gfx::Vector2dF target_value(10.f, 20.f);
+ gfx::ScrollOffset initial_value(2.f, 40.f);
+ gfx::ScrollOffset target_value(10.f, 20.f);
scoped_ptr<ScrollOffsetAnimationCurve> curve(
ScrollOffsetAnimationCurve::Create(
target_value,
@@ -72,20 +72,21 @@ TEST(ScrollOffsetAnimationCurveTest, GetValue) {
EXPECT_VECTOR2DF_EQ(initial_value, curve->GetValue(-1.0));
EXPECT_VECTOR2DF_EQ(initial_value, curve->GetValue(0.0));
- EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(6.f, 30.f), curve->GetValue(duration/2.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));
// Verify that GetValue takes the timing function into account.
- gfx::Vector2dF value = curve->GetValue(duration/4.0);
+ gfx::ScrollOffset value = curve->GetValue(duration/4.0);
EXPECT_NEAR(3.0333f, value.x(), 0.00015f);
EXPECT_NEAR(37.4168f, value.y(), 0.00015f);
}
// Verify that a clone behaves exactly like the original.
TEST(ScrollOffsetAnimationCurveTest, Clone) {
- gfx::Vector2dF initial_value(2.f, 40.f);
- gfx::Vector2dF target_value(10.f, 20.f);
+ gfx::ScrollOffset initial_value(2.f, 40.f);
+ gfx::ScrollOffset target_value(10.f, 20.f);
scoped_ptr<ScrollOffsetAnimationCurve> curve(
ScrollOffsetAnimationCurve::Create(
target_value,
@@ -103,7 +104,7 @@ TEST(ScrollOffsetAnimationCurveTest, Clone) {
EXPECT_VECTOR2DF_EQ(initial_value,
clone->ToScrollOffsetAnimationCurve()->GetValue(0.0));
EXPECT_VECTOR2DF_EQ(
- gfx::Vector2dF(6.f, 30.f),
+ gfx::ScrollOffset(6.f, 30.f),
clone->ToScrollOffsetAnimationCurve()->GetValue(duration / 2.0));
EXPECT_VECTOR2DF_EQ(
target_value,
@@ -113,15 +114,15 @@ TEST(ScrollOffsetAnimationCurveTest, Clone) {
clone->ToScrollOffsetAnimationCurve()->GetValue(duration + 1.0));
// Verify that the timing function was cloned correctly.
- gfx::Vector2dF value =
+ gfx::ScrollOffset value =
clone->ToScrollOffsetAnimationCurve()->GetValue(duration / 4.0);
EXPECT_NEAR(3.0333f, value.x(), 0.00015f);
EXPECT_NEAR(37.4168f, value.y(), 0.00015f);
}
TEST(ScrollOffsetAnimationCurveTest, UpdateTarget) {
- gfx::Vector2dF initial_value(0.f, 0.f);
- gfx::Vector2dF target_value(0.f, 3600.f);
+ gfx::ScrollOffset initial_value(0.f, 0.f);
+ gfx::ScrollOffset target_value(0.f, 3600.f);
scoped_ptr<ScrollOffsetAnimationCurve> curve(
ScrollOffsetAnimationCurve::Create(
target_value, EaseInOutTimingFunction::Create().Pass()));
@@ -130,14 +131,14 @@ TEST(ScrollOffsetAnimationCurveTest, UpdateTarget) {
EXPECT_EQ(1800.0, curve->GetValue(0.5).y());
EXPECT_EQ(3600.0, curve->GetValue(1.0).y());
- curve->UpdateTarget(0.5, gfx::Vector2dF(0.0, 9900.0));
+ curve->UpdateTarget(0.5, gfx::ScrollOffset(0.0, 9900.0));
EXPECT_EQ(2.0, curve->Duration());
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::Vector2dF(0.0, 7200.0));
+ curve->UpdateTarget(1.0, gfx::ScrollOffset(0.0, 7200.0));
EXPECT_NEAR(1.674, curve->Duration(), 0.01);
EXPECT_NEAR(5566.49, curve->GetValue(1.0).y(), 0.01);
« no previous file with comments | « cc/animation/scroll_offset_animation_curve.cc ('k') | cc/base/math_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698