use of com.helger.css.decl.CSSDeclaration in project ph-css by phax.
the class CSSShortHandDescriptorTest method testBorder1.
@Test
public void testBorder1() {
final CSSShortHandDescriptor aSHD = CSSShortHandRegistry.getShortHandDescriptor(ECSSProperty.BORDER);
assertNotNull(aSHD);
final CSSDeclaration aDecl = CSSReaderDeclarationList.readFromString("border:1px", ECSSVersion.CSS30).getDeclarationAtIndex(0);
assertNotNull(aDecl);
final List<CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces(aDecl);
assertNotNull(aSplittedDecls);
assertEquals(3, aSplittedDecls.size());
assertEquals("border-width:1px", aSplittedDecls.get(0).getAsCSSString(CWS));
assertEquals("border-style:solid", aSplittedDecls.get(1).getAsCSSString(CWS));
assertEquals("border-color:black", aSplittedDecls.get(2).getAsCSSString(CWS));
}
use of com.helger.css.decl.CSSDeclaration in project ph-css by phax.
the class CSSShortHandDescriptorTest method testBorder3b.
@Test
public void testBorder3b() {
final CSSShortHandDescriptor aSHD = CSSShortHandRegistry.getShortHandDescriptor(ECSSProperty.BORDER);
assertNotNull(aSHD);
final CSSDeclaration aDecl = CSSReaderDeclarationList.readFromString("border:red 1px dashed", ECSSVersion.CSS30).getDeclarationAtIndex(0);
assertNotNull(aDecl);
final List<CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces(aDecl);
assertNotNull(aSplittedDecls);
assertEquals(3, aSplittedDecls.size());
assertEquals("border-color:red", aSplittedDecls.get(0).getAsCSSString(CWS));
assertEquals("border-width:1px", aSplittedDecls.get(1).getAsCSSString(CWS));
assertEquals("border-style:dashed", aSplittedDecls.get(2).getAsCSSString(CWS));
}
use of com.helger.css.decl.CSSDeclaration in project ph-css by phax.
the class CSSShortHandDescriptorTest method testBorder2.
@Test
public void testBorder2() {
final CSSShortHandDescriptor aSHD = CSSShortHandRegistry.getShortHandDescriptor(ECSSProperty.BORDER);
assertNotNull(aSHD);
final CSSDeclaration aDecl = CSSReaderDeclarationList.readFromString("border:1px dashed", ECSSVersion.CSS30).getDeclarationAtIndex(0);
assertNotNull(aDecl);
final List<CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces(aDecl);
assertNotNull(aSplittedDecls);
assertEquals(3, aSplittedDecls.size());
assertEquals("border-width:1px", aSplittedDecls.get(0).getAsCSSString(CWS));
assertEquals("border-style:dashed", aSplittedDecls.get(1).getAsCSSString(CWS));
assertEquals("border-color:black", aSplittedDecls.get(2).getAsCSSString(CWS));
}
use of com.helger.css.decl.CSSDeclaration in project ph-css by phax.
the class CSSShortHandDescriptorTest method testMargin4.
@Test
public void testMargin4() {
final CSSShortHandDescriptor aSHD = CSSShortHandRegistry.getShortHandDescriptor(ECSSProperty.MARGIN);
assertNotNull(aSHD);
final CSSDeclaration aDecl = CSSReaderDeclarationList.readFromString("margin:1px 3px 5px 7px", ECSSVersion.CSS30).getDeclarationAtIndex(0);
assertNotNull(aDecl);
final List<CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces(aDecl);
assertNotNull(aSplittedDecls);
assertEquals(4, aSplittedDecls.size());
assertEquals("margin-top:1px", aSplittedDecls.get(0).getAsCSSString(CWS));
assertEquals("margin-right:3px", aSplittedDecls.get(1).getAsCSSString(CWS));
assertEquals("margin-bottom:5px", aSplittedDecls.get(2).getAsCSSString(CWS));
assertEquals("margin-left:7px", aSplittedDecls.get(3).getAsCSSString(CWS));
}
use of com.helger.css.decl.CSSDeclaration in project ph-css by phax.
the class WikiVisitFromHtml method readFromStyleAttributeWithAPI.
public static void readFromStyleAttributeWithAPI() {
final String sStyle = "color:red; background:fixed !important";
final CSSDeclarationList aDeclList = CSSReaderDeclarationList.readFromString(sStyle, ECSSVersion.CSS30);
if (aDeclList == null)
throw new IllegalStateException("Failed to parse CSS: " + sStyle);
// For all contained declarations
for (final CSSDeclaration aDeclaration : aDeclList.getAllDeclarations()) System.out.println(aDeclaration.getProperty() + ": " + aDeclaration.getExpression().getAsCSSString(new CSSWriterSettings(ECSSVersion.CSS30)) + (aDeclaration.isImportant() ? " (important)" : " (not important)"));
}
Aggregations