Chromium Code Reviews| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 | 129 |
| 130 helper.addCSSRules("div::content { }"); | 130 helper.addCSSRules("div::content { }"); |
| 131 RuleSet& ruleSet = helper.ruleSet(); | 131 RuleSet& ruleSet = helper.ruleSet(); |
| 132 AtomicString str("div"); | 132 AtomicString str("div"); |
| 133 const TerminatedArray<RuleData>* rules = ruleSet.tagRules(str); | 133 const TerminatedArray<RuleData>* rules = ruleSet.tagRules(str); |
| 134 ASSERT_EQ(1u, rules->size()); | 134 ASSERT_EQ(1u, rules->size()); |
| 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) | |
| 140 { | |
| 141 CSSTestHelper helper; | |
| 142 | |
| 143 helper.addCSSRules(":host { }"); | |
| 144 RuleSet& ruleSet = helper.ruleSet(); | |
| 145 const Vector<RuleData>* rules = ruleSet.shadowHostRules(); | |
| 146 ASSERT_EQ(1u, rules->size()); | |
| 147 } | |
| 148 | |
| 149 TEST(RuleSetTest, findBestRuleSetAndAdd_HostWithId) | |
| 150 { | |
| 151 CSSTestHelper helper; | |
| 152 | |
| 153 helper.addCSSRules(":host(#x) { }"); | |
| 154 RuleSet& ruleSet = helper.ruleSet(); | |
| 155 const Vector<RuleData>* rules = ruleSet.shadowHostRules(); | |
| 156 ASSERT_EQ(1u, rules->size()); | |
| 157 } | |
|
kochi
2014/12/12 09:54:40
How about adding a test for ".foo:host {}" will re
rune
2014/12/12 15:44:02
Done.
| |
| 158 | |
| 159 TEST(RuleSetTest, findBestRuleSetAndAdd_HostContext) | |
| 160 { | |
| 161 CSSTestHelper helper; | |
| 162 | |
| 163 helper.addCSSRules(":host-context(*) { }"); | |
| 164 RuleSet& ruleSet = helper.ruleSet(); | |
| 165 const Vector<RuleData>* rules = ruleSet.shadowHostRules(); | |
| 166 ASSERT_EQ(1u, rules->size()); | |
| 167 } | |
| 168 | |
| 169 TEST(RuleSetTest, findBestRuleSetAndAdd_HostContextWithId) | |
| 170 { | |
| 171 CSSTestHelper helper; | |
| 172 | |
| 173 helper.addCSSRules(":host-context(#x) { }"); | |
| 174 RuleSet& ruleSet = helper.ruleSet(); | |
| 175 const Vector<RuleData>* rules = ruleSet.shadowHostRules(); | |
| 176 ASSERT_EQ(1u, rules->size()); | |
| 177 } | |
| 178 | |
| 179 TEST(RuleSetTest, findBestRuleSetAndAdd_HostAndHostContextNotInRightmost) | |
| 180 { | |
| 181 CSSTestHelper helper; | |
| 182 | |
| 183 helper.addCSSRules(":host-context(#x) .y, :host(.a) > #b { }"); | |
| 184 RuleSet& ruleSet = helper.ruleSet(); | |
| 185 const Vector<RuleData>* shadowRules = ruleSet.shadowHostRules(); | |
| 186 const TerminatedArray<RuleData>* idRules = ruleSet.idRules("b"); | |
| 187 const TerminatedArray<RuleData>* classRules = ruleSet.classRules("y"); | |
| 188 ASSERT_EQ(0u, shadowRules->size()); | |
| 189 ASSERT_EQ(1u, idRules->size()); | |
| 190 ASSERT_EQ(1u, classRules->size()); | |
| 191 } | |
| 192 | |
| 139 } // namespace blink | 193 } // namespace blink |
| OLD | NEW |