Search in sources :

Example 16 with WImage

use of com.github.bordertech.wcomponents.WImage in project wcomponents by BorderTech.

the class WImageRenderer_Test method testRendererCorrectlyConfigured.

@Test
public void testRendererCorrectlyConfigured() {
    WImage image = new WImage();
    Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(image) instanceof WImageRenderer);
}
Also used : WImage(com.github.bordertech.wcomponents.WImage) Test(org.junit.Test)

Example 17 with WImage

use of com.github.bordertech.wcomponents.WImage in project wcomponents by BorderTech.

the class WImageRenderer_Test method testDoPaint.

@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
    MockImage content = new MockImage();
    WImage image = new WImage();
    assertSchemaMatch(image);
    image = new WImage();
    setActiveContext(createUIContext());
    image.setImage(content);
    assertSchemaMatch(image);
    assertXpathEvaluatesTo(image.getId(), "//html:img/@id", image);
    assertSrcMatch(image);
    assertXpathEvaluatesTo("", "//html:img/@alt", image);
    assertXpathNotExists("//html:img/@hidden", image);
    assertXpathNotExists("//html:img/@width", image);
    assertXpathNotExists("//html:img/@height", image);
    content.setDescription("WImage_Test.testRenderedFormat.description");
    content.setSize(new Dimension(-123, -456));
    setFlag(image, ComponentModel.HIDE_FLAG, true);
    assertXpathEvaluatesTo(content.getDescription(), "//html:img/@alt", image);
    assertXpathEvaluatesTo("hidden", "//html:img/@hidden", image);
    assertXpathNotExists("//html:img/@width", image);
    assertXpathNotExists("//html:img/@height", image);
    assertSrcMatch(image);
    content.setSize(new Dimension(123, 456));
    assertSchemaMatch(image);
    assertXpathEvaluatesTo("123", "//html:img/@width", image);
    assertXpathEvaluatesTo("456", "//html:img/@height", image);
    content.setSize(new Dimension(0, 0));
    assertSchemaMatch(image);
    assertXpathEvaluatesTo("0", "//html:img/@width", image);
    assertXpathEvaluatesTo("0", "//html:img/@height", image);
}
Also used : WImage(com.github.bordertech.wcomponents.WImage) Dimension(java.awt.Dimension) MockImage(com.github.bordertech.wcomponents.MockImage) Test(org.junit.Test)

Example 18 with WImage

use of com.github.bordertech.wcomponents.WImage in project wcomponents by BorderTech.

the class WImageRenderer_Test method testXssEscaping.

@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
    WImage image = new WImage();
    MockImage content = new MockImage();
    content.setDescription(getMaliciousAttribute("html:img"));
    setActiveContext(createUIContext());
    image.setImage(content);
    assertSafeContent(image);
    image.setImageUrl(getMaliciousAttribute());
    assertSafeContent(image);
}
Also used : WImage(com.github.bordertech.wcomponents.WImage) MockImage(com.github.bordertech.wcomponents.MockImage) Test(org.junit.Test)

Aggregations

WImage (com.github.bordertech.wcomponents.WImage)18 WDecoratedLabel (com.github.bordertech.wcomponents.WDecoratedLabel)6 WText (com.github.bordertech.wcomponents.WText)6 Test (org.junit.Test)5 WButton (com.github.bordertech.wcomponents.WButton)4 WMenuItem (com.github.bordertech.wcomponents.WMenuItem)4 Action (com.github.bordertech.wcomponents.Action)3 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)3 WHeading (com.github.bordertech.wcomponents.WHeading)3 WLink (com.github.bordertech.wcomponents.WLink)3 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)3 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)3 MockImage (com.github.bordertech.wcomponents.MockImage)2 WComponent (com.github.bordertech.wcomponents.WComponent)2 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)2 WMenu (com.github.bordertech.wcomponents.WMenu)2 WPanel (com.github.bordertech.wcomponents.WPanel)2 WSubMenu (com.github.bordertech.wcomponents.WSubMenu)2 FlowLayout (com.github.bordertech.wcomponents.layout.FlowLayout)2 SystemException (com.github.bordertech.wcomponents.util.SystemException)2