From 421a5c8265f5d65c7dca1827e8f5af0b66ab3fe9 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 21 Apr 2020 14:03:35 +0100 Subject: [PATCH] JAL-3210 try adding setup method to unit test failing on server... --- test/jalview/gui/SeqCanvasTest.java | 44 +++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/test/jalview/gui/SeqCanvasTest.java b/test/jalview/gui/SeqCanvasTest.java index 73aeb79..22035f1 100644 --- a/test/jalview/gui/SeqCanvasTest.java +++ b/test/jalview/gui/SeqCanvasTest.java @@ -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()); + } } -- 1.7.10.2