| Index: Source/core/animation/FilterStyleInterpolationTest.cpp
|
| diff --git a/Source/core/animation/FilterStyleInterpolationTest.cpp b/Source/core/animation/FilterStyleInterpolationTest.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c547baeba282187fd48a48b3e1c09cefeadd3bf5
|
| --- /dev/null
|
| +++ b/Source/core/animation/FilterStyleInterpolationTest.cpp
|
| @@ -0,0 +1,55 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "config.h"
|
| +#include "core/animation/FilterStyleInterpolation.h"
|
| +
|
| +#include "core/css/CSSPrimitiveValue.h"
|
| +
|
| +#include <gtest/gtest.h>
|
| +
|
| +namespace blink {
|
| +
|
| +class AnimationFilterStyleInterpolationTest : public ::testing::Test {
|
| +protected:
|
| + static PassRefPtrWillBeRawPtr<CSSFunctionValue> roundTrip(PassRefPtrWillBeRawPtr<CSSValue> value)
|
| + {
|
| + CSSValueID functionType;
|
| + ASSERT(FilterStyleInterpolation::canCreateFrom(*value, *value));
|
| + OwnPtrWillBeRawPtr<InterpolableValue> interpolableValue = FilterStyleInterpolation::toInterpolableValue(*value, functionType);
|
| + return FilterStyleInterpolation::fromInterpolableValue(*interpolableValue, functionType);
|
| + }
|
| +
|
| + static void testPrimitiveValue(RefPtrWillBeRawPtr<CSSValue> value, CSSValueID functionType, double expected, CSSPrimitiveValue::UnitType unitType)
|
| + {
|
| + EXPECT_TRUE(value->isFunctionValue());
|
| + const CSSFunctionValue& filterValue = toCSSFunctionValue(*value);
|
| + EXPECT_EQ(functionType, filterValue.functionType());
|
| + EXPECT_EQ(1U, filterValue.length());
|
| + EXPECT_TRUE(filterValue.item(0)->isPrimitiveValue());
|
| + const CSSPrimitiveValue& element = toCSSPrimitiveValue(*filterValue.item(0));
|
| + EXPECT_EQ(expected, element.getDoubleValue());
|
| + EXPECT_EQ(unitType, element.primitiveType());
|
| + }
|
| +};
|
| +
|
| +TEST_F(AnimationFilterStyleInterpolationTest, ZeroTest)
|
| +{
|
| + RefPtrWillBeRawPtr<CSSFunctionValue> filter;
|
| +
|
| + filter = CSSFunctionValue::create(CSSValueBlur);
|
| + filter->append(CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX));
|
| + testPrimitiveValue(roundTrip(filter), CSSValueBlur, 0, CSSPrimitiveValue::CSS_PX);
|
| +}
|
| +
|
| +TEST_F(AnimationFilterStyleInterpolationTest, SimpleTest)
|
| +{
|
| + RefPtrWillBeRawPtr<CSSFunctionValue> filter;
|
| +
|
| + filter = CSSFunctionValue::create(CSSValueOpacity);
|
| + filter->append(CSSPrimitiveValue::create(0.5, CSSPrimitiveValue::CSS_NUMBER));
|
| + testPrimitiveValue(roundTrip(filter), CSSValueOpacity, 0.5, CSSPrimitiveValue::CSS_NUMBER);
|
| +}
|
| +
|
| +}
|
|
|