From 30699eac9d45c7ba7b0dd97dc5e568562c7b2df9 Mon Sep 17 00:00:00 2001 From: kiramt Date: Fri, 17 Mar 2017 14:11:11 +0000 Subject: [PATCH] JAL-2388 ViewportRanges unit test --- test/jalview/viewmodel/ViewportRangesTest.java | 100 ++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 test/jalview/viewmodel/ViewportRangesTest.java diff --git a/test/jalview/viewmodel/ViewportRangesTest.java b/test/jalview/viewmodel/ViewportRangesTest.java new file mode 100644 index 0000000..cfd03cd --- /dev/null +++ b/test/jalview/viewmodel/ViewportRangesTest.java @@ -0,0 +1,100 @@ +package jalview.viewmodel; + +import static org.testng.Assert.assertEquals; + +import jalview.analysis.AlignmentGenerator; +import jalview.datamodel.AlignmentI; + +import org.testng.annotations.Test; + +public class ViewportRangesTest { + + AlignmentGenerator gen = new AlignmentGenerator(false); + + AlignmentI al = gen.generate(20, 30, 1, 5, 5); + + @Test + public void testViewportRanges() + { + ViewportRanges vr = new ViewportRanges(al); + + assertEquals(vr.getStartRes(),0); + assertEquals(vr.getEndRes(), al.getWidth()-1); + assertEquals(vr.getStartSeq(), 0); + assertEquals(vr.getEndSeq(), al.getHeight() - 1); + } + + @Test + public void testGetAbsoluteAlignmentHeight() + { + ViewportRanges vr = new ViewportRanges(al); + + assertEquals(vr.getAbsoluteAlignmentHeight(), al.getHeight()); + + al.getHiddenSequences().hideSequence(al.getSequenceAt(3)); + assertEquals(vr.getAbsoluteAlignmentHeight(), al.getHeight() + 1); + } + + @Test + public void testGetAbsoluteAlignmentWidth() + { + ViewportRanges vr = new ViewportRanges(al); + assertEquals(vr.getAbsoluteAlignmentWidth(), al.getWidth()); + } + + @Test + public void testSetEndRes() + { + ViewportRanges vr = new ViewportRanges(al); + vr.setEndRes(-1); + assertEquals(vr.getEndRes(), 0); + + vr.setEndRes(al.getWidth()); + assertEquals(vr.getEndRes(), al.getWidth() - 1); + + vr.setEndRes(al.getWidth() - 1); + assertEquals(vr.getEndRes(), al.getWidth() - 1); + } + + @Test + public void testSetEndSeq() + { + ViewportRanges vr = new ViewportRanges(al); + vr.setEndSeq(-1); + assertEquals(vr.getEndSeq(), 0); + + vr.setEndSeq(al.getHeight()); + assertEquals(vr.getEndSeq(), al.getHeight() - 1); + + vr.setEndRes(al.getHeight() - 1); + assertEquals(vr.getEndSeq(), al.getHeight() - 1); + } + + @Test + public void testSetStartRes() + { + ViewportRanges vr = new ViewportRanges(al); + vr.setStartRes(-1); + assertEquals(vr.getStartRes(), 0); + + vr.setStartRes(al.getWidth()); + assertEquals(vr.getStartRes(), al.getWidth() - 1); + + vr.setStartRes(al.getWidth() - 1); + assertEquals(vr.getStartRes(), al.getWidth() - 1); + } + + @Test + public void testSetStartSeq() + { + ViewportRanges vr = new ViewportRanges(al); + vr.setStartSeq(-1); + assertEquals(vr.getStartSeq(), 0); + + vr.setStartSeq(al.getHeight()); + assertEquals(vr.getStartSeq(), al.getHeight() - 1); + + vr.setStartSeq(al.getHeight() - 1); + assertEquals(vr.getStartSeq(), al.getHeight() - 1); + } +} -- 1.7.10.2