use of com.sldeditor.ui.detail.config.FieldConfigCommonData in project sldeditor by robward-scisys.
the class FieldConfigBaseTest method testFunctionUpdated.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBase#functionUpdated(org.opengis.filter.expression.Expression)}.
*/
@Test
public void testFunctionUpdated() {
FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
String expectedLabel = "test label";
TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, false));
TestUpdateSymbolInterface listener = new TestUpdateSymbolInterface();
field.addDataChangedListener(listener);
assertFalse(listener.hasBeenCalled());
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
DefaultFunctionFactory functionFactory = new DefaultFunctionFactory();
FunctionName functionName = null;
for (FunctionName func : functionFactory.getFunctionNames()) {
if (func.getName() == "greaterThan") {
functionName = func;
break;
}
}
assertNotNull(functionName);
Expression testExpression = ff.function(functionName.getFunctionName(), ff.literal(1), ff.literal(2));
field.functionUpdated(testExpression);
assertTrue(listener.hasBeenCalled());
assertEquals(ExpressionTypeEnum.E_FUNCTION, field.getExpressionType());
Expression expression = field.getExpression();
assertTrue(expression.toString().startsWith(functionName.getName()));
}
use of com.sldeditor.ui.detail.config.FieldConfigCommonData 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.ui.detail.config.FieldConfigCommonData in project sldeditor by robward-scisys.
the class FieldConfigBooleanTest method testGenerateExpression.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBoolean#generateExpression()}.
*/
@Test
public void testGenerateExpression() {
boolean valueOnly = true;
FieldConfigBoolean field = new FieldConfigBoolean(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly));
field.setTestValue(null, true);
field.populateField((Boolean) null);
field.populateField(Boolean.TRUE);
field.populateExpression(null);
field.createUI();
field.createUI();
field.populateField(Boolean.TRUE);
assertTrue(field.getBooleanValue());
field.populateExpression(Boolean.FALSE);
assertFalse(field.getBooleanValue());
field.setTestValue(null, true);
assertTrue(field.getBooleanValue());
assertTrue(field.getStringValue().toLowerCase().compareTo("true") == 0);
}
use of com.sldeditor.ui.detail.config.FieldConfigCommonData in project sldeditor by robward-scisys.
the class FieldConfigBoundingBoxTest method testSetEnabled.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBoundingBox#internal_setEnabled(boolean)}.
* Test method for {@link com.sldeditor.ui.detail.config.FieldConfigBoundingBox#isEnabled()}.
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigBoundingBox#createUI(javax.swing.Box)}.
*/
@Test
public void testSetEnabled() {
// Value only, no attribute/expression dropdown
boolean valueOnly = true;
FieldConfigBoundingBox field = new FieldConfigBoundingBox(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();
assertEquals(expectedValue, field.isEnabled());
expectedValue = false;
field.internal_setEnabled(expectedValue);
assertEquals(expectedValue, field.isEnabled());
// Has attribute/expression dropdown
valueOnly = false;
FieldConfigBoundingBox field2 = new FieldConfigBoundingBox(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 FieldConfigColourTest method testAttributeSelection.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.FieldConfigColour#attributeSelection(java.lang.String)}.
*/
@Test
public void testAttributeSelection() {
boolean valueOnly = true;
FieldConfigColour field = new FieldConfigColour(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly));
field.attributeSelection(null);
// Does nothing
}
Aggregations