use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class WTextFieldRenderer_Test method testXssEscaping.
@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
WTextField textField = new WTextField();
textField.setText(getMaliciousContent());
assertSafeContent(textField);
textField.setToolTip(getMaliciousAttribute("ui:textfield"));
assertSafeContent(textField);
textField.setAccessibleText(getMaliciousAttribute("ui:textfield"));
assertSafeContent(textField);
}
use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class WButtonRenderer_Test method testAllOptions.
@Test
public void testAllOptions() throws IOException, SAXException, XpathException {
WButton button = new WButton("All");
button.setDisabled(true);
setFlag(button, ComponentModel.HIDE_FLAG, true);
button.setToolTip("Title");
button.setAccessKey('T');
button.setImageUrl("http://localhost/image.png");
button.setImagePosition(ImagePosition.EAST);
button.setRenderAsLink(true);
button.setAjaxTarget(new WTextField());
button.setPopupTrigger(true);
setActiveContext(createUIContext());
WPanel validationComponent = new WPanel();
button.setAction(new ValidatingAction(new WValidationErrors(), validationComponent) {
@Override
public void executeOnValid(final ActionEvent event) {
// Do nothing
}
});
WContainer root = new WContainer();
root.add(button);
root.add(validationComponent);
assertXpathExists("//html:button[@id]", button);
assertXpathExists("//html:button[contains(@class, 'wc-linkbutton')]", button);
assertXpathEvaluatesTo(button.getText(), "//html:button", button);
assertXpathEvaluatesTo("disabled", "//html:button/@disabled", button);
assertXpathEvaluatesTo("hidden", "//html:button/@hidden", button);
assertXpathEvaluatesTo(button.getToolTip(), "//html:button/@title", button);
assertXpathUrlEvaluatesTo(button.getImageUrl(), "//html:button//html:img/@src", button);
assertXpathExists("//html:button/html:span[contains(@class, 'wc_btn_imge')]", button);
assertXpathEvaluatesTo(button.getAccessKeyAsString(), "//html:button/@accesskey", button);
assertXpathEvaluatesTo("true", "//html:button/@aria-haspopup", button);
assertXpathEvaluatesTo(validationComponent.getId(), "//html:button/@data-wc-validate", button);
assertXpathEvaluatesTo(button.getId(), "//ui:ajaxtrigger/@triggerId", button);
button.setImagePosition(ImagePosition.NORTH);
assertXpathExists("//html:button/html:span[contains(@class, 'wc_btn_imgn')]", button);
button.setImagePosition(ImagePosition.SOUTH);
assertXpathExists("//html:button/html:span[contains(@class, 'wc_btn_imgs')]", button);
button.setImagePosition(ImagePosition.WEST);
assertXpathExists("//html:button/html:span[contains(@class, 'wc_btn_imgw')]", button);
button.setClientCommandOnly(true);
assertXpathEvaluatesTo("button", "//html:button/@type", button);
}
use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class WComponentGroupRenderer_Test method testDoPaint.
@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
// Setup Group
WComponent actionTarget1 = new WTextField();
WComponent actionTarget2 = new WTextField();
WComponent actionTarget3 = new WTextField();
WComponentGroup<WComponent> group = new WComponentGroup<>();
group.addToGroup(actionTarget1);
group.addToGroup(actionTarget2);
group.addToGroup(actionTarget3);
WContainer root = new WContainer();
root.add(actionTarget1);
root.add(actionTarget2);
root.add(actionTarget3);
root.add(group);
setActiveContext(createUIContext());
// Validate Schema
assertSchemaMatch(root);
// Check group
assertXpathEvaluatesTo("1", "count(//ui:componentGroup)", root);
assertXpathEvaluatesTo("3", "count(//ui:componentGroup/ui:component)", root);
assertXpathEvaluatesTo(group.getId(), "//ui:componentGroup/@id", root);
assertXpathEvaluatesTo(actionTarget1.getId(), "//ui:componentGroup/ui:component[position()=1]/@id", root);
assertXpathEvaluatesTo(actionTarget2.getId(), "//ui:componentGroup/ui:component[position()=2]/@id", root);
assertXpathEvaluatesTo(actionTarget3.getId(), "//ui:componentGroup/ui:component[position()=3]/@id", root);
}
use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class WFieldSetRenderer_Test method testDoPaint.
@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
final String title = "WFieldSetRenderer_Test.testDoPaint.title";
WTextField text = new WTextField();
WFieldSet fieldSet = new WFieldSet(title);
fieldSet.add(text);
text.setText("text1");
assertSchemaMatch(fieldSet);
// Check Attributes
assertXpathEvaluatesTo(fieldSet.getId(), "//ui:fieldset/@id", fieldSet);
assertXpathNotExists("//ui:fieldset/@frame", fieldSet);
// Check Input
assertXpathEvaluatesTo(text.getText(), "//ui:fieldset/ui:content/ui:textfield", fieldSet);
fieldSet.setFrameType(FrameType.NO_BORDER);
assertXpathEvaluatesTo("noborder", "//ui:fieldset/@frame", fieldSet);
fieldSet.setFrameType(FrameType.NO_TEXT);
assertXpathEvaluatesTo("notext", "//ui:fieldset/@frame", fieldSet);
fieldSet.setFrameType(FrameType.NONE);
assertXpathEvaluatesTo("none", "//ui:fieldset/@frame", fieldSet);
}
use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class WFieldWarningIndicatorRenderer_Test method testRendererCorrectlyConfigured.
/**
* Test the Layout is correctly configured.
*/
@Test
public void testRendererCorrectlyConfigured() {
WFieldWarningIndicator indicator = new WFieldWarningIndicator(new WTextField());
Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(indicator) instanceof WFieldWarningIndicatorRenderer);
}
Aggregations