use of org.apache.wicket.util.tester.TagTester in project wicket by apache.
the class NonCachingImageTest method test.
/**
* {@link NonCachingImage} always adds anticache.
*/
@Test
public void test() {
NonCachingImagePage page = tester.startPage(NonCachingImagePage.class);
TagTester tag = tester.getTagById(page.image.getMarkupId());
assertTrue(tag.getAttribute("src").contains("antiCache"));
}
use of org.apache.wicket.util.tester.TagTester in project wicket by apache.
the class TextAreaTest method requiredAttribute.
/**
* https://issues.apache.org/jira/browse/WICKET-5289
*/
@Test
public void requiredAttribute() {
TestPage testPage = new TestPage();
testPage.textArea.setOutputMarkupId(true);
testPage.textArea.setType(String.class);
testPage.textArea.setRequired(true);
testPage.textArea.add(new HTML5Attributes());
tester.startPage(testPage);
TagTester tagTester = tester.getTagById(testPage.textArea.getMarkupId());
String required = tagTester.getAttribute("required");
assertEquals("required", required);
}
use of org.apache.wicket.util.tester.TagTester in project wicket by apache.
the class MediaTagsTest method audioTagIsRenderedRight.
@Test
public void audioTagIsRenderedRight() {
tester.startPage(MediaTagsTestPage.class);
String lastResponseAsString = tester.getLastResponse().getDocument();
TagTester createTagByAttribute = TagTester.createTagByAttribute(lastResponseAsString, "audio");
assertTrue(createTagByAttribute.hasAttribute("autoplay"));
assertTrue(createTagByAttribute.hasAttribute("controls"));
assertTrue(createTagByAttribute.hasAttribute("loop"));
assertTrue(createTagByAttribute.hasAttribute("muted"));
assertEquals("user-credentials", createTagByAttribute.getAttribute("crossorigin"));
String attribute = createTagByAttribute.getAttribute("src");
assertTrue("The time period is set right in the src attribute", attribute.contains("#t=5,10"));
assertTrue("page parameter is in the url of the src attribute", attribute.contains("test=test"));
}
use of org.apache.wicket.util.tester.TagTester in project wicket by apache.
the class MediaTagsTest method extendedVideoTagIsRenderedRight.
@Test
public void extendedVideoTagIsRenderedRight() {
tester.startPage(MediaTagsExtendedTestPage.class);
String lastResponseAsString = tester.getLastResponse().getDocument();
TagTester createTagByAttribute = TagTester.createTagByAttribute(lastResponseAsString, "video");
assertTrue(createTagByAttribute.hasChildTag("source"));
assertTrue(createTagByAttribute.hasChildTag("track"));
TagTester sourceTag = TagTester.createTagByAttribute(lastResponseAsString, "source");
assertEquals("video/mp4", sourceTag.getAttribute("type"));
assertEquals("screen and (device-width:500px)", sourceTag.getAttribute("media"));
assertEquals("http://www.mytestpage.xc/video.m4a", sourceTag.getAttribute("src"));
TagTester trackTag = TagTester.createTagByAttribute(lastResponseAsString, "track");
assertTrue(trackTag.getAttribute("src").contains("dummySubtitles"));
assertEquals("subtitles", trackTag.getAttribute("kind"));
assertEquals("Subtitles of video", trackTag.getAttribute("label"));
assertEquals("default", trackTag.getAttribute("default"));
assertEquals("de", trackTag.getAttribute("srclang"));
}
use of org.apache.wicket.util.tester.TagTester in project wicket by apache.
the class ButtonTest method whenButtonElement_thenModelObjectIsUsedAsTextContent.
/**
* https://issues.apache.org/jira/browse/WICKET-6225
*/
@Test
public void whenButtonElement_thenModelObjectIsUsedAsTextContent() {
tester.getApplication().getMarkupSettings().setStripWicketTags(false);
String text = "some text & another text";
TestPage testPage = new TestPage(Model.of(text)) {
@Override
public IResourceStream getMarkupResourceStream(MarkupContainer container, Class<?> containerClass) {
return new StringResourceStream("<html><body>" + "<form wicket:id=\"form\"><button wicket:id=\"button\"></button></form></body></html>");
}
};
tester.startPage(testPage);
TagTester buttonTagTester = tester.getTagByWicketId("button");
assertThat(buttonTagTester, is(notNullValue()));
assertThat(buttonTagTester.getAttribute("value"), is(nullValue()));
assertThat(buttonTagTester.getValue(), is(equalTo(text)));
}
Aggregations