+ }
+
+ @Test(groups = { "Functional" }, singleThreaded = true, priority = 11)
+ public void testForceQuit() throws Exception
+ {
+ String inFile = "examples/uniref50.fa";
+ AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(inFile,
+ DataSourceType.FILE);
+ assertNotNull(af, "Didn't read input file " + inFile);
+
+ long start = System.currentTimeMillis();
+
+ // start a long save (10s)
+ Jalview2XML.setDebugDelaySave(10);
+ Cache.setProperty("DEBUG_DELAY_SAVE", "true");
+ Desktop.instance.saveState_actionPerformed(false);
+
+ // give the saveState thread time to start!
+ Thread.sleep(100);
+
+ // this will select "Force Quit"
+ JvOptionPane.setMockResponse(JvOptionPane.YES_OPTION);
+ QResponse response = QuitHandler.getQuitResponse(true,
+ QuitHandler.defaultOkQuit, () -> {
+ // set FORCE_QUIT without the force quit
+ jalview.bin.Console.debug(
+ "Setting FORCE_QUIT without actually quitting");
+ QuitHandler.setResponse(QResponse.FORCE_QUIT);
+ }, QuitHandler.defaultCancelQuit);
+ long end = System.currentTimeMillis();
+
+ Assert.assertEquals(response, QResponse.FORCE_QUIT);
+ // if the wait (min wait is 1s) wasn't long enough...
+ Assert.assertTrue(end - start > 1000,
+ "Force-Quit-whilst-saving was too short (" + (end - start)
+ + "ms)");
+ // if the wait was too long (probably waited for file to save)
+ Assert.assertTrue(end - start < 9090,
+ "Force-Quit-whilst-saving was too long (" + (end - start)
+ + "ms)");
+