1// Copyright 2014 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 "config.h" 6#include "core/css/CSSTestHelper.h" 7#include "core/css/RuleSet.h" 8 9#include <gtest/gtest.h> 10 11namespace blink { 12 13TEST(CSSSelector, Representations) 14{ 15 CSSTestHelper helper; 16 17 const char* cssRules = 18 "summary::-webkit-details-marker { }" 19 "* {}" 20 "div {}" 21 "#id {}" 22 ".class {}" 23 "[attr] {}" 24 "div:hover {}" 25 "div:nth-child(2){}" 26 ".class#id { }" 27 "#id.class { }" 28 "[attr]#id { }" 29 "div[attr]#id { }" 30 "div::content { }" 31 "div::first-line { }" 32 ".a.b.c { }" 33 "div:not(.a) { }" // without class a 34 "div:not(:visited) { }" // without the visited pseudo class 35 36 "[attr=\"value\"] { }" // Exact equality 37 "[attr~=\"value\"] { }" // One of a space-separated list 38 "[attr^=\"value\"] { }" // Begins with 39 "[attr$=\"value\"] { }" // Ends with 40 "[attr*=\"value\"] { }" // Substring equal to 41 "[attr|=\"value\"] { }" // One of a hyphen-separated list 42 43 ".a .b { }" // .b is a descendant of .a 44 ".a > .b { }" // .b is a direct descendant of .a 45 ".a ~ .b { }" // .a precedes .b in sibling order 46 ".a + .b { }" // .a element immediately precedes .b in sibling order 47 ".a, .b { }" // matches .a or .b 48 49 ".a.b .c {}"; 50 51 helper.addCSSRules(cssRules); 52 EXPECT_EQ(30u, helper.ruleSet().ruleCount()); // .a, .b counts as two rules. 53#ifndef NDEBUG 54 helper.ruleSet().show(); 55#endif 56} 57 58} // namespace blink 59