| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "core/animation/animatable/AnimatableDoubleAndBool.h" | |
| 6 | |
| 7 #include "testing/gtest/include/gtest/gtest.h" | |
| 8 | |
| 9 namespace blink { | |
| 10 | |
| 11 TEST(AnimationAnimatableDoubleAndBoolTest, Create) { | |
| 12 EXPECT_TRUE( | |
| 13 static_cast<bool>(AnimatableDoubleAndBool::create(30, false).get())); | |
| 14 EXPECT_TRUE( | |
| 15 static_cast<bool>(AnimatableDoubleAndBool::create(270, true).get())); | |
| 16 } | |
| 17 | |
| 18 TEST(AnimationAnimatableDoubleAndBoolTest, Equal) { | |
| 19 EXPECT_TRUE(AnimatableDoubleAndBool::create(30, false)->equals( | |
| 20 AnimatableDoubleAndBool::create(30, false).get())); | |
| 21 EXPECT_TRUE(AnimatableDoubleAndBool::create(270, true)->equals( | |
| 22 AnimatableDoubleAndBool::create(270, true).get())); | |
| 23 EXPECT_FALSE(AnimatableDoubleAndBool::create(30, false)->equals( | |
| 24 AnimatableDoubleAndBool::create(270, true).get())); | |
| 25 EXPECT_FALSE(AnimatableDoubleAndBool::create(30, false)->equals( | |
| 26 AnimatableDoubleAndBool::create(270, false).get())); | |
| 27 EXPECT_FALSE(AnimatableDoubleAndBool::create(30, false)->equals( | |
| 28 AnimatableDoubleAndBool::create(30, true).get())); | |
| 29 } | |
| 30 | |
| 31 TEST(AnimationAnimatableDoubleAndBoolTest, ToDouble) { | |
| 32 EXPECT_EQ(5.9, AnimatableDoubleAndBool::create(5.9, false)->toDouble()); | |
| 33 EXPECT_EQ(-10, AnimatableDoubleAndBool::create(-10, true)->toDouble()); | |
| 34 } | |
| 35 | |
| 36 TEST(AnimationAnimatableDoubleAndBoolTest, Flag) { | |
| 37 EXPECT_FALSE(AnimatableDoubleAndBool::create(5.9, false)->flag()); | |
| 38 EXPECT_TRUE(AnimatableDoubleAndBool::create(-10, true)->flag()); | |
| 39 } | |
| 40 | |
| 41 TEST(AnimationAnimatableDoubleAndBoolTest, InterpolateFalse) { | |
| 42 RefPtr<AnimatableDoubleAndBool> from10 = | |
| 43 AnimatableDoubleAndBool::create(10, false); | |
| 44 RefPtr<AnimatableDoubleAndBool> to20 = | |
| 45 AnimatableDoubleAndBool::create(20, false); | |
| 46 EXPECT_FALSE( | |
| 47 toAnimatableDoubleAndBool( | |
| 48 AnimatableValue::interpolate(from10.get(), to20.get(), -0.5).get()) | |
| 49 ->flag()); | |
| 50 EXPECT_EQ( | |
| 51 5, toAnimatableDoubleAndBool( | |
| 52 AnimatableValue::interpolate(from10.get(), to20.get(), -0.5).get()) | |
| 53 ->toDouble()); | |
| 54 EXPECT_EQ(10, | |
| 55 toAnimatableDoubleAndBool( | |
| 56 AnimatableValue::interpolate(from10.get(), to20.get(), 0).get()) | |
| 57 ->toDouble()); | |
| 58 EXPECT_EQ( | |
| 59 14, toAnimatableDoubleAndBool( | |
| 60 AnimatableValue::interpolate(from10.get(), to20.get(), 0.4).get()) | |
| 61 ->toDouble()); | |
| 62 EXPECT_EQ( | |
| 63 15, toAnimatableDoubleAndBool( | |
| 64 AnimatableValue::interpolate(from10.get(), to20.get(), 0.5).get()) | |
| 65 ->toDouble()); | |
| 66 EXPECT_EQ( | |
| 67 16, toAnimatableDoubleAndBool( | |
| 68 AnimatableValue::interpolate(from10.get(), to20.get(), 0.6).get()) | |
| 69 ->toDouble()); | |
| 70 EXPECT_EQ(20, | |
| 71 toAnimatableDoubleAndBool( | |
| 72 AnimatableValue::interpolate(from10.get(), to20.get(), 1).get()) | |
| 73 ->toDouble()); | |
| 74 EXPECT_EQ( | |
| 75 25, toAnimatableDoubleAndBool( | |
| 76 AnimatableValue::interpolate(from10.get(), to20.get(), 1.5).get()) | |
| 77 ->toDouble()); | |
| 78 EXPECT_FALSE( | |
| 79 toAnimatableDoubleAndBool( | |
| 80 AnimatableValue::interpolate(from10.get(), to20.get(), 1.5).get()) | |
| 81 ->flag()); | |
| 82 } | |
| 83 | |
| 84 TEST(AnimationAnimatableDoubleAndBoolTest, InterpolateTrue) { | |
| 85 RefPtr<AnimatableDoubleAndBool> from10 = | |
| 86 AnimatableDoubleAndBool::create(10, true); | |
| 87 RefPtr<AnimatableDoubleAndBool> to20 = | |
| 88 AnimatableDoubleAndBool::create(20, true); | |
| 89 EXPECT_TRUE( | |
| 90 toAnimatableDoubleAndBool( | |
| 91 AnimatableValue::interpolate(from10.get(), to20.get(), -0.5).get()) | |
| 92 ->flag()); | |
| 93 EXPECT_EQ( | |
| 94 5, toAnimatableDoubleAndBool( | |
| 95 AnimatableValue::interpolate(from10.get(), to20.get(), -0.5).get()) | |
| 96 ->toDouble()); | |
| 97 EXPECT_EQ(10, | |
| 98 toAnimatableDoubleAndBool( | |
| 99 AnimatableValue::interpolate(from10.get(), to20.get(), 0).get()) | |
| 100 ->toDouble()); | |
| 101 EXPECT_EQ( | |
| 102 14, toAnimatableDoubleAndBool( | |
| 103 AnimatableValue::interpolate(from10.get(), to20.get(), 0.4).get()) | |
| 104 ->toDouble()); | |
| 105 EXPECT_EQ( | |
| 106 15, toAnimatableDoubleAndBool( | |
| 107 AnimatableValue::interpolate(from10.get(), to20.get(), 0.5).get()) | |
| 108 ->toDouble()); | |
| 109 EXPECT_EQ( | |
| 110 16, toAnimatableDoubleAndBool( | |
| 111 AnimatableValue::interpolate(from10.get(), to20.get(), 0.6).get()) | |
| 112 ->toDouble()); | |
| 113 EXPECT_EQ(20, | |
| 114 toAnimatableDoubleAndBool( | |
| 115 AnimatableValue::interpolate(from10.get(), to20.get(), 1).get()) | |
| 116 ->toDouble()); | |
| 117 EXPECT_EQ( | |
| 118 25, toAnimatableDoubleAndBool( | |
| 119 AnimatableValue::interpolate(from10.get(), to20.get(), 1.5).get()) | |
| 120 ->toDouble()); | |
| 121 EXPECT_TRUE( | |
| 122 toAnimatableDoubleAndBool( | |
| 123 AnimatableValue::interpolate(from10.get(), to20.get(), 1.5).get()) | |
| 124 ->flag()); | |
| 125 } | |
| 126 | |
| 127 TEST(AnimationAnimatableDoubleAndBoolTest, Step) { | |
| 128 RefPtr<AnimatableDoubleAndBool> from10 = | |
| 129 AnimatableDoubleAndBool::create(10, true); | |
| 130 RefPtr<AnimatableDoubleAndBool> to20 = | |
| 131 AnimatableDoubleAndBool::create(20, false); | |
| 132 EXPECT_TRUE( | |
| 133 toAnimatableDoubleAndBool( | |
| 134 AnimatableValue::interpolate(from10.get(), to20.get(), -0.5).get()) | |
| 135 ->flag()); | |
| 136 EXPECT_EQ( | |
| 137 10, | |
| 138 toAnimatableDoubleAndBool( | |
| 139 AnimatableValue::interpolate(from10.get(), to20.get(), -0.5).get()) | |
| 140 ->toDouble()); | |
| 141 EXPECT_EQ(10, | |
| 142 toAnimatableDoubleAndBool( | |
| 143 AnimatableValue::interpolate(from10.get(), to20.get(), 0).get()) | |
| 144 ->toDouble()); | |
| 145 EXPECT_EQ( | |
| 146 10, toAnimatableDoubleAndBool( | |
| 147 AnimatableValue::interpolate(from10.get(), to20.get(), 0.4).get()) | |
| 148 ->toDouble()); | |
| 149 EXPECT_TRUE( | |
| 150 toAnimatableDoubleAndBool( | |
| 151 AnimatableValue::interpolate(from10.get(), to20.get(), 0.4).get()) | |
| 152 ->flag()); | |
| 153 | |
| 154 EXPECT_FALSE( | |
| 155 toAnimatableDoubleAndBool( | |
| 156 AnimatableValue::interpolate(from10.get(), to20.get(), 0.6).get()) | |
| 157 ->flag()); | |
| 158 EXPECT_EQ( | |
| 159 20, toAnimatableDoubleAndBool( | |
| 160 AnimatableValue::interpolate(from10.get(), to20.get(), 0.6).get()) | |
| 161 ->toDouble()); | |
| 162 EXPECT_EQ(20, | |
| 163 toAnimatableDoubleAndBool( | |
| 164 AnimatableValue::interpolate(from10.get(), to20.get(), 1).get()) | |
| 165 ->toDouble()); | |
| 166 EXPECT_EQ( | |
| 167 20, toAnimatableDoubleAndBool( | |
| 168 AnimatableValue::interpolate(from10.get(), to20.get(), 1.5).get()) | |
| 169 ->toDouble()); | |
| 170 EXPECT_FALSE( | |
| 171 toAnimatableDoubleAndBool( | |
| 172 AnimatableValue::interpolate(from10.get(), to20.get(), 1.5).get()) | |
| 173 ->flag()); | |
| 174 } | |
| 175 | |
| 176 } // namespace blink | |
| OLD | NEW |