use of org.w3c.dom.css.CSSMediaRule in project webtools.sourceediting by eclipse.
the class CSSMediaRuleTest method testCreateRule.
public void testCreateRule() {
ICSSStyleSheet sheet = getStyleSheet();
ICSSDocument doc = sheet;
ICSSMediaRule newRule = doc.createCSSMediaRule();
MediaList newList = newRule.getMedia();
newList.appendMedium("media1");
newList.appendMedium("media2");
sheet.insertRuleBefore(newRule, null);
CSSRuleList ruleList = sheet.getCssRules();
CSSRule rule = ruleList.item(0);
assertTrue(rule instanceof CSSMediaRule);
CSSMediaRule mediaRule = (CSSMediaRule) rule;
MediaList mediaList = mediaRule.getMedia();
assertEquals(2, mediaList.getLength());
assertEquals("media1", mediaList.item(0));
assertEquals("media2", mediaList.item(1));
assertEquals("@media media1, media2 {" + FileUtil.commonEOL + "}", mediaRule.getCssText());
}
Aggregations