CssDeclarationValidationMaster { public static boolean checkDeclaration(CssDeclaration declaration) { ICssDeclarationValidator validator = DEFAULT_VALIDATORS.get(declaration.getProperty()); return validator == null || validator.isValid(declaration); } private  CssDeclarationValidationMaster(); static boolean checkDeclaration(CssDeclaration declaration);  }
@Test public void fontSizeEnumValidationTest() { Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "larger"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "smaller"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "xx-small"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "x-small"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "small"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "medium"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "large"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "x-large"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "xx-large"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "smaler"))); }
@Test public void fontSizeNumericValidationTest() { Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "5px"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "5jaja"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "normal"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "5%"))); }
@Test public void wordSpacingValidationTest() { Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.WORD_SPACING, "5px"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.WORD_SPACING, "5jaja"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.WORD_SPACING, "normal"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.WORD_SPACING, "5%"))); }
@Test public void letterSpacingValidationTest() { Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LETTER_SPACING, "5px"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LETTER_SPACING, "5jaja"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LETTER_SPACING, "normal"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LETTER_SPACING, "5%"))); }
@Test public void textIndentValidationTest() { Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.TEXT_INDENT, "5px"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.TEXT_INDENT, "5jaja"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.TEXT_INDENT, "normal"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.TEXT_INDENT, "5%"))); }
@Test public void lineHeightValidationTest() { Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LINE_HEIGHT, "5px"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LINE_HEIGHT, "5jaja"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LINE_HEIGHT, "normal"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LINE_HEIGHT, "5%"))); }
@Test public void backgroundRepeatValidationTest() { Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "initial"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "no-repeat"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "repeat no-repeat"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "space"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "round"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "space repeat"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "no-repeat round"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "no-repeat,repeat"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "no-repeat repeat,repeat"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "repeat-x, repeat no-repeat"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "5px"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "ja"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "repeat-x repeat"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "initial repeat"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "repeat, repeat-x repeat"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "ja, repeat"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "initial, repeat"))); }
@Test public void backgroundPositionValidationTest() { Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_POSITION_X, "initial"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_POSITION_Y, "-0"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_POSITION_Y, "5px"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_POSITION_X, "5em"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_POSITION_Y, "5px, 5%, bottom"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_POSITION_X, "left 5%, right"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_POSITION_X, "5"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_POSITION_Y, "ja"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_POSITION_X, "initial 5px"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_POSITION_Y, "ja, 5px"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_POSITION_X, "initial, 5px"))); }
@Test public void backgroundSizeTest() { Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "initial"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "0"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "10px"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "10%"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "10% 10px"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "10px 10em"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "auto"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "auto 10px"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "10px auto"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "cover"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "contain"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "5px, 10%, auto"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "5px 10%, 20em"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "ja"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "10"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "cover 10px"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "initial 10px"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "10px contain"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "ja, 5px"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "5px, ja"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "initial, 10px"))); }
@Test public void backgroundOriginTest() { Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_ORIGIN, "initial"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_ORIGIN, "border-box"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_ORIGIN, "padding-box"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_ORIGIN, "content-box"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_ORIGIN, "content-box, border-box"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_ORIGIN, "5px"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_ORIGIN, "ja"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_ORIGIN, "border-box border-box"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_ORIGIN, "content-box padding-box"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_ORIGIN, "ja, padding-box"))); }
@Test public void backgroundClipTest() { Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_CLIP, "initial"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_CLIP, "border-box"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_CLIP, "padding-box"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_CLIP, "content-box"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_CLIP, "content-box, border-box"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_CLIP, "5px"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_CLIP, "ja"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_CLIP, "border-box border-box"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_CLIP, "content-box padding-box"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_CLIP, "ja, padding-box"))); }
@Test public void backgroundImageTest() { Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "initial"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "url(rock_texture.jpg)"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "linear-gradient(red,green,blue)"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "url()"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "none"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "url(img.jpg),url(img2.jpg)"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "none,url(img2.jpg)"))); Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "linear-gradient(red,green,blue),url(img2.jpg)"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "ja"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "5px"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "url(url(rock_texture.jpg)"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "true-linear-gradient(red,green,blue)"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "url(img.jpg) url(img2.jpg)"))); Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "initial,url(img.jpg)"))); }