use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.
the class WButtonRenderer_Test method testButtonImageToolTipRender.
@Test
public void testButtonImageToolTipRender() throws IOException, SAXException, XpathException {
WButton button = new WButton();
String expected = "alt text";
WImage buttonImage = new WImage("http://localhost/image.png", expected);
button.setImage(buttonImage.getImage());
assertXpathEvaluatesTo(expected, "//html:button/@title", button);
}
use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.
the class WButtonRenderer_Test method testBasic.
@Test
public void testBasic() throws IOException, SAXException, XpathException {
WButton button = new WButton("Basic");
assertXpathExists("//html:button[@id]", button);
assertXpathEvaluatesTo("Basic", "//html:button", button);
assertXpathNotExists("//html:button[@disabled]", button);
assertXpathNotExists("//html:button[@hidden]", button);
assertXpathNotExists("//html:button[@title]", button);
assertXpathNotExists("//html:button[//html:img]", button);
assertXpathNotExists("//html:button[@accesskey]", button);
assertXpathNotExists("//html:button[following-sibling::ui:ajaxcontrol]", button);
assertXpathNotExists("//html:button[@data-wc-validate]", button);
assertXpathNotExists("//html:button[@aria-haspopup]", button);
assertXpathNotExists("//html:button[@type='button']", button);
}
use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.
the class WButtonRenderer_Test method testXssEscaping.
@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
WButton button = new WButton(getMaliciousContent());
assertSafeContent(button);
button.setToolTip(getMaliciousAttribute("html:button"));
assertSafeContent(button);
button.setAccessibleText(getMaliciousAttribute("html:button"));
assertSafeContent(button);
button.setImageUrl(getMaliciousAttribute());
assertSafeContent(button);
}
use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.
the class WCheckBoxRenderer_Test method testDoPaint.
@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
WCheckBox wcbTest = new WCheckBox();
WComponentGroup<WCheckBox> group = new WComponentGroup<>();
WButton button = new WButton("test");
WContainer root = new WContainer();
root.add(wcbTest);
root.add(group);
root.add(button);
setActiveContext(createUIContext());
assertSchemaMatch(wcbTest);
assertXpathExists("//ui:checkbox", wcbTest);
assertXpathEvaluatesTo(wcbTest.getId(), "//ui:checkbox/@id", wcbTest);
// Check groupName
assertXpathNotExists("//ui:checkbox/@groupName", wcbTest);
wcbTest.setGroup(group);
assertSchemaMatch(wcbTest);
assertXpathEvaluatesTo(group.getId(), "//ui:checkbox/@groupName", wcbTest);
// Check disabled
assertXpathNotExists("//ui:checkbox/@disabled", wcbTest);
wcbTest.setDisabled(true);
assertSchemaMatch(wcbTest);
assertXpathEvaluatesTo("true", "//ui:checkbox/@disabled", wcbTest);
// Check hidden
assertXpathNotExists("//ui:checkbox/@hidden", wcbTest);
setFlag(wcbTest, ComponentModel.HIDE_FLAG, true);
assertSchemaMatch(wcbTest);
assertXpathEvaluatesTo("true", "//ui:checkbox/@hidden", wcbTest);
// Check required
assertXpathNotExists("//ui:checkbox/@required", wcbTest);
wcbTest.setMandatory(true);
assertSchemaMatch(wcbTest);
assertXpathEvaluatesTo("true", "//ui:checkbox/@required", wcbTest);
// Check selected
assertXpathNotExists("//ui:checkbox/@selected", wcbTest);
wcbTest.setSelected(true);
assertSchemaMatch(wcbTest);
assertXpathEvaluatesTo("true", "//ui:checkbox/@selected", wcbTest);
// Check submitOnChange
assertXpathNotExists("//ui:checkbox/@submitOnChange", wcbTest);
wcbTest.setSubmitOnChange(true);
assertSchemaMatch(wcbTest);
assertXpathEvaluatesTo("true", "//ui:checkbox/@submitOnChange", wcbTest);
// Check toolTip
assertXpathNotExists("//ui:checkbox/@toolTip", wcbTest);
wcbTest.setToolTip("WCheckBox_Test.testRenderedFormat.title");
assertSchemaMatch(wcbTest);
assertXpathEvaluatesTo(wcbTest.getToolTip(), "//ui:checkbox/@toolTip", wcbTest);
// Check accessibleText
assertXpathNotExists("//ui:checkbox/@accessibleText", wcbTest);
wcbTest.setAccessibleText("WCheckBox_Test.testRenderedFormat.accessibleText");
assertSchemaMatch(wcbTest);
assertXpathEvaluatesTo(wcbTest.getAccessibleText(), "//ui:checkbox/@accessibleText", wcbTest);
// Check button id
assertXpathNotExists("//ui:checkbox/@buttonId", wcbTest);
wcbTest.setDefaultSubmitButton(button);
assertSchemaMatch(wcbTest);
assertXpathEvaluatesTo(button.getId(), "//ui:checkbox/@buttonId", wcbTest);
}
use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.
the class WDataTableRenderer_Test method testDoPaintTableActionsInvisibleButton.
@Test
public void testDoPaintTableActionsInvisibleButton() throws IOException, SAXException, XpathException {
WDataTable component = new WDataTable();
component.addColumn(new WTableColumn(COL1_HEADING_TEST, WTextField.class));
component.addColumn(new WTableColumn(COL2_HEADING_TEST, WTextField.class));
component.addColumn(new WTableColumn(COL3_HEADING_TEST, WTextField.class));
TableDataModel tableModel = createTableModel();
component.setDataModel(tableModel);
component.setVisible(true);
WButton button1 = new WButton(TEST_ACTION_ONE);
component.addAction(button1);
// Visible
assertXpathExists("//ui:table/ui:actions", component);
// Not Visible
button1.setVisible(false);
assertXpathNotExists("//ui:table/ui:actions", component);
}
Aggregations