Search in sources :

Example 96 with WTextField

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

the class GroupExpression_Test method testBuildNot.

@Test
public void testBuildNot() {
    GroupExpression expr = new GroupExpression(GroupExpression.Type.NOT);
    BooleanExpression operand1 = new CompareExpression(CompareType.EQUAL, new WTextField(), "1");
    expr.add(operand1);
    Not condition = (Not) expr.build();
    Assert.assertEquals("Incorrect 1st operand for NOT", operand1.build().toString(), condition.getCondition().toString());
}
Also used : Not(com.github.bordertech.wcomponents.subordinate.Not) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 97 with WTextField

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

the class SubordinateBuilder_Test method testWhenTrue.

@Test
public void testWhenTrue() {
    SubordinateBuilder builder = new SubordinateBuilder();
    WTextField comp1 = new WTextField();
    WTextField comp2 = new WTextField();
    builder.condition().equals(comp1, "x");
    builder.whenTrue().disable(comp1);
    builder.whenFalse().enable(comp2);
    setActiveContext(createUIContext());
    Assert.assertFalse("comp1 should not be disabled until rule executes", comp1.isDisabled());
    Assert.assertFalse("comp2 should not be disabled", comp2.isDisabled());
    comp1.setText("x");
    builder.build().applyTheControls();
    Assert.assertTrue("comp1 should be disabled", comp1.isDisabled());
    Assert.assertFalse("comp2 should not be disabled", comp2.isDisabled());
}
Also used : WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 98 with WTextField

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

the class SubordinateBuilder_Test method testMissingActions.

@Test(expected = SystemException.class)
public void testMissingActions() {
    SubordinateBuilder builder = new SubordinateBuilder();
    builder.condition().equals(new WTextField(), "x");
    builder.build();
}
Also used : WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 99 with WTextField

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

the class SubordinateBuilder_Test method testWhenFalse.

@Test
public void testWhenFalse() {
    SubordinateBuilder builder = new SubordinateBuilder();
    WTextField comp1 = new WTextField();
    WTextField comp2 = new WTextField();
    builder.condition().equals(comp1, "x");
    builder.whenFalse().disable(comp1);
    builder.whenTrue().enable(comp2);
    Assert.assertFalse("comp1 should not be disabled until rule executes", comp1.isDisabled());
    Assert.assertFalse("comp2 should not be disabled", comp2.isDisabled());
    setActiveContext(createUIContext());
    comp1.setText("y");
    builder.build().applyTheControls();
    Assert.assertTrue("comp1 should be disabled", comp1.isDisabled());
    Assert.assertFalse("comp2 should not be disabled", comp2.isDisabled());
}
Also used : WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Example 100 with WTextField

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

the class HtmlRenderUtilTest method testGetEffectivePlaceholderWithExplicitValue.

@Test
public void testGetEffectivePlaceholderWithExplicitValue() {
    Placeholderable field = new WTextField();
    String expected = "my placeholder is boring";
    field.setPlaceholder(expected);
    String actual = HtmlRenderUtil.getEffectivePlaceholder(field);
    Assert.assertEquals(expected, actual);
}
Also used : WTextField(com.github.bordertech.wcomponents.WTextField) Placeholderable(com.github.bordertech.wcomponents.Placeholderable) Test(org.junit.Test)

Aggregations

WTextField (com.github.bordertech.wcomponents.WTextField)117 Test (org.junit.Test)90 SubordinateTarget (com.github.bordertech.wcomponents.SubordinateTarget)21 WCheckBox (com.github.bordertech.wcomponents.WCheckBox)21 WContainer (com.github.bordertech.wcomponents.WContainer)21 Equal (com.github.bordertech.wcomponents.subordinate.Equal)16 GreaterThanOrEqual (com.github.bordertech.wcomponents.subordinate.GreaterThanOrEqual)15 LessThanOrEqual (com.github.bordertech.wcomponents.subordinate.LessThanOrEqual)15 NotEqual (com.github.bordertech.wcomponents.subordinate.NotEqual)15 Rule (com.github.bordertech.wcomponents.subordinate.Rule)15 WSubordinateControl (com.github.bordertech.wcomponents.subordinate.WSubordinateControl)15 SubordinateTrigger (com.github.bordertech.wcomponents.SubordinateTrigger)14 WTextArea (com.github.bordertech.wcomponents.WTextArea)14 WComponentGroup (com.github.bordertech.wcomponents.WComponentGroup)12 WDropdown (com.github.bordertech.wcomponents.WDropdown)12 WButton (com.github.bordertech.wcomponents.WButton)11 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)11 WHeading (com.github.bordertech.wcomponents.WHeading)10 WLabel (com.github.bordertech.wcomponents.WLabel)10 Hide (com.github.bordertech.wcomponents.subordinate.Hide)10