use of com.sldeditor.test.unit.datasource.impl.DummyExternalSLDFile in project sldeditor by robward-scisys.
the class LegendPanelImageTest method testRenderSymbol.
/**
* Test method for {@link com.sldeditor.ui.legend.LegendPanelImage#renderSymbol()}.
*/
@Test
void testRenderSymbol() {
TestLegendPanelImage testObj = new TestLegendPanelImage();
DummyExternalSLDFile external = new DummyExternalSLDFile();
SelectedSymbol.getInstance().setSld(external.getSLD());
testObj.renderSymbol();
testObj.setFilenameDisplayed(true);
testObj.showFilenamePressed();
testObj.setFilenameDisplayed(false);
testObj.showFilenamePressed();
testObj.setStyleNameDisplayed(true);
testObj.showStyleNamePressed();
testObj.setStyleNameDisplayed(false);
testObj.showStyleNamePressed();
// Empty style layer name
StyledLayer styledLayer = external.getSLD().layers().get(0);
styledLayer.setName(null);
testObj.setStyleNameDisplayed(true);
testObj.showStyleNamePressed();
File selectedFile = null;
try {
selectedFile = File.createTempFile("test", ".sld");
} catch (IOException e) {
fail(e.getMessage());
}
// Write legend image with no file filter
Image image = testObj.getImageIcon().getImage();
File f = null;
try {
f = testObj.writeLegendImage(null, selectedFile, image);
} catch (IOException e) {
fail(e.getMessage());
}
assertTrue(f.exists());
f.delete();
selectedFile.delete();
// Write legend image with file filter and no file suffix
try {
selectedFile = File.createTempFile("test", "test");
} catch (IOException e) {
fail(e.getMessage());
}
image = testObj.getImageIcon().getImage();
try {
f = testObj.writeLegendImage(new ImageFilter(ImageFileExtensionUtils.PNG), selectedFile, image);
} catch (IOException e) {
fail(e.getMessage());
}
assertTrue(f.exists());
f.delete();
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection stringSelection = new StringSelection("cleared clipboard");
c.setContents(stringSelection, null);
testObj.copyToClipboard();
c = Toolkit.getDefaultToolkit().getSystemClipboard();
assertTrue(c.isDataFlavorAvailable(DataFlavor.imageFlavor));
selectedFile.delete();
}
use of com.sldeditor.test.unit.datasource.impl.DummyExternalSLDFile in project sldeditor by robward-scisys.
the class SLDEditorOperationsTest method testReloadSLDFile.
/**
* Test method for {@link com.sldeditor.SLDEditorOperations#reloadSLDFile()}.
*/
@Test
void testReloadSLDFile() {
SLDEditorOperations.getInstance().reloadSLDFile();
DummyExternalSLDFile external = new DummyExternalSLDFile();
SLDEditorFile.getInstance().setSLDData(external.getSLDData());
SLDEditorMain testObj = new SLDEditorMain(null);
File f = null;
try {
f = File.createTempFile("test", ".sld");
} catch (IOException e) {
fail(e.getMessage());
}
external.getSLDData().setSLDFile(f);
try {
testObj.saveFile(f.toURI().toURL());
} catch (MalformedURLException e) {
fail(e.getMessage());
}
assertTrue(f.exists());
FileSystemExtensionFactory.getFileExtensionList(null);
SLDEditorOperations.getInstance().reloadSLDFile();
FileSystemExtensionFactory.override(null);
f.delete();
}
use of com.sldeditor.test.unit.datasource.impl.DummyExternalSLDFile in project sldeditor by robward-scisys.
the class SLDEditorMainTest method testChooseNewSLD.
/**
* Test method for {@link com.sldeditor.SLDEditorMain#chooseNewSLD()}.
*/
@Test
void testChooseNewSLD() {
TestSLDEditorMain testObj = new TestSLDEditorMain(new JPanel());
JFrame frame = new JFrame();
Controller.getInstance().setFrame(frame);
testObj.newSLD(null);
// SLD file
DummyExternalSLDFile external = new DummyExternalSLDFile();
List<SLDDataInterface> newSLDList = new ArrayList<SLDDataInterface>();
newSLDList.add(external.getSLDData());
testObj.newSLD(newSLDList);
}
use of com.sldeditor.test.unit.datasource.impl.DummyExternalSLDFile in project sldeditor by robward-scisys.
the class SLDEditorMainTest method testSaveFile.
/**
* Test method for {@link com.sldeditor.SLDEditorMain#saveFile(java.net.URL)}.
*/
@Test
void testSaveFile() {
TestSLDEditorMain testObj = new TestSLDEditorMain(new JPanel());
testObj.saveFile(null);
// SLD file
DummyExternalSLDFile external = new DummyExternalSLDFile();
SLDEditorFile.getInstance().setSLDData(external.getSLDData());
File f = null;
try {
f = File.createTempFile("test", ".sld");
} catch (IOException e) {
fail(e.getMessage());
}
try {
testObj.saveFile(f.toURI().toURL());
} catch (MalformedURLException e) {
fail(e.getMessage());
}
assertTrue(f.exists());
f.delete();
}
use of com.sldeditor.test.unit.datasource.impl.DummyExternalSLDFile in project sldeditor by robward-scisys.
the class SLDEditorMainTest method testUpdateWindowTitle.
/**
* Test method for {@link com.sldeditor.SLDEditorMain#updateWindowTitle(boolean)}.
*/
@Test
void testUpdateWindowTitle() {
TestSLDEditorMain testObj = new TestSLDEditorMain(new JPanel());
JFrame frame = new JFrame();
Controller.getInstance().setFrame(frame);
// No SLD Editor file and SLD file
testObj.updateWindowTitle(false);
String actual = Controller.getInstance().getFrame().getTitle();
assertEquals(SLDEditorMain.generateApplicationTitleString() + " - ", actual);
testObj.updateWindowTitle(true);
actual = Controller.getInstance().getFrame().getTitle();
assertEquals(SLDEditorMain.generateApplicationTitleString() + " - *", actual);
// SLD Editor file and SLD file
DummyExternalSLDFile external = new DummyExternalSLDFile();
SLDEditorFile.getInstance().setSLDData(external.getSLDData());
String sldEditorFile = "tmp.sldeditor";
SLDEditorFile.getInstance().setSldEditorFile(new File(sldEditorFile));
// Data not updated
testObj.updateWindowTitle(false);
actual = Controller.getInstance().getFrame().getTitle();
assertEquals(SLDEditorMain.generateApplicationTitleString() + " - " + sldEditorFile + " - " + external.getSLDData().getLayerName() + " ", actual);
// Data updated
testObj.updateWindowTitle(true);
actual = Controller.getInstance().getFrame().getTitle();
assertEquals(SLDEditorMain.generateApplicationTitleString() + " - " + sldEditorFile + " - " + external.getSLDData().getLayerName() + "*", actual);
// Just sld layer
SLDEditorFile.getInstance().setSldEditorFile(null);
testObj.updateWindowTitle(true);
actual = Controller.getInstance().getFrame().getTitle();
assertEquals(SLDEditorMain.generateApplicationTitleString() + " - " + external.getSLDData().getLayerName() + "*", actual);
}
Aggregations