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

Side by Side Diff: Source/core/css/parser/SizesCalcParserTest.cpp

Issue 273683005: Web Animations API: Deferred computation of interpolated values (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add missing test file Created 6 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/CSSPrimitiveValue.cpp ('k') | Source/core/css/resolver/StyleResolver.h » ('j') | 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 "config.h" 5 #include "config.h"
6 #include "core/css/parser/SizesCalcParser.h" 6 #include "core/css/parser/SizesCalcParser.h"
7 7
8 #include "core/css/CSSPrimitiveValue.h" 8 #include "core/css/CSSPrimitiveValue.h"
9 #include "core/css/MediaValuesCached.h" 9 #include "core/css/MediaValuesCached.h"
10 #include "core/css/StylePropertySet.h" 10 #include "core/css/StylePropertySet.h"
11 #include "core/css/parser/MediaQueryTokenizer.h" 11 #include "core/css/parser/MediaQueryTokenizer.h"
12 12
13 #include <gtest/gtest.h> 13 #include <gtest/gtest.h>
14 14
15 namespace WebCore { 15 namespace WebCore {
16 16
17 struct TestCase { 17 struct TestCase {
18 const char* input; 18 const char* input;
19 const unsigned output; 19 const unsigned output;
20 const bool valid; 20 const bool valid;
21 const bool dontRunInCSSCalc; 21 const bool dontRunInCSSCalc;
22 }; 22 };
23 23
24 static void initLengthArray(CSSLengthArray& lengthArray)
25 {
26 lengthArray.resize(CSSPrimitiveValue::LengthUnitTypeCount);
27 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; ++i)
28 lengthArray.at(i) = 0;
29 }
30
31 static void verifyCSSCalc(String text, double value, bool valid, unsigned fontSi ze, unsigned viewportWidth, unsigned viewportHeight) 24 static void verifyCSSCalc(String text, double value, bool valid, unsigned fontSi ze, unsigned viewportWidth, unsigned viewportHeight)
32 { 25 {
33 CSSLengthArray lengthArray; 26 CSSLengthArray lengthArray;
34 initLengthArray(lengthArray); 27 CSSPrimitiveValue::zeroLengthArray(lengthArray);
35 RefPtr<MutableStylePropertySet> propertySet = MutableStylePropertySet::creat e(); 28 RefPtr<MutableStylePropertySet> propertySet = MutableStylePropertySet::creat e();
36 propertySet->setProperty(CSSPropertyLeft, text); 29 propertySet->setProperty(CSSPropertyLeft, text);
37 RefPtrWillBeRawPtr<CSSValue> cssValue = propertySet->getPropertyCSSValue(CSS PropertyLeft); 30 RefPtrWillBeRawPtr<CSSValue> cssValue = propertySet->getPropertyCSSValue(CSS PropertyLeft);
38 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(cssValue.get()); 31 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(cssValue.get());
39 if (primitiveValue) 32 if (primitiveValue)
40 primitiveValue->accumulateLengthArray(lengthArray); 33 primitiveValue->accumulateLengthArray(lengthArray);
41 else 34 else
42 ASSERT_EQ(valid, false); 35 ASSERT_EQ(valid, false);
43 int length = lengthArray.at(CSSPrimitiveValue::UnitTypePixels); 36 int length = lengthArray.at(CSSPrimitiveValue::UnitTypePixels);
44 length += lengthArray.at(CSSPrimitiveValue::UnitTypeFontSize) * fontSize; 37 length += lengthArray.at(CSSPrimitiveValue::UnitTypeFontSize) * fontSize;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } 120 }
128 121
129 for (unsigned i = 0; testCases[i].input; ++i) { 122 for (unsigned i = 0; testCases[i].input; ++i) {
130 if (testCases[i].dontRunInCSSCalc) 123 if (testCases[i].dontRunInCSSCalc)
131 continue; 124 continue;
132 verifyCSSCalc(testCases[i].input, testCases[i].output, testCases[i].vali d, data.defaultFontSize, data.viewportWidth, data.viewportHeight); 125 verifyCSSCalc(testCases[i].input, testCases[i].output, testCases[i].vali d, data.defaultFontSize, data.viewportWidth, data.viewportHeight);
133 } 126 }
134 } 127 }
135 128
136 } // namespace 129 } // namespace
OLDNEW
« no previous file with comments | « Source/core/css/CSSPrimitiveValue.cpp ('k') | Source/core/css/resolver/StyleResolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698