+ assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+ }
+
+ /**
+ * Test that the box position is set correctly when there are hidden rows at
+ * the start
+ */
+ @Test(groups = { "Functional" })
+ public void testSetBoxFromViewportHiddenRowsAtStart()
+ {
+ int firstHidden = 0;
+ int lastHidden = 20;
+ hideSequences(firstHidden, lastHidden + 1, lastHidden + 1);
+
+ // move viewport to start of alignment:
+ // box moves to below hidden rows, height remains same
+ moveViewport(0, 0);
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(od.getBoxY(),
+ (lastHidden + 1) * scaleh * av.getCharHeight(), 1.5);
+ assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+ assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+
+ // move viewport to end of alignment, need to account for hidden rows
+ // because of how alignment panel/overview panel are implemented
+
+ // AlignViewport adjusts endSeq using Alignment height which excludes hidden
+ // rows if we happen to be at the bottom of the alignment
+ // od.setBoxPosition adjusts endSeq to include hidden rows
+ // od.checkValid adjusts scroll position to exclude hidden rows
+ // TODO this test fails because of the above!
+
+ /* moveViewport(0, 525 - viewHeight - lastHidden - 1);
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(od.getBoxY(),
+ (525 - viewHeight) * scaleh
+ * av.getCharHeight(), 1.5);
+ assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+ assertEquals(od.getBoxHeight(), boxHeight, 1.5);*/
+ }
+
+ /**
+ * Test that the box position is set correctly when there are hidden rows in
+ * the middle
+ */
+ @Test(groups = { "Functional" })
+ public void testSetBoxFromViewportHiddenRowsInMiddle()
+ {
+ int firstHidden = 200;
+ int lastHidden = 210;
+ hideSequences(firstHidden, lastHidden + 1, lastHidden + 1);
+
+ // move viewport to start of alignment:
+ // box, height etc as in non-hidden case
+ // TODO fails with boxy=12 because that's what setBoxPosition sets it to!
+ /*moveViewport(0, 0);
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(od.getBoxY(), 0);
+ assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+ assertEquals(od.getBoxHeight(), boxHeight, 1.5);*/
+
+ // move viewport to straddle hidden rows
+ // TODO also fails with boxY out by 12
+ /*moveViewport(0, 198);
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(od.getBoxY(), (int) (198 * scaleh * av.getCharHeight()),
+ 1.5);
+ assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+ assertEquals(od.getBoxHeight(), boxHeight
+ + ((lastHidden - firstHidden) * scaleh * av.getCharHeight()),
+ 1.5);*/
+ }
+
+ /**
+ * Test that the box position is set correctly when there are hidden rows at
+ * the bottom
+ */
+ @Test(groups = { "Functional" })
+ public void testSetBoxFromViewportHiddenRowsAtEnd()
+ {
+ int firstHidden = 500;
+ int lastHidden = 524;
+ hideSequences(firstHidden - 1, lastHidden, firstHidden - 1);
+
+ // move viewport to start of alignment:
+ // box, height etc as in non-hidden case
+ moveViewport(0, 0);
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(od.getBoxY(), 0);
+ assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+ assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+
+ // move viewport to end of alignment
+ // TODO fails with wrong boxHeight who knows why
+ /*moveViewport(0, firstHidden - viewHeight - 1);
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(od.getBoxY(),
+ (int) ((firstHidden - viewHeight - 1)
+ * scaleh * av.getCharHeight()), 1.5);
+ assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+ assertEquals(
+ od.getBoxHeight(),
+ boxHeight
+ + (int) ((lastHidden - firstHidden + 1) * scaleh * av
+ .getCharHeight()), 1.5);*/
+
+ }
+
+ /**
+ * Test setting of the box position, when there are hidden rows at the start
+ * of the alignment
+ */
+ @Test(groups = { "Functional" })
+ public void testFromMouseWithHiddenRowsAtStart()
+ {
+ od.checkValid();
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(od.getBoxY(), 0);
+ assertEquals(od.getBoxWidth(), boxWidth);
+ assertEquals(od.getScrollCol(), 0);
+ assertEquals(od.getScrollRow(), 0);
+
+ // hide rows at start and check updated box position is correct
+ // changes boxY but not boxheight
+ int lastHiddenRow = 30;
+ hideSequences(0, lastHiddenRow + 1, lastHiddenRow + 1);
+
+ od.setBoxPosition();
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(od.getBoxY(),
+ (int) ((lastHiddenRow + 1) * scaleh * av.getCharHeight()));
+ assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+ assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+
+ // click in hidden rows
+ // TODO fails because boxHeight is 27 not 25 (possible rounding issue)
+ /* mouseClick(od, 0, 0);
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(od.getBoxY(), 0);
+ assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+ assertEquals(od.getBoxHeight(), boxHeight
+ + (int) ((lastHiddenRow + 1) * scaleh * av.getCharHeight()),
+ 1.5);*/
+
+ // click below hidden rows
+ mouseClick(od, 0, 150);
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(od.getBoxY(), 150, 1.5);
+ assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+ assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+ }
+
+ /**
+ * Test setting of the box position, when there are hidden rows at the middle
+ * of the alignment
+ */
+ @Test(groups = { "Functional" })
+ public void testFromMouseWithHiddenRowsInMiddle()
+ {
+ od.checkValid();
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(od.getBoxY(), 0);
+ assertEquals(od.getBoxWidth(), boxWidth);
+ assertEquals(od.getScrollCol(), 0);
+ assertEquals(od.getScrollRow(), 0);
+
+ // hide rows in middle and check updated box position is correct
+ // no changes
+ int firstHiddenRow = 50;
+ int lastHiddenRow = 60;
+ hideSequences(firstHiddenRow, lastHiddenRow + 1, lastHiddenRow + 1);
+
+ od.setBoxPosition();
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(od.getBoxY(), 0);
+ assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+ assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+
+ // click above hidden rows, so that box overlaps
+ int ypos = 40;
+ // TODO test fails because box does not change height - dealt with by scroll
+ // values
+ /* mouseClick(od, 0, (int) (ypos / scaleh / av.getCharHeight()));
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(od.getBoxY(), (int) (ypos / scaleh / av.getCharHeight()),
+ 1.5);
+ assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+ assertEquals(
+ od.getBoxHeight(),
+ boxHeight
+ + (int) ((lastHiddenRow - firstHiddenRow + 1) / scaleh / av
+ .getCharHeight()), 1.5);
+ */
+ // click so that box straddles hidden rows
+ ypos = 48;
+ // TODO test fails because box does not change height - dealt with by scroll
+ // values
+ /*mouseClick(od, 0, (int) (ypos / scaleh / av.getCharHeight()));
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(od.getBoxY(), (int) (ypos / scaleh / av.getCharHeight()),
+ 1.5);
+ assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+ assertEquals(
+ od.getBoxHeight(),
+ boxHeight
+ + (int) ((lastHiddenRow - firstHiddenRow + 1) / scaleh / av
+ .getCharHeight()), 1.5);*/
+ }
+
+ /**
+ * Test setting of the box position, when there are hidden rows at the end of
+ * the alignment
+ */
+ @Test(groups = { "Functional" })
+ public void testFromMouseWithHiddenRowsAtEnd()
+ {
+ od.checkValid();
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(od.getBoxY(), 0);
+ assertEquals(od.getBoxWidth(), boxWidth);
+ assertEquals(od.getScrollCol(), 0);
+ assertEquals(od.getScrollRow(), 0);
+
+ // hide rows at end and check updated box position is correct
+ // no changes
+ int firstHidden = 500;
+ int lastHidden = 524;
+ hideSequences(firstHidden - 1, lastHidden, firstHidden - 1);
+
+ od.setBoxPosition();
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(od.getBoxY(), 0);
+ assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+ assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+
+ // click above hidden rows
+ int ypos = 40; // row 40
+ mouseClick(od, 0, (int) (ypos * scaleh * av.getCharHeight()));
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(od.getBoxY(), (int) (ypos * scaleh * av.getCharHeight()),
+ 1.5);
+ assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+ assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+
+ // click above hidden rows so box overlaps
+ // boxY moved upwards, boxHeight remains same
+ // TODO fails with boxY located at row 497 - correction done by
+ // setScrollValues
+ /* ypos = 497; // row 497
+ mouseClick(od, 0, (int) (ypos * scaleh * av.getCharHeight()));
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(
+ od.getBoxY(),
+ (int) ((firstHidden - viewHeight) * scaleh * av.getCharHeight()),
+ 1.5);
+ assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+ assertEquals(od.getBoxHeight(), boxHeight, 1.5);*/
+
+ // click within hidden rows
+ ypos = 505;
+ // TODO: fails with wrong boxHeight - correction done by setScrollValues(?)
+ /*mouseClick(od, 0, (int) (ypos * scaleh * av.getCharHeight()));
+ assertEquals(od.getBoxX(), 0);
+ assertEquals(
+ od.getBoxY(),
+ (int) ((firstHidden - viewHeight) * scaleh * av.getCharHeight()),
+ 1.5);
+ assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+ assertEquals(od.getBoxHeight(), boxHeight, 1.5);*/