Search in sources :

Example 66 with WButton

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);
}
Also used : WImage(com.github.bordertech.wcomponents.WImage) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Example 67 with WButton

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);
}
Also used : WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Example 68 with WButton

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);
}
Also used : WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Example 69 with WButton

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);
}
Also used : WContainer(com.github.bordertech.wcomponents.WContainer) WComponentGroup(com.github.bordertech.wcomponents.WComponentGroup) WCheckBox(com.github.bordertech.wcomponents.WCheckBox) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Example 70 with WButton

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);
}
Also used : WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WDataTable(com.github.bordertech.wcomponents.WDataTable) SimpleTableDataModel(com.github.bordertech.wcomponents.SimpleTableDataModel) TableDataModel(com.github.bordertech.wcomponents.TableDataModel) WTextField(com.github.bordertech.wcomponents.WTextField) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Aggregations

WButton (com.github.bordertech.wcomponents.WButton)76 Test (org.junit.Test)39 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)25 Action (com.github.bordertech.wcomponents.Action)20 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)18 WTextField (com.github.bordertech.wcomponents.WTextField)17 WHeading (com.github.bordertech.wcomponents.WHeading)16 WContainer (com.github.bordertech.wcomponents.WContainer)14 WPanel (com.github.bordertech.wcomponents.WPanel)13 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)11 ValidatingAction (com.github.bordertech.wcomponents.validation.ValidatingAction)10 WLabel (com.github.bordertech.wcomponents.WLabel)9 WTableColumn (com.github.bordertech.wcomponents.WTableColumn)8 UIContext (com.github.bordertech.wcomponents.UIContext)7 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)7 WText (com.github.bordertech.wcomponents.WText)6 WDataTable (com.github.bordertech.wcomponents.WDataTable)5 WFieldSet (com.github.bordertech.wcomponents.WFieldSet)5 WTable (com.github.bordertech.wcomponents.WTable)5 AdapterBasicTableModel (com.github.bordertech.wcomponents.AdapterBasicTableModel)4