use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigGeometryFieldTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#redoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#dataSourceLoaded(com.sldeditor.datasource.impl.GeometryTypeEnum, boolean)}.
*/
@Test
public void testUndoAction() {
FieldConfigGeometryField field = new FieldConfigGeometryField(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", true));
field.undoAction(null);
field.redoAction(null);
field.createUI();
field.undoAction(null);
field.redoAction(null);
TestDataSource testDataSource = new TestDataSource();
@SuppressWarnings("unused") DataSourceInterface dataSource = DataSourceFactory.createDataSource(testDataSource);
field.dataSourceLoaded(GeometryTypeEnum.POLYGON, false);
String expectedTestValue = testDataSource.getDefaultGeometryField();
field.setTestValue(FieldIdEnum.UNKNOWN, expectedTestValue);
assertTrue(expectedTestValue.compareTo(field.getStringValue()) == 0);
String expectedUndoTestValue = "";
String expectedRedoTestValue = testDataSource.getDefaultGeometryField();
UndoEvent undoEvent = new UndoEvent(null, FieldIdEnum.UNKNOWN, expectedUndoTestValue, expectedRedoTestValue);
field.undoAction(undoEvent);
assertTrue(expectedUndoTestValue.compareTo(field.getStringValue()) == 0);
field.redoAction(undoEvent);
assertTrue(expectedRedoTestValue.compareTo(field.getStringValue()) == 0);
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigGeometryTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigGeometry#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
FieldConfigGeometry field = new FieldConfigGeometry(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", false), "button text");
field.undoAction(null);
field.redoAction(null);
field.createUI();
field.setTestValue(FieldIdEnum.UNKNOWN, (String) null);
field.populateField((String) null);
field.populateExpression((String) null);
String wktPoint = "POINT( 48.44 -123.37)";
field.populateField(wktPoint);
String actualValue = field.getStringValue();
assertTrue(wktPoint.compareTo(actualValue) == 0);
String wktPolygon = "POLYGON((20 10, 30 0, 40 10, 30 20, 20 10))";
field.populateField(wktPolygon);
actualValue = field.getStringValue();
assertTrue(wktPolygon.compareTo(actualValue) == 0);
String wktLine = "LINESTRING(0 2, 2 0, 8 6)";
field.populateExpression(wktLine);
actualValue = field.getStringValue();
assertTrue(wktLine.compareTo(actualValue) == 0);
UndoManager.getInstance().undo();
actualValue = field.getStringValue();
assertTrue(wktPolygon.compareTo(actualValue) == 0);
UndoManager.getInstance().redo();
actualValue = field.getStringValue();
assertTrue(wktLine.compareTo(actualValue) == 0);
// 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 FieldConfigStringTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigString#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigString#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
boolean valueOnly = true;
FieldConfigString field = new FieldConfigString(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), "button text");
field.undoAction(null);
field.redoAction(null);
field.createUI();
field.createUI();
field.undoAction(null);
field.redoAction(null);
String expectedTestValue = "test value";
field.setTestValue(null, expectedTestValue);
assertTrue(expectedTestValue.compareTo(field.getStringValue()) == 0);
String expectedUndoTestValue = "undo value";
String expectedRedoTestValue = "redo value";
UndoEvent undoEvent = new UndoEvent(null, FieldIdEnum.UNKNOWN, expectedUndoTestValue, expectedRedoTestValue);
field.undoAction(undoEvent);
assertTrue(expectedUndoTestValue.compareTo(field.getStringValue()) == 0);
field.redoAction(undoEvent);
assertTrue(expectedRedoTestValue.compareTo(field.getStringValue()) == 0);
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigTransformationTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.transform.FieldConfigTransformation#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.transform.FieldConfigTransformation#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
boolean valueOnly = true;
FieldConfigTransformation field = new FieldConfigTransformation(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), "edit", "clear");
field.undoAction(null);
field.redoAction(null);
field.createUI();
field.undoAction(null);
field.redoAction(null);
String expectedTestValue = "test value";
field.setTestValue(FieldIdEnum.UNKNOWN, expectedTestValue);
assertTrue(expectedTestValue.compareTo(field.getStringValue()) == 0);
String expectedUndoTestValue = "undo value";
String expectedRedoTestValue = "redo value";
UndoEvent undoEvent = new UndoEvent(null, FieldIdEnum.UNKNOWN, expectedUndoTestValue, expectedRedoTestValue);
field.undoAction(undoEvent);
assertTrue(expectedUndoTestValue.compareTo(field.getStringValue()) == 0);
field.redoAction(undoEvent);
assertTrue(expectedRedoTestValue.compareTo(field.getStringValue()) == 0);
// Increase code coverage status
undoEvent = new UndoEvent(null, FieldIdEnum.UNKNOWN, Integer.valueOf(0), Double.valueOf(10.0));
field.undoAction(undoEvent);
field.redoAction(undoEvent);
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigBoundingBoxTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBoundingBox#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBoundingBox#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
FieldConfigBoundingBox field = new FieldConfigBoundingBox(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", false));
field.undoAction(null);
field.redoAction(null);
field.createUI();
field.createUI();
CoordinateReferenceSystem crs = CoordManager.getInstance().getWGS84();
ReferencedEnvelope envelope1 = new ReferencedEnvelope(0.0, 1.0, 51.0, 51.1, crs);
field.populateField(envelope1);
assertTrue(envelope1.toString().compareTo(field.getStringValue()) == 0);
ReferencedEnvelope envelope2 = new ReferencedEnvelope(-10.0, -4.0, 31.0, 45.11, crs);
field.populateField(envelope2);
assertTrue(envelope2.toString().compareTo(field.getStringValue()) == 0);
UndoManager.getInstance().undo();
String actualValue = field.getStringValue();
assertTrue(actualValue.compareTo(envelope1.toString()) == 0);
UndoManager.getInstance().redo();
actualValue = field.getStringValue();
assertTrue(actualValue.compareTo(envelope2.toString()) == 0);
field.undoAction(null);
field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
field.redoAction(null);
field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
}
Aggregations