X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fgui%2FAlignmentPanelTest.java;h=80dc939bcc2b4214333c63026fd7ff1fdae00323;hb=fcb944cdd9de849c89f0a8744ae6e56e22de9c1e;hp=c580a884343e64e96e80d4acac7f0a18d2207846;hpb=97b26ba418dec7a6e926378205d25470bf098633;p=jalview.git diff --git a/test/jalview/gui/AlignmentPanelTest.java b/test/jalview/gui/AlignmentPanelTest.java index c580a88..80dc939 100644 --- a/test/jalview/gui/AlignmentPanelTest.java +++ b/test/jalview/gui/AlignmentPanelTest.java @@ -21,6 +21,7 @@ package jalview.gui; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotEquals; import jalview.bin.Cache; import jalview.bin.Jalview; @@ -30,6 +31,8 @@ import jalview.io.DataSourceType; import jalview.io.FileLoader; import jalview.viewmodel.ViewportRanges; +import java.lang.reflect.InvocationTargetException; + import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -130,15 +133,17 @@ 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" }); - Cache.applicationProperties.setProperty("SHOW_IDENTITY", + Cache.setPropertyNoSave("SHOW_IDENTITY", Boolean.TRUE.toString()); af = new FileLoader().LoadFileWaitTillLoaded("examples/uniref50.fa", DataSourceType.FILE); + + af.paintImmediately(af.getBounds()); /* * wait for Consensus thread to complete @@ -149,7 +154,7 @@ public class AlignmentPanelTest { try { - wait(50); + wait(250); // BH was 50 } catch (InterruptedException e) { } @@ -163,9 +168,10 @@ public class AlignmentPanelTest * or without hidden columns */ @Test(groups = "Functional") - public void TestSetScrollValues() + public void testSetScrollValues() { ViewportRanges ranges = af.getViewport().getRanges(); + af.alignPanel.setScrollValues(0, 0); int oldres = ranges.getEndRes(); af.alignPanel.setScrollValues(-1, 5); @@ -187,6 +193,8 @@ public class AlignmentPanelTest int scrollpos = 60; af.getViewport().hideColumns(30, 50); af.alignPanel.setScrollValues(scrollpos, 5); + + af.paintImmediately(af.getBounds()); assertEquals(ranges.getEndRes(), oldres + scrollpos); // scroll to position within hidden columns, still sets endres to oldres + @@ -204,6 +212,7 @@ public class AlignmentPanelTest scrollpos = 130; af.getViewport().showAllHiddenColumns(); af.alignPanel.setScrollValues(scrollpos, 5); + af.paintImmediately(af.getBounds()); assertEquals(ranges.getEndRes(), af.getViewport() .getAlignment().getWidth() - 1); @@ -212,9 +221,59 @@ public class AlignmentPanelTest // endRes should be set to width of alignment - 1 - the number of hidden // columns af.getViewport().hideColumns(30, 50); + af.paintImmediately(af.getBounds()); af.alignPanel.setScrollValues(scrollpos, 5); assertEquals(ranges.getEndRes(), af.getViewport() .getAlignment().getWidth() - 1 - 21); // 21 is the number of hidden // columns } + + /** + * Test that update layout reverts to original (unwrapped) values for endRes + * when switching from wrapped back to unwrapped mode (JAL-2739) + */ + @Test(groups = "Functional") + public void testUpdateLayout_endRes() + { + // get details of original alignment dimensions + ViewportRanges ranges = af.getViewport().getRanges(); + int endres = ranges.getEndRes(); + + // System.out.println("APT range end0 " + ranges.getEndRes()); + // wrap + af.alignPanel.getAlignViewport().setWrapAlignment(true); + af.alignPanel.updateLayout(); + af.paintImmediately(af.getBounds()); + waitSome(); + // System.out.println("APT range end1 " + ranges.getEndRes()); + // endRes has changed + assertNotEquals(ranges.getEndRes(), endres); + + // unwrap + af.alignPanel.getAlignViewport().setWrapAlignment(false); + af.alignPanel.updateLayout(); + waitSome(); + af.paintImmediately(af.getBounds()); + + // System.out.println("APT range end3 " + ranges.getEndRes()); + + // endRes back to original value + assertEquals(ranges.getEndRes(), endres); + + } + + private void waitSome() + { + + // just a hack + synchronized (this) + { + try + { + wait(250); + } catch (InterruptedException e) + { + } + } + } }