Search in sources :

Example 1 with Stylesheet

use of org.eclipse.mylyn.wikitext.parser.css.Stylesheet in project mylyn.docs by eclipse.

the class CssParserTest method testSimple.

public void testSimple() throws IOException {
    Stylesheet stylesheet = parser.parse(readFully(CssParserTest.class.getSimpleName() + "_0.css"));
    assertNotNull(stylesheet);
    assertEquals(25, stylesheet.getBlocks().size());
}
Also used : Stylesheet(org.eclipse.mylyn.wikitext.parser.css.Stylesheet)

Example 2 with Stylesheet

use of org.eclipse.mylyn.wikitext.parser.css.Stylesheet in project mylyn.docs by eclipse.

the class HtmlTextPresentationParserTest method assertDefaultCssStyles.

private void assertDefaultCssStyles(String expectedStyles, final String elementName) {
    Stylesheet stylesheet = defaultStylesheet();
    final List<String> styles = new ArrayList<>();
    Receiver receiver = new Receiver() {

        @Override
        public void apply(CssRule rule) {
            styles.add(rule.name + ": " + rule.value);
        }
    };
    stylesheet.applyTo(new ElementInfo() {

        @Override
        public boolean hasId(String id) {
            return false;
        }

        @Override
        public boolean hasCssClass(String cssClass) {
            return false;
        }

        @Override
        public ElementInfo getParent() {
            return null;
        }

        @Override
        public String getLocalName() {
            return elementName;
        }
    }, receiver);
    assertEquals("element " + elementName, expectedStyles, Joiner.on("; ").join(styles));
}
Also used : CssRule(org.eclipse.mylyn.wikitext.parser.css.CssRule) ElementInfo(org.eclipse.mylyn.wikitext.parser.css.ElementInfo) ArrayList(java.util.ArrayList) Receiver(org.eclipse.mylyn.wikitext.parser.css.Stylesheet.Receiver) Stylesheet(org.eclipse.mylyn.wikitext.parser.css.Stylesheet)

Example 3 with Stylesheet

use of org.eclipse.mylyn.wikitext.parser.css.Stylesheet in project mylyn.docs by eclipse.

the class CssParserTest method testComments.

public void testComments() {
    Stylesheet stylesheet = parser.parse("tr { /* font-size: 115%; */ font-size: 100%; } /* foo { sdf: sdf; } */");
    List<Block> blocks = stylesheet.getBlocks();
    assertEquals(1, blocks.size());
    Block block = blocks.get(0);
    List<CssRule> rules = block.getRules();
    assertEquals(1, rules.size());
    CssRule rule = rules.get(0);
    assertEquals("font-size", rule.name);
    assertEquals("100%", rule.value);
}
Also used : CssRule(org.eclipse.mylyn.wikitext.parser.css.CssRule) Block(org.eclipse.mylyn.wikitext.parser.css.Block) Stylesheet(org.eclipse.mylyn.wikitext.parser.css.Stylesheet)

Aggregations

Stylesheet (org.eclipse.mylyn.wikitext.parser.css.Stylesheet)3 CssRule (org.eclipse.mylyn.wikitext.parser.css.CssRule)2 ArrayList (java.util.ArrayList)1 Block (org.eclipse.mylyn.wikitext.parser.css.Block)1 ElementInfo (org.eclipse.mylyn.wikitext.parser.css.ElementInfo)1 Receiver (org.eclipse.mylyn.wikitext.parser.css.Stylesheet.Receiver)1