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

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

Issue 1858753003: Remove RawPtr from core/css (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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/SizesCalcParser.h" 5 #include "core/css/parser/SizesCalcParser.h"
6 6
7 #include "core/MediaTypeNames.h" 7 #include "core/MediaTypeNames.h"
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/parser/CSSParser.h" 10 #include "core/css/parser/CSSParser.h"
(...skipping 13 matching lines...) Expand all
24 { 24 {
25 lengthArray.resize(CSSPrimitiveValue::LengthUnitTypeCount); 25 lengthArray.resize(CSSPrimitiveValue::LengthUnitTypeCount);
26 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; ++i) 26 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; ++i)
27 lengthArray.at(i) = 0; 27 lengthArray.at(i) = 0;
28 } 28 }
29 29
30 static void verifyCSSCalc(String text, double value, bool valid, unsigned fontSi ze, unsigned viewportWidth, unsigned viewportHeight) 30 static void verifyCSSCalc(String text, double value, bool valid, unsigned fontSi ze, unsigned viewportWidth, unsigned viewportHeight)
31 { 31 {
32 CSSLengthArray lengthArray; 32 CSSLengthArray lengthArray;
33 initLengthArray(lengthArray); 33 initLengthArray(lengthArray);
34 RawPtr<CSSValue> cssValue = CSSParser::parseSingleValue(CSSPropertyLeft, tex t); 34 CSSValue* cssValue = CSSParser::parseSingleValue(CSSPropertyLeft, text);
35 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(cssValue.get()); 35 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(cssValue);
36 if (primitiveValue) 36 if (primitiveValue)
37 primitiveValue->accumulateLengthArray(lengthArray); 37 primitiveValue->accumulateLengthArray(lengthArray);
38 else 38 else
39 ASSERT_EQ(valid, false); 39 ASSERT_EQ(valid, false);
40 float length = lengthArray.at(CSSPrimitiveValue::UnitTypePixels); 40 float length = lengthArray.at(CSSPrimitiveValue::UnitTypePixels);
41 length += lengthArray.at(CSSPrimitiveValue::UnitTypeFontSize) * fontSize; 41 length += lengthArray.at(CSSPrimitiveValue::UnitTypeFontSize) * fontSize;
42 length += lengthArray.at(CSSPrimitiveValue::UnitTypeViewportWidth) * viewpor tWidth / 100.0; 42 length += lengthArray.at(CSSPrimitiveValue::UnitTypeViewportWidth) * viewpor tWidth / 100.0;
43 length += lengthArray.at(CSSPrimitiveValue::UnitTypeViewportHeight) * viewpo rtHeight / 100.0; 43 length += lengthArray.at(CSSPrimitiveValue::UnitTypeViewportHeight) * viewpo rtHeight / 100.0;
44 ASSERT_EQ(value, length); 44 ASSERT_EQ(value, length);
45 } 45 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 data.deviceHeight = 643; 105 data.deviceHeight = 643;
106 data.devicePixelRatio = 2.0; 106 data.devicePixelRatio = 2.0;
107 data.colorBitsPerComponent = 24; 107 data.colorBitsPerComponent = 24;
108 data.monochromeBitsPerComponent = 0; 108 data.monochromeBitsPerComponent = 0;
109 data.primaryPointerType = PointerTypeFine; 109 data.primaryPointerType = PointerTypeFine;
110 data.defaultFontSize = 16; 110 data.defaultFontSize = 16;
111 data.threeDEnabled = true; 111 data.threeDEnabled = true;
112 data.mediaType = MediaTypeNames::screen; 112 data.mediaType = MediaTypeNames::screen;
113 data.strictMode = true; 113 data.strictMode = true;
114 data.displayMode = WebDisplayModeBrowser; 114 data.displayMode = WebDisplayModeBrowser;
115 RawPtr<MediaValues> mediaValues = MediaValuesCached::create(data); 115 MediaValues* mediaValues = MediaValuesCached::create(data);
116 116
117 for (unsigned i = 0; testCases[i].input; ++i) { 117 for (unsigned i = 0; testCases[i].input; ++i) {
118 SizesCalcParser calcParser(CSSTokenizer::Scope(testCases[i].input).token Range(), mediaValues); 118 SizesCalcParser calcParser(CSSTokenizer::Scope(testCases[i].input).token Range(), mediaValues);
119 ASSERT_EQ(testCases[i].valid, calcParser.isValid()); 119 ASSERT_EQ(testCases[i].valid, calcParser.isValid());
120 if (calcParser.isValid()) 120 if (calcParser.isValid())
121 ASSERT_EQ(testCases[i].output, calcParser.result()); 121 ASSERT_EQ(testCases[i].output, calcParser.result());
122 } 122 }
123 123
124 for (unsigned i = 0; testCases[i].input; ++i) { 124 for (unsigned i = 0; testCases[i].input; ++i) {
125 if (testCases[i].dontRunInCSSCalc) 125 if (testCases[i].dontRunInCSSCalc)
126 continue; 126 continue;
127 verifyCSSCalc(testCases[i].input, testCases[i].output, testCases[i].vali d, data.defaultFontSize, data.viewportWidth, data.viewportHeight); 127 verifyCSSCalc(testCases[i].input, testCases[i].output, testCases[i].vali d, data.defaultFontSize, data.viewportWidth, data.viewportHeight);
128 } 128 }
129 } 129 }
130 130
131 } // namespace blink 131 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698