use of com.helger.css.decl.CascadingStyleSheet in project ph-css by phax.
the class CSSReader30FuncTest method testReadSpecialGood.
@Test
public void testReadSpecialGood() {
final ECSSVersion eVersion = ECSSVersion.CSS30;
final Charset aCharset = StandardCharsets.UTF_8;
final File aFile = new File("src/test/resources/testfiles/css30/good/artificial/hacks2.css");
final CascadingStyleSheet aCSS = CSSReader.readFromFile(aFile, aCharset, eVersion);
assertNotNull(aCSS);
final String sCSS = new CSSWriter(eVersion, false).getCSSAsString(aCSS);
assertNotNull(sCSS);
if (false)
m_aLogger.info(sCSS);
}
use of com.helger.css.decl.CascadingStyleSheet in project ph-css by phax.
the class Issue22Test method testIssue.
@Test
public void testIssue() {
// Multiple errors contained
final IReadableResource aRes = new ClassPathResource("testfiles/css30/good/issue22.css");
assertTrue(aRes.exists());
final CascadingStyleSheet aCSS = CSSReader.readFromStream(aRes, new CSSReaderSettings().setFallbackCharset(StandardCharsets.UTF_8).setCustomErrorHandler(new LoggingCSSParseErrorHandler()));
assertNotNull(aCSS);
if (false)
System.out.println(new CSSWriter(ECSSVersion.CSS30).getCSSAsString(aCSS));
}
use of com.helger.css.decl.CascadingStyleSheet in project ph-css by phax.
the class Issue26Test method testIssue.
@Test
public void testIssue() {
final IReadableResource aRes = new ClassPathResource("testfiles/css30/bad_but_browsercompliant/issue26.css");
assertTrue(aRes.exists());
final CascadingStyleSheet aCSS = CSSReader.readFromStream(aRes, new CSSReaderSettings().setFallbackCharset(StandardCharsets.UTF_8).setBrowserCompliantMode(true).setCustomErrorHandler(new LoggingCSSParseErrorHandler()));
assertNotNull(aCSS);
if (false)
System.out.println(new CSSWriter().getCSSAsString(aCSS));
}
use of com.helger.css.decl.CascadingStyleSheet in project ph-css by phax.
the class Issue3Test method testErrorInSupportsRule1.
@Test
public void testErrorInSupportsRule1() {
// Parse error in style declaration "unexpected::;"
final String sTest = "@supports(column-count: 1) { body { unexpected::; } } span {color:blue;}";
final CascadingStyleSheet aCSS = _parse(sTest, true);
assertNotNull(aCSS);
if (true)
_print(aCSS);
assertEquals(1, aCSS.getSupportsRuleCount());
assertEquals(1, aCSS.getSupportsRuleAtIndex(0).getRuleCount());
assertEquals(0, ((CSSStyleRule) aCSS.getSupportsRuleAtIndex(0).getRuleAtIndex(0)).getDeclarationCount());
assertEquals(1, aCSS.getStyleRuleCount());
}
use of com.helger.css.decl.CascadingStyleSheet in project ph-css by phax.
the class Issue3Test method testErrorInStyleDeclarationBlock1a.
@Test
public void testErrorInStyleDeclarationBlock1a() {
// Parse error in "unexpected background"
final String sTest = "body { background:red; unexpected background:blue; } span {color:blue;}";
// Expected output:
// body { background:red; background:blue; } span {color:blue;}
final CascadingStyleSheet aCSS = _parse(sTest, true);
assertNotNull(aCSS);
if (true)
_print(aCSS);
assertEquals(2, aCSS.getStyleRuleCount());
// only first background is present
assertEquals(1, aCSS.getStyleRuleAtIndex(0).getDeclarationCount());
}
Aggregations