This source file includes following definitions.
- TEST
- TEST
- TEST
- TEST
- TEST
- TEST
- TEST
- TEST
#include "config.h"
#include "core/css/CSSTestHelper.h"
#include "core/css/RuleSet.h"
#include <gtest/gtest.h>
namespace WebCore {
TEST(RuleSetTest, findBestRuleSetAndAdd_CustomPseudoElements)
{
CSSTestHelper helper;
helper.addCSSRules("summary::-webkit-details-marker { }");
RuleSet& ruleSet = helper.ruleSet();
AtomicString str("-webkit-details-marker");
const TerminatedArray<RuleData>* rules = ruleSet.shadowPseudoElementRules(str);
ASSERT_EQ(1u, rules->size());
ASSERT_EQ(str, rules->at(0).selector().value());
}
TEST(RuleSetTest, findBestRuleSetAndAdd_Id)
{
CSSTestHelper helper;
helper.addCSSRules("#id { }");
RuleSet& ruleSet = helper.ruleSet();
AtomicString str("id");
const TerminatedArray<RuleData>* rules = ruleSet.idRules(str);
ASSERT_EQ(1u, rules->size());
ASSERT_EQ(str, rules->at(0).selector().value());
}
TEST(RuleSetTest, findBestRuleSetAndAdd_NthChild)
{
CSSTestHelper helper;
helper.addCSSRules("div:nth-child(2) { }");
RuleSet& ruleSet = helper.ruleSet();
AtomicString str("div");
const TerminatedArray<RuleData>* rules = ruleSet.tagRules(str);
ASSERT_EQ(1u, rules->size());
ASSERT_EQ(str, rules->at(0).selector().tagQName().localName());
}
TEST(RuleSetTest, findBestRuleSetAndAdd_ClassThenId)
{
CSSTestHelper helper;
helper.addCSSRules(".class#id { }");
RuleSet& ruleSet = helper.ruleSet();
AtomicString str("id");
const TerminatedArray<RuleData>* rules = ruleSet.idRules(str);
ASSERT_EQ(1u, rules->size());
AtomicString classStr("class");
ASSERT_EQ(classStr, rules->at(0).selector().value());
}
TEST(RuleSetTest, findBestRuleSetAndAdd_IdThenClass)
{
CSSTestHelper helper;
helper.addCSSRules("#id.class { }");
RuleSet& ruleSet = helper.ruleSet();
AtomicString str("id");
const TerminatedArray<RuleData>* rules = ruleSet.idRules(str);
ASSERT_EQ(1u, rules->size());
ASSERT_EQ(str, rules->at(0).selector().value());
}
TEST(RuleSetTest, findBestRuleSetAndAdd_AttrThenId)
{
CSSTestHelper helper;
helper.addCSSRules("[attr]#id { }");
RuleSet& ruleSet = helper.ruleSet();
AtomicString str("id");
const TerminatedArray<RuleData>* rules = ruleSet.idRules(str);
ASSERT_EQ(1u, rules->size());
AtomicString attrStr("attr");
ASSERT_EQ(attrStr, rules->at(0).selector().attribute().localName());
}
TEST(RuleSetTest, findBestRuleSetAndAdd_TagThenAttrThenId)
{
CSSTestHelper helper;
helper.addCSSRules("div[attr]#id { }");
RuleSet& ruleSet = helper.ruleSet();
AtomicString str("id");
const TerminatedArray<RuleData>* rules = ruleSet.idRules(str);
ASSERT_EQ(1u, rules->size());
AtomicString tagStr("div");
ASSERT_EQ(tagStr, rules->at(0).selector().tagQName().localName());
}
TEST(RuleSetTest, findBestRuleSetAndAdd_DivWithContent)
{
CSSTestHelper helper;
helper.addCSSRules("div::content { }");
RuleSet& ruleSet = helper.ruleSet();
AtomicString str("div");
const TerminatedArray<RuleData>* rules = ruleSet.tagRules(str);
ASSERT_EQ(1u, rules->size());
AtomicString valueStr("content");
ASSERT_EQ(valueStr, rules->at(0).selector().value());
}
}