X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fviewmodel%2FViewportRangesTest.java;fp=test%2Fjalview%2Fviewmodel%2FViewportRangesTest.java;h=70a36875d44c14008705dae516111d9611d56752;hb=e54df488cd82761bfb0e9372aeae2acc5a1324d7;hp=86f0d62caeb891cc7bd1818337a427f2437a5c46;hpb=171bb10b5fdc06925e47025829e6cede32b85b63;p=jalview.git diff --git a/test/jalview/viewmodel/ViewportRangesTest.java b/test/jalview/viewmodel/ViewportRangesTest.java index 86f0d62..70a3687 100644 --- a/test/jalview/viewmodel/ViewportRangesTest.java +++ b/test/jalview/viewmodel/ViewportRangesTest.java @@ -699,6 +699,37 @@ public class ViewportRangesTest { assertEquals(vrsmall.getViewportWidth(), 7); assertEquals(vrsmall.getStartRes(), 0); } + + @Test(groups = { "Functional" }) + public void testGetWrappedMaxScroll() + { + // generate an ungapped alignment of width 140 + int alignmentWidth = 140; + AlignmentI al2 = gen.generate(alignmentWidth, 15, 1, 0, 5); + ViewportRanges vr = new ViewportRanges(al2); + vr.setStartEndRes(0, 39); + int width = vr.getViewportWidth(); // 40 + int partWidth = alignmentWidth % width; // 20 + + /* + * there are 3 * 40 remainder 20 residues + * number of widths depends on offset (scroll right) + * 4 widths (maxScroll = 3) if offset by 0 or more than 19 columns + * 5 widths (maxScroll = 4) if 1 <= offset <= 19 + */ + for (int col = 0; col < alignmentWidth; col++) + { + int offset = col % width; + if (offset > 0 && offset < partWidth) + { + assertEquals(vr.getWrappedMaxScroll(col), 4, "col " + col); + } + else + { + assertEquals(vr.getWrappedMaxScroll(col), 3, "col " + col); + } + } + } } // mock listener for property change events