Merge branch 'bug/JAL-3120restoreFeatureColour' into merge/JAL-3120
[jalview.git] / test / jalview / gui / FreeUpMemoryTest.java
index e93bfac..9b21274 100644 (file)
@@ -1,6 +1,7 @@
 package jalview.gui;
 
 import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
 import static org.testng.Assert.assertTrue;
 
 import jalview.analysis.AlignmentGenerator;
@@ -11,6 +12,7 @@ import jalview.datamodel.SequenceGroup;
 import jalview.io.DataSourceType;
 import jalview.io.FileLoader;
 
+import java.awt.event.MouseEvent;
 import java.io.File;
 import java.io.IOException;
 import java.io.PrintStream;
@@ -18,6 +20,8 @@ import java.io.PrintStream;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
+import junit.extensions.PA;
+
 public class FreeUpMemoryTest
 {
   private static final int ONE_MB = 1000 * 1000;
@@ -30,16 +34,12 @@ public class FreeUpMemoryTest
   {
     Jalview.main(new String[] { "-nonews", "-props",
         "test/jalview/testProps.jvprops" });
-    Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
-            Boolean.TRUE.toString());
-    Cache.applicationProperties.setProperty("SHOW_QUALITY",
-            Boolean.TRUE.toString());
-    Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
-            Boolean.TRUE.toString());
-    Cache.applicationProperties.setProperty("SHOW_OCCUPANCY",
-            Boolean.TRUE.toString());
-    Cache.applicationProperties.setProperty("SHOW_IDENTITY",
-            Boolean.TRUE.toString());
+    String True = Boolean.TRUE.toString();
+    Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS", True);
+    Cache.applicationProperties.setProperty("SHOW_QUALITY", True);
+    Cache.applicationProperties.setProperty("SHOW_CONSERVATION", True);
+    Cache.applicationProperties.setProperty("SHOW_OCCUPANCY", True);
+    Cache.applicationProperties.setProperty("SHOW_IDENTITY", True);
   }
 
   /**
@@ -84,18 +84,19 @@ public class FreeUpMemoryTest
   protected void checkUsedMemory(long expectedMax)
   {
     /*
-     * request garbage collection and wait briefly for it to run;
+     * request garbage collection and wait for it to run;
      * NB there is no guarantee when, or whether, it will do so
+     * wait time depends on JRE/processor, generous allowance here  
      */
     System.gc();
-    waitFor(100);
+    waitFor(1500);
 
     /*
      * a second gc() call should not be necessary - but it is!
      * the test passes with it, and fails without it
      */
     System.gc();
-    waitFor(100);
+    waitFor(1500);
 
     /*
      * check used memory is 'reasonably low'
@@ -142,6 +143,20 @@ public class FreeUpMemoryTest
     }
 
     /*
+     * open an Overview window
+     */
+    af.overviewMenuItem_actionPerformed(null);
+    assertNotNull(af.alignPanel.overviewPanel);
+
+    /*
+     * exercise the pop-up menu in the Overview Panel (JAL-2864)
+     */
+    Object[] args = new Object[] {
+        new MouseEvent(af, 0, 0, 0, 0, 0, 1, true) };
+    PA.invokeMethod(af.alignPanel.overviewPanel,
+            "showPopupMenu(java.awt.event.MouseEvent)", args);
+
+    /*
      * set a selection group - potential memory leak if it retains
      * a reference to the alignment
      */