use of org.w3c.dom.css.CSSValueList in project webtools.sourceediting by eclipse.
the class CSSPageRuleTest method testInsertText1.
public void testInsertText1() throws IOException {
ICSSModel model = getModel();
IStructuredDocument structuredDocument = model.getStructuredDocument();
structuredDocument.set(FileUtil.createString("src/org/eclipse/wst/css/core/tests/testfiles", "CSSPageRuleTest.css"));
CSSStyleSheet sheet = (CSSStyleSheet) model.getDocument();
CSSRuleList ruleList = sheet.getCssRules();
assertEquals(6, ruleList.getLength());
CSSRule rule;
CSSStyleDeclaration declaration;
CSSValue value;
CSSValueList valueList;
// rule 1
rule = ruleList.item(0);
assertEquals(CSSRule.PAGE_RULE, rule.getType());
assertTrue(rule instanceof CSSPageRule);
declaration = ((CSSPageRule) rule).getStyle();
assertEquals(2, declaration.getLength());
value = declaration.getPropertyCSSValue("size");
assertTrue(value instanceof CSSValueList);
valueList = (CSSValueList) value;
assertEquals(2, valueList.getLength());
checkPrimitiveNumber(valueList.item(0), new PrimitiveNumber(CSSPrimitiveValue.CSS_IN, (float) 8.5));
checkPrimitiveNumber(valueList.item(1), new PrimitiveNumber(CSSPrimitiveValue.CSS_IN, 11));
value = declaration.getPropertyCSSValue("margin");
checkPrimitiveNumber(value, new PrimitiveNumber(CSSPrimitiveValue.CSS_CM, 2));
}
use of org.w3c.dom.css.CSSValueList in project webtools.sourceediting by eclipse.
the class CSSFontFaceRuleTest method _testInsertText2.
public void _testInsertText2() throws IOException {
ICSSModel model = getModel();
IStructuredDocument structuredDocument = model.getStructuredDocument();
structuredDocument.set(FileUtil.createString("src/org/eclipse/wst/css/core/tests/testfiles", "CSSFontFaceRuleTest.css"));
CSSStyleSheet sheet = (CSSStyleSheet) model.getDocument();
CSSRuleList ruleList = sheet.getCssRules();
assertEquals(3, ruleList.getLength());
CSSRule rule;
CSSStyleDeclaration declaration;
CSSValue value;
CSSValueList valueList;
// rule 2
rule = ruleList.item(1);
assertEquals(CSSRule.FONT_FACE_RULE, rule.getType());
assertTrue(rule instanceof CSSFontFaceRule);
declaration = ((CSSFontFaceRule) rule).getStyle();
assertEquals(6, declaration.getLength());
value = declaration.getPropertyCSSValue("src");
assertTrue(value instanceof CSSValueList);
valueList = (CSSValueList) value;
assertEquals(9, valueList.getLength());
checkPrimitiveString(valueList.item(0), new PrimitiveString(ICSSPrimitiveValue.CSS_LOCAL, "Palatino"));
checkPrimitiveString(valueList.item(1), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
checkPrimitiveString(valueList.item(2), new PrimitiveString(ICSSPrimitiveValue.CSS_LOCAL, "Times New Roman"));
checkPrimitiveString(valueList.item(3), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
checkPrimitiveString(valueList.item(4), new PrimitiveString(ICSSPrimitiveValue.CSS_LOCAL, "New York"));
checkPrimitiveString(valueList.item(5), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
checkPrimitiveString(valueList.item(6), new PrimitiveString(ICSSPrimitiveValue.CSS_LOCAL, "Utopia"));
checkPrimitiveString(valueList.item(7), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
checkPrimitiveString(valueList.item(8), new PrimitiveString(CSSPrimitiveValue.CSS_URI, "http://somewhere/free/font"));
value = declaration.getPropertyCSSValue("font-family");
checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "serif"));
value = declaration.getPropertyCSSValue("font-weight");
assertTrue(value instanceof CSSValueList);
valueList = (CSSValueList) value;
assertEquals(9, valueList.getLength());
checkPrimitiveNumber(valueList.item(0), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 100));
checkPrimitiveString(valueList.item(1), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
checkPrimitiveNumber(valueList.item(2), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 200));
checkPrimitiveString(valueList.item(3), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
checkPrimitiveNumber(valueList.item(4), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 300));
checkPrimitiveString(valueList.item(5), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
checkPrimitiveNumber(valueList.item(6), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 400));
checkPrimitiveString(valueList.item(7), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
checkPrimitiveNumber(valueList.item(8), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 500));
value = declaration.getPropertyCSSValue("font-style");
checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "normal"));
value = declaration.getPropertyCSSValue("font-variant");
checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "normal"));
value = declaration.getPropertyCSSValue("font-size");
checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "all"));
}
Aggregations