From 91b3af9bfa70fc853ec6e74096454e17882a7543 Mon Sep 17 00:00:00 2001 From: James Procter Date: Thu, 8 Jun 2023 11:30:55 +0100 Subject: [PATCH] JAL-4196 structure view cli tests wait using new jalview.Desktop.instance.operationsAreInProgress() returns true if any desktop windows have a progress indicator still active --- src/jalview/gui/Desktop.java | 20 ++++++++++++++++++++ test/jalview/bin/CommandsTest2.java | 16 ++++++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index bfd700f..33ba97c 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -3589,4 +3589,24 @@ public class Desktop extends jalview.jbgui.GDesktop Desktop.instance = null; } } + + /** + * checks if any progress bars are being displayed in any of the windows managed by the desktop + * @return + */ + public boolean operationsAreInProgress() + { + JInternalFrame[] frames = getAllFrames(); + for (JInternalFrame frame:frames) + { + if (frame instanceof IProgressIndicator) + { + if (((IProgressIndicator)frame).operationInProgress()) + { + return true; + } + } + } + return operationInProgress(); + } } diff --git a/test/jalview/bin/CommandsTest2.java b/test/jalview/bin/CommandsTest2.java index 0c2071a..d6b6f3c 100644 --- a/test/jalview/bin/CommandsTest2.java +++ b/test/jalview/bin/CommandsTest2.java @@ -65,14 +65,18 @@ public class CommandsTest2 String[] args = cmdLine.split("\\s+"); CommandsTest.callJalviewMain(args); - try + while (Desktop.instance!=null && Desktop.instance.operationsAreInProgress()) { - // sleep for slow build server to open annotations and viewer windows - Thread.sleep(seqNum * 50 + annNum * 50 + viewerNum * 500); - } catch (InterruptedException e) - { - e.printStackTrace(); + try + { + // sleep for slow build server to open annotations and viewer windows + Thread.sleep(viewerNum * 50); + } catch (InterruptedException e) + { + e.printStackTrace(); + } } + ; AlignFrame[] afs = Desktop.getAlignFrames(); Assert.assertNotNull(afs); -- 1.7.10.2