Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #102 from ttencate/test_starter_args

Make LwjglTestStarter accept a test name on the command line
  • Loading branch information...
commit 7c7be463fec68ac446c514bbc95c5c21d0156ec0 2 parents 33e6144 + 0bb9127
@badlogic badlogic authored
View
46 tests/gdx-tests-lwjgl/src/com/badlogic/gdx/tests/lwjgl/LwjglTestStarter.java
@@ -54,6 +54,27 @@ public LwjglTestStarter () throws HeadlessException {
setVisible(true);
}
+ /**
+ * Runs the {@link GdxTest} with the given name.
+ *
+ * @param testName the name of a test class
+ * @return {@code true} if the test was found and run, {@code false} otherwise
+ */
+ public static boolean runTest (String testName) {
+ GdxTest test = GdxTests.newTest(testName);
+ if (test == null) {
+ return false;
+ }
+ LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
+ config.width = 640;
+ config.height = 480;
+ config.title = testName;
+ config.useGL20 = test.needsGL20();
+ config.forceExit = false;
+ new LwjglApplication(test, config);
+ return true;
+ }
+
class TestList extends JPanel {
public TestList () {
setLayout(new BorderLayout());
@@ -88,17 +109,10 @@ public void keyPressed (KeyEvent e) {
@Override
public void actionPerformed (ActionEvent e) {
String testName = (String)list.getSelectedValue();
- GdxTest test = GdxTests.newTest(testName);
- dispose();
- LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
- config.width = 640;
- config.height = 480;
- config.title = testName;
- config.useGL20 = test.needsGL20();
- config.forceExit = false;
- new LwjglApplication(test, config);
prefs.putString("last", testName);
prefs.flush();
+ dispose();
+ runTest(testName);
}
});
@@ -110,7 +124,21 @@ public void actionPerformed (ActionEvent e) {
}
}
+ /**
+ * Runs a libgdx test.
+ *
+ * If no arguments are provided on the command line, shows a list of tests to choose from.
+ * If an argument is present, the test with that name will immediately be run.
+ *
+ * @param argv command line arguments
+ */
public static void main (String[] argv) throws Exception {
+ if (argv.length > 0) {
+ if (runTest(argv[0])) {
+ return;
+ // Otherwise, fall back to showing the list
+ }
+ }
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
new LwjglTestStarter();
}
Please sign in to comment.
Something went wrong with that request. Please try again.