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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/parser/CSSParserTokenTest.cpp
diff --git a/third_party/WebKit/Source/core/css/parser/CSSParserTokenTest.cpp b/third_party/WebKit/Source/core/css/parser/CSSParserTokenTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e9204e1b88bedfdf3b99934d924e9379708e3322
--- /dev/null
+++ b/third_party/WebKit/Source/core/css/parser/CSSParserTokenTest.cpp
@@ -0,0 +1,51 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/css/parser/CSSParserToken.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+
+static CSSParserString toParserString(const String& string)
+{
+ CSSParserString result;
+ 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.
+ return result;
+}
+
+static CSSParserToken ident(const String& string) { return CSSParserToken(IdentToken, toParserString(string)); }
+static CSSParserToken dimension(double value, const String& unit)
+{
+ CSSParserToken token(NumberToken, value, NumberValueType, NoSign);
+ token.convertToDimensionWithUnit(toParserString(unit));
+ return token;
+}
+
+TEST(CSSParserTokenTest, IdentTokenEquality)
+{
+ String foo8Bit("foo");
+ String bar8Bit("bar");
+ String foo16Bit = String::make16BitFrom8BitSource(foo8Bit.characters8(), foo8Bit.length());
+
+ EXPECT_EQ(ident(foo8Bit), ident(foo16Bit));
+ EXPECT_EQ(ident(foo16Bit), ident(foo8Bit));
+ EXPECT_EQ(ident(foo16Bit), ident(foo16Bit));
+ EXPECT_NE(ident(bar8Bit), ident(foo8Bit));
+ EXPECT_NE(ident(bar8Bit), ident(foo16Bit));
+}
+
+TEST(CSSParserTokenTest, DimensionTokenEquality)
+{
+ String em8Bit("em");
+ String rem8Bit("rem");
+ String em16Bit = String::make16BitFrom8BitSource(em8Bit.characters8(), em8Bit.length());
+
+ EXPECT_EQ(dimension(1, em8Bit), dimension(1, em16Bit));
+ EXPECT_EQ(dimension(1, em8Bit), dimension(1, em8Bit));
+ EXPECT_NE(dimension(1, em8Bit), dimension(1, rem8Bit));
+ EXPECT_NE(dimension(2, em8Bit), dimension(1, em16Bit));
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698