JAL-4195 tidy up desktop instances after creating them
[jalview.git] / test / jalview / bin / CommandsTest.java
index b4c927b..61892df 100644 (file)
@@ -49,8 +49,15 @@ public class CommandsTest
   @AfterMethod(alwaysRun = true)
   public void tearDown()
   {
-    if (Desktop.instance != null)
-      Desktop.instance.closeAll_actionPerformed(null);
+    Desktop.closeDesktop();
+  }
+  
+  public static void callJalviewMain(String[] args) {
+    if (Jalview.getInstance()!=null) {
+      Jalview.getInstance().doMain(args);
+    } else {
+      Jalview.main(args);
+    }
   }
 
   /* --setprops is currently disabled so this test won't work
@@ -71,7 +78,7 @@ public class CommandsTest
           int numFrames, String[] sequences)
   {
     String[] args = (cmdLine + " --gui").split("\\s+");
-    Jalview.main(args);
+    callJalviewMain(args);
     Commands cmds = Jalview.getInstance().getCommands();
     Assert.assertNotNull(cmds);
     Assert.assertEquals(cmds.commandArgsProvided(), cmdArgs,
@@ -111,7 +118,7 @@ public class CommandsTest
   {
     cleanupFiles(filenames);
     String[] args = (cmdLine + " --gui").split("\\s+");
-    Jalview.main(args);
+    callJalviewMain(args);
     Commands cmds = Jalview.getInstance().getCommands();
     Assert.assertNotNull(cmds);
     File lastFile = null;
@@ -139,7 +146,7 @@ public class CommandsTest
   {
     cleanupFiles(filenames);
     String[] args = (cmdLine + " --gui").split("\\s+");
-    Jalview.main(args);
+    callJalviewMain(args);
     Commands cmds = Jalview.getInstance().getCommands();
     Assert.assertNotNull(cmds);
     File lastFile = null;
@@ -297,7 +304,7 @@ public class CommandsTest
           String[] nonfilenames)
   {
     String[] args = (cmdLine + " --gui").split("\\s+");
-    Jalview.main(args);
+    callJalviewMain(args);
     Commands cmds = Jalview.getInstance().getCommands();
     Assert.assertNotNull(cmds);
     for (String filename : filenames)