use of org.apache.wicket.util.tester.TagTester in project wicket by apache.
the class EscapeAttributesInChoicesTest method escapeAttributes.
@Test
public void escapeAttributes() {
tester.startPage(EscapeAttributesInChoicesPage.class);
String lastResponseAsString = tester.getLastResponseAsString();
TagTester radioTagTester = tester.getTagById("radiofield1-apple\" onmouseover=\"alert('hi');\" \"");
assertNotNull(radioTagTester);
assertNull(radioTagTester.getAttribute("onmouseover"));
TagTester dropDownChoiceOptionTagTester = createTagByAttribute(lastResponseAsString, "value", "apple\" onmouseover=\"alert('hi');\" \"");
assertNotNull(dropDownChoiceOptionTagTester);
assertNull(dropDownChoiceOptionTagTester.getAttribute("onmouseover"));
TagTester checkBoxMultipleChoiceTagTester = createTagByAttribute(lastResponseAsString, "name", "checkboxfield");
assertNotNull(checkBoxMultipleChoiceTagTester);
assertEquals("apple\" onmouseover=\"alert('hi');\" \"", checkBoxMultipleChoiceTagTester.getAttribute("value"));
assertNull(checkBoxMultipleChoiceTagTester.getAttribute("onmouseover"));
TagTester labelForCheckBoxMultipleChoiceTagTester = createTagByAttribute(lastResponseAsString, "for", "checkboxfield2-checkboxfield_apple\" onmouseover=\"alert('hi');\" \"");
assertNotNull(labelForCheckBoxMultipleChoiceTagTester);
assertNull(labelForCheckBoxMultipleChoiceTagTester.getAttribute("onmouseover"));
}
use of org.apache.wicket.util.tester.TagTester in project wicket by apache.
the class AjaxUpdatedImageTest method wicket1382.
/**
* Tests that Image re-rendered in Ajax request have 'wicket:antiCache' parameter in its 'src'
* attribute value
*/
@Test
public void wicket1382() {
AjaxyImagesPage page = tester.startPage(AjaxyImagesPage.class);
TagTester tagTester = tester.getTagById(page.image.getMarkupId());
final String srcAttr = tagTester.getAttribute("src");
assertFalse("Image has not be rendered in Ajax request so it has no wicket:antiCache' parameter", srcAttr.contains("antiCache"));
// make an ajax call
tester.clickLink("link", true);
page = (AjaxyImagesPage) tester.getLastRenderedPage();
tagTester = tester.getTagById(page.image.getMarkupId());
final String srcAttr1 = tagTester.getAttribute("src");
assertTrue("Image has not be rendered in Ajax request so it has no wicket:antiCache' parameter", srcAttr1.contains("antiCache"));
}
use of org.apache.wicket.util.tester.TagTester in project wicket by apache.
the class ExternalImageTest method testExternalImageModel.
@Test
public void testExternalImageModel() {
tester.startPage(ExternalImageTestPage.class);
tester.getLastResponse().getDocument();
Component externalImage2Component = tester.getComponentFromLastRenderedPage("externalImage2");
ExternalImage externalImage2 = (ExternalImage) externalImage2Component;
TagTester tagById = tester.getTagById("externalImage2");
IModel<List<Serializable>> srcSet = externalImage2.getSrcSetModel();
for (Serializable model : srcSet.getObject()) {
String attribute = tagById.getAttribute("srcset");
Assert.assertTrue(attribute.contains(model.toString()));
}
String attribute = tagById.getAttribute("src");
Assert.assertEquals(externalImage2.getDefaultModelObject(), attribute);
}
use of org.apache.wicket.util.tester.TagTester in project wicket by apache.
the class ResponsiveImageTest method testPictureTagIsRenderedRight.
@Test
public void testPictureTagIsRenderedRight() {
tester.startPage(ImagePictureTestPage.class);
String lastResponseAsString = tester.getLastResponse().getDocument();
TagTester pictureTagTester = TagTester.createTagByAttribute(lastResponseAsString, "picture");
Assert.assertTrue(pictureTagTester.hasChildTag("img"));
Assert.assertTrue(pictureTagTester.hasChildTag("source"));
TagTester sourceTagTester = TagTester.createTagByAttribute(lastResponseAsString, "source");
Assert.assertTrue(sourceTagTester.hasAttribute("media"));
Assert.assertEquals("(min-width: 650px)", sourceTagTester.getAttribute("media"));
Assert.assertEquals("(min-width: 50em) 33vw", sourceTagTester.getAttribute("sizes"));
}
use of org.apache.wicket.util.tester.TagTester in project wicket by apache.
the class ResponsiveImageTest method testSrcSetIsNotAvailableOnDefaultUsage.
@Test
public void testSrcSetIsNotAvailableOnDefaultUsage() {
tester.startPage(ImageResourceReferenceTestPage.class);
String lastResponseAsString = tester.getLastResponse().getDocument();
TagTester createTagByAttribute = TagTester.createTagByAttribute(lastResponseAsString, "img");
Assert.assertFalse(createTagByAttribute.hasAttribute("srcset"));
Assert.assertEquals(Image.Cors.ANONYMOUS.getRealName(), createTagByAttribute.getAttribute("crossorigin"));
}
Aggregations