OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014, Google Inc. All rights reserved. | 2 * Copyright (c) 2014, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 AtomicString valueStr("content"); | 135 AtomicString valueStr("content"); |
136 ASSERT_EQ(valueStr, rules->at(0).selector().value()); | 136 ASSERT_EQ(valueStr, rules->at(0).selector().value()); |
137 } | 137 } |
138 | 138 |
139 TEST(RuleSetTest, findBestRuleSetAndAdd_Host) | 139 TEST(RuleSetTest, findBestRuleSetAndAdd_Host) |
140 { | 140 { |
141 CSSTestHelper helper; | 141 CSSTestHelper helper; |
142 | 142 |
143 helper.addCSSRules(":host { }"); | 143 helper.addCSSRules(":host { }"); |
144 RuleSet& ruleSet = helper.ruleSet(); | 144 RuleSet& ruleSet = helper.ruleSet(); |
145 const Vector<RuleData>* rules = ruleSet.shadowHostRules(); | 145 const WillBeHeapVector<RuleData>* rules = ruleSet.shadowHostRules(); |
146 ASSERT_EQ(1u, rules->size()); | 146 ASSERT_EQ(1u, rules->size()); |
147 } | 147 } |
148 | 148 |
149 TEST(RuleSetTest, findBestRuleSetAndAdd_HostWithId) | 149 TEST(RuleSetTest, findBestRuleSetAndAdd_HostWithId) |
150 { | 150 { |
151 CSSTestHelper helper; | 151 CSSTestHelper helper; |
152 | 152 |
153 helper.addCSSRules(":host(#x) { }"); | 153 helper.addCSSRules(":host(#x) { }"); |
154 RuleSet& ruleSet = helper.ruleSet(); | 154 RuleSet& ruleSet = helper.ruleSet(); |
155 const Vector<RuleData>* rules = ruleSet.shadowHostRules(); | 155 const WillBeHeapVector<RuleData>* rules = ruleSet.shadowHostRules(); |
156 ASSERT_EQ(1u, rules->size()); | 156 ASSERT_EQ(1u, rules->size()); |
157 } | 157 } |
158 | 158 |
159 TEST(RuleSetTest, findBestRuleSetAndAdd_HostContext) | 159 TEST(RuleSetTest, findBestRuleSetAndAdd_HostContext) |
160 { | 160 { |
161 CSSTestHelper helper; | 161 CSSTestHelper helper; |
162 | 162 |
163 helper.addCSSRules(":host-context(*) { }"); | 163 helper.addCSSRules(":host-context(*) { }"); |
164 RuleSet& ruleSet = helper.ruleSet(); | 164 RuleSet& ruleSet = helper.ruleSet(); |
165 const Vector<RuleData>* rules = ruleSet.shadowHostRules(); | 165 const WillBeHeapVector<RuleData>* rules = ruleSet.shadowHostRules(); |
166 ASSERT_EQ(1u, rules->size()); | 166 ASSERT_EQ(1u, rules->size()); |
167 } | 167 } |
168 | 168 |
169 TEST(RuleSetTest, findBestRuleSetAndAdd_HostContextWithId) | 169 TEST(RuleSetTest, findBestRuleSetAndAdd_HostContextWithId) |
170 { | 170 { |
171 CSSTestHelper helper; | 171 CSSTestHelper helper; |
172 | 172 |
173 helper.addCSSRules(":host-context(#x) { }"); | 173 helper.addCSSRules(":host-context(#x) { }"); |
174 RuleSet& ruleSet = helper.ruleSet(); | 174 RuleSet& ruleSet = helper.ruleSet(); |
175 const Vector<RuleData>* rules = ruleSet.shadowHostRules(); | 175 const WillBeHeapVector<RuleData>* rules = ruleSet.shadowHostRules(); |
176 ASSERT_EQ(1u, rules->size()); | 176 ASSERT_EQ(1u, rules->size()); |
177 } | 177 } |
178 | 178 |
179 TEST(RuleSetTest, findBestRuleSetAndAdd_HostAndHostContextNotInRightmost) | 179 TEST(RuleSetTest, findBestRuleSetAndAdd_HostAndHostContextNotInRightmost) |
180 { | 180 { |
181 CSSTestHelper helper; | 181 CSSTestHelper helper; |
182 | 182 |
183 helper.addCSSRules(":host-context(#x) .y, :host(.a) > #b { }"); | 183 helper.addCSSRules(":host-context(#x) .y, :host(.a) > #b { }"); |
184 RuleSet& ruleSet = helper.ruleSet(); | 184 RuleSet& ruleSet = helper.ruleSet(); |
185 const Vector<RuleData>* shadowRules = ruleSet.shadowHostRules(); | 185 const WillBeHeapVector<RuleData>* shadowRules = ruleSet.shadowHostRules(); |
186 const TerminatedArray<RuleData>* idRules = ruleSet.idRules("b"); | 186 const TerminatedArray<RuleData>* idRules = ruleSet.idRules("b"); |
187 const TerminatedArray<RuleData>* classRules = ruleSet.classRules("y"); | 187 const TerminatedArray<RuleData>* classRules = ruleSet.classRules("y"); |
188 ASSERT_EQ(0u, shadowRules->size()); | 188 ASSERT_EQ(0u, shadowRules->size()); |
189 ASSERT_EQ(1u, idRules->size()); | 189 ASSERT_EQ(1u, idRules->size()); |
190 ASSERT_EQ(1u, classRules->size()); | 190 ASSERT_EQ(1u, classRules->size()); |
191 } | 191 } |
192 | 192 |
193 TEST(RuleSetTest, findBestRuleSetAndAdd_HostAndClass) | 193 TEST(RuleSetTest, findBestRuleSetAndAdd_HostAndClass) |
194 { | 194 { |
195 CSSTestHelper helper; | 195 CSSTestHelper helper; |
196 | 196 |
197 helper.addCSSRules(".foo:host { }"); | 197 helper.addCSSRules(".foo:host { }"); |
198 RuleSet& ruleSet = helper.ruleSet(); | 198 RuleSet& ruleSet = helper.ruleSet(); |
199 const Vector<RuleData>* rules = ruleSet.shadowHostRules(); | 199 const WillBeHeapVector<RuleData>* rules = ruleSet.shadowHostRules(); |
200 ASSERT_EQ(0u, rules->size()); | 200 ASSERT_EQ(0u, rules->size()); |
201 } | 201 } |
202 | 202 |
203 TEST(RuleSetTest, findBestRuleSetAndAdd_HostContextAndClass) | 203 TEST(RuleSetTest, findBestRuleSetAndAdd_HostContextAndClass) |
204 { | 204 { |
205 CSSTestHelper helper; | 205 CSSTestHelper helper; |
206 | 206 |
207 helper.addCSSRules(".foo:host-context(*) { }"); | 207 helper.addCSSRules(".foo:host-context(*) { }"); |
208 RuleSet& ruleSet = helper.ruleSet(); | 208 RuleSet& ruleSet = helper.ruleSet(); |
209 const Vector<RuleData>* rules = ruleSet.shadowHostRules(); | 209 const WillBeHeapVector<RuleData>* rules = ruleSet.shadowHostRules(); |
210 ASSERT_EQ(0u, rules->size()); | 210 ASSERT_EQ(0u, rules->size()); |
211 } | 211 } |
212 | 212 |
213 } // namespace blink | 213 } // namespace blink |
OLD | NEW |