cz.vutbr.web.css.CSSException Java Examples
The following examples show how to use
cz.vutbr.web.css.CSSException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FontFaceTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testFFMultiSrc() throws IOException, CSSException { log.info("input:\n\n\n" + TEST_STRING2 + "\n\n\n"); StyleSheet ss; ss = CSSFactory.parseString(TEST_STRING2, null); assertEquals("One rule is set", 1, ss.size()); RuleFontFace rule = (RuleFontFace) ss.get(0); assertEquals("Rule contains 2 declarations ", 2, rule.size()); assertEquals("Rule contains font-family declaration", "font-family: 'MyWebFont';\n", rule.get(0).toString()); assertEquals("Rule contains scr declaration", "src: url('myfont.woff2') format('woff2'), url('myfont.woff') format('woff'), url('myfont.ttf') format('truetype');\n", rule.get(1).toString()); }
Example #2
Source File: SelectorTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testPreceding() throws CSSException, IOException { StyleSheet ss = CSSFactory.parseString(TEST_PRECEDING, null); assertEquals("One rule is set", 1, ss.size()); RuleSet rule = (RuleSet) ss.get(0); List<CombinedSelector> cslist = SelectorsUtil.appendCS(null); SelectorsUtil.appendSimpleSelector(cslist, "DIV", null); SelectorsUtil.appendPreceding(cslist, "P"); assertArrayEquals("Rule contains one combined selectors DIV~P ", cslist.toArray(), rule.getSelectors()); assertEquals("Rule contains one declaration {color:blue;}", DeclarationsUtil.appendDeclaration(null, "color", tf .createColor(0, 0, 255)), rule.asList()); }
Example #3
Source File: SimpleTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testRGBFunction1() throws IOException, CSSException { StyleSheet ss = CSSFactory.parseString(TEST_RGBFUNCTION1, null); assertEquals("One rule is set", 1, ss.size()); RuleSet rule = (RuleSet) ss.get(0); assertArrayEquals("Rule contains one selector BODY ", SelectorsUtil.createSelectors("BODY"), rule.getSelectors()); assertEquals("Rule contains one declaration {color: #00aa85;}", DeclarationsUtil.appendDeclaration(null, "color", tf.createColor(192, 64, 32)), rule.asList()); }
Example #4
Source File: SimpleTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testRGBFunctionInvalid() throws IOException, CSSException { StyleSheet ss = CSSFactory.parseString(TEST_RGBFUNCTION_INVALID, null); assertEquals("One rule is set", 1, ss.size()); RuleSet rule = (RuleSet) ss.get(0); assertArrayEquals("Rule contains one selector BODY ", SelectorsUtil.createSelectors("BODY"), rule.getSelectors()); assertEquals("Rule contains one declaration", 1, rule.size()); Term<?> value = rule.get(0).get(0); assertTrue("Assigned value is TermFunction (not TermColor)", value instanceof TermFunction); }
Example #5
Source File: AnalyzerTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@BeforeClass public static void init() throws IOException, CSSException, SAXException { log.info("\n\n\n == AnalyzerTest test at {} == \n\n\n", new Date()); DOMSource ds = new DOMSource(AnalyzerTest.class.getResourceAsStream("/simple/data.html")); doc = ds.parse(); sheet = CSSFactory.parse(AnalyzerTest.class.getResource("/simple/data.css"), null); analyzer = new Analyzer(sheet); NodeList list = doc.getElementsByTagName("body"); assertEquals("There is one <body> element", 1, list.getLength()); //walker = new TidyTreeWalker(list.item(0), NodeFilter.SHOW_ELEMENT); DocumentTraversal traversal = (DocumentTraversal) doc; walker = traversal.createTreeWalker(list.item(0), NodeFilter.SHOW_ELEMENT, null, false); elements = new ElementMap(doc); }
Example #6
Source File: GradientTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testSampleGradients() throws IOException, CSSException { StyleSheet ss = CSSFactory.parseString(SAMPLE_LINEAR_GRADIENT_1, null); assertEquals("One rule is set", 1, ss.size()); RuleSet rule1 = (RuleSet) ss.get(0); assertArrayEquals("Rule contains one selector div ", SelectorsUtil.createSelectors("div"), rule1.getSelectors()); assertEquals("Rule contains one declaration for background ", "background", rule1.get(0).getProperty()); assertEquals("Rule contains one term ", 1, rule1.get(0).size()); assertTrue("Rule contains a TermFunction ", rule1.get(0).get(0) instanceof TermFunction); TermFunction func = (TermFunction) rule1.get(0).get(0); assertEquals("Function name is linear-gradient ", "linear-gradient", func.getFunctionName()); List<List<Term<?>>> separatedArguments = func.getSeparatedArgs(tf.createOperator(',')); assertEquals("There are 3 comma-separated arguments ", 3, separatedArguments.size()); assertEquals("The first argument is to bottom ", Arrays.asList(tf.createIdent("to"), tf.createIdent("bottom")), separatedArguments.get(0)); assertEquals("The first argument is pretty-printed as \"to bottom\" ", "linear-gradient(to bottom,", func.toString().substring(0, "linear-gradient(to bottom,".length())); assertEquals("The second argument is rgba(245,245,245,1) 0% ", Arrays.asList(tf.createColor(245, 245, 245, 255), tf.createPercent(0f)), separatedArguments.get(1)); assertEquals("The second argument is rgba(221,221,221,1) 100% ", Arrays.asList(tf.createColor(221, 221, 221, 255), tf.createPercent(100f)), separatedArguments.get(2)); }
Example #7
Source File: SelectorTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testClass() throws CSSException, IOException { StyleSheet ss = CSSFactory.parseString(TEST_CLASS, null); assertEquals("One rule is set", 1, ss.size()); RuleSet rule = (RuleSet) ss.get(0); List<CombinedSelector> cslist = SelectorsUtil.appendCS(null); SelectorsUtil.appendSimpleSelector(cslist, null, null, rf .createClass("fit")); assertArrayEquals("Rule contains one class selector .fit", cslist.toArray(), rule .getSelectors()); assertEquals("Rule contains one declaration { width: 80%;}", DeclarationsUtil.appendDeclaration(null, "width", tf .createPercent(80.0f)), rule.asList()); }
Example #8
Source File: SelectorTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testID() throws CSSException, IOException { StyleSheet ss = CSSFactory.parseString(TEST_ID, null); assertEquals("One rule is set", 1, ss.size()); RuleSet rule = (RuleSet) ss.get(0); List<CombinedSelector> cslist = SelectorsUtil.appendCS(null); SelectorsUtil.appendSimpleSelector(cslist, null, null, rf .createID("krysa")); assertArrayEquals("Rule contains one ID selector #krysa", cslist.toArray(), rule .getSelectors()); assertEquals("Rule contains one declaration { font-size: 100px;}", DeclarationsUtil.appendDeclaration(null, "font-size", tf .createLength(100.0f).setUnit(TermNumeric.Unit.px)), rule.asList()); }
Example #9
Source File: SelectorTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testPseudoFunc() throws CSSException, IOException { StyleSheet ss = CSSFactory.parseString(TEST_PSEUDO_FUNC, null); assertEquals("One rule is set", 1, ss.size()); RuleSet rule = (RuleSet) ss.get(0); List<CombinedSelector> cslist = SelectorsUtil.appendCS(null); SelectorsUtil.appendSimpleSelector(cslist, null, null, rf.createPseudoClass("lang", "fr")); SelectorsUtil.appendChild(cslist, "Q"); assertArrayEquals("Rule contains one combined pseudoselector :lang(fr)>Q", cslist.toArray(), rule.getSelectors()); List<Term<?>> terms = DeclarationsUtil.appendTerm(null, null, tf .createString("« ")); DeclarationsUtil.appendSpaceTerm(terms, tf.createString(" »")); assertEquals("Rule contains one declaration { quotes: '« ' ' »' }", DeclarationsUtil.appendDeclaration(null, "quotes", terms), rule .asList()); }
Example #10
Source File: SelectorTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testEscapedID() throws CSSException, IOException { StyleSheet ss = CSSFactory.parseString(TEST_ESCAPED_ID, null); assertEquals("One rule is set", 1, ss.size()); RuleSet rule = (RuleSet) ss.get(0); List<CombinedSelector> cslist = SelectorsUtil.appendCS(null); SelectorsUtil.appendSimpleSelector(cslist, null, null, rf .createID("1krysa")); assertArrayEquals("Rule contains one ID selector #1krysa", cslist.toArray(), rule .getSelectors()); assertEquals("Rule contains one declaration { font-size: 100px;}", DeclarationsUtil.appendDeclaration(null, "font-size", tf .createLength(100.0f).setUnit(TermNumeric.Unit.px)), rule.asList()); }
Example #11
Source File: SelectorTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testAdjacent() throws CSSException, IOException { StyleSheet ss = CSSFactory.parseString(TEST_ADJACENT, null); assertEquals("One rule is set", 1, ss.size()); RuleSet rule = (RuleSet) ss.get(0); List<CombinedSelector> cslist = SelectorsUtil.appendCS(null); SelectorsUtil.appendSimpleSelector(cslist, "DIV", null); SelectorsUtil.appendAdjacent(cslist, "P"); assertArrayEquals("Rule contains one combined selectors DIV+P ", cslist.toArray(), rule.getSelectors()); assertEquals("Rule contains one declaration {color:blue;}", DeclarationsUtil.appendDeclaration(null, "color", tf .createColor(0, 0, 255)), rule.asList()); }
Example #12
Source File: SimpleTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testRGBAFunction1() throws IOException, CSSException { StyleSheet ss = CSSFactory.parseString(TEST_RGBAFUNCTION1, null); assertEquals("One rule is set", 1, ss.size()); RuleSet rule = (RuleSet) ss.get(0); assertArrayEquals("Rule contains one selector BODY ", SelectorsUtil.createSelectors("BODY"), rule.getSelectors()); assertEquals("Rule contains one declaration with color", DeclarationsUtil.appendDeclaration(null, "color", tf.createColor(255, 0, 0, 51)), rule.asList()); }
Example #13
Source File: SelectorTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testIDAttrib() throws CSSException, IOException { StyleSheet ss = CSSFactory.parseString(TEST_IDATTRIB, null); assertEquals("One rule is set", 1, ss.size()); RuleSet rule = (RuleSet) ss.get(0); List<CombinedSelector> cslist = SelectorsUtil.appendCS(null); SelectorsUtil.appendSimpleSelector(cslist, null, null, rf .createID("krysa"), rf.createAttribute("krysa", true, Selector.Operator.EQUALS, "id")); assertArrayEquals("Rule contains one ID selector #krysa[id='krysa']", cslist.toArray(), rule.getSelectors()); assertEquals("Rule contains one declaration { text-align: right }", DeclarationsUtil.appendDeclaration(null, "text-align", tf .createIdent("right")), rule.asList()); }
Example #14
Source File: SelectorTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testAsterisk() throws CSSException, IOException { StyleSheet ss = CSSFactory.parseString(TEST_ASTERISK, null); assertEquals("One rule is set", 1, ss.size()); List<CombinedSelector> cslist = SelectorsUtil.appendCS(null); SelectorsUtil.appendSimpleSelector(cslist, "*", null, rf .createClass("home")); assertArrayEquals("Rule 1 contains one combined selector *.home", cslist.toArray(), ((RuleSet) ss.get(0)).getSelectors()); List<Term<?>> terms = DeclarationsUtil.appendTerm(null, null, tf .createIdent("Verdana")); DeclarationsUtil.appendCommaTerm(terms, tf.createIdent("monospace")); assertEquals( "Rule contains one declaration { font-family: Verdana, monospace }", DeclarationsUtil.appendDeclaration(null, "font-family", terms), ((RuleSet) ss.get(0)).asList()); }
Example #15
Source File: SelectorTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testAttribute() throws CSSException, IOException { StyleSheet ss = CSSFactory.parseString(TEST_ATTRIB, null); assertEquals("One rule is set", 1, ss.size()); RuleSet rule = (RuleSet) ss.get(0); List<CombinedSelector> cslist = SelectorsUtil.appendCS(null); SelectorsUtil.appendSimpleSelector(cslist, "A", null, rf .createAttribute("fit.vutbr.cz", true, Selector.Operator.EQUALS, "href"), rf.createAttribute( "fit", false, Selector.Operator.DASHMATCH, "id")); assertArrayEquals( "Rule contains one ID attributed selector A[href='fit.vutbr.cz'][id|=fit]", cslist.toArray(), rule.getSelectors()); assertEquals("Rule contains one declaration { text-align: left; }", DeclarationsUtil.appendDeclaration(null, "text-align", tf .createIdent("left")), rule.asList()); }
Example #16
Source File: FunctionsTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void rectFunctions() throws IOException, CSSException { StyleSheet ss1 = CSSFactory.parseString(TEST_RECT1, null); assertEquals("Two properties are accepted", 2, ss1.get(0).size()); Declaration d1 = (Declaration) ss1.get(0).get(0); TermRect r1 = (TermRect) d1.get(0); assertEquals("The last one is a correct length", tf.createLength(2f, Unit.ch), r1.getValue().get(3)); StyleSheet ss2 = CSSFactory.parseString(TEST_RECT2, null); assertEquals("Two properties are accepted", 2, ss2.get(0).size()); Declaration d2 = (Declaration) ss2.get(0).get(0); TermRect r2 = (TermRect) d2.get(0); assertEquals("The last one is a correct length", tf.createLength(2f, Unit.ch), r2.getValue().get(3)); StyleSheet ss3 = CSSFactory.parseString(TEST_RECT3, null); assertEquals("Two properties are accepted", 2, ss3.get(0).size()); Declaration d3 = (Declaration) ss3.get(0).get(0); TermRect r3 = (TermRect) d3.get(0); assertEquals("The last one is a correct length", null, r3.getValue().get(3)); }
Example #17
Source File: PseudoClassTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void nonlegacyPseudoElementSupport() throws CSSException, IOException { StyleSheet style = CSSFactory.parseString(TEST_PSEUDO_2, null); assertEquals("There are 4 rules", 4, style.size()); List<CombinedSelector> sel1 = SelectorsUtil.appendSimpleSelector(null, "p", null, rf.createPseudoElement("first-line")); List<CombinedSelector> sel2 = SelectorsUtil.appendSimpleSelector(null, "p", null, rf.createPseudoElement("first-letter")); List<CombinedSelector> sel3 = SelectorsUtil.appendSimpleSelector(null, "p", null, rf.createPseudoElement("before")); List<CombinedSelector> sel4 = SelectorsUtil.appendSimpleSelector(null, "p", null, rf.createPseudoElement("after")); RuleSet rule1 = (RuleSet) style.get(0); assertArrayEquals("Rule contains one selector p::first-line", sel1.toArray(), rule1.getSelectors()); assertEquals("Rule contains one declaration", 1, rule1.size()); RuleSet rule2 = (RuleSet) style.get(1); assertArrayEquals("Rule contains one selector p::first-letter", sel2.toArray(), rule2.getSelectors()); assertEquals("Rule contains one declaration", 1, rule2.size()); RuleSet rule3 = (RuleSet) style.get(2); assertArrayEquals("Rule contains one selector p::before", sel3.toArray(), rule3.getSelectors()); assertEquals("Rule contains one declaration", 1, rule3.size()); RuleSet rule4 = (RuleSet) style.get(3); assertArrayEquals("Rule contains one selector p::after", sel4.toArray(), rule4.getSelectors()); assertEquals("Rule contains one declaration", 1, rule4.size()); }
Example #18
Source File: FontFaceTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testFFSources() throws IOException, CSSException { log.info("input:\n\n\n" + TEST_STRING4 + "\n\n\n"); StyleSheet ss; ss = CSSFactory.parseString(TEST_STRING4, null); assertEquals("Four rules are set", 4, ss.size()); RuleFontFace rule = (RuleFontFace) ss.get(0); assertEquals("Rule contains 5 declarations", 5, rule.size()); List<RuleFontFace.Source> srcs = rule.getSources(); assertEquals("There are 3 sources declared", 3, srcs.size()); assertEquals("First name is correct", "Indie Flower", ((RuleFontFace.SourceLocal) srcs.get(0)).getName()); assertEquals("Second name is correct", "IndieFlower", ((RuleFontFace.SourceLocal) srcs.get(1)).getName()); assertEquals("Third name is correct URI", "https://fonts.gstatic.com/s/indieflower/v9/10JVD_humAd5zP2yrFqw6ugdm0LZdjqr5-oayXSOefg.woff2", ((RuleFontFace.SourceURL) srcs.get(2)).getURI().getValue()); List<String> unirange = rule.getUnicodeRanges(); assertEquals("There are 11 unicode ranges", 11, unirange.size()); }
Example #19
Source File: PseudoClassTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void rangeInputPseudoElements() throws CSSException, IOException { StyleSheet style = CSSFactory.parseString(TEST_RANGE, null); assertEquals("There are 6 rules", 6, style.size()); for (int i = 0; i < TEST_RANGE_ELEMENTS.length; i++) { List<CombinedSelector> cslist = SelectorsUtil.appendSimpleSelector(null, "input", null, rf.createAttribute("range", false, Selector.Operator.EQUALS, "type"), rf.createPseudoElement(TEST_RANGE_ELEMENTS[i])); RuleSet rule = (RuleSet) style.get(i); assertArrayEquals("Rule contains one selector input[type=range]::" + TEST_RANGE_ELEMENTS[i], cslist.toArray(), rule.getSelectors()); assertEquals("Rule contains one declaration", 1, rule.size()); } }
Example #20
Source File: SelectorTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testAttributePresence() throws CSSException, IOException { StyleSheet ss = CSSFactory.parseString(TEST_ATTRIB_PRESENCE, null); assertEquals("One rule is set", 1, ss.size()); List<CombinedSelector> cslist = SelectorsUtil.appendCS(null); SelectorsUtil.appendSimpleSelector(cslist, "*", null, rf .createAttribute(null, false, Selector.Operator.NO_OPERATOR, "href")); assertArrayEquals("Rule 1 contains one combined selector *[href]", cslist.toArray(), ((RuleSet) ss.get(0)).getSelectors()); List<Term<?>> terms = DeclarationsUtil.appendTerm(null, null, tf .createIdent("Verdana")); DeclarationsUtil.appendCommaTerm(terms, tf.createIdent("monospace")); assertEquals( "Rule contains one declaration { text-decoration: underline }", DeclarationsUtil.appendDeclaration(null, "text-decoration", tf .createIdent("underline")), ((RuleSet) ss.get(0)) .asList()); }
Example #21
Source File: KeyframesTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testSimpleKeyframes() throws IOException, CSSException { log.info("input:\n\n\n" + TEST_STRING1 + "\n\n\n"); StyleSheet ss; ss = CSSFactory.parseString(TEST_STRING1, null); assertEquals("Two rules are present", 2, ss.size()); RuleKeyframes rule = (RuleKeyframes) ss.get(0); assertEquals("Keyframes name is correct ", "test_anim", rule.getName()); assertEquals("Rule contains 5 keyframes ", 5, rule.size()); assertEquals("Selector is correct ", tf.createPercent(0.0f), rule.get(0).getPercentages().get(0)); assertEquals("Selector is correct ", tf.createPercent(50.0f), rule.get(1).getPercentages().get(0)); assertEquals("Selector is correct ", tf.createPercent(50.0f), rule.get(2).getPercentages().get(0)); assertEquals("Selector is correct ", tf.createPercent(60.0f), rule.get(3).getPercentages().get(0)); assertEquals("Selector is correct ", tf.createPercent(72.0f), rule.get(3).getPercentages().get(1)); assertEquals("Selector is correct ", tf.createPercent(100.0f), rule.get(4).getPercentages().get(0)); assertEquals("Second keyframe has two declarations ", 2, rule.get(1).size()); }
Example #22
Source File: SelectorTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testDescendant() throws CSSException, IOException { StyleSheet ss = CSSFactory.parseString(TEST_DESCENDANT, null); assertEquals("One rule is set", 1, ss.size()); RuleSet rule = (RuleSet) ss.get(0); List<CombinedSelector> cslist = SelectorsUtil.appendCS(null); SelectorsUtil.appendSimpleSelector(cslist, "H1", null); SelectorsUtil.appendDescendant(cslist, "P"); assertArrayEquals("Rule contains one combined selectors H1 P ", cslist.toArray(), rule.getSelectors()); assertEquals("Rule contains one declaration {display:inline;}", DeclarationsUtil.appendDeclaration(null, "display", tf .createIdent("inline")), rule.asList()); }
Example #23
Source File: SimpleTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testHSLAFunction1() throws IOException, CSSException { StyleSheet ss = CSSFactory.parseString(TEST_HSLAFUNCTION1, null); assertEquals("One rule is set", 1, ss.size()); RuleSet rule = (RuleSet) ss.get(0); assertArrayEquals("Rule contains one selector BODY ", SelectorsUtil.createSelectors("BODY"), rule.getSelectors()); assertEquals("Rule contains one declaration with color", DeclarationsUtil.appendDeclaration(null, "color", tf.createColor(0, 0, 255, 102)), rule.asList()); }
Example #24
Source File: FunctionsTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void contentInvalid() throws IOException, CSSException { for (int i = 0; i < TEST_CONTENT_INVALID.length; i++) { StyleSheet ss = CSSFactory.parseString(TEST_CONTENT_INVALID[i], null); assertEquals("One rule is parset [" + i + "]", 1, ss.size()); assertEquals("One property is set [" + i + "]", 1, ss.get(0).size()); } }
Example #25
Source File: ImportTest1.java From jStyleParser with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void importTokenization() throws CSSException, IOException { CSSFactory.parseString(SIMPLE_IMPORT, null); CSSFactory.parseString(QUOT_IMPORT, null); CSSFactory.parseString(URL_IMPORT, null); CSSFactory.parseString(DOUBLE_IMPORT, null); CSSFactory.parseString(MEDIA_IMPORT, null); }
Example #26
Source File: GrammarRecovery2Test.java From jStyleParser with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void invalidCharColon() throws IOException, CSSException { StyleSheet ss = CSSFactory.parseString(TEST_DECL3A, null); assertEquals("One property is accepted (second one is invalid)", 1, ss.get(0).size()); ss = CSSFactory.parseString(TEST_DECL3B, null); assertEquals("One property is accepted (first one is invalid)", 1, ss.get(0).size()); }
Example #27
Source File: FontFaceTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void testSimpleFF() throws IOException, CSSException { log.info("input:\n\n\n" + TEST_STRING1 + "\n\n\n"); StyleSheet ss; ss = CSSFactory.parseString(TEST_STRING1, null); assertEquals("One rule is set", 1, ss.size()); RuleFontFace rule = (RuleFontFace) ss.get(0); assertEquals("Rule contains 2 declarations ", 2, rule.size()); assertEquals("Rule contains font-family declaration", "font-family: 'MyWebFont';\n", rule.get(0).toString()); assertEquals("Rule contains scr declaration", "src: url('myfont.woff2') format('woff2');\n", rule.get(1).toString()); }
Example #28
Source File: HtmlUtils.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
private static List<RuleBlock<?>> getAtRuleBlocks(String css, StylesEmbeddingOptions options) { try { return getAtRuleBlocks(CSSFactory.parseString(css, options.getBaseUrl()), options); } catch (IOException | CSSException e) { logger.error("Style sheets parsing failed", e); } return Collections.emptyList(); }
Example #29
Source File: FunctionsTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void vendorSpecificUnderscore() throws IOException, CSSException { StyleSheet ss = CSSFactory.parseString(TEST_DECL1A, null); assertEquals("Two properties are accepted", 2, ss.get(0).size()); final RuleSet rule = (RuleSet) ss.get(0); assertEquals("The first property value has three terms", 3, rule.get(0).size()); }
Example #30
Source File: EscapingTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 5 votes |
private void assertSingleId(String input, String className) throws IOException, CSSException { StyleSheet ss = CSSFactory.parseString(input, null); assertEquals("One rule is set", 1, ss.size()); RuleSet rule = (RuleSet) ss.get(0); assertEquals("One combined selector", rule.getSelectors().length, 1); CombinedSelector cs = rule.getSelectors()[0]; assertEquals("One selector", cs.size(), 1); assertEquals("The class name is correct", className, cs.get(0).getIDName()); }