use of org.eclipse.scout.rt.platform.status.Status in project scout.rt by eclipse.
the class FormFieldTest method testAddRemoveAddErrorStatus.
@Test
public void testAddRemoveAddErrorStatus() throws Exception {
SimpleTestFormField testField = new SimpleTestFormField();
P_PropertyChangeEventCounter counter = new P_PropertyChangeEventCounter();
testField.addPropertyChangeListener(IFormField.PROP_ERROR_STATUS, counter);
IMultiStatus status0 = testField.getErrorStatus();
testField.addErrorStatus(new Status("error"));
assertTrue(testField.getErrorStatus().containsStatus(Status.class));
IMultiStatus status1 = testField.getErrorStatus();
testField.removeErrorStatus(Status.class);
assertNull(testField.getErrorStatus());
IMultiStatus status2 = testField.getErrorStatus();
testField.addErrorStatus(new Status("error"));
assertTrue(testField.getErrorStatus().containsStatus(Status.class));
IMultiStatus status3 = testField.getErrorStatus();
assertNotEquals(status0, status1);
assertNotEquals(status1, status2);
assertNotEquals(status2, status3);
// adding + removing + adding
assertEquals(3, counter.getCount());
}
use of org.eclipse.scout.rt.platform.status.Status in project scout.rt by eclipse.
the class FormFieldTest method testRemoveErrorStatus.
@Test
public void testRemoveErrorStatus() throws Exception {
SimpleTestFormField testField = new SimpleTestFormField();
P_PropertyChangeEventCounter counter = new P_PropertyChangeEventCounter();
testField.addPropertyChangeListener(IFormField.PROP_ERROR_STATUS, counter);
IMultiStatus status0 = testField.getErrorStatus();
testField.addErrorStatus(new Status("error"));
assertTrue(testField.getErrorStatus().containsStatus(Status.class));
IMultiStatus status1 = testField.getErrorStatus();
testField.removeErrorStatus(Status.class);
assertNull(testField.getErrorStatus());
IMultiStatus status2 = testField.getErrorStatus();
assertNotEquals(status0, status1);
assertNotEquals(status1, status2);
assertEquals(2, counter.getCount());
}
use of org.eclipse.scout.rt.platform.status.Status in project scout.rt by eclipse.
the class FormFieldTest method testSetSameErrorStatus.
@Test
public void testSetSameErrorStatus() throws Exception {
SimpleTestFormField testField = new SimpleTestFormField();
P_PropertyChangeEventCounter counter = new P_PropertyChangeEventCounter();
testField.addPropertyChangeListener(IFormField.PROP_ERROR_STATUS, counter);
final MultiStatus ms = new MultiStatus();
ms.add(new Status("error"));
testField.setErrorStatus(ms);
assertEquals(ms, testField.getErrorStatus());
assertNotSame(ms, testField.getErrorStatus());
final MultiStatus ms2 = new MultiStatus();
// new object, but same content
ms2.add(new Status("error"));
testField.setErrorStatus(ms2);
assertEquals(ms2, testField.getErrorStatus());
assertNotSame(ms2, testField.getErrorStatus());
assertEquals(1, counter.getCount());
}
use of org.eclipse.scout.rt.platform.status.Status in project scout.rt by eclipse.
the class FormFieldTest method testClearErrorStatus.
@Test
public void testClearErrorStatus() throws Exception {
SimpleTestFormField testField = new SimpleTestFormField();
testField.addErrorStatus(new Status("error"));
testField.clearErrorStatus();
assertNull(testField.getErrorStatus());
}
use of org.eclipse.scout.rt.platform.status.Status in project scout.rt by eclipse.
the class AbstractFormTest method testValidForm_ErrorStatus.
/**
* Tests that validating a valid form with an ok status should not result in any error.
*/
@Test
public void testValidForm_ErrorStatus() {
String errorMessage = "";
try {
TestForm form = new TestForm();
form.getMainBox().addErrorStatus(new Status("ErrorMessage"));
form.validateForm();
} catch (VetoException ve) {
errorMessage = ve.getDisplayMessage();
}
final String expectedTextPart = "Main Box: ErrorMessage";
assertTrue("expected errorMessage contains: '" + expectedTextPart + "', but was '" + errorMessage + "'", errorMessage.contains(expectedTextPart));
}
Aggregations