Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: Source/core/animation/LengthPairStyleInterpolationTest.cpp

Issue 1303173007: Oilpan: Unship Oilpan from CSSValues Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/LengthPairStyleInterpolation.h" 6 #include "core/animation/LengthPairStyleInterpolation.h"
7 7
8 #include "core/css/CSSPrimitiveValue.h" 8 #include "core/css/CSSPrimitiveValue.h"
9 #include "core/css/CSSValue.h" 9 #include "core/css/CSSValue.h"
10 #include "core/css/Pair.h" 10 #include "core/css/Pair.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 LengthPairStyleInterpolationTest : public ::testing::Test { 17 class LengthPairStyleInterpolationTest : public ::testing::Test {
18 18
19 protected: 19 protected:
20 static PassOwnPtrWillBeRawPtr<InterpolableValue> lengthPairToInterpolableVal ue(const CSSValue& value) 20 static PassOwnPtrWillBeRawPtr<InterpolableValue> lengthPairToInterpolableVal ue(const CSSValue& value)
21 { 21 {
22 return LengthPairStyleInterpolation::lengthPairToInterpolableValue(value ); 22 return LengthPairStyleInterpolation::lengthPairToInterpolableValue(value );
23 } 23 }
24 24
25 static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToLengthPair(Interp olableValue* value, InterpolationRange range) 25 static PassRefPtr<CSSValue> interpolableValueToLengthPair(InterpolableValue* value, InterpolationRange range)
26 { 26 {
27 return LengthPairStyleInterpolation::interpolableValueToLengthPair(value , range); 27 return LengthPairStyleInterpolation::interpolableValueToLengthPair(value , range);
28 } 28 }
29 29
30 static PassRefPtrWillBeRawPtr<CSSValue> roundTrip(PassRefPtrWillBeRawPtr<CSS Value> value, InterpolationRange range) 30 static PassRefPtr<CSSValue> roundTrip(PassRefPtr<CSSValue> value, Interpolat ionRange range)
31 { 31 {
32 return interpolableValueToLengthPair(lengthPairToInterpolableValue(*valu e).get(), range); 32 return interpolableValueToLengthPair(lengthPairToInterpolableValue(*valu e).get(), range);
33 } 33 }
34 34
35 static void testPrimitiveValue(RefPtrWillBeRawPtr<CSSValue> value, double fi rst, double second, CSSPrimitiveValue::UnitType unitType) 35 static void testPrimitiveValue(RefPtr<CSSValue> value, double first, double second, CSSPrimitiveValue::UnitType unitType)
36 { 36 {
37 EXPECT_TRUE(value->isPrimitiveValue()); 37 EXPECT_TRUE(value->isPrimitiveValue());
38 38
39 Pair* pair = toCSSPrimitiveValue(value.get())->getPairValue(); 39 Pair* pair = toCSSPrimitiveValue(value.get())->getPairValue();
40 ASSERT_TRUE(pair); 40 ASSERT_TRUE(pair);
41 41
42 EXPECT_EQ(pair->first()->getDoubleValue(), first); 42 EXPECT_EQ(pair->first()->getDoubleValue(), first);
43 EXPECT_EQ(pair->second()->getDoubleValue(), second); 43 EXPECT_EQ(pair->second()->getDoubleValue(), second);
44 44
45 EXPECT_EQ(pair->first()->typeWithCalcResolved(), unitType); 45 EXPECT_EQ(pair->first()->typeWithCalcResolved(), unitType);
46 EXPECT_EQ(pair->second()->typeWithCalcResolved(), unitType); 46 EXPECT_EQ(pair->second()->typeWithCalcResolved(), unitType);
47 } 47 }
48 }; 48 };
49 49
50 TEST_F(LengthPairStyleInterpolationTest, ZeroTest) 50 TEST_F(LengthPairStyleInterpolationTest, ZeroTest)
51 { 51 {
52 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstPx = CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Pixels); 52 RefPtr<CSSPrimitiveValue> firstPx = CSSPrimitiveValue::create(0, CSSPrimitiv eValue::UnitType::Pixels);
53 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondPx = CSSPrimitiveValue::create(0 , CSSPrimitiveValue::UnitType::Pixels); 53 RefPtr<CSSPrimitiveValue> secondPx = CSSPrimitiveValue::create(0, CSSPrimiti veValue::UnitType::Pixels);
54 RefPtrWillBeRawPtr<Pair> pairPx = Pair::create(firstPx, secondPx, Pair::Keep IdenticalValues); 54 RefPtr<Pair> pairPx = Pair::create(firstPx, secondPx, Pair::KeepIdenticalVal ues);
55 RefPtrWillBeRawPtr<CSSValue> value1 = roundTrip(CSSPrimitiveValue::create(pa irPx.release()), RangeNonNegative); 55 RefPtr<CSSValue> value1 = roundTrip(CSSPrimitiveValue::create(pairPx.release ()), RangeNonNegative);
56 testPrimitiveValue(value1, 0, 0, CSSPrimitiveValue::UnitType::Pixels); 56 testPrimitiveValue(value1, 0, 0, CSSPrimitiveValue::UnitType::Pixels);
57 57
58 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstPc = CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Percentage); 58 RefPtr<CSSPrimitiveValue> firstPc = CSSPrimitiveValue::create(0, CSSPrimitiv eValue::UnitType::Percentage);
59 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondPc = CSSPrimitiveValue::create(0 , CSSPrimitiveValue::UnitType::Percentage); 59 RefPtr<CSSPrimitiveValue> secondPc = CSSPrimitiveValue::create(0, CSSPrimiti veValue::UnitType::Percentage);
60 RefPtrWillBeRawPtr<Pair> pairPc = Pair::create(firstPc, secondPc, Pair::Keep IdenticalValues); 60 RefPtr<Pair> pairPc = Pair::create(firstPc, secondPc, Pair::KeepIdenticalVal ues);
61 RefPtrWillBeRawPtr<CSSValue> value2 = roundTrip(CSSPrimitiveValue::create(pa irPc.release()), RangeNonNegative); 61 RefPtr<CSSValue> value2 = roundTrip(CSSPrimitiveValue::create(pairPc.release ()), RangeNonNegative);
62 testPrimitiveValue(value2, 0, 0, CSSPrimitiveValue::UnitType::Percentage); 62 testPrimitiveValue(value2, 0, 0, CSSPrimitiveValue::UnitType::Percentage);
63 63
64 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstEms = CSSPrimitiveValue::create(0 , CSSPrimitiveValue::UnitType::Ems); 64 RefPtr<CSSPrimitiveValue> firstEms = CSSPrimitiveValue::create(0, CSSPrimiti veValue::UnitType::Ems);
65 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondEms = CSSPrimitiveValue::create( 0, CSSPrimitiveValue::UnitType::Ems); 65 RefPtr<CSSPrimitiveValue> secondEms = CSSPrimitiveValue::create(0, CSSPrimit iveValue::UnitType::Ems);
66 RefPtrWillBeRawPtr<Pair> pairEms = Pair::create(firstEms, secondEms, Pair::K eepIdenticalValues); 66 RefPtr<Pair> pairEms = Pair::create(firstEms, secondEms, Pair::KeepIdentical Values);
67 RefPtrWillBeRawPtr<CSSValue> value3 = roundTrip(CSSPrimitiveValue::create(pa irEms.release()), RangeNonNegative); 67 RefPtr<CSSValue> value3 = roundTrip(CSSPrimitiveValue::create(pairEms.releas e()), RangeNonNegative);
68 testPrimitiveValue(value3, 0, 0, CSSPrimitiveValue::UnitType::Ems); 68 testPrimitiveValue(value3, 0, 0, CSSPrimitiveValue::UnitType::Ems);
69 69
70 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstPcNeg = CSSPrimitiveValue::create (0, CSSPrimitiveValue::UnitType::Percentage); 70 RefPtr<CSSPrimitiveValue> firstPcNeg = CSSPrimitiveValue::create(0, CSSPrimi tiveValue::UnitType::Percentage);
71 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondPcNeg = CSSPrimitiveValue::creat e(0, CSSPrimitiveValue::UnitType::Percentage); 71 RefPtr<CSSPrimitiveValue> secondPcNeg = CSSPrimitiveValue::create(0, CSSPrim itiveValue::UnitType::Percentage);
72 RefPtrWillBeRawPtr<Pair> pairPcNeg = Pair::create(firstPcNeg, secondPcNeg, P air::KeepIdenticalValues); 72 RefPtr<Pair> pairPcNeg = Pair::create(firstPcNeg, secondPcNeg, Pair::KeepIde nticalValues);
73 RefPtrWillBeRawPtr<CSSValue> value4 = roundTrip(CSSPrimitiveValue::create(pa irPcNeg.release()), RangeAll); 73 RefPtr<CSSValue> value4 = roundTrip(CSSPrimitiveValue::create(pairPcNeg.rele ase()), RangeAll);
74 testPrimitiveValue(value4, 0, 0, CSSPrimitiveValue::UnitType::Percentage); 74 testPrimitiveValue(value4, 0, 0, CSSPrimitiveValue::UnitType::Percentage);
75 } 75 }
76 76
77 TEST_F(LengthPairStyleInterpolationTest, MultipleValueTest) 77 TEST_F(LengthPairStyleInterpolationTest, MultipleValueTest)
78 { 78 {
79 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstPx = CSSPrimitiveValue::create(10 , CSSPrimitiveValue::UnitType::Pixels); 79 RefPtr<CSSPrimitiveValue> firstPx = CSSPrimitiveValue::create(10, CSSPrimiti veValue::UnitType::Pixels);
80 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondPx = CSSPrimitiveValue::create(2 0, CSSPrimitiveValue::UnitType::Pixels); 80 RefPtr<CSSPrimitiveValue> secondPx = CSSPrimitiveValue::create(20, CSSPrimit iveValue::UnitType::Pixels);
81 RefPtrWillBeRawPtr<Pair> pairPx = Pair::create(firstPx, secondPx, Pair::Keep IdenticalValues); 81 RefPtr<Pair> pairPx = Pair::create(firstPx, secondPx, Pair::KeepIdenticalVal ues);
82 RefPtrWillBeRawPtr<CSSValue> value5 = roundTrip(CSSPrimitiveValue::create(pa irPx.release()), RangeNonNegative); 82 RefPtr<CSSValue> value5 = roundTrip(CSSPrimitiveValue::create(pairPx.release ()), RangeNonNegative);
83 testPrimitiveValue(value5, 10, 20, CSSPrimitiveValue::UnitType::Pixels); 83 testPrimitiveValue(value5, 10, 20, CSSPrimitiveValue::UnitType::Pixels);
84 84
85 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstPc = CSSPrimitiveValue::create(30 , CSSPrimitiveValue::UnitType::Percentage); 85 RefPtr<CSSPrimitiveValue> firstPc = CSSPrimitiveValue::create(30, CSSPrimiti veValue::UnitType::Percentage);
86 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondPc = CSSPrimitiveValue::create(- 30, CSSPrimitiveValue::UnitType::Percentage); 86 RefPtr<CSSPrimitiveValue> secondPc = CSSPrimitiveValue::create(-30, CSSPrimi tiveValue::UnitType::Percentage);
87 RefPtrWillBeRawPtr<Pair> pairPc = Pair::create(firstPc, secondPc, Pair::Keep IdenticalValues); 87 RefPtr<Pair> pairPc = Pair::create(firstPc, secondPc, Pair::KeepIdenticalVal ues);
88 RefPtrWillBeRawPtr<CSSValue> value6 = roundTrip(CSSPrimitiveValue::create(pa irPc.release()), RangeNonNegative); 88 RefPtr<CSSValue> value6 = roundTrip(CSSPrimitiveValue::create(pairPc.release ()), RangeNonNegative);
89 testPrimitiveValue(value6, 30, 0, CSSPrimitiveValue::UnitType::Percentage); 89 testPrimitiveValue(value6, 30, 0, CSSPrimitiveValue::UnitType::Percentage);
90 } 90 }
91 91
92 } 92 }
OLDNEW
« no previous file with comments | « Source/core/animation/LengthPairStyleInterpolation.cpp ('k') | Source/core/animation/LengthStyleInterpolation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698