use of org.w3c.dom.css.CSSImportRule in project webtools.sourceediting by eclipse.
the class CSSImportRuleTest method checkInsert.
private void checkInsert(String ruleString, String href, String[] media) {
CSSStyleSheet sheet = getStyleSheet();
assertEquals(0, sheet.insertRule(ruleString, 0));
CSSRuleList ruleList = sheet.getCssRules();
CSSRule rule = ruleList.item(0);
assertTrue(rule instanceof CSSImportRule);
CSSImportRule importRule = (CSSImportRule) rule;
assertEquals(href, importRule.getHref());
if (media != null) {
assertEquals(media.length, importRule.getMedia().getLength());
for (int i = 0; i < media.length; i++) {
assertEquals(media[i], importRule.getMedia().item(i));
}
}
assertEquals(ruleString, importRule.getCssText());
}
use of org.w3c.dom.css.CSSImportRule in project webtools.sourceediting by eclipse.
the class CSSImportRuleTest method testCreateRule.
public void testCreateRule() {
ICSSStyleSheet sheet = getStyleSheet();
ICSSDocument doc = sheet;
ICSSImportRule newRule = doc.createCSSImportRule();
newRule.setHref("dummy.css");
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 CSSImportRule);
CSSImportRule importRule = (CSSImportRule) rule;
assertEquals("dummy.css", importRule.getHref());
MediaList mediaList = importRule.getMedia();
assertEquals(2, mediaList.getLength());
assertEquals("media1", mediaList.item(0));
assertEquals("media2", mediaList.item(1));
assertEquals("@import url(\"dummy.css\") media1, media2;", importRule.getCssText());
}
Aggregations