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

Unified Diff: Source/core/css/CSSCalculationValueTest.cpp

Issue 23439004: CSS Calc: Use Lengths instead of numbers to represent pixels (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased to ToT again Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/CSSCalculationValue.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/CSSCalculationValueTest.cpp
diff --git a/Source/core/css/CSSCalculationValueTest.cpp b/Source/core/css/CSSCalculationValueTest.cpp
index bfd0be481e6d653fa92181abb1f847e37164f811..c2f80b1a3ee987e8b356d83dda8bb6ac1823c71f 100644
--- a/Source/core/css/CSSCalculationValueTest.cpp
+++ b/Source/core/css/CSSCalculationValueTest.cpp
@@ -41,6 +41,15 @@ using namespace WebCore;
namespace {
+void testExpression(PassRefPtr<CSSCalcExpressionNode> expression, const RenderStyle* style)
+{
+ EXPECT_TRUE(
+ expression->equals(
+ *CSSCalcValue::createExpressionNode(
+ expression->toCalcValue(style, style, style->effectiveZoom()).get(),
+ style).get()));
+}
+
TEST(CSSCalculationValue, CreateExpressionNodeFromLength)
{
RefPtr<RenderStyle> style = RenderStyle::create();
@@ -97,4 +106,42 @@ TEST(CSSCalculationValue, CreateExpressionNodeFromLength)
EXPECT_TRUE(actual->equals(*expected.get()));
}
+TEST(CSSCalculationValue, CreateExpressionNodeFromLengthFromExpressionNode)
+{
+ RefPtr<CSSCalcExpressionNode> expression;
+ RefPtr<RenderStyle> style = RenderStyle::createDefaultStyle();
+ style->setEffectiveZoom(5);
+
+ testExpression(
+ CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(10, CSSPrimitiveValue::CSS_PX), true),
+ style.get());
+
+ testExpression(
+ CSSCalcValue::createExpressionNode(
+ CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(10, CSSPrimitiveValue::CSS_PX), true),
+ CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(20, CSSPrimitiveValue::CSS_PX), true),
+ CalcAdd),
+ style.get());
+
+ testExpression(
+ CSSCalcValue::createExpressionNode(
+ CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(30, CSSPrimitiveValue::CSS_PX), true),
+ CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(40, CSSPrimitiveValue::CSS_NUMBER), true),
+ CalcMultiply),
+ style.get());
+
+ testExpression(
+ CSSCalcValue::createExpressionNode(
+ CSSCalcValue::createExpressionNode(
+ CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(50, CSSPrimitiveValue::CSS_PX), true),
+ CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(0.25, CSSPrimitiveValue::CSS_NUMBER), false),
+ CalcMultiply),
+ CSSCalcValue::createExpressionNode(
+ CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(60, CSSPrimitiveValue::CSS_PX), true),
+ CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(0.75, CSSPrimitiveValue::CSS_NUMBER), false),
+ CalcMultiply),
+ CalcAdd),
+ style.get());
+}
+
}
« no previous file with comments | « Source/core/css/CSSCalculationValue.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698