TestChooser multi-run fix.

Not all TestXXX class extends Application class.
If test doesn't extend Application, call main() instead of start() method.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7144 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
mul..va 2011-03-31 08:40:53 +00:00
parent 16fc60c8a0
commit fbc980152e

View File

@ -265,11 +265,13 @@ public class TestChooser extends JDialog {
Class<?> clazz = (Class)appClass[i];
try {
Object app = clazz.newInstance();
if (app instanceof Application) {
if (app instanceof SimpleApplication) {
final Method settingMethod = clazz.getMethod("setShowSettings", boolean.class);
settingMethod.invoke(app, showSetting);
}
final Method mainMethod = clazz.getMethod("start", null);
mainMethod.invoke(app, null);
// wait for destroy
Field contextField = Application.class.getDeclaredField("context");
contextField.setAccessible(true);
JmeContext context = null;
@ -283,6 +285,12 @@ public class TestChooser extends JDialog {
while (context.isCreated()) {
Thread.sleep(100);
}
} else {
final Method mainMethod = clazz.getMethod("main", (new String[0]).getClass());
mainMethod.invoke(app, new Object[]{new String[0]});
}
// wait for destroy
System.gc();
} catch (IllegalAccessException ex) {
logger.log(Level.SEVERE, "Cannot access constructor: "+clazz.getName(), ex);
} catch (IllegalArgumentException ex) {