use of com.sldeditor.ui.detail.config.FieldConfigCommonData 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.ui.detail.config.FieldConfigCommonData in project sldeditor by robward-scisys.
the class FieldConfigColourTest method testSetEnabled.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigColour#internal_setEnabled(boolean)}. Test
* method for {@link com.sldeditor.ui.detail.config.FieldConfigColour#isEnabled()}.
*/
@Test
public void testSetEnabled() {
// Value only, no attribute/expression dropdown
boolean valueOnly = true;
FieldConfigColour field = new FieldConfigColour(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly));
// Text field will not have been created
boolean expectedValue = true;
field.internal_setEnabled(expectedValue);
assertFalse(field.isEnabled());
// Create text field
field.createUI();
field.createUI();
assertEquals(expectedValue, field.isEnabled());
expectedValue = false;
field.internal_setEnabled(expectedValue);
assertEquals(expectedValue, field.isEnabled());
// Has attribute/expression dropdown
valueOnly = false;
FieldConfigColour field2 = new FieldConfigColour(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly));
// Text field will not have been created
expectedValue = true;
field2.internal_setEnabled(expectedValue);
assertFalse(field2.isEnabled());
// Create text field
field2.createUI();
assertEquals(expectedValue, field2.isEnabled());
expectedValue = false;
field2.internal_setEnabled(expectedValue);
// Actual value is coming from the attribute panel, not the text field
assertEquals(!expectedValue, field2.isEnabled());
}
use of com.sldeditor.ui.detail.config.FieldConfigCommonData in project sldeditor by robward-scisys.
the class FieldConfigDSPropertiesTest method testCreateCopy.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigDSProperties#createCopy(com.sldeditor.ui.detail.config.FieldConfigBase)}.
*/
@Test
public void testCreateCopy() {
boolean valueOnly = true;
class TestFieldConfigDSProperties extends FieldConfigDSProperties {
public TestFieldConfigDSProperties(FieldConfigCommonData commonData) {
super(commonData);
}
public FieldConfigPopulate callCreateCopy(FieldConfigBase fieldConfigBase) {
return createCopy(fieldConfigBase);
}
}
TestFieldConfigDSProperties field = new TestFieldConfigDSProperties(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
FieldConfigDSProperties copy = (FieldConfigDSProperties) field.callCreateCopy(null);
assertNull(copy);
copy = (FieldConfigDSProperties) field.callCreateCopy(field);
assertEquals(field.getFieldId(), copy.getFieldId());
assertTrue(field.getLabel().compareTo(copy.getLabel()) == 0);
assertEquals(field.isValueOnly(), copy.isValueOnly());
}
use of com.sldeditor.ui.detail.config.FieldConfigCommonData in project sldeditor by robward-scisys.
the class FieldConfigDSPropertiesTest method testSetVisible.
/**
* Test method for {@link com.sldeditor.ui.detail.config.FieldConfigDSProperties#setVisible(boolean)}.
*/
@Test
public void testSetVisible() {
boolean valueOnly = true;
FieldConfigDSProperties field = new FieldConfigDSProperties(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
boolean expectedValue = true;
field.setVisible(expectedValue);
field.createUI();
field.setVisible(expectedValue);
expectedValue = false;
field.setVisible(expectedValue);
}
use of com.sldeditor.ui.detail.config.FieldConfigCommonData 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