JAL-3210 try adding setup method to unit test failing on server...
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 21 Apr 2020 13:03:35 +0000 (14:03 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 21 Apr 2020 13:03:35 +0000 (14:03 +0100)
test/jalview/gui/SeqCanvasTest.java

index 73aeb79..22035f1 100644 (file)
@@ -22,19 +22,22 @@ package jalview.gui;
 
 import static org.testng.Assert.assertEquals;
 
-import jalview.datamodel.AlignmentI;
-import jalview.io.DataSourceType;
-import jalview.io.FileLoader;
-
 import java.awt.Font;
 import java.awt.FontMetrics;
 
+import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
+import jalview.bin.Cache;
+import jalview.datamodel.AlignmentI;
+import jalview.io.DataSourceType;
+import jalview.io.FileLoader;
 import junit.extensions.PA;
 
 public class SeqCanvasTest
 {
+  private AlignFrame af;
+
   /**
    * Test the method that computes wrapped width in residues, height of wrapped
    * widths in pixels, and the number of widths visible
@@ -42,8 +45,6 @@ public class SeqCanvasTest
   @Test(groups = "Functional")
   public void testCalculateWrappedGeometry_noAnnotations()
   {
-    AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
-            "examples/uniref50.fa", DataSourceType.FILE);
     AlignViewport av = af.getViewport();
     AlignmentI al = av.getAlignment();
     assertEquals(al.getWidth(), 157);
@@ -212,8 +213,6 @@ public class SeqCanvasTest
   @Test(groups = "Functional")
   public void testCalculateWrappedGeometry_withAnnotations()
   {
-    AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
-            "examples/uniref50.fa", DataSourceType.FILE);
     AlignViewport av = af.getViewport();
     AlignmentI al = av.getAlignment();
     assertEquals(al.getWidth(), 157);
@@ -310,20 +309,18 @@ public class SeqCanvasTest
   @Test(groups = "Functional")
   public void testCalculateWrappedGeometry_fromScrolled()
   {
-    AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
-            "examples/uniref50.fa", DataSourceType.FILE);
     AlignViewport av = af.getViewport();
     AlignmentI al = av.getAlignment();
     assertEquals(al.getWidth(), 157);
     assertEquals(al.getHeight(), 15);
     av.getRanges().setStartEndSeq(0, 3);
+    av.setFont(new Font("SansSerif", Font.PLAIN, 14), true);
+    av.setWrapAlignment(true);
     av.setShowAnnotation(false);
     av.setScaleAboveWrapped(true);
 
     SeqCanvas testee = af.alignPanel.getSeqPanel().seqCanvas;
 
-    av.setWrapAlignment(true);
-    av.setFont(new Font("SansSerif", Font.PLAIN, 14), true);
     int charHeight = av.getCharHeight();
     int charWidth = av.getCharWidth();
     assertEquals(charHeight, 17);
@@ -338,4 +335,27 @@ public class SeqCanvasTest
             "wrappedRepeatHeightPx");
     assertEquals(repeatingHeight, charHeight * (2 + al.getHeight()));
   }
+
+  @BeforeMethod(alwaysRun = true)
+  public void setUp()
+  {
+    Cache.loadProperties("test/jalview/io/testProps.jvprops");
+    Cache.applicationProperties.setProperty("SHOW_IDENTITY",
+            Boolean.TRUE.toString());
+    af = new FileLoader().LoadFileWaitTillLoaded("examples/uniref50.fa",
+            DataSourceType.FILE);
+  
+    /*
+     * wait for Consensus thread to complete
+     */
+    do
+    {
+      try
+      {
+        Thread.sleep(50);
+      } catch (InterruptedException x)
+      {
+      }
+    } while (af.getViewport().getCalcManager().isWorking());
+  }
 }