use of com.sldeditor.ui.detail.config.FieldConfigSlider in project sldeditor by robward-scisys.
the class FieldConfigSliderTest method testRevertToDefaultValue.
/**
* Test method for {@link
* com.sldeditor.ui.detail.config.FieldConfigSlider#revertToDefaultValue()}. Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigSlider#setDefaultValue(double)}.
*/
@Test
public void testRevertToDefaultValue() {
boolean valueOnly = true;
FieldConfigSlider field = new FieldConfigSlider(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly, false));
double defaultDefaultValue = 0.5;
field.revertToDefaultValue();
assertTrue(Math.abs(field.getDoubleValue() - defaultDefaultValue) < 0.001);
field.createUI();
field.createUI();
Double expectedDefaultValue = 0.42;
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.FieldConfigSlider in project sldeditor by robward-scisys.
the class FieldConfigSliderTest method testValueStored.
@Test
public void testValueStored() {
boolean valueOnly = true;
class TestFieldConfigSlider extends FieldConfigSlider {
public TestFieldConfigSlider(FieldConfigCommonData commonData) {
super(commonData);
}
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.detail.config.FieldConfigBoundingBox#valueStored()
*/
@Override
protected void valueStored(Integer value) {
super.valueStored(value);
}
}
TestFieldConfigSlider field = new TestFieldConfigSlider(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly, false));
class TestUpdateSymbol implements UpdateSymbolInterface {
public boolean dataChanged = false;
@Override
public void dataChanged(FieldIdEnum changedField) {
dataChanged = true;
}
}
;
TestUpdateSymbol update = new TestUpdateSymbol();
int undoListSize = UndoManager.getInstance().getUndoListSize();
field.createUI();
field.addDataChangedListener(update);
assertFalse(update.dataChanged);
field.valueStored(12);
assertTrue(update.dataChanged);
assertEquals(undoListSize + 1, UndoManager.getInstance().getUndoListSize());
update.dataChanged = false;
// now suppress undo events
field = new TestFieldConfigSlider(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly, true));
undoListSize = UndoManager.getInstance().getUndoListSize();
field.addDataChangedListener(update);
assertFalse(update.dataChanged);
field.valueStored(34);
assertTrue(update.dataChanged);
assertEquals(undoListSize, UndoManager.getInstance().getUndoListSize());
}
use of com.sldeditor.ui.detail.config.FieldConfigSlider in project sldeditor by robward-scisys.
the class FieldConfigSliderTest method testGenerateExpression.
/**
* Test method for {@link
* com.sldeditor.ui.detail.config.FieldConfigSlider#generateExpression()}. Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigSlider#populateExpression(java.lang.Object,
* org.opengis.filter.expression.Expression)}. Test method for {@link
* com.sldeditor.ui.detail.config.FieldConfigSlider#populateField(java.lang.Double)}. Test
* method for {@link
* com.sldeditor.ui.detail.config.FieldConfigSlider#setTestValue(com.sldeditor.ui.detail.config.FieldId,
* double)}. Test method for {@link
* com.sldeditor.ui.detail.config.FieldConfigSlider#getDoubleValue()}.
*/
@Test
public void testGenerateExpression() {
boolean valueOnly = true;
FieldConfigSlider field = new FieldConfigSlider(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly, false));
double defaultDefaultValue = 0.5;
double expectedValue = 1.0;
field.populateField(expectedValue);
double actualValue = field.getDoubleValue();
assertTrue(Math.abs(actualValue - defaultDefaultValue) < 0.001);
field.setTestValue(null, expectedValue);
actualValue = field.getDoubleValue();
assertTrue(Math.abs(actualValue - defaultDefaultValue) < 0.001);
field.populateExpression(null);
actualValue = field.getDoubleValue();
assertTrue(Math.abs(actualValue - defaultDefaultValue) < 0.001);
field.createUI();
field.populateField(expectedValue);
actualValue = field.getDoubleValue();
assertTrue(Math.abs(actualValue - expectedValue) < 0.001);
double expectedValue2 = 0.14;
field.setTestValue(null, expectedValue2);
actualValue = field.getDoubleValue();
assertTrue(Math.abs(actualValue - expectedValue2) < 0.001);
Integer expectedValue3a = Integer.valueOf(1);
field.populateExpression(expectedValue3a);
actualValue = field.getDoubleValue();
assertTrue(Math.abs(actualValue - expectedValue3a) < 0.001);
Double expectedValue3c = Double.valueOf(0.4);
field.populateExpression(expectedValue3c);
actualValue = field.getDoubleValue();
assertTrue(Math.abs(actualValue - expectedValue3c) < 0.001);
double expectedValue3d = 0.87;
String expectedValue3dString = String.valueOf(expectedValue3d);
field.populateExpression(expectedValue3dString);
actualValue = field.getDoubleValue();
assertTrue(Math.abs(actualValue - expectedValue3d) < 0.001);
}
Aggregations