Search in sources :

Example 71 with WButton

use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.

the class WDataTableRenderer_Test method testDoPaintTableActions.

@Test
public void testDoPaintTableActions() 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);
    component.addAction(new WButton(TEST_ACTION_ONE));
    component.addAction(new WButton(TEST_ACTION_TWO));
    assertXpathExists("//ui:table/ui:actions", component);
    assertXpathEvaluatesTo(TEST_ACTION_ONE, "//ui:table/ui:actions/ui:action[1]/html:button", component);
    assertXpathEvaluatesTo(TEST_ACTION_TWO, "//ui:table/ui:actions/ui:action[2]/html:button", 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)

Example 72 with WButton

use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.

the class WDateFieldRenderer_Test method testDoPaintAllOptions.

@Test
public void testDoPaintAllOptions() throws IOException, SAXException, XpathException {
    WButton button = new WButton();
    WDateField dateField = new WDateField();
    dateField.setDate(TEST_DATE);
    dateField.setDisabled(true);
    setFlag(dateField, ComponentModel.HIDE_FLAG, true);
    dateField.setMandatory(true);
    dateField.setToolTip("TITLE");
    dateField.setAccessibleText("ALT");
    dateField.setDefaultSubmitButton(button);
    dateField.setMinDate(DateUtilities.createDate(01, 02, 2011));
    dateField.setMaxDate(DateUtilities.createDate(02, 03, 2012));
    setActiveContext(createUIContext());
    // Validate Schema
    assertSchemaMatch(dateField);
    // Check Attributes
    assertXpathEvaluatesTo(dateField.getId(), "//ui:datefield/@id", dateField);
    // Optional
    assertXpathEvaluatesTo(TEST_INTERNAL_DATE_STRING, "//ui:datefield/@date", dateField);
    assertXpathEvaluatesTo("true", "//ui:datefield/@disabled", dateField);
    assertXpathEvaluatesTo("true", "//ui:datefield/@hidden", dateField);
    assertXpathEvaluatesTo("true", "//ui:datefield/@required", dateField);
    assertXpathEvaluatesTo("TITLE", "//ui:datefield/@toolTip", dateField);
    assertXpathEvaluatesTo("ALT", "//ui:datefield/@accessibleText", dateField);
    assertXpathEvaluatesTo(button.getId(), "//ui:datefield/@buttonId", dateField);
    assertXpathEvaluatesTo("2011-02-01", "//ui:datefield/@min", dateField);
    assertXpathEvaluatesTo("2012-03-02", "//ui:datefield/@max", dateField);
}
Also used : WDateField(com.github.bordertech.wcomponents.WDateField) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Example 73 with WButton

use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.

the class WDialogRenderer_Test method testRenderTrigger.

@Test
public void testRenderTrigger() throws IOException, SAXException, XpathException {
    WButton trigger = new WButton("Launch dialog");
    WButton content = new WButton("Dialog content");
    WDialog dialog = new WDialog(content, trigger);
    assertXpathExists("//ui:dialog", dialog);
    assertXpathEvaluatesTo(dialog.getId(), "//ui:dialog/@id", dialog);
    assertXpathNotExists("//ui:dialog/@open", dialog);
    assertXpathEvaluatesTo(trigger.getId(), "//ui:dialog/html:button/@id", dialog);
    assertXpathEvaluatesTo(trigger.getId(), "//ui:dialog/@triggerid", dialog);
}
Also used : WDialog(com.github.bordertech.wcomponents.WDialog) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Example 74 with WButton

use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.

the class WEmailFieldRenderer_Test method testDoPaint.

@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
    WEmailField field = new WEmailField();
    WButton button = new WButton();
    WSuggestions suggestions = new WSuggestions();
    WContainer root = new WContainer();
    root.add(field);
    root.add(button);
    root.add(suggestions);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getId(), "//ui:emailfield/@id", field);
    assertXpathNotExists("//ui:emailfield/@disabled", field);
    assertXpathNotExists("//ui:emailfield/@hidden", field);
    assertXpathNotExists("//ui:emailfield/@required", field);
    assertXpathNotExists("//ui:emailfield/@readOnly", field);
    assertXpathNotExists("//ui:emailfield/@maxLength", field);
    assertXpathNotExists("//ui:emailfield/@toolTip", field);
    assertXpathNotExists("//ui:emailfield/@accessibleText", field);
    assertXpathNotExists("//ui:emailfield/@size", field);
    assertXpathNotExists("//ui:emailfield/@buttonId", field);
    assertXpathNotExists("//ui:emailfield/@list", field);
    field.setDisabled(true);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("true", "//ui:emailfield/@disabled", field);
    setFlag(field, ComponentModel.HIDE_FLAG, true);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("true", "//ui:emailfield/@hidden", field);
    field.setMandatory(true);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("true", "//ui:emailfield/@required", field);
    field.setMaxLength(50);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("50", "//ui:emailfield/@maxLength", field);
    field.setToolTip("tooltip");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getToolTip(), "//ui:emailfield/@toolTip", field);
    field.setAccessibleText("accessible");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getAccessibleText(), "//ui:emailfield/@accessibleText", field);
    field.setColumns(40);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("40", "//ui:emailfield/@size", field);
    field.setDefaultSubmitButton(button);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(button.getId(), "//ui:emailfield/@buttonId", field);
    // RFC 2606
    field.setText("nobody@wc.test");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getText(), "normalize-space(//ui:emailfield)", field);
    field.setSuggestions(suggestions);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(suggestions.getId(), "//ui:emailfield/@list", field);
    field.setPlaceholder("enter stuff here");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("enter stuff here", "//ui:emailfield/@placeholder", field);
}
Also used : WContainer(com.github.bordertech.wcomponents.WContainer) WSuggestions(com.github.bordertech.wcomponents.WSuggestions) WEmailField(com.github.bordertech.wcomponents.WEmailField) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Example 75 with WButton

use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.

the class UicStats_Test method setUp.

@Before
public void setUp() {
    UIContext uic;
    uic = new UIContextImpl();
    setActiveContext(uic);
    app = new WApplication();
    button = new WButton("PUSH");
    app.add(button);
    label = new WLabel("HERE");
    app.add(label);
    uic.setUI(app);
    stats = new UicStats(uic);
}
Also used : UIContext(com.github.bordertech.wcomponents.UIContext) WApplication(com.github.bordertech.wcomponents.WApplication) UIContextImpl(com.github.bordertech.wcomponents.UIContextImpl) WButton(com.github.bordertech.wcomponents.WButton) WLabel(com.github.bordertech.wcomponents.WLabel) Before(org.junit.Before)

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