X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fgui%2FAlignmentPanelTest.java;h=a137ff6b95ba1fc320994ee748962375b6f362fc;hb=57738a1f3c19b1c3a00bd3ac5108f8cd0af32f99;hp=85ca37c9482bd22616628c13b9d2854879b73d9f;hpb=ad6e0dcf682399eb8b7a0ac49d3fcc63f4f991f2;p=jalview.git diff --git a/test/jalview/gui/AlignmentPanelTest.java b/test/jalview/gui/AlignmentPanelTest.java index 85ca37c..a137ff6 100644 --- a/test/jalview/gui/AlignmentPanelTest.java +++ b/test/jalview/gui/AlignmentPanelTest.java @@ -23,6 +23,16 @@ package jalview.gui; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotEquals; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.FontMetrics; +import java.lang.reflect.InvocationTargetException; + +import javax.swing.SwingUtilities; + +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + import jalview.api.AlignViewportI; import jalview.bin.Cache; import jalview.bin.Jalview; @@ -32,21 +42,16 @@ import jalview.io.DataSourceType; import jalview.io.FileLoader; import jalview.viewmodel.ViewportRanges; -import java.awt.Dimension; -import java.awt.Font; - -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - public class AlignmentPanelTest { AlignFrame af; @BeforeMethod(alwaysRun = true) - public void setUp() + public void setUp() throws InvocationTargetException, InterruptedException { - Jalview.main(new String[] { "-nonews", "-props", - "test/jalview/testProps.jvprops" }); + Jalview.main( + new String[] + { "-nonews", "-props", "test/jalview/testProps.jvprops" }); Cache.applicationProperties.setProperty("SHOW_IDENTITY", Boolean.TRUE.toString()); @@ -54,20 +59,29 @@ public class AlignmentPanelTest DataSourceType.FILE); /* + * ensure the panel has been repainted and so ViewportRanges set + */ + SwingUtilities.invokeAndWait(new Runnable() + { + @Override + public void run() + { + af.repaint(); + } + }); + + /* * wait for Consensus thread to complete */ - synchronized (this) + do { - while (af.getViewport().getConsensusSeq() == null) + try + { + Thread.sleep(50); + } catch (InterruptedException x) { - try - { - wait(50); - } catch (InterruptedException e) - { - } } - } + } while (af.getViewport().getCalcManager().isWorking()); } /** @@ -117,8 +131,8 @@ public class AlignmentPanelTest scrollpos = 130; af.getViewport().showAllHiddenColumns(); af.alignPanel.setScrollValues(scrollpos, 5); - assertEquals(ranges.getEndRes(), af.getViewport() - .getAlignment().getWidth() - 1); + assertEquals(ranges.getEndRes(), + af.getViewport().getAlignment().getWidth() - 1); // now hide some columns, and scroll to position within // distance of the end of the alignment @@ -126,9 +140,11 @@ public class AlignmentPanelTest // columns af.getViewport().hideColumns(30, 50); af.alignPanel.setScrollValues(scrollpos, 5); - assertEquals(ranges.getEndRes(), af.getViewport() - .getAlignment().getWidth() - 1 - 21); // 21 is the number of hidden - // columns + assertEquals(ranges.getEndRes(), + af.getViewport().getAlignment().getWidth() - 1 - 21); // 21 is the + // number of + // hidden + // columns } /** @@ -158,8 +174,8 @@ public class AlignmentPanelTest } /** - * Test the variant of calculateIdWidth that only recomputes the width if it is - * not already saved in the viewport (initial value is -1) + * Test the variant of calculateIdWidth that only recomputes the width if it + * is not already saved in the viewport (initial value is -1) */ @Test(groups = "Functional") public void testCalculateIdWidth_noArgs() @@ -226,8 +242,13 @@ public class AlignmentPanelTest */ AlignmentAnnotation aa = av.getAlignment().getAlignmentAnnotation()[0]; aa.label = "THIS IS A VERY LONG LABEL INDEED"; + FontMetrics fmfor = af.alignPanel + .getFontMetrics(af.alignPanel.getAlabels().getFont()); + // Assumption ID_WIDTH_PADDING == 4 + int expwidth = 4 + fmfor.stringWidth(aa.label); d = af.alignPanel.calculateIdWidth(2000); - assertEquals(d.width, 229); // 4 + pixel width of "THIS IS A VERY LONG LABEL INDEED" + assertEquals(d.width, expwidth); // 228 == ID_WIDTH_PADDING + pixel width of + // "THIS IS A VERY LONG LABEL INDEED" assertEquals(d.height, 12); /* @@ -239,7 +260,7 @@ public class AlignmentPanelTest assertEquals(d.height, 12); } - @Test(groups = "Functional") + @Test(groups = { "Functional", "Not-bamboo" }) public void testGetVisibleWidth() { /*