Skip to content

Commit

Permalink
Added small test on import
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Oct 10, 2024
1 parent a659caa commit c3c1e6e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ph-css/src/test/java/com/helger/css/parser/ParserCSS30Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package com.helger.css.parser;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

Expand Down Expand Up @@ -61,7 +62,31 @@ public void testBasic2 () throws ParseException
aNode);
assertNotNull (aCSS);

// Remove all font-face rules
for (final ICSSTopLevelRule aTopLevelRule : aCSS.getAllFontFaceRules ())
assertTrue (aCSS.removeRule (aTopLevelRule).isChanged ());
}

@Test
public void testBasic3 () throws ParseException
{
final ParserCSS30TokenManager aTokenHdl = new ParserCSS30TokenManager (new CSSCharStream (new NonBlockingStringReader ("@import url(\"anything\"); bla foo;")));
aTokenHdl.setCustomErrorHandler (CSSReader.getDefaultParseErrorHandler ());

final ParserCSS30 aParser = new ParserCSS30 (aTokenHdl);
aParser.disable_tracing ();
aParser.setBrowserCompliantMode (true);
aParser.setCustomErrorHandler (CSSReader.getDefaultParseErrorHandler ());
final CSSNode aNode = aParser.styleSheet ();
assertNotNull (aNode);

final CascadingStyleSheet aCSS = CSSHandler.readCascadingStyleSheetFromNode (ECSSVersion.CSS30,
CSSReader.getDefaultInterpretErrorHandler (),
false,
aNode);
assertNotNull (aCSS);

assertEquals (1, aCSS.getAllImportRules ().size ());
assertEquals (0, aCSS.getAllRules ().size ());
}
}

0 comments on commit c3c1e6e

Please sign in to comment.