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

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

Issue 1896893004: Hook up style invalidation for CSS Paint API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@css-paint-register
Patch Set: Redo CSSParserToken::operator==() Created 4 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "core/css/parser/CSSParserToken.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace blink {
10
11 static CSSParserString toParserString(const String& string)
12 {
13 CSSParserString result;
14 result.init(string);
esprehn 2016/05/09 21:59:54 we should just add explicit constructors to CSSPar
ikilpatrick 2016/05/10 20:39:37 Acknowledged.
15 return result;
16 }
17
18 static CSSParserToken ident(const String& string) { return CSSParserToken(IdentT oken, toParserString(string)); }
19 static CSSParserToken dimension(double value, const String& unit)
20 {
21 CSSParserToken token(NumberToken, value, NumberValueType, NoSign);
22 token.convertToDimensionWithUnit(toParserString(unit));
23 return token;
24 }
25
26 TEST(CSSParserTokenTest, IdentTokenEquality)
27 {
28 String foo8Bit("foo");
29 String bar8Bit("bar");
30 String foo16Bit = String::make16BitFrom8BitSource(foo8Bit.characters8(), foo 8Bit.length());
31
32 EXPECT_EQ(ident(foo8Bit), ident(foo16Bit));
33 EXPECT_EQ(ident(foo16Bit), ident(foo8Bit));
34 EXPECT_EQ(ident(foo16Bit), ident(foo16Bit));
35 EXPECT_NE(ident(bar8Bit), ident(foo8Bit));
36 EXPECT_NE(ident(bar8Bit), ident(foo16Bit));
37 }
38
39 TEST(CSSParserTokenTest, DimensionTokenEquality)
40 {
41 String em8Bit("em");
42 String rem8Bit("rem");
43 String em16Bit = String::make16BitFrom8BitSource(em8Bit.characters8(), em8Bi t.length());
44
45 EXPECT_EQ(dimension(1, em8Bit), dimension(1, em16Bit));
46 EXPECT_EQ(dimension(1, em8Bit), dimension(1, em8Bit));
47 EXPECT_NE(dimension(1, em8Bit), dimension(1, rem8Bit));
48 EXPECT_NE(dimension(2, em8Bit), dimension(1, em16Bit));
49 }
50
51 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698