JAL-3253 JAL-3260 SwingJS-3.2.9.v1e and tests
[jalview.git] / test / jalview / gui / AlignmentPanelTest.java
index fd67ac4..51d3e37 100644 (file)
@@ -36,6 +36,7 @@ import java.lang.reflect.InvocationTargetException;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
+@Test(singleThreaded = true)
 public class AlignmentPanelTest
 {
   SequenceI seq1 = new Sequence(
@@ -135,6 +136,7 @@ public class AlignmentPanelTest
   @BeforeMethod(alwaysRun = true)
   public void setUp() throws InvocationTargetException, InterruptedException
   {
+    Jalview.setSynchronous(true);
     Jalview.main(new String[] { "-nonews", "-props",
         "test/jalview/testProps.jvprops" });
 
@@ -168,7 +170,7 @@ public class AlignmentPanelTest
    * or without hidden columns
    */
   @Test(groups = "Functional")
-  public void TestSetScrollValues()
+  public void testSetScrollValues()
   {
     ViewportRanges ranges = af.getViewport().getRanges();
     af.alignPanel.setScrollValues(0, 0);
@@ -213,6 +215,7 @@ public class AlignmentPanelTest
     af.getViewport().showAllHiddenColumns();
     af.alignPanel.setScrollValues(scrollpos, 5);
     af.paintImmediately(af.getBounds());
+    waitSome();
     assertEquals(ranges.getEndRes(), af.getViewport()
             .getAlignment().getWidth() - 1);
 
@@ -233,26 +236,48 @@ public class AlignmentPanelTest
    * when switching from wrapped back to unwrapped mode (JAL-2739)
    */
   @Test(groups = "Functional")
-  public void TestUpdateLayout_endRes()
+  public void testUpdateLayout_endRes()
   {
     // get details of original alignment dimensions
     ViewportRanges ranges = af.getViewport().getRanges();
     int endres = ranges.getEndRes();
 
+    // System.out.println("APT range end0 " + ranges.getEndRes());
     // wrap
     af.alignPanel.getAlignViewport().setWrapAlignment(true);
     af.alignPanel.updateLayout();
     af.paintImmediately(af.getBounds());
-
+    waitSome();
+    // System.out.println("APT range end1 " + ranges.getEndRes());
     // endRes has changed
     assertNotEquals(ranges.getEndRes(), endres);
 
     // unwrap
     af.alignPanel.getAlignViewport().setWrapAlignment(false);
     af.alignPanel.updateLayout();
+    waitSome();
     af.paintImmediately(af.getBounds());
+
+    // System.out.println("APT range end3 " + ranges.getEndRes());
+
     // endRes back to original value
+    System.out.println(endres + " vs " + ranges.getEndRes());
     assertEquals(ranges.getEndRes(), endres);
 
   }
+
+  private void waitSome()
+  {
+
+    // just a hack
+    synchronized (this)
+    {
+      try
+      {
+        wait(250);
+      } catch (InterruptedException e)
+      {
+      }
+    }
+  }
 }