| Index: third_party/WebKit/Source/core/css/parser/CSSParserFastPathsTest.cpp
|
| diff --git a/third_party/WebKit/Source/core/css/parser/CSSParserFastPathsTest.cpp b/third_party/WebKit/Source/core/css/parser/CSSParserFastPathsTest.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5e30abe85209123d176077892cedb16b70eab677
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/core/css/parser/CSSParserFastPathsTest.cpp
|
| @@ -0,0 +1,55 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "core/css/parser/CSSParserFastPaths.h"
|
| +
|
| +#include "core/css/CSSPrimitiveValue.h"
|
| +#include "core/css/CSSValueList.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace blink {
|
| +
|
| +TEST(CSSParserFastPathsTest, ParseTransform)
|
| +{
|
| + CSSValue* value = CSSParserFastPaths::maybeParseValue(CSSPropertyTransform, "translate(5.5px, 5px)", HTMLStandardMode);
|
| + ASSERT_NE(nullptr, value);
|
| + ASSERT_TRUE(value->isValueList());
|
| + ASSERT_EQ("translate(5.5px, 5px)", value->cssText());
|
| +
|
| + value = CSSParserFastPaths::maybeParseValue(CSSPropertyTransform, "translate3d(5px, 5px, 10.1px)", HTMLStandardMode);
|
| + ASSERT_NE(nullptr, value);
|
| + ASSERT_TRUE(value->isValueList());
|
| + ASSERT_EQ("translate3d(5px, 5px, 10.1px)", value->cssText());
|
| +}
|
| +
|
| +TEST(CSSParserFastPathsTest, ParseComplexTransform)
|
| +{
|
| + // Random whitespace is on purpose.
|
| + static const char* kComplexTransform =
|
| + "translateX(5px) "
|
| + "translateZ(20.5px) "
|
| + "translateY(10px) "
|
| + "scale3d(0.5, 1, 0.7) "
|
| + "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) ";
|
| + static const char* kComplexTransformNormalized =
|
| + "translateX(5px) "
|
| + "translateZ(20.5px) "
|
| + "translateY(10px) "
|
| + "scale3d(0.5, 1, 0.7) "
|
| + "matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)";
|
| + CSSValue* value = CSSParserFastPaths::maybeParseValue(CSSPropertyTransform, kComplexTransform, HTMLStandardMode);
|
| + ASSERT_NE(nullptr, value);
|
| + ASSERT_TRUE(value->isValueList());
|
| + ASSERT_EQ(kComplexTransformNormalized, value->cssText());
|
| +}
|
| +
|
| +TEST(CSSParserFastPathsTest, ParseTransformNotFastPath)
|
| +{
|
| + CSSValue* value = CSSParserFastPaths::maybeParseValue(CSSPropertyTransform, "rotateX(1deg)", HTMLStandardMode);
|
| + ASSERT_EQ(nullptr, value);
|
| + value = CSSParserFastPaths::maybeParseValue(CSSPropertyTransform, "translateZ(1px) rotateX(1deg)", HTMLStandardMode);
|
| + ASSERT_EQ(nullptr, value);
|
| +}
|
| +
|
| +} // namespace blink
|
|
|