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

Unified Diff: Source/core/animation/AnimatableLengthTest.cpp

Issue 64293008: Wrap CSS length conversion arguments in an object (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: erm.. use DEFINE_STATIC_REF Created 7 years, 1 month 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
Index: Source/core/animation/AnimatableLengthTest.cpp
diff --git a/Source/core/animation/AnimatableLengthTest.cpp b/Source/core/animation/AnimatableLengthTest.cpp
index b8772ab80559a68b3ba650c54b45ed02619477d6..8620935a654b5f89fc30c18e7f4e107c6c965af0 100644
--- a/Source/core/animation/AnimatableLengthTest.cpp
+++ b/Source/core/animation/AnimatableLengthTest.cpp
@@ -35,6 +35,7 @@
#include "core/animation/AnimatableValueTestHelper.h"
#include "core/css/CSSCalculationValue.h"
#include "core/css/CSSPrimitiveValue.h"
+#include "core/css/CSSToLengthConversionData.h"
#include "core/rendering/style/RenderStyle.h"
#include "core/rendering/style/StyleInheritedData.h"
#include "platform/CalculationValue.h"
@@ -51,6 +52,8 @@ protected:
virtual void SetUp()
{
style = RenderStyle::createDefaultStyle();
+ conversionDataZoom1 = CSSToLengthConversionData(style.get(), style.get(), 1);
+ conversionDataZoom3 = conversionDataZoom1.copyWithAdjustedZoom(3);
}
PassRefPtr<AnimatableLength> create(double value, CSSPrimitiveValue::UnitTypes type)
@@ -88,6 +91,8 @@ protected:
}
RefPtr<RenderStyle> style;
+ CSSToLengthConversionData conversionDataZoom1;
+ CSSToLengthConversionData conversionDataZoom3;
};
TEST_F(AnimationAnimatableLengthTest, CanCreateFrom)
@@ -164,15 +169,15 @@ TEST_F(AnimationAnimatableLengthTest, ToCSSValue)
TEST_F(AnimationAnimatableLengthTest, ToLength)
{
- EXPECT_EQ(Length(-5, WebCore::Fixed), create(-5, CSSPrimitiveValue::CSS_PX)->toLength(style.get(), style.get(), 1));
- EXPECT_EQ(Length(-15, WebCore::Fixed), create(-5, CSSPrimitiveValue::CSS_PX)->toLength(style.get(), style.get(), 3));
- EXPECT_EQ(Length(0, WebCore::Fixed), create(-5, CSSPrimitiveValue::CSS_PX)->toLength(style.get(), style.get(), 1, NonNegativeValues));
- EXPECT_EQ(Length(0, WebCore::Fixed), create(-5, CSSPrimitiveValue::CSS_PX)->toLength(style.get(), style.get(), 3, NonNegativeValues));
+ EXPECT_EQ(Length(-5, WebCore::Fixed), create(-5, CSSPrimitiveValue::CSS_PX)->toLength(conversionDataZoom1));
+ EXPECT_EQ(Length(-15, WebCore::Fixed), create(-5, CSSPrimitiveValue::CSS_PX)->toLength(conversionDataZoom3));
+ EXPECT_EQ(Length(0, WebCore::Fixed), create(-5, CSSPrimitiveValue::CSS_PX)->toLength(conversionDataZoom1, NonNegativeValues));
+ EXPECT_EQ(Length(0, WebCore::Fixed), create(-5, CSSPrimitiveValue::CSS_PX)->toLength(conversionDataZoom3, NonNegativeValues));
- EXPECT_EQ(Length(-5, Percent), create(-5, CSSPrimitiveValue::CSS_PERCENTAGE)->toLength(style.get(), style.get(), 1));
- EXPECT_EQ(Length(-5, Percent), create(-5, CSSPrimitiveValue::CSS_PERCENTAGE)->toLength(style.get(), style.get(), 3));
- EXPECT_EQ(Length(0, Percent), create(-5, CSSPrimitiveValue::CSS_PERCENTAGE)->toLength(style.get(), style.get(), 1, NonNegativeValues));
- EXPECT_EQ(Length(0, Percent), create(-5, CSSPrimitiveValue::CSS_PERCENTAGE)->toLength(style.get(), style.get(), 3, NonNegativeValues));
+ EXPECT_EQ(Length(-5, Percent), create(-5, CSSPrimitiveValue::CSS_PERCENTAGE)->toLength(conversionDataZoom1));
+ EXPECT_EQ(Length(-5, Percent), create(-5, CSSPrimitiveValue::CSS_PERCENTAGE)->toLength(conversionDataZoom3));
+ EXPECT_EQ(Length(0, Percent), create(-5, CSSPrimitiveValue::CSS_PERCENTAGE)->toLength(conversionDataZoom1, NonNegativeValues));
+ EXPECT_EQ(Length(0, Percent), create(-5, CSSPrimitiveValue::CSS_PERCENTAGE)->toLength(conversionDataZoom3, NonNegativeValues));
EXPECT_EQ(
Length(CalculationValue::create(
@@ -181,7 +186,7 @@ TEST_F(AnimationAnimatableLengthTest, ToLength)
adoptPtr(new CalcExpressionLength(Length(-5, Percent))),
CalcAdd)),
ValueRangeAll)),
- create(-5, CSSPrimitiveValue::CSS_PX, -5, CSSPrimitiveValue::CSS_PERCENTAGE)->toLength(style.get(), style.get(), 1));
+ create(-5, CSSPrimitiveValue::CSS_PX, -5, CSSPrimitiveValue::CSS_PERCENTAGE)->toLength(conversionDataZoom1));
EXPECT_EQ(
Length(CalculationValue::create(
adoptPtr(new CalcExpressionBinaryOperation(
@@ -189,7 +194,7 @@ TEST_F(AnimationAnimatableLengthTest, ToLength)
adoptPtr(new CalcExpressionLength(Length(-5, Percent))),
CalcAdd)),
ValueRangeAll)),
- create(-5, CSSPrimitiveValue::CSS_PX, -5, CSSPrimitiveValue::CSS_PERCENTAGE)->toLength(style.get(), style.get(), 3));
+ create(-5, CSSPrimitiveValue::CSS_PX, -5, CSSPrimitiveValue::CSS_PERCENTAGE)->toLength(conversionDataZoom3));
EXPECT_EQ(
Length(CalculationValue::create(
adoptPtr(new CalcExpressionBinaryOperation(
@@ -197,7 +202,7 @@ TEST_F(AnimationAnimatableLengthTest, ToLength)
adoptPtr(new CalcExpressionLength(Length(-5, Percent))),
CalcAdd)),
ValueRangeNonNegative)),
- create(-5, CSSPrimitiveValue::CSS_PX, -5, CSSPrimitiveValue::CSS_PERCENTAGE)->toLength(style.get(), style.get(), 1, NonNegativeValues));
+ create(-5, CSSPrimitiveValue::CSS_PX, -5, CSSPrimitiveValue::CSS_PERCENTAGE)->toLength(conversionDataZoom1, NonNegativeValues));
EXPECT_EQ(
Length(CalculationValue::create(
adoptPtr(new CalcExpressionBinaryOperation(
@@ -205,7 +210,7 @@ TEST_F(AnimationAnimatableLengthTest, ToLength)
adoptPtr(new CalcExpressionLength(Length(-5, Percent))),
CalcAdd)),
ValueRangeNonNegative)),
- create(-5, CSSPrimitiveValue::CSS_PX, -5, CSSPrimitiveValue::CSS_PERCENTAGE)->toLength(style.get(), style.get(), 3, NonNegativeValues));
+ create(-5, CSSPrimitiveValue::CSS_PX, -5, CSSPrimitiveValue::CSS_PERCENTAGE)->toLength(conversionDataZoom3, NonNegativeValues));
}
TEST_F(AnimationAnimatableLengthTest, Interpolate)

Powered by Google App Engine
This is Rietveld 408576698