{
endRes = 0;
}
+ else if (end > getVisibleAlignmentWidth() - 1)
+ {
+ endRes = getVisibleAlignmentWidth() - 1;
+ }
else
{
endRes = end;
{
vpstart = 0;
}
- else if (vpstart + w - 1 > getVisibleAlignmentWidth() - 1)
+ else if ((w <= getVisibleAlignmentWidth())
+ && (vpstart + w - 1 > getVisibleAlignmentWidth() - 1))
+ // viewport width is less than the full alignment and we are running off the
+ // RHS edge
{
- vpstart = getVisibleAlignmentWidth() - 1;
+ vpstart = getVisibleAlignmentWidth() - w;
}
setStartEndRes(vpstart, vpstart + w - 1);
}
{
vpstart = 0;
}
- else if (vpstart + h - 1 > getVisibleAlignmentHeight() - 1)
+ else if ((h <= getVisibleAlignmentHeight())
+ && (vpstart + h - 1 > getVisibleAlignmentHeight() - 1))
+ // viewport height is less than the full alignment and we are running off
+ // the bottom
{
vpstart = getVisibleAlignmentHeight() - h;
}
}
else
{
- if (endRes > getVisibleAlignmentWidth() - 1)
+ if (endRes >= getVisibleAlignmentWidth() - 1)
{
return false;
}
AlignmentI al = gen.generate(20, 30, 1, 5, 5);
+ AlignmentI smallAl = gen.generate(7, 2, 2, 5, 5);
+
@BeforeMethod
public void cleanUp()
{
assertEquals(vr.getEndRes(), 19);
vr.setStartEndRes(al.getWidth(), al.getWidth());
- assertEquals(vr.getEndRes(), al.getWidth());
+ assertEquals(vr.getEndRes(), al.getWidth() - 1);
+
+ ViewportRanges vrsmall = new ViewportRanges(smallAl);
+ vrsmall.setStartEndRes(al.getWidth(), al.getWidth());
+ assertEquals(vrsmall.getEndRes(), 6);
}
@Test(groups = { "Functional" })
// reset out of bounds start values to within bounds
vr.setViewportStartAndWidth(35, 5);
assertEquals(vr.getViewportWidth(), 5);
- assertEquals(vr.getStartRes(), 20);
+ assertEquals(vr.getStartRes(), 16);
+
+ // small alignment doesn't get bounds reset
+ ViewportRanges vrsmall = new ViewportRanges(smallAl);
+ vrsmall.setViewportStartAndWidth(0, 63);
+ assertEquals(vrsmall.getViewportWidth(), 7);
+ assertEquals(vrsmall.getStartRes(), 0);
}
@Test(groups = { "Functional" })
vr.scrollRight(false);
assertEquals(vr.getStartRes(), 0);
- vr.setViewportStartAndWidth(19, 5);
+ vr.setViewportStartAndWidth(15, 5);
vr.scrollRight(true);
- assertEquals(vr.getStartRes(), 20);
+ assertEquals(vr.getStartRes(), 16);
// can't scroll right past end
vr.scrollRight(true);
- assertEquals(vr.getStartRes(), 20);
+ assertEquals(vr.getStartRes(), 16);
}
@Test(groups = { "Functional" })
// hide last 2 columns
HiddenColumns cols = new HiddenColumns();
- cols.hideColumns(18, 19);
+ cols.hideColumns(19, 20);
al.setHiddenColumns(cols);
vr.setViewportStartAndWidth(1, 5);
vr.scrollRight(false);
assertEquals(vr.getStartRes(), 0);
- vr.setViewportStartAndWidth(19, 5);
+ vr.setViewportStartAndWidth(13, 5);
vr.scrollRight(true);
- assertEquals(vr.getStartRes(), 18);
+ assertEquals(vr.getStartRes(), 14);
// can't scroll right past last visible col
vr.scrollRight(true);
- assertEquals(vr.getStartRes(), 18);
+ assertEquals(vr.getStartRes(), 14);
}
@Test(groups = { "Functional" })