use of com.sldeditor.ui.detail.config.FieldConfigSymbolType in project sldeditor by robward-scisys.
the class FieldConfigSymbolTypeTest method testUndoAction.
/**
* Test method for {@link
* com.sldeditor.ui.detail.config.FieldConfigSymbolType#undoAction(com.sldeditor.common.undo.UndoInterface)}.
* Test method for {@link
* com.sldeditor.ui.detail.config.FieldConfigSymbolType#redoAction(com.sldeditor.common.undo.UndoInterface)}.
*/
@Test
public void testUndoAction() {
UndoManager.getInstance().setPopulationCheck(Controller.getInstance());
boolean valueOnly = true;
FieldConfigSymbolType field = new FieldConfigSymbolType(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly, false));
field.undoAction(null);
field.redoAction(null);
field.createUI();
field.createUI();
FieldConfigMarker marker = new FieldConfigMarker(new FieldConfigCommonData(String.class, FieldIdEnum.ANGLE, "label", valueOnly, false), null, null, null);
marker.createUI();
List<ValueComboBoxData> dataList = new ArrayList<ValueComboBoxData>();
dataList.add(new ValueComboBoxData("key 1", "Value 1", FieldConfigMarker.class));
dataList.add(new ValueComboBoxData("key 2", "Value 2", FieldConfigMarker.class));
dataList.add(new ValueComboBoxData("key 3", "Value 3", FieldConfigMarker.class));
List<ValueComboBoxDataGroup> combinedSymbolList = new ArrayList<ValueComboBoxDataGroup>();
combinedSymbolList.add(new ValueComboBoxDataGroup(dataList));
field.createUI();
field.addField(marker);
field.populate(null, combinedSymbolList);
String expectedValue2 = "key 2";
field.populateExpression(expectedValue2);
String actualValue2 = field.getStringValue();
assertTrue(actualValue2.compareTo(field.getStringValue()) == 0);
ValueComboBoxData actualValueObj2 = field.getEnumValue();
assertNotNull(actualValueObj2.getKey());
assertTrue(actualValueObj2.getKey().compareTo(expectedValue2) == 0);
String expectedValue3 = "key 1";
field.populateField(expectedValue3);
String actualValue3 = field.getStringValue();
assertTrue(expectedValue3.compareTo(actualValue3) == 0);
String expectedValue4 = "key 3";
field.populateField(expectedValue4);
String actualValue4 = field.getStringValue();
assertTrue(expectedValue4.compareTo(actualValue4) == 0);
UndoManager.getInstance().undo();
String actualValue = field.getStringValue();
assertTrue(expectedValue3.compareTo(actualValue) == 0);
UndoManager.getInstance().redo();
actualValue = field.getStringValue();
assertTrue(expectedValue4.compareTo(actualValue) == 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)));
UndoManager.getInstance().setPopulationCheck(null);
}
use of com.sldeditor.ui.detail.config.FieldConfigSymbolType in project sldeditor by robward-scisys.
the class FieldConfigSymbolTypeTest method testSetEnabled.
/**
* Test method for {@link
* com.sldeditor.ui.detail.config.FieldConfigSymbolType#internalSetEnabled(boolean)}. Test
* method for {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#isEnabled()}.
*/
@Test
public void testSetEnabled() {
// Value only, no attribute/expression dropdown
boolean valueOnly = true;
FieldConfigSymbolType field = new FieldConfigSymbolType(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly, false));
// Text field will not have been created
boolean expectedValue = true;
field.internalSetEnabled(expectedValue);
assertFalse(field.isEnabled());
// Create text field
field.createUI();
assertEquals(expectedValue, field.isEnabled());
expectedValue = false;
field.internalSetEnabled(expectedValue);
assertEquals(expectedValue, field.isEnabled());
// Has attribute/expression dropdown
valueOnly = false;
FieldConfigSymbolType field2 = new FieldConfigSymbolType(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly, false));
// Text field will not have been created
expectedValue = true;
field2.internalSetEnabled(expectedValue);
assertFalse(field2.isEnabled());
// Create text field
field2.createUI();
assertEquals(expectedValue, field2.isEnabled());
expectedValue = false;
field2.internalSetEnabled(expectedValue);
// Actual value is coming from the attribute panel, not the text field
assertEquals(!expectedValue, field2.isEnabled());
}
use of com.sldeditor.ui.detail.config.FieldConfigSymbolType in project sldeditor by robward-scisys.
the class FieldConfigFilenameTest method testGetFill.
/**
* Test method for {@link
* com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename#getFill(org.opengis.style.GraphicFill,
* com.sldeditor.ui.detail.GraphicPanelFieldManager)}.
*/
@Test
public void testGetFill() {
boolean valueOnly = true;
FieldConfigFilename field = new FieldConfigFilename(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly, false), null, null, null);
GraphicFill graphicFill = null;
GraphicPanelFieldManager fieldConfigManager = null;
assertNull(field.getFill(graphicFill, fieldConfigManager));
Class<?> panelId = PointFillDetails.class;
FieldIdEnum colourFieldId = FieldIdEnum.FILL_COLOUR;
FieldConfigColour colourField = new FieldConfigColour(new FieldConfigCommonData(panelId, colourFieldId, "", false, false));
colourField.createUI();
String expectedColourValue = "#012345";
colourField.setTestValue(FieldIdEnum.UNKNOWN, expectedColourValue);
double expectedOpacityValue = 0.72;
FieldConfigSlider opacityField = new FieldConfigSlider(new FieldConfigCommonData(panelId, colourFieldId, "", false, false));
opacityField.createUI();
opacityField.populateField(expectedOpacityValue);
FieldConfigBase symbolSelectionField = new FieldConfigSymbolType(new FieldConfigCommonData(panelId, colourFieldId, "", false, false));
symbolSelectionField.createUI();
fieldConfigManager = new GraphicPanelFieldManager(panelId);
fieldConfigManager.add(colourFieldId, colourField);
FieldIdEnum opacityFieldId = FieldIdEnum.OVERALL_OPACITY;
fieldConfigManager.add(opacityFieldId, opacityField);
FieldIdEnum symbolSelectionFieldId = FieldIdEnum.SYMBOL_TYPE;
fieldConfigManager.add(symbolSelectionFieldId, symbolSelectionField);
field.createUI();
StyleBuilder styleBuilder = new StyleBuilder();
graphicFill = styleBuilder.createGraphic();
Fill actualValue = field.getFill(graphicFill, fieldConfigManager);
assertTrue(actualValue.getOpacity().toString().compareTo(String.valueOf(expectedOpacityValue)) == 0);
}
Aggregations