use of org.w3c.dom.css.CSSStyleDeclaration in project webtools.sourceediting by eclipse.
the class CSSFontFamilyTest method testFontFamilies.
public void testFontFamilies() throws IOException {
ICSSModel model = getModel();
IStructuredDocument structuredDocument = model.getStructuredDocument();
structuredDocument.set(FileUtil.createString("src/org/eclipse/wst/css/core/tests/testfiles", "CSSFontFamilyTest.css"));
CSSStyleSheet sheet = (CSSStyleSheet) model.getDocument();
CSSRuleList rules = sheet.getCssRules();
assertEquals(4, rules.getLength());
// Rule 1: No whitespace
CSSRule rule;
CSSStyleDeclaration declaration;
CSSValue value;
// Rule 1: No whitespace
rule = rules.item(0);
assertEquals(CSSRule.STYLE_RULE, rule.getType());
assertTrue(rule instanceof CSSStyleRule);
declaration = ((CSSStyleRule) rule).getStyle();
value = declaration.getPropertyCSSValue(FONT_FAMILY);
checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "Courier"));
// Rule 2: Single whitespace
rule = rules.item(1);
assertEquals(CSSRule.STYLE_RULE, rule.getType());
assertTrue(rule instanceof CSSStyleRule);
declaration = ((CSSStyleRule) rule).getStyle();
value = declaration.getPropertyCSSValue(FONT_FAMILY);
checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "Courier New"));
// Rule 3: In quotes
rule = rules.item(2);
assertEquals(CSSRule.STYLE_RULE, rule.getType());
assertTrue(rule instanceof CSSStyleRule);
declaration = ((CSSStyleRule) rule).getStyle();
value = declaration.getPropertyCSSValue(FONT_FAMILY);
checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_STRING, "Courier New"));
// Rule 4: Tabs and spaces all over
rule = rules.item(3);
assertEquals(CSSRule.STYLE_RULE, rule.getType());
assertTrue(rule instanceof CSSStyleRule);
declaration = ((CSSStyleRule) rule).getStyle();
value = declaration.getPropertyCSSValue(FONT_FAMILY);
checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "Comic Sans"));
}
use of org.w3c.dom.css.CSSStyleDeclaration in project webtools.sourceediting by eclipse.
the class CSSPageRuleTest method testInsertText4.
public void testInsertText4() 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;
// rule 4
rule = ruleList.item(3);
assertEquals(CSSRule.PAGE_RULE, rule.getType());
assertTrue(rule instanceof CSSPageRule);
assertEquals(":right", ((CSSPageRule) rule).getSelectorText());
declaration = ((CSSPageRule) rule).getStyle();
assertEquals(2, declaration.getLength());
value = declaration.getPropertyCSSValue("margin-left");
checkPrimitiveNumber(value, new PrimitiveNumber(CSSPrimitiveValue.CSS_CM, 3));
value = declaration.getPropertyCSSValue("margin-right");
checkPrimitiveNumber(value, new PrimitiveNumber(CSSPrimitiveValue.CSS_CM, 4));
}
use of org.w3c.dom.css.CSSStyleDeclaration in project webtools.sourceediting by eclipse.
the class CSSPageRuleTest method testInsertText5.
public void testInsertText5() 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 5
rule = ruleList.item(4);
assertEquals(CSSRule.PAGE_RULE, rule.getType());
assertTrue(rule instanceof CSSPageRule);
assertEquals("narrow", ((CSSPageRule) rule).getSelectorText());
declaration = ((CSSPageRule) rule).getStyle();
assertEquals(1, 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_CM, 9));
checkPrimitiveNumber(valueList.item(1), new PrimitiveNumber(CSSPrimitiveValue.CSS_CM, 18));
}
use of org.w3c.dom.css.CSSStyleDeclaration in project webtools.sourceediting by eclipse.
the class CSSFontFaceRuleTest 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", "CSSFontFaceRuleTest.css"));
CSSStyleSheet sheet = (CSSStyleSheet) model.getDocument();
CSSRuleList ruleList = sheet.getCssRules();
assertEquals(3, ruleList.getLength());
CSSRule rule;
CSSStyleDeclaration declaration;
CSSValue value;
CSSValueList valueList;
// rule 1
rule = ruleList.item(0);
assertEquals(CSSRule.FONT_FACE_RULE, rule.getType());
assertTrue(rule instanceof CSSFontFaceRule);
declaration = ((CSSFontFaceRule) rule).getStyle();
assertEquals(4, declaration.getLength());
value = declaration.getPropertyCSSValue("font-family");
checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_STRING, "Swiss 721"));
value = declaration.getPropertyCSSValue("src");
checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_URI, "swiss721blk.pfr"));
value = declaration.getPropertyCSSValue("font-style");
assertTrue(value instanceof CSSValueList);
valueList = (CSSValueList) value;
assertEquals(3, valueList.getLength());
checkPrimitiveString(valueList.item(0), new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "normal"));
checkPrimitiveString(valueList.item(1), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
checkPrimitiveString(valueList.item(2), new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "italic"));
value = declaration.getPropertyCSSValue("font-weight");
assertTrue(value instanceof CSSValueList);
valueList = (CSSValueList) value;
assertEquals(3, valueList.getLength());
checkPrimitiveNumber(valueList.item(0), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 800));
checkPrimitiveString(valueList.item(1), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
checkPrimitiveNumber(valueList.item(2), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 900));
}
use of org.w3c.dom.css.CSSStyleDeclaration in project webtools.sourceediting by eclipse.
the class CSSFontFaceRuleTest method _testInsertText3.
public void _testInsertText3() 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 3
rule = ruleList.item(2);
assertEquals(CSSRule.FONT_FACE_RULE, rule.getType());
assertTrue(rule instanceof CSSFontFaceRule);
declaration = ((CSSFontFaceRule) rule).getStyle();
assertEquals(5, declaration.getLength());
value = declaration.getPropertyCSSValue("src");
assertTrue(value instanceof CSSValueList);
valueList = (CSSValueList) value;
assertEquals(4, valueList.getLength());
checkPrimitiveString(valueList.item(0), new PrimitiveString(ICSSPrimitiveValue.CSS_LOCAL, "Alabama Italic"));
checkPrimitiveString(valueList.item(1), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
checkPrimitiveString(valueList.item(2), new PrimitiveString(CSSPrimitiveValue.CSS_URI, "http://www.fonts.org/A/alabama-italic"));
checkPrimitiveString(valueList.item(3), new PrimitiveString(ICSSPrimitiveValue.CSS_FORMAT, "truetype"));
value = declaration.getPropertyCSSValue("panose-1");
assertTrue(value instanceof CSSValueList);
valueList = (CSSValueList) value;
assertEquals(10, valueList.getLength());
checkPrimitiveNumber(valueList.item(0), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 2));
checkPrimitiveNumber(valueList.item(1), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 4));
checkPrimitiveNumber(valueList.item(2), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 5));
checkPrimitiveNumber(valueList.item(3), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 2));
checkPrimitiveNumber(valueList.item(4), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 5));
checkPrimitiveNumber(valueList.item(5), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 4));
checkPrimitiveNumber(valueList.item(6), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 5));
checkPrimitiveNumber(valueList.item(7), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 9));
checkPrimitiveNumber(valueList.item(8), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 3));
checkPrimitiveNumber(valueList.item(9), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 3));
value = declaration.getPropertyCSSValue("font-family");
assertTrue(value instanceof CSSValueList);
valueList = (CSSValueList) value;
assertEquals(3, valueList.getLength());
checkPrimitiveString(valueList.item(0), new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "Alabama"));
checkPrimitiveString(valueList.item(1), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
checkPrimitiveString(valueList.item(2), new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "serif"));
value = declaration.getPropertyCSSValue("font-weight");
assertTrue(value instanceof CSSValueList);
valueList = (CSSValueList) value;
assertEquals(5, valueList.getLength());
checkPrimitiveNumber(valueList.item(0), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 300));
checkPrimitiveString(valueList.item(1), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
checkPrimitiveNumber(valueList.item(2), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 400));
checkPrimitiveString(valueList.item(3), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
checkPrimitiveNumber(valueList.item(4), new PrimitiveNumber(ICSSPrimitiveValue.CSS_INTEGER, 500));
value = declaration.getPropertyCSSValue("font-style");
assertTrue(value instanceof CSSValueList);
valueList = (CSSValueList) value;
assertEquals(3, valueList.getLength());
checkPrimitiveString(valueList.item(0), new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "italic"));
checkPrimitiveString(valueList.item(1), new PrimitiveString(ICSSPrimitiveValue.CSS_COMMA, ","));
checkPrimitiveString(valueList.item(2), new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "oblique"));
}
Aggregations