Rename rendering/RenderFileUploadControl to layout/LayoutFileUploadControl.
[chromium-blink-merge.git] / third_party / WebKit / Source / core / animation / LengthPairStyleInterpolationTest.cpp
blobb7856aff8b3d5ad34e79464ba641497b34278844
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.
5 #include "config.h"
6 #include "core/animation/LengthPairStyleInterpolation.h"
8 #include "core/css/CSSPrimitiveValue.h"
9 #include "core/css/CSSValue.h"
10 #include "core/css/Pair.h"
11 #include "core/css/StylePropertySet.h"
13 #include <gtest/gtest.h>
15 namespace blink {
17 class LengthPairStyleInterpolationTest : public ::testing::Test {
19 protected:
20 static PassOwnPtrWillBeRawPtr<InterpolableValue> lengthPairToInterpolableValue(const CSSValue& value)
22 return LengthPairStyleInterpolation::lengthPairToInterpolableValue(value);
25 static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToLengthPair(InterpolableValue* value, InterpolationRange range)
27 return LengthPairStyleInterpolation::interpolableValueToLengthPair(value, range);
30 static PassRefPtrWillBeRawPtr<CSSValue> roundTrip(PassRefPtrWillBeRawPtr<CSSValue> value, InterpolationRange range)
32 return interpolableValueToLengthPair(lengthPairToInterpolableValue(*value).get(), range);
35 static void testPrimitiveValue(RefPtrWillBeRawPtr<CSSValue> value, double first, double second, CSSPrimitiveValue::UnitType unitType)
37 EXPECT_TRUE(value->isPrimitiveValue());
39 Pair* pair = toCSSPrimitiveValue(value.get())->getPairValue();
40 ASSERT_TRUE(pair);
42 EXPECT_EQ(pair->first()->getDoubleValue(), first);
43 EXPECT_EQ(pair->second()->getDoubleValue(), second);
45 EXPECT_EQ(pair->first()->primitiveType(), unitType);
46 EXPECT_EQ(pair->second()->primitiveType(), unitType);
50 TEST_F(LengthPairStyleInterpolationTest, ZeroTest)
52 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstPx = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX);
53 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondPx = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX);
54 RefPtrWillBeRawPtr<Pair> pairPx = Pair::create(firstPx, secondPx, Pair::KeepIdenticalValues);
55 RefPtrWillBeRawPtr<CSSValue> value1 = roundTrip(CSSPrimitiveValue::create(pairPx.release()), RangeNonNegative);
56 testPrimitiveValue(value1, 0, 0, CSSPrimitiveValue::CSS_PX);
58 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstPc = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PERCENTAGE);
59 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondPc = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PERCENTAGE);
60 RefPtrWillBeRawPtr<Pair> pairPc = Pair::create(firstPc, secondPc, Pair::KeepIdenticalValues);
61 RefPtrWillBeRawPtr<CSSValue> value2 = roundTrip(CSSPrimitiveValue::create(pairPc.release()), RangeNonNegative);
62 testPrimitiveValue(value2, 0, 0, CSSPrimitiveValue::CSS_PERCENTAGE);
64 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstEms = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_EMS);
65 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondEms = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_EMS);
66 RefPtrWillBeRawPtr<Pair> pairEms = Pair::create(firstEms, secondEms, Pair::KeepIdenticalValues);
67 RefPtrWillBeRawPtr<CSSValue> value3 = roundTrip(CSSPrimitiveValue::create(pairEms.release()), RangeNonNegative);
68 testPrimitiveValue(value3, 0, 0, CSSPrimitiveValue::CSS_EMS);
70 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstPcNeg = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PERCENTAGE);
71 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondPcNeg = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PERCENTAGE);
72 RefPtrWillBeRawPtr<Pair> pairPcNeg = Pair::create(firstPcNeg, secondPcNeg, Pair::KeepIdenticalValues);
73 RefPtrWillBeRawPtr<CSSValue> value4 = roundTrip(CSSPrimitiveValue::create(pairPcNeg.release()), RangeAll);
74 testPrimitiveValue(value4, 0, 0, CSSPrimitiveValue::CSS_PERCENTAGE);
77 TEST_F(LengthPairStyleInterpolationTest, MultipleValueTest)
79 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstPx = CSSPrimitiveValue::create(10, CSSPrimitiveValue::CSS_PX);
80 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondPx = CSSPrimitiveValue::create(20, CSSPrimitiveValue::CSS_PX);
81 RefPtrWillBeRawPtr<Pair> pairPx = Pair::create(firstPx, secondPx, Pair::KeepIdenticalValues);
82 RefPtrWillBeRawPtr<CSSValue> value5 = roundTrip(CSSPrimitiveValue::create(pairPx.release()), RangeNonNegative);
83 testPrimitiveValue(value5, 10, 20, CSSPrimitiveValue::CSS_PX);
85 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstPc = CSSPrimitiveValue::create(30, CSSPrimitiveValue::CSS_PERCENTAGE);
86 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondPc = CSSPrimitiveValue::create(-30, CSSPrimitiveValue::CSS_PERCENTAGE);
87 RefPtrWillBeRawPtr<Pair> pairPc = Pair::create(firstPc, secondPc, Pair::KeepIdenticalValues);
88 RefPtrWillBeRawPtr<CSSValue> value6 = roundTrip(CSSPrimitiveValue::create(pairPc.release()), RangeNonNegative);
89 testPrimitiveValue(value6, 30, 0, CSSPrimitiveValue::CSS_PERCENTAGE);