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);
}
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);
}
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);
}
Aggregations