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

Side by Side 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 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/cssom/FilteredComputedStylePropertyMap.h"
6
7 #include "core/css/CSSComputedStyleDeclaration.h"
8 #include "core/testing/DummyPageHolder.h"
9 #include "platform/heap/Handle.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace blink {
13
14 class FilteredComputedStylePropertyMapTest : public ::testing::Test {
15 public:
16 FilteredComputedStylePropertyMapTest()
17 : m_page(DummyPageHolder::create())
18 {
19 m_declaration = CSSComputedStyleDeclaration::create(m_page->document().d ocumentElement());
20 }
21
22 CSSComputedStyleDeclaration* declaration() const { return m_declaration.get( ); }
23
24 private:
25 OwnPtr<DummyPageHolder> m_page;
26 Persistent<CSSComputedStyleDeclaration> m_declaration;
27 };
28
29 TEST_F(FilteredComputedStylePropertyMapTest, GetProperties)
30 {
31 Vector<CSSPropertyID> nativeProperties({CSSPropertyColor, CSSPropertyAlignIt ems});
32 Vector<CSSPropertyID> emptyNativeProperties;
33 Vector<AtomicString> customProperties({"--foo", "--bar"});
34 Vector<AtomicString> emptyCustomProperties;
35
36 Persistent<FilteredComputedStylePropertyMap> map = FilteredComputedStyleProp ertyMap::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.
37 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.
38 ASSERT_TRUE(map->getProperties().contains("align-items"));
39 ASSERT_TRUE(map->getProperties().contains("--foo"));
40 ASSERT_TRUE(map->getProperties().contains("--bar"));
41
42 map = FilteredComputedStylePropertyMap::create(declaration(), nativeProperti es, emptyCustomProperties);
43 ASSERT_TRUE(map->getProperties().contains("color"));
44 ASSERT_TRUE(map->getProperties().contains("align-items"));
45
46 map = FilteredComputedStylePropertyMap::create(declaration(), emptyNativePro perties, customProperties);
47 ASSERT_TRUE(map->getProperties().contains("--foo"));
48 ASSERT_TRUE(map->getProperties().contains("--bar"));
49 }
50
51 TEST_F(FilteredComputedStylePropertyMapTest, NativePropertyAccessors)
52 {
53 Vector<CSSPropertyID> nativeProperties({CSSPropertyColor, CSSPropertyAlignIt ems});
54 Vector<AtomicString> emptyCustomProperties;
55 Persistent<FilteredComputedStylePropertyMap> map = FilteredComputedStyleProp ertyMap::create(declaration(), nativeProperties, emptyCustomProperties);
56
57 TrackExceptionState exceptionState;
58
59 map->get("color", exceptionState);
60 ASSERT_FALSE(exceptionState.hadException());
61
62 map->has("color", exceptionState);
63 ASSERT_FALSE(exceptionState.hadException());
64
65 map->getAll("color", exceptionState);
66 ASSERT_FALSE(exceptionState.hadException());
67
68 map->get("align-contents", exceptionState);
69 ASSERT_TRUE(exceptionState.hadException());
70 exceptionState.clearException();
71
72 map->has("align-contents", exceptionState);
73 ASSERT_TRUE(exceptionState.hadException());
74 exceptionState.clearException();
75
76 map->getAll("align-contents", exceptionState);
77 ASSERT_TRUE(exceptionState.hadException());
78 exceptionState.clearException();
79 }
80
81 TEST_F(FilteredComputedStylePropertyMapTest, CustomPropertyAccessors)
82 {
83 Vector<CSSPropertyID> emptyNativeProperties;
84 Vector<AtomicString> customProperties({"--foo", "--bar"});
85 Persistent<FilteredComputedStylePropertyMap> map = FilteredComputedStyleProp ertyMap::create(declaration(), emptyNativeProperties, customProperties);
86
87 TrackExceptionState exceptionState;
88
89 map->get("--foo", exceptionState);
90 ASSERT_FALSE(exceptionState.hadException());
91
92 map->has("--foo", exceptionState);
93 ASSERT_FALSE(exceptionState.hadException());
94
95 map->getAll("--foo", exceptionState);
96 ASSERT_FALSE(exceptionState.hadException());
97
98 map->get("--quix", exceptionState);
99 ASSERT_TRUE(exceptionState.hadException());
100 exceptionState.clearException();
101
102 map->has("--quix", exceptionState);
103 ASSERT_TRUE(exceptionState.hadException());
104 exceptionState.clearException();
105
106 map->getAll("--quix", exceptionState);
107 ASSERT_TRUE(exceptionState.hadException());
108 exceptionState.clearException();
109 }
110
111 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698