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

Side by Side Diff: Source/core/animation/LengthBoxStyleInterpolationTest.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/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 PassOwnPtrWillBeRawPtr<InterpolableValue> lengthBoxToInterpolableValu e(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 PassRefPtr<CSSValue> interpolableValueToLengthBox(InterpolableValue* 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 PassRefPtr<CSSValue> roundTrip(PassRefPtr<CSSValue> value)
30 { 30 {
31 return interpolableValueToLengthBox(lengthBoxToInterpolableValue(*value) .get(), *value, *value); 31 return interpolableValueToLengthBox(lengthBoxToInterpolableValue(*value) .get(), *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(RefPtr<CSSValue> value, double left, double r ight, double top, double bottom, CSSPrimitiveValue::UnitType unitType)
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);
42 EXPECT_EQ(rect->bottom()->getDoubleValue(), bottom); 42 EXPECT_EQ(rect->bottom()->getDoubleValue(), bottom);
43 43
44 EXPECT_EQ(unitType, rect->left()->typeWithCalcResolved()); 44 EXPECT_EQ(unitType, rect->left()->typeWithCalcResolved());
45 EXPECT_EQ(unitType, rect->right()->typeWithCalcResolved()); 45 EXPECT_EQ(unitType, rect->right()->typeWithCalcResolved());
46 EXPECT_EQ(unitType, rect->top()->typeWithCalcResolved()); 46 EXPECT_EQ(unitType, rect->top()->typeWithCalcResolved());
47 EXPECT_EQ(unitType, rect->bottom()->typeWithCalcResolved()); 47 EXPECT_EQ(unitType, rect->bottom()->typeWithCalcResolved());
48 } 48 }
49 }; 49 };
50 50
51 TEST_F(AnimationLengthBoxStyleInterpolationTest, ZeroLengthBox) 51 TEST_F(AnimationLengthBoxStyleInterpolationTest, ZeroLengthBox)
52 { 52 {
53 RefPtrWillBeRawPtr<Rect> rectPx = Rect::create(); 53 RefPtr<Rect> rectPx = Rect::create();
54 rectPx->setLeft(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Pi xels)); 54 rectPx->setLeft(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Pi xels));
55 rectPx->setRight(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::P ixels)); 55 rectPx->setRight(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::P ixels));
56 rectPx->setTop(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Pix els)); 56 rectPx->setTop(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Pix els));
57 rectPx->setBottom(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType:: Pixels)); 57 rectPx->setBottom(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType:: Pixels));
58 RefPtrWillBeRawPtr<CSSValue> value = roundTrip(CSSPrimitiveValue::create(rec tPx.release())); 58 RefPtr<CSSValue> value = roundTrip(CSSPrimitiveValue::create(rectPx.release( )));
59 testPrimitiveValue(value, 0, 0, 0, 0, CSSPrimitiveValue::UnitType::Pixels); 59 testPrimitiveValue(value, 0, 0, 0, 0, CSSPrimitiveValue::UnitType::Pixels);
60 60
61 RefPtrWillBeRawPtr<Rect> rectEms = Rect::create(); 61 RefPtr<Rect> rectEms = Rect::create();
62 rectEms->setLeft(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::E ms)); 62 rectEms->setLeft(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::E ms));
63 rectEms->setRight(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType:: Ems)); 63 rectEms->setRight(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType:: Ems));
64 rectEms->setTop(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Em s)); 64 rectEms->setTop(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Em s));
65 rectEms->setBottom(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType: :Ems)); 65 rectEms->setBottom(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType: :Ems));
66 66
67 value = roundTrip(CSSPrimitiveValue::create(rectEms.release())); 67 value = roundTrip(CSSPrimitiveValue::create(rectEms.release()));
68 testPrimitiveValue(value, 0, 0, 0, 0, CSSPrimitiveValue::UnitType::Ems); 68 testPrimitiveValue(value, 0, 0, 0, 0, CSSPrimitiveValue::UnitType::Ems);
69 } 69 }
70 70
71 TEST_F(AnimationLengthBoxStyleInterpolationTest, SingleUnitBox) 71 TEST_F(AnimationLengthBoxStyleInterpolationTest, SingleUnitBox)
72 { 72 {
73 RefPtrWillBeRawPtr<Rect> rectPx = Rect::create(); 73 RefPtr<Rect> rectPx = Rect::create();
74 rectPx->setLeft(CSSPrimitiveValue::create(10, CSSPrimitiveValue::UnitType::P ixels)); 74 rectPx->setLeft(CSSPrimitiveValue::create(10, CSSPrimitiveValue::UnitType::P ixels));
75 rectPx->setRight(CSSPrimitiveValue::create(10, CSSPrimitiveValue::UnitType:: Pixels)); 75 rectPx->setRight(CSSPrimitiveValue::create(10, CSSPrimitiveValue::UnitType:: Pixels));
76 rectPx->setTop(CSSPrimitiveValue::create(10, CSSPrimitiveValue::UnitType::Pi xels)); 76 rectPx->setTop(CSSPrimitiveValue::create(10, CSSPrimitiveValue::UnitType::Pi xels));
77 rectPx->setBottom(CSSPrimitiveValue::create(10, CSSPrimitiveValue::UnitType: :Pixels)); 77 rectPx->setBottom(CSSPrimitiveValue::create(10, CSSPrimitiveValue::UnitType: :Pixels));
78 78
79 RefPtrWillBeRawPtr<CSSValue> value = roundTrip(CSSPrimitiveValue::create(rec tPx.release())); 79 RefPtr<CSSValue> value = roundTrip(CSSPrimitiveValue::create(rectPx.release( )));
80 testPrimitiveValue(value, 10, 10, 10, 10, CSSPrimitiveValue::UnitType::Pixel s); 80 testPrimitiveValue(value, 10, 10, 10, 10, CSSPrimitiveValue::UnitType::Pixel s);
81 81
82 RefPtrWillBeRawPtr<Rect> rectPer = Rect::create(); 82 RefPtr<Rect> rectPer = Rect::create();
83 rectPer->setLeft(CSSPrimitiveValue::create(30, CSSPrimitiveValue::UnitType:: Percentage)); 83 rectPer->setLeft(CSSPrimitiveValue::create(30, CSSPrimitiveValue::UnitType:: Percentage));
84 rectPer->setRight(CSSPrimitiveValue::create(30, CSSPrimitiveValue::UnitType: :Percentage)); 84 rectPer->setRight(CSSPrimitiveValue::create(30, CSSPrimitiveValue::UnitType: :Percentage));
85 rectPer->setTop(CSSPrimitiveValue::create(30, CSSPrimitiveValue::UnitType::P ercentage)); 85 rectPer->setTop(CSSPrimitiveValue::create(30, CSSPrimitiveValue::UnitType::P ercentage));
86 rectPer->setBottom(CSSPrimitiveValue::create(30, CSSPrimitiveValue::UnitType ::Percentage)); 86 rectPer->setBottom(CSSPrimitiveValue::create(30, CSSPrimitiveValue::UnitType ::Percentage));
87 87
88 value = roundTrip(CSSPrimitiveValue::create(rectPer.release())); 88 value = roundTrip(CSSPrimitiveValue::create(rectPer.release()));
89 testPrimitiveValue(value, 30, 30, 30, 30, CSSPrimitiveValue::UnitType::Perce ntage); 89 testPrimitiveValue(value, 30, 30, 30, 30, CSSPrimitiveValue::UnitType::Perce ntage);
90 90
91 RefPtrWillBeRawPtr<Rect> rectEms = Rect::create(); 91 RefPtr<Rect> rectEms = Rect::create();
92 rectEms->setLeft(CSSPrimitiveValue::create(-10, CSSPrimitiveValue::UnitType: :Ems)); 92 rectEms->setLeft(CSSPrimitiveValue::create(-10, CSSPrimitiveValue::UnitType: :Ems));
93 rectEms->setRight(CSSPrimitiveValue::create(-10, CSSPrimitiveValue::UnitType ::Ems)); 93 rectEms->setRight(CSSPrimitiveValue::create(-10, CSSPrimitiveValue::UnitType ::Ems));
94 rectEms->setTop(CSSPrimitiveValue::create(-10, CSSPrimitiveValue::UnitType:: Ems)); 94 rectEms->setTop(CSSPrimitiveValue::create(-10, CSSPrimitiveValue::UnitType:: Ems));
95 rectEms->setBottom(CSSPrimitiveValue::create(-10, CSSPrimitiveValue::UnitTyp e::Ems)); 95 rectEms->setBottom(CSSPrimitiveValue::create(-10, CSSPrimitiveValue::UnitTyp e::Ems));
96 96
97 value = roundTrip(CSSPrimitiveValue::create(rectEms.release())); 97 value = roundTrip(CSSPrimitiveValue::create(rectEms.release()));
98 testPrimitiveValue(value, -10, -10, -10, -10, CSSPrimitiveValue::UnitType::E ms); 98 testPrimitiveValue(value, -10, -10, -10, -10, CSSPrimitiveValue::UnitType::E ms);
99 } 99 }
100 100
101 TEST_F(AnimationLengthBoxStyleInterpolationTest, MultipleValues) 101 TEST_F(AnimationLengthBoxStyleInterpolationTest, MultipleValues)
102 { 102 {
103 RefPtrWillBeRawPtr<Rect> rectPx = Rect::create(); 103 RefPtr<Rect> rectPx = Rect::create();
104 rectPx->setLeft(CSSPrimitiveValue::create(10, CSSPrimitiveValue::UnitType::P ixels)); 104 rectPx->setLeft(CSSPrimitiveValue::create(10, CSSPrimitiveValue::UnitType::P ixels));
105 rectPx->setRight(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::P ixels)); 105 rectPx->setRight(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::P ixels));
106 rectPx->setTop(CSSPrimitiveValue::create(20, CSSPrimitiveValue::UnitType::Pi xels)); 106 rectPx->setTop(CSSPrimitiveValue::create(20, CSSPrimitiveValue::UnitType::Pi xels));
107 rectPx->setBottom(CSSPrimitiveValue::create(40, CSSPrimitiveValue::UnitType: :Pixels)); 107 rectPx->setBottom(CSSPrimitiveValue::create(40, CSSPrimitiveValue::UnitType: :Pixels));
108 108
109 RefPtrWillBeRawPtr<CSSValue> value = roundTrip(CSSPrimitiveValue::create(rec tPx.release())); 109 RefPtr<CSSValue> value = roundTrip(CSSPrimitiveValue::create(rectPx.release( )));
110 testPrimitiveValue(value, 10, 0, 20, 40, CSSPrimitiveValue::UnitType::Pixels ); 110 testPrimitiveValue(value, 10, 0, 20, 40, CSSPrimitiveValue::UnitType::Pixels );
111 111
112 RefPtrWillBeRawPtr<Rect> rectPer = Rect::create(); 112 RefPtr<Rect> rectPer = Rect::create();
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 }
OLDNEW
« no previous file with comments | « Source/core/animation/LengthBoxStyleInterpolation.cpp ('k') | Source/core/animation/LengthPairStyleInterpolation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698