use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigColourMapTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
FieldConfigColourMap field = new FieldConfigColourMap(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", true));
field.undoAction(null);
field.redoAction(null);
field.createUI();
ColorMap expectedValue1 = new ColorMapImpl();
field.populateField(expectedValue1);
assertEquals(expectedValue1, field.getColourMap());
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
ColorMap expectedValue2 = new ColorMapImpl();
ColorMapEntryImpl entry = new ColorMapEntryImpl();
entry.setColor(ff.literal("#001122"));
expectedValue2.addColorMapEntry(entry);
field.populateField(expectedValue2);
UndoManager.getInstance().undo();
assertEquals(expectedValue1.getColorMapEntries().length, field.getColourMap().getColorMapEntries().length);
UndoManager.getInstance().redo();
assertEquals(expectedValue2.getColorMapEntries().length, field.getColourMap().getColorMapEntries().length);
// 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.common.undo.UndoEvent 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.common.undo.UndoEvent 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.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigRangeTest method testUndoAction.
/**
* Test method for {@link com.sldeditor.ui.detail.config.FieldConfigRange#undoAction(com.sldeditor.common.undo.UndoInterface)}. Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigRange#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@SuppressWarnings("rawtypes")
@Test
public void testUndoAction() {
boolean valueOnly = true;
FieldConfigRange field = new FieldConfigRange(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly), org.jaitools.numeric.Range.class);
field.undoAction(null);
field.redoAction(null);
Range expectedValue1 = Range.create(3.0, false, 11.0, false);
field.createUI();
field.populateField(expectedValue1);
Range actualValue = field.getRange();
assertTrue(Math.abs(actualValue.getMin().doubleValue() - expectedValue1.getMin().doubleValue()) < 0.001);
assertEquals(actualValue.isMinIncluded(), expectedValue1.isMinIncluded());
assertTrue(Math.abs(actualValue.getMax().doubleValue() - expectedValue1.getMax().doubleValue()) < 0.001);
assertEquals(actualValue.isMaxIncluded(), expectedValue1.isMaxIncluded());
Range expectedValue2 = Range.create(23.0, true, 51.0, false);
field.populateField(expectedValue2);
actualValue = field.getRange();
assertTrue(Math.abs(actualValue.getMin().doubleValue() - expectedValue2.getMin().doubleValue()) < 0.001);
assertEquals(actualValue.isMinIncluded(), expectedValue2.isMinIncluded());
assertTrue(Math.abs(actualValue.getMax().doubleValue() - expectedValue2.getMax().doubleValue()) < 0.001);
assertEquals(actualValue.isMaxIncluded(), expectedValue2.isMaxIncluded());
UndoManager.getInstance().undo();
actualValue = field.getRange();
assertTrue(Math.abs(actualValue.getMin().doubleValue() - expectedValue1.getMin().doubleValue()) < 0.001);
assertEquals(actualValue.isMinIncluded(), expectedValue1.isMinIncluded());
assertTrue(Math.abs(actualValue.getMax().doubleValue() - expectedValue1.getMax().doubleValue()) < 0.001);
assertEquals(actualValue.isMaxIncluded(), expectedValue1.isMaxIncluded());
UndoManager.getInstance().redo();
actualValue = field.getRange();
assertTrue(Math.abs(actualValue.getMin().doubleValue() - expectedValue2.getMin().doubleValue()) < 0.001);
assertEquals(actualValue.isMinIncluded(), expectedValue2.isMinIncluded());
assertTrue(Math.abs(actualValue.getMax().doubleValue() - expectedValue2.getMax().doubleValue()) < 0.001);
assertEquals(actualValue.isMaxIncluded(), expectedValue2.isMaxIncluded());
// 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.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigSliderTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigSlider#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigSlider#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
boolean valueOnly = true;
FieldConfigSlider field = new FieldConfigSlider(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly));
field.undoAction(null);
field.redoAction(null);
double expectedValue1 = 0.13;
field.createUI();
field.populateField(expectedValue1);
assertTrue(Math.abs(field.getDoubleValue() - expectedValue1) < 0.001);
double expectedValue2 = 0.98;
field.setTestValue(null, 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.undoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
field.redoAction(null);
field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
}
Aggregations