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