| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 AtomicString valueStr("content"); | 134 AtomicString valueStr("content"); |
| 135 ASSERT_EQ(valueStr, rules->at(0).selector().tagHistory()->value()); | 135 ASSERT_EQ(valueStr, rules->at(0).selector().tagHistory()->value()); |
| 136 } | 136 } |
| 137 | 137 |
| 138 TEST(RuleSetTest, findBestRuleSetAndAdd_Host) | 138 TEST(RuleSetTest, findBestRuleSetAndAdd_Host) |
| 139 { | 139 { |
| 140 CSSTestHelper helper; | 140 CSSTestHelper helper; |
| 141 | 141 |
| 142 helper.addCSSRules(":host { }"); | 142 helper.addCSSRules(":host { }"); |
| 143 RuleSet& ruleSet = helper.ruleSet(); | 143 RuleSet& ruleSet = helper.ruleSet(); |
| 144 const WillBeHeapVector<RuleData>* rules = ruleSet.shadowHostRules(); | 144 const HeapVector<RuleData>* rules = ruleSet.shadowHostRules(); |
| 145 ASSERT_EQ(1u, rules->size()); | 145 ASSERT_EQ(1u, rules->size()); |
| 146 } | 146 } |
| 147 | 147 |
| 148 TEST(RuleSetTest, findBestRuleSetAndAdd_HostWithId) | 148 TEST(RuleSetTest, findBestRuleSetAndAdd_HostWithId) |
| 149 { | 149 { |
| 150 CSSTestHelper helper; | 150 CSSTestHelper helper; |
| 151 | 151 |
| 152 helper.addCSSRules(":host(#x) { }"); | 152 helper.addCSSRules(":host(#x) { }"); |
| 153 RuleSet& ruleSet = helper.ruleSet(); | 153 RuleSet& ruleSet = helper.ruleSet(); |
| 154 const WillBeHeapVector<RuleData>* rules = ruleSet.shadowHostRules(); | 154 const HeapVector<RuleData>* rules = ruleSet.shadowHostRules(); |
| 155 ASSERT_EQ(1u, rules->size()); | 155 ASSERT_EQ(1u, rules->size()); |
| 156 } | 156 } |
| 157 | 157 |
| 158 TEST(RuleSetTest, findBestRuleSetAndAdd_HostContext) | 158 TEST(RuleSetTest, findBestRuleSetAndAdd_HostContext) |
| 159 { | 159 { |
| 160 CSSTestHelper helper; | 160 CSSTestHelper helper; |
| 161 | 161 |
| 162 helper.addCSSRules(":host-context(*) { }"); | 162 helper.addCSSRules(":host-context(*) { }"); |
| 163 RuleSet& ruleSet = helper.ruleSet(); | 163 RuleSet& ruleSet = helper.ruleSet(); |
| 164 const WillBeHeapVector<RuleData>* rules = ruleSet.shadowHostRules(); | 164 const HeapVector<RuleData>* rules = ruleSet.shadowHostRules(); |
| 165 ASSERT_EQ(1u, rules->size()); | 165 ASSERT_EQ(1u, rules->size()); |
| 166 } | 166 } |
| 167 | 167 |
| 168 TEST(RuleSetTest, findBestRuleSetAndAdd_HostContextWithId) | 168 TEST(RuleSetTest, findBestRuleSetAndAdd_HostContextWithId) |
| 169 { | 169 { |
| 170 CSSTestHelper helper; | 170 CSSTestHelper helper; |
| 171 | 171 |
| 172 helper.addCSSRules(":host-context(#x) { }"); | 172 helper.addCSSRules(":host-context(#x) { }"); |
| 173 RuleSet& ruleSet = helper.ruleSet(); | 173 RuleSet& ruleSet = helper.ruleSet(); |
| 174 const WillBeHeapVector<RuleData>* rules = ruleSet.shadowHostRules(); | 174 const HeapVector<RuleData>* rules = ruleSet.shadowHostRules(); |
| 175 ASSERT_EQ(1u, rules->size()); | 175 ASSERT_EQ(1u, rules->size()); |
| 176 } | 176 } |
| 177 | 177 |
| 178 TEST(RuleSetTest, findBestRuleSetAndAdd_HostAndHostContextNotInRightmost) | 178 TEST(RuleSetTest, findBestRuleSetAndAdd_HostAndHostContextNotInRightmost) |
| 179 { | 179 { |
| 180 CSSTestHelper helper; | 180 CSSTestHelper helper; |
| 181 | 181 |
| 182 helper.addCSSRules(":host-context(#x) .y, :host(.a) > #b { }"); | 182 helper.addCSSRules(":host-context(#x) .y, :host(.a) > #b { }"); |
| 183 RuleSet& ruleSet = helper.ruleSet(); | 183 RuleSet& ruleSet = helper.ruleSet(); |
| 184 const WillBeHeapVector<RuleData>* shadowRules = ruleSet.shadowHostRules(); | 184 const HeapVector<RuleData>* shadowRules = ruleSet.shadowHostRules(); |
| 185 const TerminatedArray<RuleData>* idRules = ruleSet.idRules("b"); | 185 const TerminatedArray<RuleData>* idRules = ruleSet.idRules("b"); |
| 186 const TerminatedArray<RuleData>* classRules = ruleSet.classRules("y"); | 186 const TerminatedArray<RuleData>* classRules = ruleSet.classRules("y"); |
| 187 ASSERT_EQ(0u, shadowRules->size()); | 187 ASSERT_EQ(0u, shadowRules->size()); |
| 188 ASSERT_EQ(1u, idRules->size()); | 188 ASSERT_EQ(1u, idRules->size()); |
| 189 ASSERT_EQ(1u, classRules->size()); | 189 ASSERT_EQ(1u, classRules->size()); |
| 190 } | 190 } |
| 191 | 191 |
| 192 TEST(RuleSetTest, findBestRuleSetAndAdd_HostAndClass) | 192 TEST(RuleSetTest, findBestRuleSetAndAdd_HostAndClass) |
| 193 { | 193 { |
| 194 CSSTestHelper helper; | 194 CSSTestHelper helper; |
| 195 | 195 |
| 196 helper.addCSSRules(".foo:host { }"); | 196 helper.addCSSRules(".foo:host { }"); |
| 197 RuleSet& ruleSet = helper.ruleSet(); | 197 RuleSet& ruleSet = helper.ruleSet(); |
| 198 const WillBeHeapVector<RuleData>* rules = ruleSet.shadowHostRules(); | 198 const HeapVector<RuleData>* rules = ruleSet.shadowHostRules(); |
| 199 ASSERT_EQ(0u, rules->size()); | 199 ASSERT_EQ(0u, rules->size()); |
| 200 } | 200 } |
| 201 | 201 |
| 202 TEST(RuleSetTest, findBestRuleSetAndAdd_HostContextAndClass) | 202 TEST(RuleSetTest, findBestRuleSetAndAdd_HostContextAndClass) |
| 203 { | 203 { |
| 204 CSSTestHelper helper; | 204 CSSTestHelper helper; |
| 205 | 205 |
| 206 helper.addCSSRules(".foo:host-context(*) { }"); | 206 helper.addCSSRules(".foo:host-context(*) { }"); |
| 207 RuleSet& ruleSet = helper.ruleSet(); | 207 RuleSet& ruleSet = helper.ruleSet(); |
| 208 const WillBeHeapVector<RuleData>* rules = ruleSet.shadowHostRules(); | 208 const HeapVector<RuleData>* rules = ruleSet.shadowHostRules(); |
| 209 ASSERT_EQ(0u, rules->size()); | 209 ASSERT_EQ(0u, rules->size()); |
| 210 } | 210 } |
| 211 | 211 |
| 212 } // namespace blink | 212 } // namespace blink |
| OLD | NEW |