use of com.sldeditor.ui.detail.config.FieldConfigDouble in project sldeditor by robward-scisys.
the class FieldConfigDoubleTest method testAttributeSelection.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigDouble#attributeSelection(java.lang.String)}.
*/
@Test
public void testAttributeSelection() {
boolean valueOnly = true;
FieldConfigDouble field = new FieldConfigDouble(new FieldConfigCommonData(Double.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.FieldConfigDouble in project sldeditor by robward-scisys.
the class FieldConfigDoubleTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigDouble#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigDouble#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
boolean valueOnly = true;
FieldConfigDouble field = new FieldConfigDouble(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly));
field.undoAction(null);
field.redoAction(null);
double expectedValue1 = 13.4;
field.createUI();
field.populateField(expectedValue1);
assertTrue(Math.abs(field.getDoubleValue() - expectedValue1) < 0.001);
double expectedValue2 = 987.6;
field.setTestValue(FieldIdEnum.UNKNOWN, expectedValue2);
assertTrue(Math.abs(field.getDoubleValue() - expectedValue2) < 0.001);
UndoManager.getInstance().undo();
assertTrue(Math.abs(field.getDoubleValue() - expectedValue1) < 0.001);
UndoManager.getInstance().redo();
assertTrue(Math.abs(field.getDoubleValue() - expectedValue2) < 0.001);
// Increase the code coverage
field.undoAction(null);
field.redoAction(null);
field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
}
use of com.sldeditor.ui.detail.config.FieldConfigDouble in project sldeditor by robward-scisys.
the class FieldConfigDoubleTest method testSetEnabled.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigDouble#internal_setEnabled(boolean)}. Test
* method for {@link com.sldeditor.ui.detail.config.FieldConfigDouble#isEnabled()}. Test method
* for {@link com.sldeditor.ui.detail.config.FieldConfigDouble#createUI(javax.swing.Box)}.
*/
@Test
public void testSetEnabled() {
// Value only, no attribute/expression dropdown
boolean valueOnly = true;
FieldConfigDouble field = new FieldConfigDouble(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly));
// Text field will not have been created
boolean expectedValue = true;
field.internal_setEnabled(expectedValue);
assertFalse(field.isEnabled());
// Create text field
field.createUI();
assertEquals(expectedValue, field.isEnabled());
expectedValue = false;
field.internal_setEnabled(expectedValue);
assertEquals(expectedValue, field.isEnabled());
// Has attribute/expression dropdown
valueOnly = false;
FieldConfigDouble field2 = new FieldConfigDouble(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly));
// Text field will not have been created
expectedValue = true;
field2.internal_setEnabled(expectedValue);
assertFalse(field2.isEnabled());
// Create text field
field2.createUI();
assertEquals(expectedValue, field2.isEnabled());
expectedValue = false;
field2.internal_setEnabled(expectedValue);
// Actual value is coming from the attribute panel, not the text field
assertEquals(!expectedValue, field2.isEnabled());
}
use of com.sldeditor.ui.detail.config.FieldConfigDouble in project sldeditor by robward-scisys.
the class FieldConfigDoubleTest method testRevertToDefaultValue.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigDouble#revertToDefaultValue()}. Test method
* for {@link com.sldeditor.ui.detail.config.FieldConfigDouble#setDefaultValue(double)}.
*/
@Test
public void testRevertToDefaultValue() {
boolean valueOnly = true;
FieldConfigDouble field = new FieldConfigDouble(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly));
field.revertToDefaultValue();
assertTrue(Math.abs(field.getDoubleValue() - 0.0) < 0.001);
field.createUI();
field.createUI();
Double expectedDefaultValue = 42.19;
field.setDefaultValue(expectedDefaultValue);
field.revertToDefaultValue();
assertTrue(Math.abs(field.getDoubleValue() - expectedDefaultValue) < 0.001);
assertTrue(String.valueOf(expectedDefaultValue).compareTo(field.getStringValue()) == 0);
}
use of com.sldeditor.ui.detail.config.FieldConfigDouble in project sldeditor by robward-scisys.
the class FieldConfigDoubleTest method testSetConfig.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigDouble#testSetConfig(double, double, double, double)}.
*/
@Test
public void testSetConfig() {
boolean valueOnly = true;
FieldConfigDouble field = new FieldConfigDouble(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly));
field.createUI();
double minValue = 10.0;
double maxValue = 20.0;
double stepSize = 1.0;
int noOfDecimalPlaces = 2;
field.setConfig(minValue, maxValue, stepSize, noOfDecimalPlaces);
// Should be set to the minimum value
double expectedValue1 = 1.4;
field.populateField(expectedValue1);
assertTrue(Math.abs(field.getDoubleValue() - minValue) < 0.001);
// Should be set to the maximum value
double expectedValue2 = 41.4;
field.populateField(expectedValue2);
assertTrue(Math.abs(field.getDoubleValue() - maxValue) < 0.001);
}
Aggregations