use of com.sldeditor.ui.detail.config.FieldConfigInteger in project sldeditor by robward-scisys.
the class FieldConfigIntegerTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigInteger#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigInteger#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
boolean valueOnly = true;
FieldConfigInteger field = new FieldConfigInteger(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
field.undoAction(null);
field.redoAction(null);
int expectedValue1 = 134;
field.createUI();
field.populateField(expectedValue1);
assertEquals(expectedValue1, field.getIntValue());
int expectedValue2 = 9876;
field.setTestValue(FieldIdEnum.UNKNOWN, expectedValue2);
assertEquals(expectedValue2, field.getIntValue());
UndoManager.getInstance().undo();
assertEquals(expectedValue1, field.getIntValue());
UndoManager.getInstance().redo();
assertEquals(expectedValue2, field.getIntValue());
// Increase the code coverage
field.undoAction(null);
field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
field.redoAction(null);
field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
}
use of com.sldeditor.ui.detail.config.FieldConfigInteger in project sldeditor by robward-scisys.
the class FieldConfigIntegerTest method testAttributeSelection.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigInteger#attributeSelection(java.lang.String)}.
*/
@Test
public void testAttributeSelection() {
boolean valueOnly = true;
FieldConfigInteger field = new FieldConfigInteger(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
field.attributeSelection(null);
field.createUI();
assertTrue(field.isEnabled());
field.attributeSelection("test");
assertFalse(field.isEnabled());
field.attributeSelection(null);
assertTrue(field.isEnabled());
}
use of com.sldeditor.ui.detail.config.FieldConfigInteger in project sldeditor by robward-scisys.
the class FieldConfigIntegerTest method testSetVisible.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigInteger#setVisible(boolean)}.
*/
@Test
public void testSetVisible() {
boolean valueOnly = true;
FieldConfigInteger field = new FieldConfigInteger(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
boolean expectedValue = true;
field.setVisible(expectedValue);
field.createUI();
field.setVisible(expectedValue);
expectedValue = false;
field.setVisible(expectedValue);
}
use of com.sldeditor.ui.detail.config.FieldConfigInteger in project sldeditor by robward-scisys.
the class FieldConfigIntegerTest method testRevertToDefaultValue.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigInteger#revertToDefaultValue()}. Test method
* for {@link com.sldeditor.ui.detail.config.FieldConfigInteger#setDefaultValue(int)}.
*/
@Test
public void testRevertToDefaultValue() {
boolean valueOnly = true;
FieldConfigInteger field = new FieldConfigInteger(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
field.revertToDefaultValue();
assertEquals(0, field.getIntValue());
field.createUI();
Integer expectedDefaultValue = 42;
field.setDefaultValue(expectedDefaultValue);
field.revertToDefaultValue();
assertEquals(expectedDefaultValue.intValue(), field.getIntValue());
assertTrue(String.valueOf(expectedDefaultValue).compareTo(field.getStringValue()) == 0);
}
use of com.sldeditor.ui.detail.config.FieldConfigInteger in project sldeditor by robward-scisys.
the class FieldConfigIntegerTest method testSetConfig.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigInteger#testSetConfig(double, double, double)}.
*/
@Test
public void testSetConfig() {
boolean valueOnly = true;
FieldConfigInteger field = new FieldConfigInteger(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
field.createUI();
int minValue = 10;
int maxValue = 20;
int stepSize = 1;
field.setConfig(minValue, maxValue, stepSize);
// Should be set to the minimum value
int expectedValue1 = 1;
field.populateField(expectedValue1);
assertEquals(minValue, field.getIntValue());
// Should be set to the maximum value
int expectedValue2 = 41;
field.populateField(expectedValue2);
assertEquals(maxValue, field.getIntValue());
}
Aggregations