use of org.w3c.dom.css.CSSPageRule 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.CSSPageRule 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.CSSPageRule 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.CSSPageRule in project webtools.sourceediting by eclipse.
the class CSSPageRuleTest method testInsertText6.
public void testInsertText6() 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 6
rule = ruleList.item(5);
assertEquals(CSSRule.PAGE_RULE, rule.getType());
assertTrue(rule instanceof CSSPageRule);
assertEquals("rotated", ((CSSPageRule) rule).getSelectorText());
declaration = ((CSSPageRule) rule).getStyle();
assertEquals(1, declaration.getLength());
value = declaration.getPropertyCSSValue("size");
checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "landscape"));
}
use of org.w3c.dom.css.CSSPageRule in project webtools.sourceediting by eclipse.
the class CSSPageRuleTest 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", "CSSPageRuleTest.css"));
CSSStyleSheet sheet = (CSSStyleSheet) model.getDocument();
CSSRuleList ruleList = sheet.getCssRules();
assertEquals(6, ruleList.getLength());
CSSRule rule;
CSSStyleDeclaration declaration;
CSSValue value;
// rule 2
rule = ruleList.item(1);
assertEquals(CSSRule.PAGE_RULE, rule.getType());
assertTrue(rule instanceof CSSPageRule);
declaration = ((CSSPageRule) rule).getStyle();
assertEquals(2, declaration.getLength());
value = declaration.getPropertyCSSValue("size");
checkPrimitiveString(value, new PrimitiveString(CSSPrimitiveValue.CSS_IDENT, "auto"));
value = declaration.getPropertyCSSValue("margin");
checkPrimitiveNumber(value, new PrimitiveNumber(CSSPrimitiveValue.CSS_PERCENTAGE, 10));
}
Aggregations