Merge branch 'alpha/JAL-3362_Jalview_212_alpha' into alpha/merge_212_JalviewJS_2112
[jalview.git] / test / jalview / gui / AlignViewportTest.java
index bd36a08..d6c875b 100644 (file)
@@ -299,6 +299,26 @@ public class AlignViewportTest
      * wait for Conservation thread to complete
      */
     AlignViewport viewport = af.getViewport();
+    waitForCalculations(viewport);
+    AlignmentAnnotation[] anns = viewport.getAlignment()
+            .getAlignmentAnnotation();
+    assertNotNull("No annotations found", anns);
+    assertEquals("More than one annotation found", 1, anns.length);
+    assertTrue("Annotation is not Quality",
+            anns[0].description.startsWith("Alignment Quality"));
+    Annotation[] annotations = anns[0].annotations;
+    assertNotNull("Quality annotations are null", annotations);
+    assertNotNull("Quality in column 1 is null", annotations[0]);
+    assertTrue("No quality value in column 1", annotations[0].value > 10f);
+  }
+
+  /**
+   * Wait for consensus etc calculation threads to complete
+   * 
+   * @param viewport
+   */
+  protected void waitForCalculations(AlignViewport viewport)
+  {
     synchronized (this)
     {
       while (viewport.getCalcManager().isWorking())
@@ -311,16 +331,6 @@ public class AlignViewportTest
         }
       }
     }
-    AlignmentAnnotation[] anns = viewport.getAlignment()
-            .getAlignmentAnnotation();
-    assertNotNull("No annotations found", anns);
-    assertEquals("More than one annotation found", 1, anns.length);
-    assertTrue("Annotation is not Quality",
-            anns[0].description.startsWith("Alignment Quality"));
-    Annotation[] annotations = anns[0].annotations;
-    assertNotNull("Quality annotations are null", annotations);
-    assertNotNull("Quality in column 1 is null", annotations[0]);
-    assertTrue("No quality value in column 1", annotations[0].value > 10f);
   }
 
   @Test(groups = { "Functional" })
@@ -469,7 +479,8 @@ public class AlignViewportTest
     String fasta = ">s1\nA-C\n>s2\nA-C\n>s3\nA-D\n>s4\n--D\n";
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(fasta,
             DataSourceType.PASTE);
-    AlignmentViewport testme = af.getViewport();
+    AlignViewport testme = af.getViewport();
+    waitForCalculations(testme);
     SequenceI cons = testme.getConsensusSeq();
     assertEquals("A-C", cons.getSequenceAsString());
   }