use of com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig in project sldeditor by robward-scisys.
the class FieldConfigEnumTest method testRevertToDefaultValue.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigEnum#revertToDefaultValue()}. Test method
* for {@link com.sldeditor.ui.detail.config.FieldConfigEnum#addConfig(java.util.List)}. Test
* method for
* {@link com.sldeditor.ui.detail.config.FieldConfigEnum#setDefaultValue(java.lang.String)}.
*/
@Test
public void testRevertToDefaultValue() {
boolean valueOnly = true;
FieldConfigEnum field = new FieldConfigEnum(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
field.revertToDefaultValue();
assertEquals(0, field.getIntValue());
SymbolTypeConfig s1 = new SymbolTypeConfig(null);
s1.addOption("key1", "Value 1");
s1.addOption("key2", "Value 2");
s1.addOption("key3", "Value 3");
s1.addField(FieldIdEnum.ANCHOR_POINT_H, true);
s1.addField(FieldIdEnum.ANCHOR_POINT_V, false);
List<SymbolTypeConfig> configList = new ArrayList<SymbolTypeConfig>();
configList.add(s1);
SymbolTypeConfig s2 = new SymbolTypeConfig(null);
s2.addOption("key4", "Value 4");
s2.addOption("key5", "Value 5");
s2.addOption("key6", "Value 6");
s2.addField(FieldIdEnum.ANGLE, true);
s2.addField(FieldIdEnum.DESCRIPTION, false);
configList.add(s2);
field.addConfig(configList);
field.createUI();
String expectedDefaultValue = "key6";
field.setDefaultValue(expectedDefaultValue);
field.revertToDefaultValue();
assertTrue(expectedDefaultValue.compareTo(field.getStringValue()) == 0);
}
use of com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig in project sldeditor by robward-scisys.
the class FieldConfigEnumTest method testUndoAction.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigEnum#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigEnum#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
SymbolTypeConfig s1 = new SymbolTypeConfig(null);
s1.addOption("key1", "Value 1");
s1.addOption("key2", "Value 2");
s1.addOption("key3", "Value 3");
s1.addField(FieldIdEnum.ANCHOR_POINT_H, true);
s1.addField(FieldIdEnum.ANCHOR_POINT_V, false);
List<SymbolTypeConfig> configList = new ArrayList<SymbolTypeConfig>();
configList.add(s1);
SymbolTypeConfig s2 = new SymbolTypeConfig(null);
s2.addOption("key4", "Value 4");
s2.addOption("key5", "Value 5");
s2.addOption("key6", "Value 6");
s2.addField(FieldIdEnum.ANGLE, true);
s2.addField(FieldIdEnum.DESCRIPTION, false);
configList.add(s2);
boolean valueOnly = true;
FieldConfigEnum field = new FieldConfigEnum(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
field.addConfig(null);
assertNull(field.getStringValue());
field.addConfig(configList);
// Now create the ui
field.createUI();
String expectedValue1 = "key2";
field.populateField(expectedValue1);
String expectedValue2 = "key6";
field.populateField(expectedValue2);
UndoManager.getInstance().undo();
String actualValueString = field.getStringValue();
assertTrue(expectedValue1.compareTo(actualValueString) == 0);
ValueComboBoxData actualValue = field.getEnumValue();
assertTrue(expectedValue1.compareTo(actualValue.getKey()) == 0);
UndoManager.getInstance().redo();
actualValueString = field.getStringValue();
assertTrue(expectedValue2.compareTo(actualValueString) == 0);
actualValue = field.getEnumValue();
assertTrue(expectedValue2.compareTo(actualValue.getKey()) == 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)));
}
Aggregations