X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fdatamodel%2FColumnSelectionTest.java;h=4d3f6115cf590ad151e75f90d26ac802d2897e62;hb=refs%2Fheads%2Fbug%2FJAL-2461;hp=e34b23f478da0de9a22c2c7f962320251b7a2e36;hpb=d387f0ee40a8e248ce08c97aca2e427aa75a40d8;p=jalview.git diff --git a/test/jalview/datamodel/ColumnSelectionTest.java b/test/jalview/datamodel/ColumnSelectionTest.java index e34b23f..4d3f611 100644 --- a/test/jalview/datamodel/ColumnSelectionTest.java +++ b/test/jalview/datamodel/ColumnSelectionTest.java @@ -132,10 +132,69 @@ public class ColumnSelectionTest assertEquals(25, cs2.findColumnPosition(40)); // check when hidden columns start at 0 that the visible column - // to the right is returned for hidden cols in the region + // is returned as 0 ColumnSelection cs3 = new ColumnSelection(); cs3.hideColumns(0, 4); - assertEquals(5, cs3.findColumnPosition(2)); + assertEquals(0, cs3.findColumnPosition(2)); + + } + + /** + * Test the method that finds the visible column position a given distance + * before another column + */ + @Test(groups = { "Functional" }) + public void testFindColumnNToLeft() + { + ColumnSelection cs = new ColumnSelection(); + + // test that without hidden columns, findColumnNToLeft returns + // position n to left of provided position + int pos = cs.subtractVisibleColumns(3, 10); + assertEquals(7, pos); + + // 0 returns same position + pos = cs.subtractVisibleColumns(0, 10); + assertEquals(10, pos); + + // overflow to left returns negative number + pos = cs.subtractVisibleColumns(3, 0); + assertEquals(-3, pos); + + // test that with hidden columns to left of result column + // behaviour is the same as above + cs.hideColumns(1, 3); + + // position n to left of provided position + pos = cs.subtractVisibleColumns(3, 10); + assertEquals(7, pos); + + // 0 returns same position + pos = cs.subtractVisibleColumns(0, 10); + assertEquals(10, pos); + + // test with one set of hidden columns between start and required position + cs.hideColumns(12, 15); + pos = cs.subtractVisibleColumns(8, 17); + assertEquals(5, pos); + + // test with two sets of hidden columns between start and required position + cs.hideColumns(20, 21); + pos = cs.subtractVisibleColumns(8, 23); + assertEquals(9, pos); + + // repeat last 2 tests with no hidden columns to left of required position + cs.revealAllHiddenColumns(); + + // test with one set of hidden columns between start and required position + cs.hideColumns(12, 15); + pos = cs.subtractVisibleColumns(8, 17); + assertEquals(5, pos); + + // test with two sets of hidden columns between start and required position + cs.hideColumns(20, 21); + pos = cs.subtractVisibleColumns(8, 23); + assertEquals(9, pos); }