use of com.helger.css.decl.CascadingStyleSheet in project ph-css by phax.
the class CSSWriterTest method testIndentationNested.
@Test
public void testIndentationNested() {
final CascadingStyleSheet aCSS = CSSReader.readFromString(CSS4, ECSSVersion.CSS30);
assertNotNull(aCSS);
final CSSWriterSettings aSettings = new CSSWriterSettings(ECSSVersion.CSS30, false);
final CSSWriter aWriter = new CSSWriter(aSettings).setWriteHeaderText(false);
assertEquals("@media print {\n" + " h1 {\n" + " color:red;\n" + " margin:1px;\n" + " }\n" + "\n" + " h2 { color:rgb(1,2,3); }\n" + "\n" + " h3 {}\n" + "\n" + " @keyframes x {\n" + " from {\n" + " align:left;\n" + " color:#123;\n" + " }\n" + " to { x:y; }\n" + " 50% {}\n" + " }\n" + "\n" + " @page {\n" + " margin:1in;\n" + " marks:none;\n" + " }\n" + "\n" + " @page :first { margin:2in; }\n" + "\n" + " @font-face {\n" + " font-family:'Soho';\n" + " src:url(Soho.eot);\n" + " }\n" + "\n" + " @font-face { src:local('Soho Gothic Pro'); }\n" + "\n" + " @font-face {}\n" + "}\n", aWriter.getCSSAsString(aCSS));
}
use of com.helger.css.decl.CascadingStyleSheet in project ph-css by phax.
the class CSSWriterTest method testHeaderText.
@Test
public void testHeaderText() {
final CascadingStyleSheet aCSS = CSSReader.readFromString(CSS5, ECSSVersion.CSS30);
assertNotNull(aCSS);
// Non-optimized version
CSSWriter aWriter = new CSSWriter(ECSSVersion.CSS30, false).setWriteHeaderText(true).setHeaderText("Unit test");
assertEquals("/*\n" + " * Unit test\n" + " */\n" + "h1 {\n" + " color:red;\n" + " margin:1px;\n" + "}\n" + "\n" + "h2 {\n" + " color:red;\n" + " margin:1px;\n" + "}\n", aWriter.getCSSAsString(aCSS));
// Optimized version
aWriter = new CSSWriter(ECSSVersion.CSS30, true).setWriteHeaderText(true).setHeaderText("Unit test2");
assertEquals("/*\n" + " * Unit test2\n" + " */\n" + "h1{color:red;margin:1px}h2{color:red;margin:1px}", aWriter.getCSSAsString(aCSS));
}
use of com.helger.css.decl.CascadingStyleSheet in project ph-css by phax.
the class CSSWriterTest method testRemoveUnnecessaryCode2.
@Test
public void testRemoveUnnecessaryCode2() {
final CascadingStyleSheet aCSS = CSSReader.readFromString(CSS4, ECSSVersion.CSS30);
assertNotNull(aCSS);
final CSSWriterSettings aSettings = new CSSWriterSettings(ECSSVersion.CSS30, false).setRemoveUnnecessaryCode(true);
final CSSWriter aWriter = new CSSWriter(aSettings).setWriteHeaderText(false);
assertEquals("@media print {\n" + " h1 {\n" + " color:red;\n" + " margin:1px;\n" + " }\n" + "\n" + " h2 { color:rgb(1,2,3); }\n" + "\n" + " @keyframes x {\n" + " from {\n" + " align:left;\n" + " color:#123;\n" + " }\n" + " to { x:y; }\n" + " }\n" + "\n" + " @page {\n" + " margin:1in;\n" + " marks:none;\n" + " }\n" + "\n" + " @page :first { margin:2in; }\n" + "\n" + " @font-face {\n" + " font-family:'Soho';\n" + " src:url(Soho.eot);\n" + " }\n" + "\n" + " @font-face { src:local('Soho Gothic Pro'); }\n" + "}\n", aWriter.getCSSAsString(aCSS));
}
use of com.helger.css.decl.CascadingStyleSheet in project ph-css by phax.
the class CSSWriterTest method testIndentation.
@Test
public void testIndentation() {
final CascadingStyleSheet aCSS = CSSReader.readFromString(CSS3, ECSSVersion.CSS30);
assertNotNull(aCSS);
final CSSWriterSettings aSettings = new CSSWriterSettings(ECSSVersion.CSS30, false);
final CSSWriter aWriter = new CSSWriter(aSettings).setWriteHeaderText(false);
assertEquals("h1 {\n" + " color:red;\n" + " margin:1px;\n" + "}\n" + "\n" + "h2 { color:rgb(1,2,3); }\n" + "\n" + "h3 {}\n" + "\n" + "@keyframes x {\n" + " from {\n" + " align:left;\n" + " color:#123;\n" + " }\n" + " to { x:y; }\n" + " 50% {}\n" + "}\n" + "\n" + "@page {\n" + " margin:1in;\n" + " marks:none;\n" + "}\n" + "\n" + "@page :first { margin:2in; }\n" + "\n" + "@page :last {}\n" + "\n" + "@media print {\n" + " div {\n" + " width:100%;\n" + " min-height:0;\n" + " }\n" + "}\n" + "\n" + "@media all {\n" + " div { width:90%; }\n" + "}\n" + "\n" + "@media tv {}\n" + "\n" + "@font-face {\n" + " font-family:'Soho';\n" + " src:url(Soho.eot);\n" + "}\n" + "\n" + "@font-face { src:local('Soho Gothic Pro'); }\n" + "\n" + "@font-face {}\n", aWriter.getCSSAsString(aCSS));
// Change indentation
aSettings.setIndent("\t");
assertEquals("h1 {\n" + "\tcolor:red;\n" + "\tmargin:1px;\n" + "}\n" + "\n" + "h2 { color:rgb(1,2,3); }\n" + "\n" + "h3 {}\n" + "\n" + "@keyframes x {\n" + "\tfrom {\n" + "\t\talign:left;\n" + "\t\tcolor:#123;\n" + "\t}\n" + "\tto { x:y; }\n" + "\t50% {}\n" + "}\n" + "\n" + "@page {\n" + "\tmargin:1in;\n" + "\tmarks:none;\n" + "}\n" + "\n" + "@page :first { margin:2in; }\n" + "\n" + "@page :last {}\n" + "\n" + "@media print {\n" + "\tdiv {\n" + "\t\twidth:100%;\n" + "\t\tmin-height:0;\n" + "\t}\n" + "}\n" + "\n" + "@media all {\n" + "\tdiv { width:90%; }\n" + "}\n" + "\n" + "@media tv {}\n" + "\n" + "@font-face {\n" + "\tfont-family:'Soho';\n" + "\tsrc:url(Soho.eot);\n" + "}\n" + "\n" + "@font-face { src:local('Soho Gothic Pro'); }\n" + "\n" + "@font-face {}\n", aWriter.getCSSAsString(aCSS));
}
Aggregations