X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fviewmodel%2FOverviewDimensionsTest.java;h=1ea07ea0f8f0f6b89d46008e15036946789e3c17;hb=7f4da0a2b0c10f158a03dbfce8878e67e90c4a68;hp=e86f41b698b4b3f7e67df08bd08d82c2110dee88;hpb=ed8a4149077b4debd9d51cca5141287e17b25fad;p=jalview.git diff --git a/test/jalview/viewmodel/OverviewDimensionsTest.java b/test/jalview/viewmodel/OverviewDimensionsTest.java index e86f41b..1ea07ea 100644 --- a/test/jalview/viewmodel/OverviewDimensionsTest.java +++ b/test/jalview/viewmodel/OverviewDimensionsTest.java @@ -39,28 +39,8 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @Test(singleThreaded = true) -public class OverviewDimensionsTest { - - SequenceI seq1 = new Sequence( - "Seq1", - "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); - - SequenceI seq2 = new Sequence( - "Seq2", - "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); - - SequenceI seq3 = new Sequence( - "Seq3", - "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); - - SequenceI seq4 = new Sequence( - "Seq4", - "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); - - SequenceI seq5 = new Sequence( - "Seq5", - "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); - +public class OverviewDimensionsTest +{ AlignmentI al; OverviewDimensions od; @@ -157,7 +137,7 @@ public class OverviewDimensionsTest { ViewportPositionProps props = new ViewportPositionProps(al1); OverviewDimensions od = new OverviewDimensions(props, true); - int scaledHeight = 266; + int scaledHeight = 267; assertEquals(od.getGraphHeight(), defaultGraphHeight); assertEquals(od.getSequencesHeight(), scaledHeight); assertEquals(od.getWidth(), maxWidth); @@ -245,7 +225,7 @@ public class OverviewDimensionsTest { // overly large boxX value reset to width-boxWidth mouseClick(od, 100, 6); - assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth() + 1); + assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth()); assertEquals(od.getBoxY(), 6); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); @@ -263,13 +243,17 @@ public class OverviewDimensionsTest { assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollCol(), Math.round((float) od.getBoxX() * alwidth / od.getWidth())); + + // here (float) od.getBoxY() * alheight / od.getSequencesHeight() = 507.5 + // and round rounds to 508; however we get 507 working with row values + // hence the subtraction of 1 assertEquals(od.getScrollRow(), Math.round((float) od.getBoxY() * alheight - / od.getSequencesHeight())); + / od.getSequencesHeight()) - 1); // click past end of alignment, as above mouseClick(od, 3000, 5); - assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth() + 1); + assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth()); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollCol(), @@ -333,7 +317,6 @@ public class OverviewDimensionsTest { assertEquals(od.getBoxHeight(), boxHeight); // try to click in hidden cols, check box does not move - // this test currently fails as the overview box does not behave like this! int xpos = 10; mouseClick(od, xpos, 0); assertEquals( @@ -359,7 +342,7 @@ public class OverviewDimensionsTest { // overly large boxX value reset to width-boxWidth xpos = 100; mouseClick(od, xpos, 5); - assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth() + 1); + assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth()); assertEquals(od.getBoxY(), 5); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); @@ -460,7 +443,7 @@ public class OverviewDimensionsTest { // boxX, scrollCol adjusted back, box width normal xpos = 3000; mouseClick(od, xpos, 5); - assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth() + 1); + assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth()); assertEquals(od.getBoxY(), 5); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); @@ -509,48 +492,43 @@ public class OverviewDimensionsTest { // click to left of hidden cols, with overlap // boxX and scrollCol adjusted for hidden cols, width normal - /* xpos = Math.round((float) 145 * od.getWidth() / alwidth) - boxWidth; - mouseClick(od, xpos, 0); - assertEquals( - od.getBoxX(), - Math.round((firstHidden - 1) * od.getWidth() / alwidth) - - boxWidth); - assertEquals(od.getBoxY(), 0); - assertEquals(od.getBoxWidth(), boxWidth); - assertEquals(od.getBoxHeight(), boxHeight); - assertEquals(od.getScrollCol(), - Math.round(od.getBoxX() * alwidth / od.getWidth())); - assertEquals(od.getScrollRow(), 0); - */ + xpos = Math.round((float) 145 * od.getWidth() / alwidth) - boxWidth; + mouseClick(od, xpos, 0); + assertEquals(od.getBoxX(), + Math.round((float) (firstHidden - 1) * od.getWidth() / alwidth) + - boxWidth + 1); + assertEquals(od.getBoxY(), 0); + assertEquals(od.getBoxWidth(), boxWidth); + assertEquals(od.getBoxHeight(), boxHeight); + assertEquals(od.getScrollCol(), + Math.round((float) od.getBoxX() * alwidth / od.getWidth())); + assertEquals(od.getScrollRow(), 0); + // click in hidden cols // boxX and scrollCol adjusted for hidden cols, width normal - // TODO breaks as above test - /*xpos = 115; - assertEquals( - od.getBoxX(), - Math.round((firstHidden - 1) * scalew * av.getCharWidth()) - - od.getBoxWidth()); + xpos = 115; + assertEquals(od.getBoxX(), + Math.round((float) (firstHidden - 1) * od.getWidth() / alwidth) + - boxWidth + 1); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getScrollCol(), - Math.round(od.getBoxX() * alwidth / od.getWidth())); - assertEquals(od.getScrollRow(), 0);*/ + Math.round((float) od.getBoxX() * alwidth / od.getWidth())); + assertEquals(od.getScrollRow(), 0); // click off end of alignment // boxX and scrollCol adjusted for hidden cols, width normal - // TODO breaks as above test - /* xpos = 3000; - assertEquals( - od.getBoxX(), - Math.round((firstHidden - 1) * scalew * av.getCharWidth()) - - od.getBoxWidth()); - assertEquals(od.getBoxY(), 0); - assertEquals(od.getBoxWidth(), boxWidth); - assertEquals(od.getBoxHeight(), boxHeight); - assertEquals(od.getScrollCol(), - Math.round(od.getBoxX() * alwidth / od.getWidth())); - assertEquals(od.getScrollRow(), 0);*/ + xpos = 3000; + assertEquals(od.getBoxX(), + Math.round((float) (firstHidden - 1) * od.getWidth() / alwidth) + - boxWidth + 1); + assertEquals(od.getBoxY(), 0); + assertEquals(od.getBoxWidth(), boxWidth); + assertEquals(od.getBoxHeight(), boxHeight); + assertEquals(od.getScrollCol(), + Math.round((float) od.getBoxX() * alwidth / od.getWidth())); + assertEquals(od.getScrollRow(), 0); } /** @@ -704,7 +682,7 @@ public class OverviewDimensionsTest { Math.round((float) 102 * od.getWidth() / alwidth)); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth - + Math.round((float) (lastHidden - firstHidden) + + Math.round((float) (lastHidden - firstHidden + 1) * od.getWidth() / alwidth)); assertEquals(od.getBoxHeight(), boxHeight); } @@ -871,7 +849,7 @@ public class OverviewDimensionsTest { // hide rows in middle and check updated box position is correct // no changes int firstHiddenRow = 50; - int lastHiddenRow = 60; + int lastHiddenRow = 54; hideSequences(firstHiddenRow, lastHiddenRow); od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps); @@ -882,34 +860,32 @@ public class OverviewDimensionsTest { assertEquals(od.getBoxHeight(), boxHeight); // 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, Math.round (ypos * alheight / od.getSequencesHeight())); - assertEquals(od.getBoxX(), 0); - assertEquals(od.getBoxY(), Math.round (ypos * alheight / od.getSequencesHeight()), - 1.5); - assertEquals(od.getBoxWidth(), boxWidth); - assertEquals( - od.getBoxHeight(), - boxHeight - + Math.round ((lastHiddenRow - firstHiddenRow + 1) / scaleh / av - .getCharHeight())); - */ + int ypos = 35; // column value in residues + mouseClick(od, 0, + Math.round((float) ypos * od.getSequencesHeight() / alheight)); + assertEquals(od.getBoxX(), 0); + assertEquals(od.getBoxY(), + Math.round((float) ypos * od.getSequencesHeight() / alheight)); + assertEquals(od.getBoxWidth(), boxWidth); + assertEquals( + od.getBoxHeight(), + boxHeight + + Math.round((float) (lastHiddenRow - firstHiddenRow + 1) + * od.getSequencesHeight() / alheight)); + // 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, Math.round (ypos * alheight / od.getSequencesHeight())); + ypos = 44; // column value in residues + mouseClick(od, 0, + Math.round((float) ypos * od.getSequencesHeight() / alheight)); assertEquals(od.getBoxX(), 0); - assertEquals(od.getBoxY(), Math.round (ypos * alheight / od.getSequencesHeight()), - 1.5); + assertEquals(od.getBoxY(), + Math.round((float) ypos * od.getSequencesHeight() / alheight)); assertEquals(od.getBoxWidth(), boxWidth); assertEquals( od.getBoxHeight(), boxHeight - + Math.round ((lastHiddenRow - firstHiddenRow + 1) / scaleh / av - .getCharHeight()));*/ + + Math.round((float) (lastHiddenRow - firstHiddenRow + 1) + * od.getSequencesHeight() / alheight)); } /** @@ -952,29 +928,28 @@ public class OverviewDimensionsTest { // 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, Math.round (ypos * scaleh * av.getCharHeight())); - assertEquals(od.getBoxX(), 0); - assertEquals( - od.getBoxY(), - Math.round ((firstHidden - viewHeight) * scaleh * av.getCharHeight()), - 1.5); - assertEquals(od.getBoxWidth(), boxWidth); - assertEquals(od.getBoxHeight(), boxHeight);*/ + ypos = 497; // row 497 + mouseClick(od, 0, + Math.round((float) ypos * od.getSequencesHeight() / alheight)); + assertEquals(od.getBoxX(), 0); + assertEquals( + od.getBoxY(), + Math.round((float) (firstHidden - viewHeight) + * od.getSequencesHeight() / alheight)); + assertEquals(od.getBoxWidth(), boxWidth); + assertEquals(od.getBoxHeight(), boxHeight); // click within hidden rows ypos = 505; - // TODO: fails with wrong boxHeight - correction done by setScrollValues(?) - /*mouseClick(od, 0, Math.round (ypos * scaleh * av.getCharHeight())); + mouseClick(od, 0, + Math.round((float) ypos * od.getSequencesHeight() / alheight)); assertEquals(od.getBoxX(), 0); assertEquals( od.getBoxY(), - Math.round ((firstHidden - viewHeight) * scaleh * av.getCharHeight()), - 1.5); + Math.round((firstHidden - viewHeight) * od.getSequencesHeight() + / alheight)); assertEquals(od.getBoxWidth(), boxWidth); - assertEquals(od.getBoxHeight(), boxHeight);*/ + assertEquals(od.getBoxHeight(), boxHeight); } /*