/** * 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); }
@Test public void testGetSeverity() { final int severity = Diagnostic.INFO; DiagnosticImpl diag = new DiagnosticImpl(severity, new WTextField(), "dummy"); Assert.assertEquals("Incorrect severity", severity, diag.getSeverity()); }
@Test(expected = IllegalArgumentException.class) public void testAddAutocompleteSectionNull() { WTextField field = new WTextField(); field.addAutocompleteSection(null); }
@Test public void testBuildLessThanOrEquals() { builder.lessThanOrEquals(new WTextField(), "1"); Assert.assertEquals("Incorrect condition", "WTextField<=\"1\"", builder.build().toString()); }
@Test public void testGetContext() { final UIContext uic = new UIContextImpl(); DiagnosticImpl diag = new DiagnosticImpl(Diagnostic.INFO, uic, new WTextField(), "dummy"); Assert.assertSame("Incorrect UI context", uic, diag.getContext()); }
@Test public void testConstructor() { SubordinateTrigger trigger = new WTextField(); String value = "test"; CompareExpression expr = new CompareExpression(CompareType.MATCH, trigger, value); Assert.assertEquals("Incorrect type", CompareType.MATCH, expr.getType()); Assert.assertEquals("Incorrect trigger", trigger, expr.getTrigger()); Assert.assertEquals("Incorrect value", value, expr.getValue()); }
@Test public void testTwoArgOrCondition() { builder.equals(new WTextField(), "1").or().equals(new WTextArea(), "2"); Assert.assertEquals("Incorrect condition", "(WTextField=\"1\" or WTextArea=\"2\")", builder. build().toString()); }
@Test public void testSetAutocompleteOff() { WTextField field = new WTextField(); field.setAutocompleteOff(); Assert.assertTrue(field.isAutocompleteOff()); }
@Test public void testGetComponent() { final WComponent component = new WTextField(); DiagnosticImpl diag = new DiagnosticImpl(Diagnostic.INFO, component, "dummy"); Assert.assertSame("Incorrect component", component, diag.getComponent()); }
@Test public void testSetLocalPhoneAutocompleteWithNullType() { WTextField field = new WTextField(); field.setLocalPhoneAutocomplete(null); Assert.assertEquals(Telephone.LOCAL.getValue(), field.getAutocomplete()); }
@Test public void testThreeArgOrCondition() { builder.equals(new WTextField(), "1").or().equals(new WTextArea(), "2").or().equals( new WDropdown(), "3"); Assert.assertEquals("Incorrect condition", "(WTextField=\"1\" or WTextArea=\"2\" or WDropdown=\"3\")", builder .build().toString()); }
@Test public void testAddFieldWithWLabel() { WFieldLayout layout = new WFieldLayout(); WField field = layout.addField(new WLabel("Test"), new WTextField()); Assert.assertNotNull(field); }
@Test public void testComponentModelSerialization() { WTextField name = new WTextField(); UIContext uic = createUIContext(); setActiveContext(uic); name.setText(TEST_STRING); Assert.assertEquals("Initial text incorrect", TEST_STRING, name.getText()); WebModel model = uic.getModel(name); model = (WebModel) pipe(model); uic.setModel(name, model); Assert.assertEquals("Text incorrect after serialization", TEST_STRING, name.getText()); }
/** * Creates a field layout with a couple of fields. * * @return a new field layout with content. */ private WFieldLayout createFieldLayout() { WFieldLayout fieldLayout = new WFieldLayout(); fieldLayout.addField("Field 1", new WTextField()); fieldLayout.addField("Field 2", new WTextArea()).getLabel().setHint("hint"); return fieldLayout; }
@Test public void testSetAutocompleteOffAfterSetting() { WTextField field = new WTextField(); field.setAutocomplete(Person.FAMILY); field.addAutocompleteSection("foo"); field.setAutocompleteOff(); Assert.assertTrue(field.isAutocompleteOff()); }
@Test public void testSetAutocompleteDate() { WTextField field = new WTextField(); for (DateType date : DateType.values()) { field.setAutocomplete(date); Assert.assertEquals(date.getValue(), field.getAutocomplete()); } }
@Test public void testSetAutocompleteEmail() { WTextField field = new WTextField(); for (Email email : Email.values()) { field.setAutocomplete(email); Assert.assertEquals(email.getValue(), field.getAutocomplete()); } }
@Test public void testSetAutocompleteNullAddressPart() { WTextField field = new WTextField(); field.setAutocomplete(Person.GIVEN); Assert.assertNotNull(field.getAutocomplete()); field.setAutocomplete((AddressPart) null); Assert.assertNull(field.getAutocomplete()); }
@Test public void testAddressAutocompleteNull() { WTextField field = new WTextField(); field.setAutocomplete(Person.GIVEN); Assert.assertNotNull(field.getAutocomplete()); field.setAddressAutocomplete(null, null); Assert.assertNull(field.getAutocomplete()); }
@Test public void testTriggerTargetArrayConstructor() { AjaxTrigger trigger = new WCheckBox(); AjaxTarget[] targets = new AjaxTarget[]{new WPanel(), new WTextField()}; WAjaxControl control = new WAjaxControl(trigger, targets); Assert.assertSame("Incorrect trigger", trigger, control.getTrigger()); Assert.assertFalse("Should not be load once", control.isLoadOnce()); Assert.assertEquals("Delay should not be set", 0, control.getDelay()); Assert.assertEquals("Incorrect targets list", Arrays.asList(targets), control.getTargets()); Assert.assertTrue("Incorrect targets array", Arrays.equals(targets, control. getTargetsArray())); }