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
3.0
mul..va 14 years ago
parent 16fc60c8a0
commit fbc980152e
  1. 42
      engine/src/test/jme3test/TestChooser.java

@ -265,24 +265,32 @@ public class TestChooser extends JDialog {
Class<?> clazz = (Class)appClass[i]; Class<?> clazz = (Class)appClass[i];
try { try {
Object app = clazz.newInstance(); Object app = clazz.newInstance();
final Method settingMethod = clazz.getMethod("setShowSettings", boolean.class); if (app instanceof Application) {
settingMethod.invoke(app, showSetting); if (app instanceof SimpleApplication) {
final Method mainMethod = clazz.getMethod("start", null); final Method settingMethod = clazz.getMethod("setShowSettings", boolean.class);
mainMethod.invoke(app, null); settingMethod.invoke(app, showSetting);
// wait for destroy }
Field contextField = Application.class.getDeclaredField("context"); final Method mainMethod = clazz.getMethod("start", null);
contextField.setAccessible(true); mainMethod.invoke(app, null);
JmeContext context = null; Field contextField = Application.class.getDeclaredField("context");
while (context == null) { contextField.setAccessible(true);
context = (JmeContext) contextField.get(app); JmeContext context = null;
Thread.sleep(100); while (context == null) {
} context = (JmeContext) contextField.get(app);
while (!context.isCreated()) { Thread.sleep(100);
Thread.sleep(100); }
} while (!context.isCreated()) {
while (context.isCreated()) { Thread.sleep(100);
Thread.sleep(100); }
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) { } catch (IllegalAccessException ex) {
logger.log(Level.SEVERE, "Cannot access constructor: "+clazz.getName(), ex); logger.log(Level.SEVERE, "Cannot access constructor: "+clazz.getName(), ex);
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {

Loading…
Cancel
Save