Merge branch 'develop' into patch/JAL-3088_finalbracenotinrightplace
[jalview.git] / test / jalview / gui / QuitHandlerTest.java
index b1dab96..a6a9642 100644 (file)
@@ -55,7 +55,7 @@ public class QuitHandlerTest
 
     Jalview.main(
             new String[]
-            { "-nowebservicediscovery", "-nosplash", "-nonews" });
+            { "--nowebservicediscovery", "--nosplash", "--nonews" });
   }
 
   @AfterClass(alwaysRun = true)
@@ -66,9 +66,12 @@ public class QuitHandlerTest
     // reset mock response
     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
     // close desktop windows/frames
-    Desktop.instance.closeAll_actionPerformed(null);
+    if (Desktop.instance != null)
+      Desktop.instance.closeAll_actionPerformed(null);
     // reset debug delay
     Jalview2XML.setDebugDelaySave(20);
+    // load normal testprops
+    Cache.loadProperties("test/jalview/testProps.jvprops");
   }
 
   @BeforeMethod(alwaysRun = true)
@@ -79,7 +82,8 @@ public class QuitHandlerTest
     // reset mock response
     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
     // close desktop windows/frames
-    Desktop.instance.closeAll_actionPerformed(null);
+    if (Desktop.instance != null)
+      Desktop.instance.closeAll_actionPerformed(null);
     // reset debug delay
     Cache.setProperty("DEBUG_DELAY_SAVE", "false");
     Jalview2XML.setDebugDelaySave(3);
@@ -126,7 +130,6 @@ public class QuitHandlerTest
     Assert.assertTrue(end - start < 500,
             "Quit-with-no-save-needed took too long (" + (end - start)
                     + "ms)");
-    Desktop.instance.closeAll_actionPerformed(null);
   }
 
   @Test(groups = { "Functional" }, singleThreaded = true, priority = 10)
@@ -154,8 +157,6 @@ public class QuitHandlerTest
     Assert.assertEquals(response, QResponse.QUIT);
     Assert.assertTrue(end - start > 2900,
             "Quit-whilst-saving was too short (" + (end - start) + "ms)");
-
-    Desktop.instance.closeAll_actionPerformed(null);
   }
 
   @Test(groups = { "Functional" }, singleThreaded = true, priority = 9)
@@ -170,17 +171,18 @@ public class QuitHandlerTest
     viewport.setSavedUpToDate(false);
     Jalview2XML.setStateSavedUpToDate(false);
 
-    // no hanging around needed here
+    // don't want to hang around here
     Cache.setProperty("DEBUG_DELAY_SAVE", "false");
     af.saveAlignment(saveProjectFile, FileFormat.Jalview);
 
-    // this is only a two button dialog [Quit] [Cancel] so use NO_OPTION
+    // this is only a two button dialog [Quit] [Cancel] so use NO_OPTION (to
+    // mean [CANCEL] -- file should already be saved so this doesn't happen and
+    // we get a QUIT response)
     JvOptionPane.setMockResponse(JvOptionPane.NO_OPTION);
     QResponse response = QuitHandler.getQuitResponse(true);
 
     // if not saved this would be CANCEL_QUIT
     Assert.assertEquals(response, QResponse.QUIT);
-    Desktop.instance.closeAll_actionPerformed(null);
   }
 
   @Test(groups = { "Functional" }, singleThreaded = true, priority = 9)
@@ -205,7 +207,6 @@ public class QuitHandlerTest
 
     // if not saved this would be CANCEL_QUIT
     Assert.assertEquals(response, QResponse.QUIT);
-    Desktop.instance.closeAll_actionPerformed(null);
   }
 
   @Test(groups = { "Functional" }, singleThreaded = true, priority = 1)
@@ -225,7 +226,6 @@ public class QuitHandlerTest
     QResponse response = QuitHandler.getQuitResponse(true);
 
     Assert.assertEquals(response, QResponse.CANCEL_QUIT);
-    Desktop.instance.closeAll_actionPerformed(null);
   }
 
   @Test(groups = { "Functional" }, singleThreaded = true, priority = 1)
@@ -253,7 +253,6 @@ public class QuitHandlerTest
     QResponse response = QuitHandler.getQuitResponse(false);
 
     Assert.assertEquals(response, QResponse.QUIT);
-    Desktop.instance.closeAll_actionPerformed(null);
   }
 
   @Test(groups = { "Functional" }, singleThreaded = true, priority = 11)
@@ -282,7 +281,6 @@ public class QuitHandlerTest
               jalview.bin.Console.debug(
                       "Setting FORCE_QUIT without actually quitting");
               QuitHandler.setResponse(QResponse.FORCE_QUIT);
-              return null;
             }, QuitHandler.defaultCancelQuit);
     long end = System.currentTimeMillis();
 
@@ -296,7 +294,6 @@ public class QuitHandlerTest
             "Force-Quit-whilst-saving was too long (" + (end - start)
                     + "ms)");
 
-    Desktop.instance.closeAll_actionPerformed(null);
   }
 
 }