OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "config.h" | 5 #include "config.h" |
6 #include "core/css/parser/CSSPropertyParser.h" | 6 #include "core/css/parser/CSSPropertyParser.h" |
7 | 7 |
8 #include "core/css/CSSValueList.h" | 8 #include "core/css/CSSValueList.h" |
9 #include "core/css/parser/CSSParser.h" | 9 #include "core/css/parser/CSSParser.h" |
10 | 10 |
11 #include <gtest/gtest.h> | 11 #include <gtest/gtest.h> |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 static unsigned computeNumberOfTracks(CSSValueList* valueList) | 15 static unsigned computeNumberOfTracks(CSSValueList* valueList) |
16 { | 16 { |
17 unsigned numberOfTracks = 0; | 17 unsigned numberOfTracks = 0; |
18 for (auto& value : *valueList) { | 18 for (auto& value : *valueList) { |
19 if (value->isGridLineNamesValue()) | 19 if (value.isGridLineNamesValue()) |
20 continue; | 20 continue; |
21 ++numberOfTracks; | 21 ++numberOfTracks; |
22 } | 22 } |
23 return numberOfTracks; | 23 return numberOfTracks; |
24 } | 24 } |
25 | 25 |
26 TEST(CSSPropertyParserTest, GridTrackLimits) | 26 TEST(CSSPropertyParserTest, GridTrackLimits) |
27 { | 27 { |
28 struct { | 28 struct { |
29 const CSSPropertyID propertyID; | 29 const CSSPropertyID propertyID; |
(...skipping 12 matching lines...) Expand all Loading... |
42 {CSSPropertyGridTemplateRows, "repeat(400000, 2em minmax(10px, max-conte
nt) 0.5fr)", 999999}, | 42 {CSSPropertyGridTemplateRows, "repeat(400000, 2em minmax(10px, max-conte
nt) 0.5fr)", 999999}, |
43 {CSSPropertyGridTemplateColumns, "repeat(600000, [first] 3vh 10% 2fr [na
v] 10px auto 1fr 6em [last])", 999999}, | 43 {CSSPropertyGridTemplateColumns, "repeat(600000, [first] 3vh 10% 2fr [na
v] 10px auto 1fr 6em [last])", 999999}, |
44 {CSSPropertyGridTemplateRows, "repeat(600000, [first] 3vh 10% 2fr [nav]
10px auto 1fr 6em [last])", 999999}, | 44 {CSSPropertyGridTemplateRows, "repeat(600000, [first] 3vh 10% 2fr [nav]
10px auto 1fr 6em [last])", 999999}, |
45 {CSSPropertyGridTemplateColumns, "repeat(100000000000000000000, 10% 1fr)
", 1000000}, | 45 {CSSPropertyGridTemplateColumns, "repeat(100000000000000000000, 10% 1fr)
", 1000000}, |
46 {CSSPropertyGridTemplateRows, "repeat(100000000000000000000, 10% 1fr)",
1000000}, | 46 {CSSPropertyGridTemplateRows, "repeat(100000000000000000000, 10% 1fr)",
1000000}, |
47 {CSSPropertyGridTemplateColumns, "repeat(100000000000000000000, 10% 5em
1fr auto auto 15px min-content)", 999999}, | 47 {CSSPropertyGridTemplateColumns, "repeat(100000000000000000000, 10% 5em
1fr auto auto 15px min-content)", 999999}, |
48 {CSSPropertyGridTemplateRows, "repeat(100000000000000000000, 10% 5em 1fr
auto auto 15px min-content)", 999999}, | 48 {CSSPropertyGridTemplateRows, "repeat(100000000000000000000, 10% 5em 1fr
auto auto 15px min-content)", 999999}, |
49 }; | 49 }; |
50 | 50 |
51 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(testCases); ++i) { | 51 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(testCases); ++i) { |
52 RefPtrWillBeRawPtr<CSSValue> value = CSSParser::parseSingleValue(testCas
es[i].propertyID, testCases[i].input); | 52 NullableCSSValue value = CSSParser::parseSingleValue(testCases[i].proper
tyID, testCases[i].input); |
53 ASSERT_TRUE(value); | 53 ASSERT_TRUE(value); |
54 ASSERT_TRUE(value->isValueList()); | 54 ASSERT_TRUE(value->isValueList()); |
55 EXPECT_EQ(computeNumberOfTracks(toCSSValueList(value.get())), testCases[
i].output); | 55 EXPECT_EQ(computeNumberOfTracks(toCSSValueList(value)), testCases[i].out
put); |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 } // namespace blink | 59 } // namespace blink |
OLD | NEW |