| 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 CSSValue* value = CSSParserFastPaths::maybeParseValue( | 14 CSSValue* value = CSSParserFastPaths::maybeParseValue( |
| 15 CSSPropertyFloat, "left", HTMLStandardMode); | 15 CSSPropertyFloat, "left", 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", | 20 value = CSSParserFastPaths::maybeParseValue(CSSPropertyFloat, "foo", |
| 22 HTMLStandardMode); | 21 HTMLStandardMode); |
| 23 ASSERT_EQ(nullptr, value); | 22 ASSERT_EQ(nullptr, value); |
| 24 } | 23 } |
| 25 TEST(CSSParserFastPathsTest, ParseInitialAndInheritKeyword) { | 24 TEST(CSSParserFastPathsTest, ParseInitialAndInheritKeyword) { |
| 26 CSSValue* value = CSSParserFastPaths::maybeParseValue( | 25 CSSValue* value = CSSParserFastPaths::maybeParseValue( |
| 27 CSSPropertyMarginTop, "inherit", HTMLStandardMode); | 26 CSSPropertyMarginTop, "inherit", HTMLStandardMode); |
| 28 ASSERT_NE(nullptr, value); | 27 ASSERT_NE(nullptr, value); |
| 29 EXPECT_TRUE(value->isInheritedValue()); | 28 EXPECT_TRUE(value->isInheritedValue()); |
| 30 value = CSSParserFastPaths::maybeParseValue(CSSPropertyMarginRight, "InHeriT", | 29 value = CSSParserFastPaths::maybeParseValue(CSSPropertyMarginRight, "InHeriT", |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 CSSValue* value = CSSParserFastPaths::maybeParseValue( | 92 CSSValue* value = CSSParserFastPaths::maybeParseValue( |
| 94 CSSPropertyTransform, "rotateX(1deg", HTMLStandardMode); | 93 CSSPropertyTransform, "rotateX(1deg", HTMLStandardMode); |
| 95 ASSERT_EQ(nullptr, value); | 94 ASSERT_EQ(nullptr, value); |
| 96 value = CSSParserFastPaths::maybeParseValue( | 95 value = CSSParserFastPaths::maybeParseValue( |
| 97 CSSPropertyTransform, "translateZ(1px) (1px, 1px) rotateX(1deg", | 96 CSSPropertyTransform, "translateZ(1px) (1px, 1px) rotateX(1deg", |
| 98 HTMLStandardMode); | 97 HTMLStandardMode); |
| 99 ASSERT_EQ(nullptr, value); | 98 ASSERT_EQ(nullptr, value); |
| 100 } | 99 } |
| 101 | 100 |
| 102 } // namespace blink | 101 } // namespace blink |
| OLD | NEW |