X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fgui%2FAlignmentPanelTest.java;fp=test%2Fjalview%2Fgui%2FAlignmentPanelTest.java;h=3d06bc81e93a3b90af1249911cf5feac8bfbd58a;hb=586ade46bdcd05ff028a1cff82c3c527326d28ec;hp=8871249533de207b3c002321a24c970227cfa5ce;hpb=adcef27f5747b4e70e89a56c3735bc3afb8ce9bf;p=jalview.git diff --git a/test/jalview/gui/AlignmentPanelTest.java b/test/jalview/gui/AlignmentPanelTest.java index 8871249..3d06bc8 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,10 +50,11 @@ 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); @@ -94,22 +96,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 + @@ -120,6 +129,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 @@ -127,8 +137,9 @@ public class AlignmentPanelTest scrollpos = 130; af.getViewport().showAllHiddenColumns(); af.alignPanel.setScrollValues(scrollpos, 5); - assertEquals(ranges.getEndRes(), af.getViewport() - .getAlignment().getWidth() - 1); + // no update necessary now + assertEquals(ranges.getEndRes(), + af.getViewport().getAlignment().getWidth() - 1); // now hide some columns, and scroll to position within // distance of the end of the alignment @@ -136,9 +147,12 @@ 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 + // no update necessary now + assertEquals(ranges.getEndRes(), + af.getViewport().getAlignment().getWidth() - 1 - 21); // 21 is the + // number of + // hidden + // columns } /** @@ -192,8 +206,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()); } @@ -215,7 +230,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 @@ -224,11 +239,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 @@ -239,17 +257,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); } @@ -261,7 +281,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 @@ -281,6 +301,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)); } }