| 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/LengthBoxStyleInterpolation.h" | 6 #include "core/animation/LengthBoxStyleInterpolation.h" | 
| 7 | 7 | 
| 8 #include "core/animation/LengthStyleInterpolation.h" | 8 #include "core/animation/LengthStyleInterpolation.h" | 
| 9 #include "core/css/CSSPrimitiveValue.h" | 9 #include "core/css/CSSPrimitiveValue.h" | 
| 10 #include "core/css/Rect.h" | 10 #include "core/css/Rect.h" | 
| 11 #include "core/css/StylePropertySet.h" | 11 #include "core/css/StylePropertySet.h" | 
| 12 | 12 | 
| 13 #include <gtest/gtest.h> | 13 #include <gtest/gtest.h> | 
| 14 | 14 | 
| 15 namespace blink { | 15 namespace blink { | 
| 16 | 16 | 
| 17 class AnimationLengthBoxStyleInterpolationTest : public ::testing::Test { | 17 class AnimationLengthBoxStyleInterpolationTest : public ::testing::Test { | 
| 18 protected: | 18 protected: | 
| 19     static PassOwnPtrWillBeRawPtr<InterpolableValue> lengthBoxToInterpolableValu
     e(const CSSValue& value) | 19     static InterpolableValue* lengthBoxToInterpolableValue(const CSSValue& value
     ) | 
| 20     { | 20     { | 
| 21         return LengthBoxStyleInterpolation::lengthBoxtoInterpolableValue(value, 
     value, false); | 21         return LengthBoxStyleInterpolation::lengthBoxtoInterpolableValue(value, 
     value, false); | 
| 22     } | 22     } | 
| 23 | 23 | 
| 24     static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToLengthBox(Interpo
     lableValue* value, const CSSValue& start, const CSSValue& end) | 24     static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToLengthBox(Interpo
     lableValue* value, const CSSValue& start, const CSSValue& end) | 
| 25     { | 25     { | 
| 26         return LengthBoxStyleInterpolation::interpolableValueToLengthBox(value, 
     start, end); | 26         return LengthBoxStyleInterpolation::interpolableValueToLengthBox(value, 
     start, end); | 
| 27     } | 27     } | 
| 28 | 28 | 
| 29     static PassRefPtrWillBeRawPtr<CSSValue> roundTrip(PassRefPtrWillBeRawPtr<CSS
     Value> value) | 29     static PassRefPtrWillBeRawPtr<CSSValue> roundTrip(PassRefPtrWillBeRawPtr<CSS
     Value> value) | 
| 30     { | 30     { | 
| 31         return interpolableValueToLengthBox(lengthBoxToInterpolableValue(*value)
     .get(), *value, *value); | 31         return interpolableValueToLengthBox(lengthBoxToInterpolableValue(*value)
     , *value, *value); | 
| 32     } | 32     } | 
| 33 | 33 | 
| 34     static void testPrimitiveValue(RefPtrWillBeRawPtr<CSSValue> value, double le
     ft, double right, double top, double bottom, CSSPrimitiveValue::UnitType unitTyp
     e) | 34     static void testPrimitiveValue(RefPtrWillBeRawPtr<CSSValue> value, double le
     ft, double right, double top, double bottom, CSSPrimitiveValue::UnitType unitTyp
     e) | 
| 35     { | 35     { | 
| 36         EXPECT_TRUE(value->isPrimitiveValue()); | 36         EXPECT_TRUE(value->isPrimitiveValue()); | 
| 37         Rect* rect = toCSSPrimitiveValue(value.get())->getRectValue(); | 37         Rect* rect = toCSSPrimitiveValue(value.get())->getRectValue(); | 
| 38 | 38 | 
| 39         EXPECT_EQ(rect->left()->getDoubleValue(), left); | 39         EXPECT_EQ(rect->left()->getDoubleValue(), left); | 
| 40         EXPECT_EQ(rect->right()->getDoubleValue(), right); | 40         EXPECT_EQ(rect->right()->getDoubleValue(), right); | 
| 41         EXPECT_EQ(rect->top()->getDoubleValue(), top); | 41         EXPECT_EQ(rect->top()->getDoubleValue(), top); | 
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 113     rectPer->setLeft(CSSPrimitiveValue::create(30, CSSPrimitiveValue::UnitType::
     Percentage)); | 113     rectPer->setLeft(CSSPrimitiveValue::create(30, CSSPrimitiveValue::UnitType::
     Percentage)); | 
| 114     rectPer->setRight(CSSPrimitiveValue::create(-30, CSSPrimitiveValue::UnitType
     ::Percentage)); | 114     rectPer->setRight(CSSPrimitiveValue::create(-30, CSSPrimitiveValue::UnitType
     ::Percentage)); | 
| 115     rectPer->setTop(CSSPrimitiveValue::create(30, CSSPrimitiveValue::UnitType::P
     ercentage)); | 115     rectPer->setTop(CSSPrimitiveValue::create(30, CSSPrimitiveValue::UnitType::P
     ercentage)); | 
| 116     rectPer->setBottom(CSSPrimitiveValue::create(-30, CSSPrimitiveValue::UnitTyp
     e::Percentage)); | 116     rectPer->setBottom(CSSPrimitiveValue::create(-30, CSSPrimitiveValue::UnitTyp
     e::Percentage)); | 
| 117 | 117 | 
| 118     value = roundTrip(CSSPrimitiveValue::create(rectPer.release())); | 118     value = roundTrip(CSSPrimitiveValue::create(rectPer.release())); | 
| 119     testPrimitiveValue(value, 30, -30, 30, -30, CSSPrimitiveValue::UnitType::Per
     centage); | 119     testPrimitiveValue(value, 30, -30, 30, -30, CSSPrimitiveValue::UnitType::Per
     centage); | 
| 120 } | 120 } | 
| 121 | 121 | 
| 122 } | 122 } | 
| OLD | NEW | 
|---|