Merge branch 'Jalview-JS/develop' into develop
[jalview.git] / test / jalview / gui / AlignViewportTest.java
index 4e15dba..00267b3 100644 (file)
@@ -297,6 +297,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())
@@ -309,16 +329,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" })
@@ -466,6 +476,7 @@ public class AlignViewportTest
     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(fasta,
             DataSourceType.PASTE);
     AlignViewport testme = af.getViewport();
+    waitForCalculations(testme);
     SequenceI cons = testme.getConsensusSeq();
     assertEquals("A-C", cons.getSequenceAsString());
   }