| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/animation/animatable/AnimatableDoubleAndBool.h" | 6 #include "core/animation/animatable/AnimatableDoubleAndBool.h" |
| 7 | 7 |
| 8 #include <gtest/gtest.h> | 8 #include <gtest/gtest.h> |
| 9 | 9 |
| 10 using namespace blink; | 10 using namespace blink; |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 TEST(AnimationAnimatableDoubleAndBoolTest, Create) | 14 TEST(AnimationAnimatableDoubleAndBoolTest, Create) |
| 15 { | 15 { |
| 16 EXPECT_TRUE(static_cast<bool>(AnimatableDoubleAndBool::create(30, false).get
())); | 16 EXPECT_TRUE(static_cast<bool>(AnimatableDoubleAndBool::create(30, false))); |
| 17 EXPECT_TRUE(static_cast<bool>(AnimatableDoubleAndBool::create(270, true).get
())); | 17 EXPECT_TRUE(static_cast<bool>(AnimatableDoubleAndBool::create(270, true))); |
| 18 } | 18 } |
| 19 | 19 |
| 20 TEST(AnimationAnimatableDoubleAndBoolTest, Equal) | 20 TEST(AnimationAnimatableDoubleAndBoolTest, Equal) |
| 21 { | 21 { |
| 22 EXPECT_TRUE(AnimatableDoubleAndBool::create(30, false)->equals(AnimatableDou
bleAndBool::create(30, false).get())); | 22 EXPECT_TRUE(AnimatableDoubleAndBool::create(30, false)->equals(AnimatableDou
bleAndBool::create(30, false))); |
| 23 EXPECT_TRUE(AnimatableDoubleAndBool::create(270, true)->equals(AnimatableDou
bleAndBool::create(270, true).get())); | 23 EXPECT_TRUE(AnimatableDoubleAndBool::create(270, true)->equals(AnimatableDou
bleAndBool::create(270, true))); |
| 24 EXPECT_FALSE(AnimatableDoubleAndBool::create(30, false)->equals(AnimatableDo
ubleAndBool::create(270, true).get())); | 24 EXPECT_FALSE(AnimatableDoubleAndBool::create(30, false)->equals(AnimatableDo
ubleAndBool::create(270, true))); |
| 25 EXPECT_FALSE(AnimatableDoubleAndBool::create(30, false)->equals(AnimatableDo
ubleAndBool::create(270, false).get())); | 25 EXPECT_FALSE(AnimatableDoubleAndBool::create(30, false)->equals(AnimatableDo
ubleAndBool::create(270, false))); |
| 26 EXPECT_FALSE(AnimatableDoubleAndBool::create(30, false)->equals(AnimatableDo
ubleAndBool::create(30, true).get())); | 26 EXPECT_FALSE(AnimatableDoubleAndBool::create(30, false)->equals(AnimatableDo
ubleAndBool::create(30, true))); |
| 27 } | 27 } |
| 28 | 28 |
| 29 TEST(AnimationAnimatableDoubleAndBoolTest, ToDouble) | 29 TEST(AnimationAnimatableDoubleAndBoolTest, ToDouble) |
| 30 { | 30 { |
| 31 EXPECT_EQ(5.9, AnimatableDoubleAndBool::create(5.9, false)->toDouble()); | 31 EXPECT_EQ(5.9, AnimatableDoubleAndBool::create(5.9, false)->toDouble()); |
| 32 EXPECT_EQ(-10, AnimatableDoubleAndBool::create(-10, true)->toDouble()); | 32 EXPECT_EQ(-10, AnimatableDoubleAndBool::create(-10, true)->toDouble()); |
| 33 } | 33 } |
| 34 | 34 |
| 35 TEST(AnimationAnimatableDoubleAndBoolTest, Flag) | 35 TEST(AnimationAnimatableDoubleAndBoolTest, Flag) |
| 36 { | 36 { |
| 37 EXPECT_FALSE(AnimatableDoubleAndBool::create(5.9, false)->flag()); | 37 EXPECT_FALSE(AnimatableDoubleAndBool::create(5.9, false)->flag()); |
| 38 EXPECT_TRUE(AnimatableDoubleAndBool::create(-10, true)->flag()); | 38 EXPECT_TRUE(AnimatableDoubleAndBool::create(-10, true)->flag()); |
| 39 } | 39 } |
| 40 | 40 |
| 41 TEST(AnimationAnimatableDoubleAndBoolTest, InterpolateFalse) | 41 TEST(AnimationAnimatableDoubleAndBoolTest, InterpolateFalse) |
| 42 { | 42 { |
| 43 RefPtrWillBeRawPtr<AnimatableDoubleAndBool> from10 = AnimatableDoubleAndBool
::create(10, false); | 43 AnimatableDoubleAndBool* from10 = AnimatableDoubleAndBool::create(10, false)
; |
| 44 RefPtrWillBeRawPtr<AnimatableDoubleAndBool> to20 = AnimatableDoubleAndBool::
create(20, false); | 44 AnimatableDoubleAndBool* to20 = AnimatableDoubleAndBool::create(20, false); |
| 45 EXPECT_FALSE(toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.g
et(), to20.get(), -0.5).get())->flag()); | 45 EXPECT_FALSE(toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, -0.5))->flag()); |
| 46 EXPECT_EQ(5, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.g
et(), to20.get(), -0.5).get())->toDouble()); | 46 EXPECT_EQ(5, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, -0.5))->toDouble()); |
| 47 EXPECT_EQ(10, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.
get(), to20.get(), 0).get())->toDouble()); | 47 EXPECT_EQ(10, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, 0))->toDouble()); |
| 48 EXPECT_EQ(14, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.
get(), to20.get(), 0.4).get())->toDouble()); | 48 EXPECT_EQ(14, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, 0.4))->toDouble()); |
| 49 EXPECT_EQ(15, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.
get(), to20.get(), 0.5).get())->toDouble()); | 49 EXPECT_EQ(15, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, 0.5))->toDouble()); |
| 50 EXPECT_EQ(16, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.
get(), to20.get(), 0.6).get())->toDouble()); | 50 EXPECT_EQ(16, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, 0.6))->toDouble()); |
| 51 EXPECT_EQ(20, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.
get(), to20.get(), 1).get())->toDouble()); | 51 EXPECT_EQ(20, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, 1))->toDouble()); |
| 52 EXPECT_EQ(25, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.
get(), to20.get(), 1.5).get())->toDouble()); | 52 EXPECT_EQ(25, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, 1.5))->toDouble()); |
| 53 EXPECT_FALSE(toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.g
et(), to20.get(), 1.5).get())->flag()); | 53 EXPECT_FALSE(toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, 1.5))->flag()); |
| 54 } | 54 } |
| 55 | 55 |
| 56 TEST(AnimationAnimatableDoubleAndBoolTest, InterpolateTrue) | 56 TEST(AnimationAnimatableDoubleAndBoolTest, InterpolateTrue) |
| 57 { | 57 { |
| 58 RefPtrWillBeRawPtr<AnimatableDoubleAndBool> from10 = AnimatableDoubleAndBool
::create(10, true); | 58 AnimatableDoubleAndBool* from10 = AnimatableDoubleAndBool::create(10, true); |
| 59 RefPtrWillBeRawPtr<AnimatableDoubleAndBool> to20 = AnimatableDoubleAndBool::
create(20, true); | 59 AnimatableDoubleAndBool* to20 = AnimatableDoubleAndBool::create(20, true); |
| 60 EXPECT_TRUE(toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.ge
t(), to20.get(), -0.5).get())->flag()); | 60 EXPECT_TRUE(toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10, t
o20, -0.5))->flag()); |
| 61 EXPECT_EQ(5, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.g
et(), to20.get(), -0.5).get())->toDouble()); | 61 EXPECT_EQ(5, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, -0.5))->toDouble()); |
| 62 EXPECT_EQ(10, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.
get(), to20.get(), 0).get())->toDouble()); | 62 EXPECT_EQ(10, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, 0))->toDouble()); |
| 63 EXPECT_EQ(14, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.
get(), to20.get(), 0.4).get())->toDouble()); | 63 EXPECT_EQ(14, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, 0.4))->toDouble()); |
| 64 EXPECT_EQ(15, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.
get(), to20.get(), 0.5).get())->toDouble()); | 64 EXPECT_EQ(15, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, 0.5))->toDouble()); |
| 65 EXPECT_EQ(16, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.
get(), to20.get(), 0.6).get())->toDouble()); | 65 EXPECT_EQ(16, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, 0.6))->toDouble()); |
| 66 EXPECT_EQ(20, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.
get(), to20.get(), 1).get())->toDouble()); | 66 EXPECT_EQ(20, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, 1))->toDouble()); |
| 67 EXPECT_EQ(25, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.
get(), to20.get(), 1.5).get())->toDouble()); | 67 EXPECT_EQ(25, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, 1.5))->toDouble()); |
| 68 EXPECT_TRUE(toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.ge
t(), to20.get(), 1.5).get())->flag()); | 68 EXPECT_TRUE(toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10, t
o20, 1.5))->flag()); |
| 69 } | 69 } |
| 70 | 70 |
| 71 TEST(AnimationAnimatableDoubleAndBoolTest, Step) | 71 TEST(AnimationAnimatableDoubleAndBoolTest, Step) |
| 72 { | 72 { |
| 73 RefPtrWillBeRawPtr<AnimatableDoubleAndBool> from10 = AnimatableDoubleAndBool
::create(10, true); | 73 AnimatableDoubleAndBool* from10 = AnimatableDoubleAndBool::create(10, true); |
| 74 RefPtrWillBeRawPtr<AnimatableDoubleAndBool> to20 = AnimatableDoubleAndBool::
create(20, false); | 74 AnimatableDoubleAndBool* to20 = AnimatableDoubleAndBool::create(20, false); |
| 75 EXPECT_TRUE(toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.ge
t(), to20.get(), -0.5).get())->flag()); | 75 EXPECT_TRUE(toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10, t
o20, -0.5))->flag()); |
| 76 EXPECT_EQ(10, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.
get(), to20.get(), -0.5).get())->toDouble()); | 76 EXPECT_EQ(10, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, -0.5))->toDouble()); |
| 77 EXPECT_EQ(10, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.
get(), to20.get(), 0).get())->toDouble()); | 77 EXPECT_EQ(10, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, 0))->toDouble()); |
| 78 EXPECT_EQ(10, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.
get(), to20.get(), 0.4).get())->toDouble()); | 78 EXPECT_EQ(10, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, 0.4))->toDouble()); |
| 79 EXPECT_TRUE(toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.ge
t(), to20.get(), 0.4).get())->flag()); | 79 EXPECT_TRUE(toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10, t
o20, 0.4))->flag()); |
| 80 | 80 |
| 81 EXPECT_FALSE(toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.g
et(), to20.get(), 0.6).get())->flag()); | 81 EXPECT_FALSE(toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, 0.6))->flag()); |
| 82 EXPECT_EQ(20, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.
get(), to20.get(), 0.6).get())->toDouble()); | 82 EXPECT_EQ(20, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, 0.6))->toDouble()); |
| 83 EXPECT_EQ(20, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.
get(), to20.get(), 1).get())->toDouble()); | 83 EXPECT_EQ(20, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, 1))->toDouble()); |
| 84 EXPECT_EQ(20, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.
get(), to20.get(), 1.5).get())->toDouble()); | 84 EXPECT_EQ(20, toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, 1.5))->toDouble()); |
| 85 EXPECT_FALSE(toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10.g
et(), to20.get(), 1.5).get())->flag()); | 85 EXPECT_FALSE(toAnimatableDoubleAndBool(AnimatableValue::interpolate(from10,
to20, 1.5))->flag()); |
| 86 } | 86 } |
| 87 | 87 |
| 88 } | 88 } |
| OLD | NEW |