--- /dev/null
+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);
+ }
+}