From dfc0fa51c8c3305bb7a50a5dcde8d10e08430462 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 7 Apr 2015 09:18:49 +0100 Subject: [PATCH] JAL-1270 test added --- test/jalview/datamodel/ColumnSelectionTest.java | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/jalview/datamodel/ColumnSelectionTest.java b/test/jalview/datamodel/ColumnSelectionTest.java index 228156a..97ef079 100644 --- a/test/jalview/datamodel/ColumnSelectionTest.java +++ b/test/jalview/datamodel/ColumnSelectionTest.java @@ -45,4 +45,31 @@ public class ColumnSelectionTest assertEquals(1, sel.size()); assertEquals(new Integer(5), sel.get(0)); } + + /** + * Test the method that finds the visible column position of an alignment + * column, allowing for hidden columns. + */ + @Test + public void testFindColumnPosition() + { + ColumnSelection cs = new ColumnSelection(); + assertEquals(5, cs.findColumnPosition(5)); + + // hiding column 6 makes no difference + cs.hideColumns(6, 6); + assertEquals(5, cs.findColumnPosition(5)); + + // hiding column 5 makes no difference + cs.hideColumns(5, 5); + assertEquals(5, cs.findColumnPosition(5)); + + // hiding column 4 moves column 5 to column 4 + cs.hideColumns(4, 4); + assertEquals(4, cs.findColumnPosition(5)); + + // hiding columns 1 and 2 moves column 5 to column 2 + cs.hideColumns(1, 2); + assertEquals(2, cs.findColumnPosition(5)); + } } -- 1.7.10.2