Search in sources :

Example 1 with CSSCharsetRule

use of org.w3c.dom.css.CSSCharsetRule in project webtools.sourceediting by eclipse.

the class CSSCharsetRuleTest method testInsertRule.

public void testInsertRule() {
    CSSStyleSheet sheet = getStyleSheet();
    assertEquals(0, sheet.insertRule(RULE, 0));
    CSSRuleList ruleList = sheet.getCssRules();
    CSSRule rule = ruleList.item(0);
    assertTrue(rule instanceof CSSCharsetRule);
    CSSCharsetRule charsetRule = (CSSCharsetRule) rule;
    assertEquals("iso-8859-1", charsetRule.getEncoding());
    assertEquals(RULE, charsetRule.getCssText());
}
Also used : CSSCharsetRule(org.w3c.dom.css.CSSCharsetRule) CSSRule(org.w3c.dom.css.CSSRule) ICSSStyleSheet(org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet) CSSStyleSheet(org.w3c.dom.css.CSSStyleSheet) CSSRuleList(org.w3c.dom.css.CSSRuleList)

Example 2 with CSSCharsetRule

use of org.w3c.dom.css.CSSCharsetRule in project webtools.sourceediting by eclipse.

the class CSSCharsetRuleTest method testCreateRule.

public void testCreateRule() {
    ICSSStyleSheet sheet = getStyleSheet();
    ICSSDocument doc = sheet;
    CSSCharsetRule newRule = doc.createCSSCharsetRule();
    newRule.setEncoding("iso-8859-1");
    sheet.insertRuleBefore(newRule, null);
    CSSRuleList ruleList = sheet.getCssRules();
    CSSRule rule = ruleList.item(0);
    assertTrue(rule instanceof CSSCharsetRule);
    CSSCharsetRule charsetRule = (CSSCharsetRule) rule;
    assertEquals("iso-8859-1", charsetRule.getEncoding());
    assertEquals(RULE, charsetRule.getCssText());
}
Also used : CSSCharsetRule(org.w3c.dom.css.CSSCharsetRule) CSSRule(org.w3c.dom.css.CSSRule) ICSSStyleSheet(org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet) ICSSDocument(org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument) CSSRuleList(org.w3c.dom.css.CSSRuleList)

Aggregations

ICSSStyleSheet (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet)2 CSSCharsetRule (org.w3c.dom.css.CSSCharsetRule)2 CSSRule (org.w3c.dom.css.CSSRule)2 CSSRuleList (org.w3c.dom.css.CSSRuleList)2 ICSSDocument (org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument)1 CSSStyleSheet (org.w3c.dom.css.CSSStyleSheet)1