1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-29 18:52:13 +01:00

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; package processing.app;
import cc.arduino.files.DeleteFilesOnShutdown;
import org.fest.swing.edt.FailOnThreadViolationRepaintManager; import org.fest.swing.edt.FailOnThreadViolationRepaintManager;
import org.fest.swing.edt.GuiActionRunner; import org.fest.swing.edt.GuiActionRunner;
import org.fest.swing.edt.GuiQuery; import org.fest.swing.edt.GuiQuery;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import processing.app.helpers.ArduinoFrameFixture; import processing.app.helpers.ArduinoFrameFixture;
import processing.app.helpers.FileUtils;
import javax.swing.*; import javax.swing.*;
@ -17,6 +17,7 @@ public abstract class AbstractGUITest {
@Before @Before
public void startUpTheIDE() throws Exception { 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 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(); FailOnThreadViolationRepaintManager.install();
@ -26,6 +27,7 @@ public abstract class AbstractGUITest {
Theme.init(); Theme.init();
Base.getPlatform().setLookAndFeel(); Base.getPlatform().setLookAndFeel();
Base.untitledFolder = Base.createTempFolder("untitled"); Base.untitledFolder = Base.createTempFolder("untitled");
DeleteFilesOnShutdown.add(Base.untitledFolder);
window = GuiActionRunner.execute(new GuiQuery<ArduinoFrameFixture>() { window = GuiActionRunner.execute(new GuiQuery<ArduinoFrameFixture>() {
@Override @Override
@ -38,7 +40,6 @@ public abstract class AbstractGUITest {
@After @After
public void stopTheIDE() { public void stopTheIDE() {
window.cleanUp(); window.cleanUp();
FileUtils.recursiveDelete(Base.untitledFolder);
} }
} }

View File

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