X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fgui%2FAlignmentPanelTest.java;fp=test%2Fjalview%2Fgui%2FAlignmentPanelTest.java;h=3c749fd4073163c9459481d4828a19fe3fbf7ba8;hb=d043ce47fc710d3eb2629ba926a8a7417bd67d8c;hp=a137ff6b95ba1fc320994ee748962375b6f362fc;hpb=04c8f7bff663aa469127e9eed4164e02933782f1;p=jalview.git diff --git a/test/jalview/gui/AlignmentPanelTest.java b/test/jalview/gui/AlignmentPanelTest.java index a137ff6..3c749fd 100644 --- a/test/jalview/gui/AlignmentPanelTest.java +++ b/test/jalview/gui/AlignmentPanelTest.java @@ -40,6 +40,7 @@ import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.SequenceI; import jalview.io.DataSourceType; import jalview.io.FileLoader; +import jalview.util.Platform; import jalview.viewmodel.ViewportRanges; public class AlignmentPanelTest @@ -49,15 +50,15 @@ public class AlignmentPanelTest @BeforeMethod(alwaysRun = true) 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", + "-jabaws", "none"}); - Cache.applicationProperties.setProperty("SHOW_IDENTITY", + Cache.setPropertyNoSave("SHOW_IDENTITY", Boolean.TRUE.toString()); af = new FileLoader().LoadFileWaitTillLoaded("examples/uniref50.fa", DataSourceType.FILE); - + /* * ensure the panel has been repainted and so ViewportRanges set */ @@ -98,22 +99,29 @@ public class AlignmentPanelTest af.alignPanel.setScrollValues(-1, 5); // setting -ve x value does not change residue + // no update necessary now assertEquals(ranges.getEndRes(), oldres); af.alignPanel.setScrollValues(0, 5); + // no update necessary now // setting 0 as x value does not change residue + // no update necessary now assertEquals(ranges.getEndRes(), oldres); af.alignPanel.setScrollValues(5, 5); // setting x value to 5 extends endRes by 5 residues + System.out.println(ranges); + // no update necessary now assertEquals(ranges.getEndRes(), oldres + 5); // scroll to position after hidden columns sets endres to oldres (width) + // position - int scrollpos = 60; + int scrollpos = 53; // was 60, but this is too high to allow full scrolling + // in Windows af.getViewport().hideColumns(30, 50); af.alignPanel.setScrollValues(scrollpos, 5); + // no update necessary now assertEquals(ranges.getEndRes(), oldres + scrollpos); // scroll to position within hidden columns, still sets endres to oldres + @@ -124,6 +132,7 @@ public class AlignmentPanelTest af.getViewport().showAllHiddenColumns(); af.getViewport().hideColumns(30, 50); af.alignPanel.setScrollValues(scrollpos, 5); + // no update necessary now assertEquals(ranges.getEndRes(), oldres + scrollpos); // scroll to position within distance of the end of the alignment @@ -131,6 +140,7 @@ public class AlignmentPanelTest scrollpos = 130; af.getViewport().showAllHiddenColumns(); af.alignPanel.setScrollValues(scrollpos, 5); + // no update necessary now assertEquals(ranges.getEndRes(), af.getViewport().getAlignment().getWidth() - 1); @@ -140,6 +150,7 @@ public class AlignmentPanelTest // columns af.getViewport().hideColumns(30, 50); af.alignPanel.setScrollValues(scrollpos, 5); + // no update necessary now assertEquals(ranges.getEndRes(), af.getViewport().getAlignment().getWidth() - 1 - 21); // 21 is the // number of @@ -174,8 +185,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() @@ -198,8 +209,9 @@ public class AlignmentPanelTest * note 4 pixels padding are added to the longest sequence name width */ av.setIdWidth(-1); // force recalculation + d = af.alignPanel.calculateIdWidth(); - assertEquals(d.width, 166); // 4 + pixel width of "Q93Z60_ARATH/1-118" + assertEquals(d.width, Platform.isWin() ? 172 : 166); // 4 + pixel width of "Q93Z60_ARATH/1-118" assertEquals(d.height, 12); assertEquals(d.width, av.getIdWidth()); } @@ -221,7 +233,7 @@ public class AlignmentPanelTest * note 4 pixels 'padding' are added to the longest seq name/annotation label */ Dimension d = af.alignPanel.calculateIdWidth(2000); - assertEquals(d.width, 166); // 4 + pixel width of "Q93Z60_ARATH/1-118" + assertEquals(d.width, Platform.isWin() ? 172 : 166); // 4 + pixel width of "Q93Z60_ARATH/1-118" assertEquals(d.height, 12); // fixed value (not used?) assertEquals(av.getIdWidth(), 18); // not changed by this method @@ -230,11 +242,14 @@ public class AlignmentPanelTest */ SequenceI seq = af.viewport.getAlignment() .findSequenceMatch("Q93Z60_ARATH")[0]; - seq.setName(seq.getName() + "MMMMM"); + String orig = seq.getName(); + seq.setName(orig + "MMMMM"); d = af.alignPanel.calculateIdWidth(2000); - assertEquals(d.width, 211); // 4 + pixel width of "Q93Z60_ARATHMMMMM/1-118" + assertEquals(d.width, Platform.isWin() ? 219 : 211); // 4 + pixel width of "Q93Z60_ARATHMMMMM/1-118" assertEquals(d.height, 12); assertEquals(av.getIdWidth(), 18); // unchanged + // for next test: + seq.setName(orig); /* * make the longest annotation name even longer @@ -245,18 +260,19 @@ public class AlignmentPanelTest FontMetrics fmfor = af.alignPanel .getFontMetrics(af.alignPanel.getAlabels().getFont()); // Assumption ID_WIDTH_PADDING == 4 + // AH! But with those added MMMM above, this was NOT the longest label! int expwidth = 4 + fmfor.stringWidth(aa.label); d = af.alignPanel.calculateIdWidth(2000); - assertEquals(d.width, expwidth); // 228 == ID_WIDTH_PADDING + pixel width of - // "THIS IS A VERY LONG LABEL INDEED" + assertEquals(d.width, expwidth); // 191 == ID_WIDTH_PADDING + pixel width of "THIS IS A VERY LONG LABEL INDEED" assertEquals(d.height, 12); /* * override with maxwidth * note the 4 pixels padding is added to this value */ - d = af.alignPanel.calculateIdWidth(213); - assertEquals(d.width, 217); + // BH but we have to be under the max width + d = af.alignPanel.calculateIdWidth(180); + assertEquals(d.width, 184); assertEquals(d.height, 12); } @@ -268,7 +284,7 @@ public class AlignmentPanelTest */ int w = af.alignPanel.getVisibleIdWidth(true); assertEquals(w, af.alignPanel.getIdPanel().getWidth()); - assertEquals(w, 115); + assertEquals(w, Platform.isWin() ? 112 : 115); /* * width for offscreen rendering is the same @@ -288,6 +304,6 @@ public class AlignmentPanelTest * preference for auto id width overrides fixed width */ Cache.setProperty("FIGURE_AUTOIDWIDTH", Boolean.TRUE.toString()); - assertEquals(115, af.alignPanel.getVisibleIdWidth(false)); + assertEquals(Platform.isWin() ? 106 : 115, af.alignPanel.getVisibleIdWidth(false)); } }