Tests weren't deleting temporary files: fixed

This commit is contained in:
Federico Fissore 2015-04-15 11:00:23 +02:00
parent 96c4576962
commit dabd6e4903
2 changed files with 6 additions and 9 deletions

View File

@ -1,12 +1,12 @@
package processing.app;
import cc.arduino.files.DeleteFilesOnShutdown;
import org.fest.swing.edt.FailOnThreadViolationRepaintManager;
import org.fest.swing.edt.GuiActionRunner;
import org.fest.swing.edt.GuiQuery;
import org.junit.After;
import org.junit.Before;
import processing.app.helpers.ArduinoFrameFixture;
import processing.app.helpers.FileUtils;
import javax.swing.*;
@ -17,6 +17,7 @@ public abstract class AbstractGUITest {
@Before
public void startUpTheIDE() throws Exception {
System.setProperty("mrj.version", "whynot"); //makes sense only on osx. See https://github.com/alexruiz/fest-swing-1.x/issues/2#issuecomment-86532042
Runtime.getRuntime().addShutdownHook(new Thread(DeleteFilesOnShutdown.INSTANCE));
FailOnThreadViolationRepaintManager.install();
@ -26,6 +27,7 @@ public abstract class AbstractGUITest {
Theme.init();
Base.getPlatform().setLookAndFeel();
Base.untitledFolder = Base.createTempFolder("untitled");
DeleteFilesOnShutdown.add(Base.untitledFolder);
window = GuiActionRunner.execute(new GuiQuery<ArduinoFrameFixture>() {
@Override
@ -38,7 +40,6 @@ public abstract class AbstractGUITest {
@After
public void stopTheIDE() {
window.cleanUp();
FileUtils.recursiveDelete(Base.untitledFolder);
}
}

View File

@ -1,23 +1,19 @@
package processing.app;
import org.junit.After;
import cc.arduino.files.DeleteFilesOnShutdown;
import org.junit.Before;
import processing.app.helpers.FileUtils;
public abstract class AbstractWithPreferencesTest {
@Before
public void init() throws Exception {
Runtime.getRuntime().addShutdownHook(new Thread(DeleteFilesOnShutdown.INSTANCE));
Base.initPlatform();
Preferences.init(null);
Theme.init();
Base.untitledFolder = Base.createTempFolder("untitled");
DeleteFilesOnShutdown.add(Base.untitledFolder);
}
@After
public void cleanup() {
FileUtils.recursiveDelete(Base.untitledFolder);
}
}