OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/css/parser/CSSParserFastPaths.h" | 5 #include "core/css/parser/CSSParserFastPaths.h" |
6 | 6 |
7 #include "core/css/CSSPrimitiveValue.h" | 7 #include "core/css/CSSIdentifierValue.h" |
8 #include "core/css/CSSValueList.h" | 8 #include "core/css/CSSValueList.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 TEST(CSSParserFastPathsTest, ParseKeyword) | 13 TEST(CSSParserFastPathsTest, ParseKeyword) |
14 { | 14 { |
15 CSSValue* value = CSSParserFastPaths::maybeParseValue(CSSPropertyFloat, "lef
t", HTMLStandardMode); | 15 CSSValue* value = CSSParserFastPaths::maybeParseValue(CSSPropertyFloat, "lef
t", HTMLStandardMode); |
16 ASSERT_NE(nullptr, value); | 16 ASSERT_NE(nullptr, value); |
17 EXPECT_TRUE(value->isPrimitiveValue()); | 17 EXPECT_TRUE(value->isIdentifierValue()); |
18 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 18 CSSIdentifierValue* identifierValue = toCSSIdentifierValue(value); |
19 EXPECT_TRUE(primitiveValue->isValueID()); | 19 EXPECT_EQ(CSSValueLeft, identifierValue->getValueID()); |
20 EXPECT_EQ(CSSValueLeft, primitiveValue->getValueID()); | |
21 value = CSSParserFastPaths::maybeParseValue(CSSPropertyFloat, "foo", HTMLSta
ndardMode); | 20 value = CSSParserFastPaths::maybeParseValue(CSSPropertyFloat, "foo", HTMLSta
ndardMode); |
22 ASSERT_EQ(nullptr, value); | 21 ASSERT_EQ(nullptr, value); |
23 } | 22 } |
24 TEST(CSSParserFastPathsTest, ParseInitialAndInheritKeyword) | 23 TEST(CSSParserFastPathsTest, ParseInitialAndInheritKeyword) |
25 { | 24 { |
26 CSSValue* value = CSSParserFastPaths::maybeParseValue(CSSPropertyMarginTop,
"inherit", HTMLStandardMode); | 25 CSSValue* value = CSSParserFastPaths::maybeParseValue(CSSPropertyMarginTop,
"inherit", HTMLStandardMode); |
27 ASSERT_NE(nullptr, value); | 26 ASSERT_NE(nullptr, value); |
28 EXPECT_TRUE(value->isInheritedValue()); | 27 EXPECT_TRUE(value->isInheritedValue()); |
29 value = CSSParserFastPaths::maybeParseValue(CSSPropertyMarginRight, "InHeriT
", HTMLStandardMode); | 28 value = CSSParserFastPaths::maybeParseValue(CSSPropertyMarginRight, "InHeriT
", HTMLStandardMode); |
30 ASSERT_NE(nullptr, value); | 29 ASSERT_NE(nullptr, value); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 83 |
85 TEST(CSSParserFastPathsTest, ParseInvalidTransform) | 84 TEST(CSSParserFastPathsTest, ParseInvalidTransform) |
86 { | 85 { |
87 CSSValue* value = CSSParserFastPaths::maybeParseValue(CSSPropertyTransform,
"rotateX(1deg", HTMLStandardMode); | 86 CSSValue* value = CSSParserFastPaths::maybeParseValue(CSSPropertyTransform,
"rotateX(1deg", HTMLStandardMode); |
88 ASSERT_EQ(nullptr, value); | 87 ASSERT_EQ(nullptr, value); |
89 value = CSSParserFastPaths::maybeParseValue(CSSPropertyTransform, "translate
Z(1px) (1px, 1px) rotateX(1deg", HTMLStandardMode); | 88 value = CSSParserFastPaths::maybeParseValue(CSSPropertyTransform, "translate
Z(1px) (1px, 1px) rotateX(1deg", HTMLStandardMode); |
90 ASSERT_EQ(nullptr, value); | 89 ASSERT_EQ(nullptr, value); |
91 } | 90 } |
92 | 91 |
93 } // namespace blink | 92 } // namespace blink |
OLD | NEW |