use of com.sldeditor.ui.detail.config.font.FieldConfigFontPreview in project sldeditor by robward-scisys.
the class FieldConfigFontPreviewTest method testRevertToDefaultValue.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#revertToDefaultValue()}.
* Test method for
* {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#setDefaultValue(java.lang.String)}.
*/
@Test
public void testRevertToDefaultValue() {
boolean valueOnly = true;
FieldConfigFontPreview field = new FieldConfigFontPreview(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly));
field.revertToDefaultValue();
String actualValue = field.getStringValue();
assertNull(actualValue);
field.createUI();
String expectedDefaultValue = fontFamilies[2];
field.setDefaultValue(expectedDefaultValue);
field.revertToDefaultValue();
actualValue = field.getStringValue();
// It returns the sample text
assertNotNull(actualValue);
}
use of com.sldeditor.ui.detail.config.font.FieldConfigFontPreview in project sldeditor by robward-scisys.
the class FieldConfigFontPreviewTest method testGenerateExpression.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#generateExpression()}. Test
* method for
* {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#populateField(org.geotools.styling.Font)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#getStringValue()}.
*/
@Test
public void testGenerateExpression() {
boolean valueOnly = true;
FieldConfigFontPreview field = new FieldConfigFontPreview(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly));
field.setTestValue(FieldIdEnum.UNKNOWN, (String) null);
field.populateField((String) null);
field.populateField((Font) null);
field.populateExpression((Font) null);
String expectedValue = fontFamilies[0];
field.createUI();
field.populateField(expectedValue);
String actualValue = field.getStringValue();
assertNotNull(actualValue);
field.setTestValue(FieldIdEnum.UNKNOWN, expectedValue);
actualValue = field.getStringValue();
assertNotNull(actualValue);
StyleBuilder styleBuilder = new StyleBuilder();
Font f1 = styleBuilder.createFont(expectedValue, false, true, 24.0);
field.populateField(f1);
assertNotNull(field.getStringValue());
Font f2 = styleBuilder.createFont(expectedValue, true, true, 24.0);
field.populateField(f2);
assertNotNull(field.getStringValue());
Font f3 = styleBuilder.createFont(expectedValue, true, false, 24.0);
field.populateField(f3);
assertNotNull(field.getStringValue());
Font f4 = styleBuilder.createFont(expectedValue, false, false, 24.0);
field.populateField(f4);
assertNotNull(field.getStringValue());
}
use of com.sldeditor.ui.detail.config.font.FieldConfigFontPreview in project sldeditor by robward-scisys.
the class FieldConfigFontPreviewTest method testCreateCopy.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#createCopy(com.sldeditor.ui.detail.config.FieldConfigBase)}.
*/
@Test
public void testCreateCopy() {
boolean valueOnly = true;
class TestFieldConfigFontPreview extends FieldConfigFontPreview {
public TestFieldConfigFontPreview(FieldConfigCommonData commonData) {
super(commonData);
}
public FieldConfigPopulate callCreateCopy(FieldConfigBase fieldConfigBase) {
return createCopy(fieldConfigBase);
}
}
TestFieldConfigFontPreview field = new TestFieldConfigFontPreview(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly));
FieldConfigFontPreview copy = (FieldConfigFontPreview) field.callCreateCopy(null);
assertNull(copy);
copy = (FieldConfigFontPreview) field.callCreateCopy(field);
assertEquals(field.getFieldId(), copy.getFieldId());
assertTrue(field.getLabel().compareTo(copy.getLabel()) == 0);
assertEquals(field.isValueOnly(), copy.isValueOnly());
}
Aggregations