BackgroundImage extends AbstractCssProperty<BackgroundImage> implements StateChangeInformer<Bean> { @Override public String getCssValue() { return cssValue; } BackgroundImage();  BackgroundImage(final String cssValue);  BackgroundImage(final BackgroundImage backgroundImage);  BackgroundImage(final String... imageUrls);  BackgroundImage(final UrlCss3Value... urlCss3Values); @Override String getCssName(); @Override String getCssValue(); @Override String toString(); @Override BackgroundImage setCssValue(final String cssValue); void setImageUrls(final String... imageUrls); void setImageUrls(final UrlCss3Value... urlCss3Values); List<UrlCss3Value> getUrlCss3Values(); void setAsInitial(); void setAsInherit(); @Override void stateChanged(final Bean stateChangedObject); static final String INITIAL; static final String INHERIT; static final String NONE; }
@Test public void testBackgroundImageStringArray() { BackgroundImage backgroundImage = new BackgroundImage("/images/HelloDesign.jpg", "/images/HelloDesign2.jpg"); assertEquals("url(\"/images/HelloDesign.jpg\"), url(\"/images/HelloDesign2.jpg\")", backgroundImage.getCssValue()); }
@Test public void testBackgroundImageUrlCss3ValueArray() { final UrlCss3Value urlCss3Value2 = new UrlCss3Value("url(\"/images/HelloDesign2.jpg\")"); final UrlCss3Value urlCss3Value1 = new UrlCss3Value("url(\"/images/HelloDesign.jpg\")"); BackgroundImage backgroundImage = new BackgroundImage(urlCss3Value1, urlCss3Value2); assertEquals("url(\"/images/HelloDesign.jpg\"), url(\"/images/HelloDesign2.jpg\")", backgroundImage.getCssValue()); }
@Test(expected = InvalidValueException.class) public void testBackgroundImageUrlCss3ValueArrayInvalidValueAssignment1() { final UrlCss3Value urlCss3Value2 = new UrlCss3Value("url(\"/images/HelloDesign2.jpg\")"); final UrlCss3Value urlCss3Value1 = new UrlCss3Value("url(\"/images/HelloDesign.jpg\")"); BackgroundImage backgroundImage = new BackgroundImage(urlCss3Value1, urlCss3Value2); assertEquals("url(\"/images/HelloDesign.jpg\"), url(\"/images/HelloDesign2.jpg\")", backgroundImage.getCssValue()); try { urlCss3Value1.setX(50); } catch (InvalidValueException e) { assertEquals(-1, urlCss3Value1.getX()); assertEquals("url(\"/images/HelloDesign.jpg\")", urlCss3Value1.getValue()); throw e; } }
@Test(expected = InvalidValueException.class) public void testBackgroundImageUrlCss3ValueArrayInvalidValueAssignment2() { final UrlCss3Value urlCss3Value2 = new UrlCss3Value("url(\"/images/HelloDesign2.jpg\")"); final UrlCss3Value urlCss3Value1 = new UrlCss3Value("url(\"/images/HelloDesign.jpg\")"); BackgroundImage backgroundImage = new BackgroundImage(urlCss3Value1, urlCss3Value2); assertEquals("url(\"/images/HelloDesign.jpg\"), url(\"/images/HelloDesign2.jpg\")", backgroundImage.getCssValue()); try { urlCss3Value1.setY(50); } catch (InvalidValueException e) { assertEquals(-1, urlCss3Value1.getY()); assertEquals("url(\"/images/HelloDesign.jpg\")", urlCss3Value1.getValue()); throw e; } }
@Test public void testGetCssValue() { BackgroundImage backgroundImage = new BackgroundImage(); backgroundImage.setCssValue("url(/images/HelloDesign.jpg), url(/images/HelloDesign2.jpg)"); assertEquals("url(\"/images/HelloDesign.jpg\"), url(\"/images/HelloDesign2.jpg\")", backgroundImage.getCssValue()); backgroundImage.setCssValue("url(\"/images/HelloDesign3.jpg\"), url(\"/images/HelloDesign4.jpg\")"); assertEquals("url(\"/images/HelloDesign3.jpg\"), url(\"/images/HelloDesign4.jpg\")", backgroundImage.getCssValue()); backgroundImage.setAsInherit(); assertNull(backgroundImage.getUrlCss3Values()); assertEquals(BackgroundImage.INHERIT, backgroundImage.getCssValue()); }
@Test public void testSetImageUrlsUrlCss3ValueArray() { final UrlCss3Value urlCss3Value2 = new UrlCss3Value("url(\"/images/HelloDesign2.jpg\")"); final UrlCss3Value urlCss3Value1 = new UrlCss3Value("url(\"/images/HelloDesign.jpg\")"); BackgroundImage backgroundImage = new BackgroundImage(urlCss3Value1, urlCss3Value2); assertEquals("url(\"/images/HelloDesign.jpg\"), url(\"/images/HelloDesign2.jpg\")", backgroundImage.getCssValue()); }
@Test(expected = InvalidValueException.class) public void testSetImageUrlsUrlCss3ValueArrayInvalidValueAssignment1() { final UrlCss3Value urlCss3Value2 = new UrlCss3Value("url(\"/images/HelloDesign2.jpg\")"); final UrlCss3Value urlCss3Value1 = new UrlCss3Value("url(\"/images/HelloDesign.jpg\")"); BackgroundImage backgroundImage = new BackgroundImage(urlCss3Value1, urlCss3Value2); assertEquals("url(\"/images/HelloDesign.jpg\"), url(\"/images/HelloDesign2.jpg\")", backgroundImage.getCssValue()); try { urlCss3Value1.setX(50); } catch (InvalidValueException e) { assertEquals(-1, urlCss3Value1.getX()); assertEquals("url(\"/images/HelloDesign.jpg\")", urlCss3Value1.getValue()); throw e; } }
@Test(expected = InvalidValueException.class) public void testSetImageUrlsUrlCss3ValueArrayInvalidValueAssignment2() { final UrlCss3Value urlCss3Value2 = new UrlCss3Value("url(\"/images/HelloDesign2.jpg\")"); final UrlCss3Value urlCss3Value1 = new UrlCss3Value("url(\"/images/HelloDesign.jpg\")"); BackgroundImage backgroundImage = new BackgroundImage(urlCss3Value1, urlCss3Value2); assertEquals("url(\"/images/HelloDesign.jpg\"), url(\"/images/HelloDesign2.jpg\")", backgroundImage.getCssValue()); try { urlCss3Value1.setX(50); } catch (InvalidValueException e) { assertEquals(-1, urlCss3Value1.getX()); assertEquals("url(\"/images/HelloDesign.jpg\")", urlCss3Value1.getValue()); throw e; } }