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

Side by Side Diff: third_party/WebKit/Source/core/css/parser/CSSPropertyParserTest.cpp

Issue 2546993002: [css-grid] Fix crash clamping grid lines (Closed)
Patch Set: Use clampTo() Created 4 years 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "core/css/parser/CSSPropertyParser.h" 5 #include "core/css/parser/CSSPropertyParser.h"
6 6
7 #include "core/css/CSSValueList.h" 7 #include "core/css/CSSValueList.h"
8 #include "core/css/parser/CSSParser.h" 8 #include "core/css/parser/CSSParser.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 TEST(CSSPropertyParserTest, GridTrackLimit16) { 150 TEST(CSSPropertyParserTest, GridTrackLimit16) {
151 const CSSValue* value = CSSParser::parseSingleValue( 151 const CSSValue* value = CSSParser::parseSingleValue(
152 CSSPropertyGridTemplateRows, 152 CSSPropertyGridTemplateRows,
153 "repeat(100000000000000000000, 10% 5em 1fr auto auto 15px min-content)"); 153 "repeat(100000000000000000000, 10% 5em 1fr auto auto 15px min-content)");
154 ASSERT_TRUE(value); 154 ASSERT_TRUE(value);
155 ASSERT_TRUE(value->isValueList()); 155 ASSERT_TRUE(value->isValueList());
156 EXPECT_EQ(computeNumberOfTracks(toCSSValueList(value)), 999999); 156 EXPECT_EQ(computeNumberOfTracks(toCSSValueList(value)), 999999);
157 } 157 }
158 158
159 static int getGridPositionInteger(const CSSValue& value) {
160 DCHECK(value.isValueList());
161 const auto& list = toCSSValueList(value);
162 DCHECK_EQ(list.length(), static_cast<size_t>(1));
163 const auto& primitiveValue = toCSSPrimitiveValue(list.item(0));
164 DCHECK(primitiveValue.isNumber());
165 return primitiveValue.getIntValue();
166 }
167
168 TEST(CSSPropertyParserTest, GridPositionLimit1) {
169 const CSSValue* value =
170 CSSParser::parseSingleValue(CSSPropertyGridColumnStart, "999999");
171 DCHECK(value);
172 EXPECT_EQ(getGridPositionInteger(*value), 999999);
173 }
174
175 TEST(CSSPropertyParserTest, GridPositionLimit2) {
176 const CSSValue* value =
177 CSSParser::parseSingleValue(CSSPropertyGridColumnEnd, "1000000");
178 DCHECK(value);
179 EXPECT_EQ(getGridPositionInteger(*value), 1000000);
180 }
181
182 TEST(CSSPropertyParserTest, GridPositionLimit3) {
183 const CSSValue* value =
184 CSSParser::parseSingleValue(CSSPropertyGridRowStart, "1000001");
185 DCHECK(value);
186 EXPECT_EQ(getGridPositionInteger(*value), 1000000);
187 }
188
189 TEST(CSSPropertyParserTest, GridPositionLimit4) {
190 const CSSValue* value =
191 CSSParser::parseSingleValue(CSSPropertyGridRowEnd, "5000000000");
192 DCHECK(value);
193 EXPECT_EQ(getGridPositionInteger(*value), 1000000);
194 }
195
196 TEST(CSSPropertyParserTest, GridPositionLimit5) {
197 const CSSValue* value =
198 CSSParser::parseSingleValue(CSSPropertyGridColumnStart, "-999999");
199 DCHECK(value);
200 EXPECT_EQ(getGridPositionInteger(*value), -999999);
201 }
202
203 TEST(CSSPropertyParserTest, GridPositionLimit6) {
204 const CSSValue* value =
205 CSSParser::parseSingleValue(CSSPropertyGridColumnEnd, "-1000000");
206 DCHECK(value);
207 EXPECT_EQ(getGridPositionInteger(*value), -1000000);
208 }
209
210 TEST(CSSPropertyParserTest, GridPositionLimit7) {
211 const CSSValue* value =
212 CSSParser::parseSingleValue(CSSPropertyGridRowStart, "-1000001");
213 DCHECK(value);
214 EXPECT_EQ(getGridPositionInteger(*value), -1000000);
215 }
216
217 TEST(CSSPropertyParserTest, GridPositionLimit8) {
218 const CSSValue* value =
219 CSSParser::parseSingleValue(CSSPropertyGridRowEnd, "-5000000000");
220 DCHECK(value);
221 EXPECT_EQ(getGridPositionInteger(*value), -1000000);
222 }
223
159 } // namespace blink 224 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698