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

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

Issue 1318543010: Change first() and second() in CSSPairValue to return const references (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Review feedback 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/CSSValuePair.h" 10 #include "core/css/CSSValuePair.h"
(...skipping 17 matching lines...) Expand all
28 } 28 }
29 29
30 static PassRefPtrWillBeRawPtr<CSSValue> roundTrip(PassRefPtrWillBeRawPtr<CSS Value> value, InterpolationRange range) 30 static PassRefPtrWillBeRawPtr<CSSValue> roundTrip(PassRefPtrWillBeRawPtr<CSS Value> value, InterpolationRange 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(RefPtrWillBeRawPtr<CSSValue> value, double fi rst, double second, CSSPrimitiveValue::UnitType unitType)
36 { 36 {
37 EXPECT_TRUE(value->isValuePair()); 37 EXPECT_TRUE(value->isValuePair());
38 const CSSValuePair& pair = toCSSValuePair(*value);
38 39
39 CSSValuePair* pair = toCSSValuePair(value.get()); 40 EXPECT_EQ(toCSSPrimitiveValue(pair.first()).getDoubleValue(), first);
40 ASSERT_TRUE(pair); 41 EXPECT_EQ(toCSSPrimitiveValue(pair.second()).getDoubleValue(), second);
41 42
42 EXPECT_EQ(toCSSPrimitiveValue(pair->first())->getDoubleValue(), first); 43 EXPECT_EQ(toCSSPrimitiveValue(pair.first()).typeWithCalcResolved(), unit Type);
43 EXPECT_EQ(toCSSPrimitiveValue(pair->second())->getDoubleValue(), second) ; 44 EXPECT_EQ(toCSSPrimitiveValue(pair.second()).typeWithCalcResolved(), uni tType);
44
45 EXPECT_EQ(toCSSPrimitiveValue(pair->first())->typeWithCalcResolved(), un itType);
46 EXPECT_EQ(toCSSPrimitiveValue(pair->second())->typeWithCalcResolved(), u nitType);
47 } 45 }
48 }; 46 };
49 47
50 TEST_F(LengthPairStyleInterpolationTest, ZeroTest) 48 TEST_F(LengthPairStyleInterpolationTest, ZeroTest)
51 { 49 {
52 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstPx = CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Pixels); 50 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstPx = CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Pixels);
53 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondPx = CSSPrimitiveValue::create(0 , CSSPrimitiveValue::UnitType::Pixels); 51 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondPx = CSSPrimitiveValue::create(0 , CSSPrimitiveValue::UnitType::Pixels);
54 RefPtrWillBeRawPtr<CSSValuePair> pairPx = CSSValuePair::create(firstPx.relea se(), secondPx.release(), CSSValuePair::KeepIdenticalValues); 52 RefPtrWillBeRawPtr<CSSValuePair> pairPx = CSSValuePair::create(firstPx.relea se(), secondPx.release(), CSSValuePair::KeepIdenticalValues);
55 RefPtrWillBeRawPtr<CSSValue> value1 = roundTrip(pairPx.release(), RangeNonNe gative); 53 RefPtrWillBeRawPtr<CSSValue> value1 = roundTrip(pairPx.release(), RangeNonNe gative);
56 testPrimitiveValue(value1, 0, 0, CSSPrimitiveValue::UnitType::Pixels); 54 testPrimitiveValue(value1, 0, 0, CSSPrimitiveValue::UnitType::Pixels);
(...skipping 26 matching lines...) Expand all
83 testPrimitiveValue(value5, 10, 20, CSSPrimitiveValue::UnitType::Pixels); 81 testPrimitiveValue(value5, 10, 20, CSSPrimitiveValue::UnitType::Pixels);
84 82
85 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstPc = CSSPrimitiveValue::create(30 , CSSPrimitiveValue::UnitType::Percentage); 83 RefPtrWillBeRawPtr<CSSPrimitiveValue> firstPc = CSSPrimitiveValue::create(30 , CSSPrimitiveValue::UnitType::Percentage);
86 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondPc = CSSPrimitiveValue::create(- 30, CSSPrimitiveValue::UnitType::Percentage); 84 RefPtrWillBeRawPtr<CSSPrimitiveValue> secondPc = CSSPrimitiveValue::create(- 30, CSSPrimitiveValue::UnitType::Percentage);
87 RefPtrWillBeRawPtr<CSSValuePair> pairPc = CSSValuePair::create(firstPc.relea se(), secondPc.release(), CSSValuePair::KeepIdenticalValues); 85 RefPtrWillBeRawPtr<CSSValuePair> pairPc = CSSValuePair::create(firstPc.relea se(), secondPc.release(), CSSValuePair::KeepIdenticalValues);
88 RefPtrWillBeRawPtr<CSSValue> value6 = roundTrip(pairPc.release(), RangeNonNe gative); 86 RefPtrWillBeRawPtr<CSSValue> value6 = roundTrip(pairPc.release(), RangeNonNe gative);
89 testPrimitiveValue(value6, 30, 0, CSSPrimitiveValue::UnitType::Percentage); 87 testPrimitiveValue(value6, 30, 0, CSSPrimitiveValue::UnitType::Percentage);
90 } 88 }
91 89
92 } 90 }
OLDNEW
« no previous file with comments | « Source/core/animation/LengthPairStyleInterpolation.cpp ('k') | Source/core/css/BasicShapeFunctions.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698