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

Unified Diff: third_party/WebKit/Source/core/dom/custom/CustomElementDescriptorTest.cpp

Issue 1996213002: Add a tuple of name, local name for hashing custom element definitions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bring patch to head. 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/custom/CustomElementDescriptorTest.cpp
diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElementDescriptorTest.cpp b/third_party/WebKit/Source/core/dom/custom/CustomElementDescriptorTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d077ad4f8f3e50a6cb64d0a18b650a7367815d12
--- /dev/null
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElementDescriptorTest.cpp
@@ -0,0 +1,43 @@
+// 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/dom/custom/CustomElementDescriptor.h"
+
+#include "core/dom/custom/CustomElementDescriptorHash.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "wtf/HashSet.h"
+#include "wtf/text/AtomicString.h"
+
+namespace blink {
+
+TEST(CustomElementDescriptorTest, equal)
+{
+ CustomElementDescriptor myTypeExtension("my-button", "button");
+ CustomElementDescriptor again("my-button", "button");
+ EXPECT_TRUE(myTypeExtension == again)
+ << "two descriptors with the same name and local name should be equal";
+}
+
+TEST(CustomElementDescriptorTest, notEqual)
+{
+ CustomElementDescriptor myTypeExtension("my-button", "button");
+ CustomElementDescriptor collidingNewType("my-button", "my-button");
+ EXPECT_FALSE(myTypeExtension == collidingNewType)
+ << "type extension should not be equal to a non-type extension";
+}
+
+TEST(CustomElementDescriptorTest, hashable)
+{
+ HashSet<CustomElementDescriptor> descriptors;
+ descriptors.add(CustomElementDescriptor("foo-bar", "foo-bar"));
+ EXPECT_TRUE(
+ descriptors.contains(CustomElementDescriptor("foo-bar", "foo-bar")))
+ << "the identical descriptor should be found in the hash set";
+ EXPECT_FALSE(descriptors.contains(CustomElementDescriptor(
+ "bad-poetry",
+ "blockquote")))
+ << "an unrelated descriptor should not be found in the hash set";
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698