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

Side by Side Diff: third_party/WebKit/Source/core/css/CSSCalculationValueTest.cpp

Issue 2056303002: [Layout API] Use Document::layoutViewItem() in ViewportStyleResolver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changed both declarations to const ref as per rune Created 4 years, 5 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/CSSGradientValue.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013, Google Inc. All rights reserved. 2 * Copyright (c) 2013, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "core/css/CSSCalculationValue.h" 31 #include "core/css/CSSCalculationValue.h"
32 32
33 #include "core/css/CSSPrimitiveValue.h" 33 #include "core/css/CSSPrimitiveValue.h"
34 #include "core/css/CSSToLengthConversionData.h" 34 #include "core/css/CSSToLengthConversionData.h"
35 #include "core/css/StylePropertySet.h" 35 #include "core/css/StylePropertySet.h"
36 #include "core/layout/api/LayoutViewItem.h"
36 #include "core/style/ComputedStyle.h" 37 #include "core/style/ComputedStyle.h"
37 #include "core/style/StyleInheritedData.h" 38 #include "core/style/StyleInheritedData.h"
38 #include "testing/gtest/include/gtest/gtest.h" 39 #include "testing/gtest/include/gtest/gtest.h"
39 40
40 namespace blink { 41 namespace blink {
41 42
42 void PrintTo(const CSSLengthArray& lengthArray, ::std::ostream* os) 43 void PrintTo(const CSSLengthArray& lengthArray, ::std::ostream* os)
43 { 44 {
44 for (double x : lengthArray.values) 45 for (double x : lengthArray.values)
45 *os << x << ' '; 46 *os << x << ' ';
(...skipping 25 matching lines...) Expand all
71 if (a.values.at(i) != b.values.at(i)) 72 if (a.values.at(i) != b.values.at(i))
72 return false; 73 return false;
73 } 74 }
74 return true; 75 return true;
75 } 76 }
76 77
77 TEST(CSSCalculationValue, AccumulatePixelsAndPercent) 78 TEST(CSSCalculationValue, AccumulatePixelsAndPercent)
78 { 79 {
79 RefPtr<ComputedStyle> style = ComputedStyle::create(); 80 RefPtr<ComputedStyle> style = ComputedStyle::create();
80 style->setEffectiveZoom(5); 81 style->setEffectiveZoom(5);
81 CSSToLengthConversionData conversionData(style.get(), style.get(), nullptr, style->effectiveZoom()); 82 CSSToLengthConversionData conversionData(style.get(), style.get(), LayoutVie wItem(nullptr), style->effectiveZoom());
82 83
83 testAccumulatePixelsAndPercent(conversionData, 84 testAccumulatePixelsAndPercent(conversionData,
84 CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(10, CSSPrim itiveValue::UnitType::Pixels), true), 85 CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(10, CSSPrim itiveValue::UnitType::Pixels), true),
85 50, 0); 86 50, 0);
86 87
87 testAccumulatePixelsAndPercent(conversionData, 88 testAccumulatePixelsAndPercent(conversionData,
88 CSSCalcValue::createExpressionNode( 89 CSSCalcValue::createExpressionNode(
89 CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(10, CSS PrimitiveValue::UnitType::Pixels), true), 90 CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(10, CSS PrimitiveValue::UnitType::Pixels), true),
90 CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(20, CSS PrimitiveValue::UnitType::Pixels), true), 91 CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(20, CSS PrimitiveValue::UnitType::Pixels), true),
91 CalcAdd), 92 CalcAdd),
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 178
178 expectation.values.at(CSSPrimitiveValue::UnitTypePixels) = 15; 179 expectation.values.at(CSSPrimitiveValue::UnitTypePixels) = 15;
179 expectation.values.at(CSSPrimitiveValue::UnitTypeFontSize) = 20; 180 expectation.values.at(CSSPrimitiveValue::UnitTypeFontSize) = 20;
180 expectation.values.at(CSSPrimitiveValue::UnitTypePercentage) = -40; 181 expectation.values.at(CSSPrimitiveValue::UnitTypePercentage) = -40;
181 EXPECT_TRUE(lengthArraysEqual(expectation, setLengthArray(actual, "calc((1 * 2) * (5px + 20em / 2) - 80% / (3 - 1) + 5px)"))); 182 EXPECT_TRUE(lengthArraysEqual(expectation, setLengthArray(actual, "calc((1 * 2) * (5px + 20em / 2) - 80% / (3 - 1) + 5px)")));
182 } 183 }
183 184
184 } // anonymous namespace 185 } // anonymous namespace
185 186
186 } // namespace blink 187 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/CSSGradientValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698