use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigInlineFeatureTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
FieldConfigInlineFeature field = new FieldConfigInlineFeature(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, null, true));
field.undoAction(null);
field.redoAction(null);
field.createUI();
DummyInlineSLDFile testData1 = new DummyInlineSLDFile();
UserLayer userLayer1 = (UserLayer) testData1.getSLD().layers().get(0);
field.populateField(userLayer1);
String expectedValue1 = InlineFeatureUtils.getInlineFeaturesText(userLayer1);
String actualValue = field.getStringValue();
assertTrue(actualValue.compareTo(expectedValue1) == 0);
DummyInlineSLDFile2 testData2 = new DummyInlineSLDFile2();
UserLayer userLayer2 = (UserLayer) testData2.getSLD().layers().get(0);
field.populateField(userLayer2);
String expectedValue2 = InlineFeatureUtils.getInlineFeaturesText(userLayer2);
actualValue = field.getStringValue();
assertTrue(actualValue.compareTo(expectedValue2) == 0);
UndoManager.getInstance().undo();
actualValue = field.getStringValue();
assertTrue(actualValue.compareTo(expectedValue1) == 0);
UndoManager.getInstance().redo();
actualValue = field.getStringValue();
assertTrue(actualValue.compareTo(expectedValue2) == 0);
// Increase the code coverage
field.undoAction(null);
field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(42.0), Integer.valueOf(11)));
field.redoAction(null);
field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(454.0), Integer.valueOf(69)));
}
use of com.sldeditor.common.undo.UndoEvent in project sldeditor by robward-scisys.
the class FieldConfigSortByTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigSortBy#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigSortBy#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
boolean valueOnly = true;
FieldConfigSortBy field = new FieldConfigSortBy(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly));
field.undoAction(null);
field.redoAction(null);
field.createUI();
field.createUI();
field.undoAction(null);
field.redoAction(null);
String expectedTestValue = "test A, test2 D";
field.setTestValue(null, expectedTestValue);
assertTrue(expectedTestValue.compareTo(field.getStringValue()) == 0);
String expectedUndoTestValue = "test2 D";
String expectedRedoTestValue = "test A, test2 D";
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 FieldConfigBooleanTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBoolean#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBoolean#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
boolean valueOnly = true;
FieldConfigBoolean field = new FieldConfigBoolean(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly));
field.undoAction(null);
field.redoAction(null);
field.createUI();
field.populateField(Boolean.TRUE);
field.populateField(Boolean.FALSE);
assertFalse(field.getBooleanValue());
UndoManager.getInstance().undo();
assertTrue(field.getBooleanValue());
UndoManager.getInstance().redo();
assertFalse(field.getBooleanValue());
field.setTestValue(null, true);
assertTrue(field.getBooleanValue());
assertTrue(field.getStringValue().toLowerCase().compareTo("true") == 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 FieldConfigColourTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigColour#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigColour#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
FieldConfigColour field = new FieldConfigColour(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", false));
field.undoAction(null);
field.redoAction(null);
field.createUI();
String colour1 = "#123456";
field.populateExpression(colour1);
String colour2 = "#AABBCC";
field.populateExpression(colour2);
UndoManager.getInstance().undo();
String actualValue = field.getStringValue();
assertTrue(colour1.compareTo(actualValue) == 0);
UndoManager.getInstance().redo();
actualValue = field.getStringValue();
assertTrue(colour2.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 FieldConfigDSPropertiesTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigDSProperties#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigDSProperties#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
boolean valueOnly = true;
TestDataSource testDataSource = new TestDataSource();
@SuppressWarnings("unused") DataSourceInterface dataSource = DataSourceFactory.createDataSource(testDataSource);
FieldConfigDSProperties field = new FieldConfigDSProperties(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
field.dataSourceLoaded(GeometryTypeEnum.POLYGON, false);
assertNull(field.getStringValue());
// Now create the ui
field.createUI();
String expectedValue1 = "Date_2";
field.populateField(expectedValue1);
String expectedValue2 = "String_3";
field.populateField(expectedValue2);
UndoManager.getInstance().undo();
String actualValueString = field.getStringValue();
assertTrue(expectedValue1.compareTo(actualValueString) == 0);
UndoManager.getInstance().redo();
actualValueString = field.getStringValue();
assertTrue(expectedValue2.compareTo(actualValueString) == 0);
// Increase the code coverage
field.undoAction(null);
field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(0), Double.valueOf(23)));
field.redoAction(null);
field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(0), Double.valueOf(54)));
DataSourceFactory.reset();
}
Aggregations