From 2c25a8d692dcc582d9ce39112af8317bd2825c5b Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 6 Jul 2017 15:59:09 +0100 Subject: [PATCH] JAL-147 unit test for hide/show sequences update ViewportRanges --- src/jalview/viewmodel/AlignmentViewport.java | 1 - test/jalview/gui/AlignViewportTest.java | 43 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index d3e502b..5a7a27f 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -1441,7 +1441,6 @@ public abstract class AlignmentViewport implements AlignViewportI, setSequenceAnnotationsVisible(seq, true); } - // ranges.setStartSeq(startSeq); ranges.setStartEndSeq(startSeq, endSeq + tmp.size()); firePropertyChange("alignment", null, alignment.getSequences()); diff --git a/test/jalview/gui/AlignViewportTest.java b/test/jalview/gui/AlignViewportTest.java index 346d74dd..b2286e0 100644 --- a/test/jalview/gui/AlignViewportTest.java +++ b/test/jalview/gui/AlignViewportTest.java @@ -46,6 +46,7 @@ import jalview.schemes.ColourSchemeI; import jalview.schemes.PIDColourScheme; import jalview.structure.StructureSelectionManager; import jalview.util.MapList; +import jalview.viewmodel.ViewportRanges; import java.util.ArrayList; import java.util.List; @@ -469,4 +470,46 @@ public class AlignViewportTest SequenceI cons = testme.getConsensusSeq(); assertEquals("A-C", cons.getSequenceAsString()); } + + @Test(groups = { "Functional" }) + public void testHideRevealSequences() + { + ViewportRanges ranges = testee.getRanges(); + assertEquals(3, al.getHeight()); + assertEquals(0, ranges.getStartSeq()); + assertEquals(2, ranges.getEndSeq()); + + /* + * hide first sequence + */ + testee.hideSequence(new SequenceI[] { al.getSequenceAt(0) }); + assertEquals(2, al.getHeight()); + assertEquals(0, ranges.getStartSeq()); + assertEquals(1, ranges.getEndSeq()); + + /* + * reveal hidden sequences above the first + */ + testee.showSequence(0); + assertEquals(3, al.getHeight()); + assertEquals(0, ranges.getStartSeq()); + assertEquals(2, ranges.getEndSeq()); + + /* + * hide first and third sequences + */ + testee.hideSequence(new SequenceI[] { al.getSequenceAt(0), + al.getSequenceAt(2) }); + assertEquals(1, al.getHeight()); + assertEquals(0, ranges.getStartSeq()); + assertEquals(0, ranges.getEndSeq()); + + /* + * reveal all hidden sequences + */ + testee.showAllHiddenSeqs(); + assertEquals(3, al.getHeight()); + assertEquals(0, ranges.getStartSeq()); + assertEquals(2, ranges.getEndSeq()); + } } -- 1.7.10.2