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

Unified Diff: third_party/WebKit/Source/core/css/cssom/FilteredComputedStylePropertyMapTest.cpp

Issue 2054633002: [Typed OM] Implement FilteredComputedStylePropertyMap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/cssom/FilteredComputedStylePropertyMapTest.cpp
diff --git a/third_party/WebKit/Source/core/css/cssom/FilteredComputedStylePropertyMapTest.cpp b/third_party/WebKit/Source/core/css/cssom/FilteredComputedStylePropertyMapTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e4fc66ee6ee9090f962e0e07dc407f242327c434
--- /dev/null
+++ b/third_party/WebKit/Source/core/css/cssom/FilteredComputedStylePropertyMapTest.cpp
@@ -0,0 +1,111 @@
+// 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/cssom/FilteredComputedStylePropertyMap.h"
+
+#include "core/css/CSSComputedStyleDeclaration.h"
+#include "core/testing/DummyPageHolder.h"
+#include "platform/heap/Handle.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+
+class FilteredComputedStylePropertyMapTest : public ::testing::Test {
+public:
+ FilteredComputedStylePropertyMapTest()
+ : m_page(DummyPageHolder::create())
+ {
+ m_declaration = CSSComputedStyleDeclaration::create(m_page->document().documentElement());
+ }
+
+ CSSComputedStyleDeclaration* declaration() const { return m_declaration.get(); }
+
+private:
+ OwnPtr<DummyPageHolder> m_page;
+ Persistent<CSSComputedStyleDeclaration> m_declaration;
+};
+
+TEST_F(FilteredComputedStylePropertyMapTest, GetProperties)
+{
+ Vector<CSSPropertyID> nativeProperties({CSSPropertyColor, CSSPropertyAlignItems});
+ Vector<CSSPropertyID> emptyNativeProperties;
+ Vector<AtomicString> customProperties({"--foo", "--bar"});
+ Vector<AtomicString> emptyCustomProperties;
+
+ Persistent<FilteredComputedStylePropertyMap> map = FilteredComputedStylePropertyMap::create(declaration(), nativeProperties, customProperties);
Timothy Loh 2016/06/09 07:53:37 Filter..Map* instead of Persistent<..>
ikilpatrick 2016/06/09 17:36:48 Done.
+ ASSERT_TRUE(map->getProperties().contains("color"));
Timothy Loh 2016/06/09 07:53:37 ASSERT->EXPECT everywhere. I think gtest style is
ikilpatrick 2016/06/09 17:36:48 Done.
+ ASSERT_TRUE(map->getProperties().contains("align-items"));
+ ASSERT_TRUE(map->getProperties().contains("--foo"));
+ ASSERT_TRUE(map->getProperties().contains("--bar"));
+
+ map = FilteredComputedStylePropertyMap::create(declaration(), nativeProperties, emptyCustomProperties);
+ ASSERT_TRUE(map->getProperties().contains("color"));
+ ASSERT_TRUE(map->getProperties().contains("align-items"));
+
+ map = FilteredComputedStylePropertyMap::create(declaration(), emptyNativeProperties, customProperties);
+ ASSERT_TRUE(map->getProperties().contains("--foo"));
+ ASSERT_TRUE(map->getProperties().contains("--bar"));
+}
+
+TEST_F(FilteredComputedStylePropertyMapTest, NativePropertyAccessors)
+{
+ Vector<CSSPropertyID> nativeProperties({CSSPropertyColor, CSSPropertyAlignItems});
+ Vector<AtomicString> emptyCustomProperties;
+ Persistent<FilteredComputedStylePropertyMap> map = FilteredComputedStylePropertyMap::create(declaration(), nativeProperties, emptyCustomProperties);
+
+ TrackExceptionState exceptionState;
+
+ map->get("color", exceptionState);
+ ASSERT_FALSE(exceptionState.hadException());
+
+ map->has("color", exceptionState);
+ ASSERT_FALSE(exceptionState.hadException());
+
+ map->getAll("color", exceptionState);
+ ASSERT_FALSE(exceptionState.hadException());
+
+ map->get("align-contents", exceptionState);
+ ASSERT_TRUE(exceptionState.hadException());
+ exceptionState.clearException();
+
+ map->has("align-contents", exceptionState);
+ ASSERT_TRUE(exceptionState.hadException());
+ exceptionState.clearException();
+
+ map->getAll("align-contents", exceptionState);
+ ASSERT_TRUE(exceptionState.hadException());
+ exceptionState.clearException();
+}
+
+TEST_F(FilteredComputedStylePropertyMapTest, CustomPropertyAccessors)
+{
+ Vector<CSSPropertyID> emptyNativeProperties;
+ Vector<AtomicString> customProperties({"--foo", "--bar"});
+ Persistent<FilteredComputedStylePropertyMap> map = FilteredComputedStylePropertyMap::create(declaration(), emptyNativeProperties, customProperties);
+
+ TrackExceptionState exceptionState;
+
+ map->get("--foo", exceptionState);
+ ASSERT_FALSE(exceptionState.hadException());
+
+ map->has("--foo", exceptionState);
+ ASSERT_FALSE(exceptionState.hadException());
+
+ map->getAll("--foo", exceptionState);
+ ASSERT_FALSE(exceptionState.hadException());
+
+ map->get("--quix", exceptionState);
+ ASSERT_TRUE(exceptionState.hadException());
+ exceptionState.clearException();
+
+ map->has("--quix", exceptionState);
+ ASSERT_TRUE(exceptionState.hadException());
+ exceptionState.clearException();
+
+ map->getAll("--quix", exceptionState);
+ ASSERT_TRUE(exceptionState.hadException());
+ exceptionState.clearException();
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698