abstract test case for SWT GUI stuff, maybe will be useful in the future

git-svn-id: https://ipscan.svn.sourceforge.net/svnroot/ipscan/trunk@311 375186e5-ef17-0410-b0b6-91563547dcda
This commit is contained in:
angryziber 2008-03-22 11:29:02 +00:00
parent ed02a4e675
commit 750d5486ca

View File

@ -0,0 +1,49 @@
/**
* This file is a part of Angry IP Scanner source code,
* see http://www.azib.net/ for more information.
* Licensed under GPLv2.
*/
package net.azib.ipscan.gui;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.junit.After;
import org.junit.Before;
/**
* SWTTestCase - base class for SWT tests
*
* @author Anton Keks
*/
public abstract class SWTTestCase {
protected static final Display display = Display.getDefault();
protected Shell shell;
@Before
public void setUp() {
newShell();
}
protected void newShell() {
disposeShell();
shell = new Shell(display);
}
private void disposeShell() {
if (shell != null) {
shell.dispose();
shell = null;
}
}
@After
public void tearDown() {
display.syncExec(new Runnable() {
public void run() {
disposeShell();
}
});
}
}