Search in sources :

Example 11 with ICSSStyleDeclaration

use of org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration in project webtools.sourceediting by eclipse.

the class TestCSSDecl method testStandaloneCSSDecl.

// commenting out this test because decl.setCssText() is not an implemented method
// public void testDecl() {
// CSSPropertyContext context = new CSSPropertyContext();
// ICSSStyleDeclaration decl = CSSStyleDeclarationFactory.getInstance().createStyleDeclaration();
// context.initialize(decl);
// decl.setCssText(getString() != null ? getString() : "");//$NON-NLS-1$
// }
// private String getString() {
// return "body {}";
// }
public void testStandaloneCSSDecl() {
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=202615
    CSSPropertyContext context = new CSSPropertyContext();
    ICSSStyleDeclaration decl = CSSStyleDeclarationFactory.getInstance().createStyleDeclaration();
    context.initialize(decl);
    String cssText = decl.getCssText();
    // $NON-NLS-1$ //$NON-NLS-2$
    assertEquals("standalone css node was not initialized", "", cssText);
    // $NON-NLS-1$
    context.setMargin("auto");
    // $NON-NLS-1$
    context.setColor("red");
    // $NON-NLS-1$
    context.setBorder("thick");
    context.applyFull(decl);
    cssText = decl.getCssText();
    // $NON-NLS-1$
    String expected = "color: red; border: thick; margin: auto";
    // $NON-NLS-1$
    assertEquals("standalone css node's properties were not set as expected", expected, cssText);
}
Also used : ICSSStyleDeclaration(org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration) CSSPropertyContext(org.eclipse.wst.css.core.internal.util.declaration.CSSPropertyContext)

Aggregations

ICSSStyleDeclaration (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration)11 ICSSNode (org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)5 ICSSStyleRule (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule)4 ArrayList (java.util.ArrayList)3 Iterator (java.util.Iterator)3 List (java.util.List)3 ICSSStyleDeclItem (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclItem)3 CSSMMNode (org.eclipse.wst.css.core.internal.metamodel.CSSMMNode)2 ICSSPrimitiveValue (org.eclipse.wst.css.core.internal.provisional.document.ICSSPrimitiveValue)2 ICSSStyleSheet (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet)2 CSSPropertyContext (org.eclipse.wst.css.core.internal.util.declaration.CSSPropertyContext)2 CSSFontFaceRule (org.w3c.dom.css.CSSFontFaceRule)2 ElementCSSInlineStyle (org.w3c.dom.css.ElementCSSInlineStyle)2 MediaList (org.w3c.dom.stylesheets.MediaList)2 HashMap (java.util.HashMap)1 Preferences (org.eclipse.core.runtime.Preferences)1 CSSMetaModelUtil (org.eclipse.wst.css.core.internal.metamodel.util.CSSMetaModelUtil)1 ICSSAttr (org.eclipse.wst.css.core.internal.provisional.document.ICSSAttr)1 ICSSMediaRule (org.eclipse.wst.css.core.internal.provisional.document.ICSSMediaRule)1 ICSSModel (org.eclipse.wst.css.core.internal.provisional.document.ICSSModel)1