X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fdatamodel%2FHiddenColumnsTest.java;h=13cb52635445a0d9f261b518e75425b36176b07c;hb=607a4aecda2f99866bb1acf7d364a6dde4e215bd;hp=62c2d223fc7013ca1c1aa8642e044d1df92bf1e9;hpb=fd8dc2879b13709703b57dd7ed4b3754b253e12f;p=jalview.git diff --git a/test/jalview/datamodel/HiddenColumnsTest.java b/test/jalview/datamodel/HiddenColumnsTest.java index 62c2d22..13cb526 100644 --- a/test/jalview/datamodel/HiddenColumnsTest.java +++ b/test/jalview/datamodel/HiddenColumnsTest.java @@ -23,7 +23,6 @@ package jalview.datamodel; import static org.testng.Assert.assertNull; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertSame; import static org.testng.AssertJUnit.assertTrue; import jalview.analysis.AlignmentGenerator; @@ -233,14 +232,17 @@ public class HiddenColumnsTest HiddenColumns cs = new HiddenColumns(); cs.hideColumns(10, 11); cs.hideColumns(5, 7); - assertEquals("[5, 7]", Arrays.toString(cs.getHiddenRegions().get(0))); + assertEquals("[5, 7]", + Arrays.toString(cs.getHiddenColumnsCopyAsList().get(0))); HiddenColumns cs2 = new HiddenColumns(cs); assertTrue(cs2.hasHiddenColumns()); - assertEquals(2, cs2.getHiddenRegions().size()); + assertEquals(2, cs2.getHiddenColumnsCopyAsList().size()); // hidden columns are held in column order - assertEquals("[5, 7]", Arrays.toString(cs2.getHiddenRegions().get(0))); - assertEquals("[10, 11]", Arrays.toString(cs2.getHiddenRegions().get(1))); + assertEquals("[5, 7]", + Arrays.toString(cs2.getHiddenColumnsCopyAsList().get(0))); + assertEquals("[10, 11]", + Arrays.toString(cs2.getHiddenColumnsCopyAsList().get(1))); } /** @@ -337,66 +339,78 @@ public class HiddenColumnsTest ColumnSelection colsel = new ColumnSelection(); HiddenColumns cs = al.getHiddenColumns(); colsel.hideSelectedColumns(5, al.getHiddenColumns()); - List hidden = cs.getHiddenRegions(); + List hidden = cs.getHiddenColumnsCopyAsList(); assertEquals(1, hidden.size()); assertEquals("[5, 5]", Arrays.toString(hidden.get(0))); colsel.hideSelectedColumns(3, al.getHiddenColumns()); + hidden = cs.getHiddenColumnsCopyAsList(); assertEquals(2, hidden.size()); // two hidden ranges, in order: - assertSame(hidden, cs.getHiddenRegions()); + assertEquals(hidden.size(), cs.getHiddenColumnsCopyAsList().size()); assertEquals("[3, 3]", Arrays.toString(hidden.get(0))); assertEquals("[5, 5]", Arrays.toString(hidden.get(1))); // hiding column 4 expands [3, 3] to [3, 4] // and merges to [5, 5] to make [3, 5] colsel.hideSelectedColumns(4, al.getHiddenColumns()); - hidden = cs.getHiddenRegions(); + hidden = cs.getHiddenColumnsCopyAsList(); assertEquals(1, hidden.size()); assertEquals("[3, 5]", Arrays.toString(hidden.get(0))); // clear hidden columns (note they are added to selected) cs.revealAllHiddenColumns(colsel); // it is now actually null but getter returns an empty list - assertTrue(cs.getHiddenRegions().isEmpty()); + assertTrue(cs.getHiddenColumnsCopyAsList().isEmpty()); cs.hideColumns(3, 6); - hidden = cs.getHiddenRegions(); + hidden = cs.getHiddenColumnsCopyAsList(); int[] firstHiddenRange = hidden.get(0); assertEquals("[3, 6]", Arrays.toString(firstHiddenRange)); // adding a subrange of already hidden should do nothing cs.hideColumns(4, 5); + hidden = cs.getHiddenColumnsCopyAsList(); assertEquals(1, hidden.size()); - assertSame(firstHiddenRange, cs.getHiddenRegions().get(0)); + assertEquals("[3, 6]", + Arrays.toString(cs.getHiddenColumnsCopyAsList().get(0))); cs.hideColumns(3, 5); + hidden = cs.getHiddenColumnsCopyAsList(); assertEquals(1, hidden.size()); - assertSame(firstHiddenRange, cs.getHiddenRegions().get(0)); + assertEquals("[3, 6]", + Arrays.toString(cs.getHiddenColumnsCopyAsList().get(0))); cs.hideColumns(4, 6); + hidden = cs.getHiddenColumnsCopyAsList(); assertEquals(1, hidden.size()); - assertSame(firstHiddenRange, cs.getHiddenRegions().get(0)); + assertEquals("[3, 6]", + Arrays.toString(cs.getHiddenColumnsCopyAsList().get(0))); cs.hideColumns(3, 6); + hidden = cs.getHiddenColumnsCopyAsList(); assertEquals(1, hidden.size()); - assertSame(firstHiddenRange, cs.getHiddenRegions().get(0)); + assertEquals("[3, 6]", + Arrays.toString(cs.getHiddenColumnsCopyAsList().get(0))); cs.revealAllHiddenColumns(colsel); cs.hideColumns(2, 4); - hidden = cs.getHiddenRegions(); + hidden = cs.getHiddenColumnsCopyAsList(); assertEquals(1, hidden.size()); assertEquals("[2, 4]", Arrays.toString(hidden.get(0))); // extend contiguous with 2 positions overlap cs.hideColumns(3, 5); + hidden = cs.getHiddenColumnsCopyAsList(); assertEquals(1, hidden.size()); assertEquals("[2, 5]", Arrays.toString(hidden.get(0))); // extend contiguous with 1 position overlap cs.hideColumns(5, 6); + hidden = cs.getHiddenColumnsCopyAsList(); assertEquals(1, hidden.size()); assertEquals("[2, 6]", Arrays.toString(hidden.get(0))); // extend contiguous with overlap both ends: cs.hideColumns(1, 7); + hidden = cs.getHiddenColumnsCopyAsList(); assertEquals(1, hidden.size()); assertEquals("[1, 7]", Arrays.toString(hidden.get(0))); } @@ -414,7 +428,7 @@ public class HiddenColumnsTest colsel.addElement(10); cs.revealHiddenColumns(5, colsel); // hidden columns list now null but getter returns empty list: - assertTrue(cs.getHiddenRegions().isEmpty()); + assertTrue(cs.getHiddenColumnsCopyAsList().isEmpty()); // revealed columns are marked as selected (added to selection): assertEquals("[10, 5, 6, 7, 8]", colsel.getSelected().toString()); @@ -422,9 +436,9 @@ public class HiddenColumnsTest colsel = new ColumnSelection(); cs = new HiddenColumns(); cs.hideColumns(5, 8); - List hidden = cs.getHiddenRegions(); + List hidden = cs.getHiddenColumnsCopyAsList(); cs.revealHiddenColumns(6, colsel); - assertSame(hidden, cs.getHiddenRegions()); + assertEquals(hidden.size(), cs.getHiddenColumnsCopyAsList().size()); assertTrue(colsel.getSelected().isEmpty()); } @@ -443,7 +457,7 @@ public class HiddenColumnsTest * revealing hidden columns adds them (in order) to the (unordered) * selection list */ - assertTrue(cs.getHiddenRegions().isEmpty()); + assertTrue(cs.getHiddenColumnsCopyAsList().isEmpty()); assertEquals("[11, 1, 2, 3, 5, 6, 7, 8]", colsel.getSelected() .toString()); } @@ -479,13 +493,13 @@ public class HiddenColumnsTest HiddenColumns cs = new HiddenColumns(); cs.hideColumns(49, 59); cs.hideColumns(69, 79); - List hidden = cs.getHiddenRegions(); + List hidden = cs.getHiddenColumnsCopyAsList(); assertEquals(2, hidden.size()); assertEquals("[49, 59]", Arrays.toString(hidden.get(0))); assertEquals("[69, 79]", Arrays.toString(hidden.get(1))); cs.hideColumns(48, 80); - hidden = cs.getHiddenRegions(); + hidden = cs.getHiddenColumnsCopyAsList(); assertEquals(1, hidden.size()); assertEquals("[48, 80]", Arrays.toString(hidden.get(0))); @@ -498,7 +512,7 @@ public class HiddenColumnsTest cs.hideColumns(50, 60); // hiding 21-49 should merge to one range cs.hideColumns(21, 49); - hidden = cs.getHiddenRegions(); + hidden = cs.getHiddenColumnsCopyAsList(); assertEquals(1, hidden.size()); assertEquals("[10, 60]", Arrays.toString(hidden.get(0))); @@ -514,7 +528,7 @@ public class HiddenColumnsTest cs.hideColumns(60, 70); cs.hideColumns(15, 45); - hidden = cs.getHiddenRegions(); + hidden = cs.getHiddenColumnsCopyAsList(); assertEquals(2, hidden.size()); assertEquals("[10, 50]", Arrays.toString(hidden.get(0))); assertEquals("[60, 70]", Arrays.toString(hidden.get(1))); @@ -531,23 +545,23 @@ public class HiddenColumnsTest one.set(1); cs = new HiddenColumns(); cs.hideMarkedBits(one); - assertEquals(1, cs.getHiddenRegions().size()); + assertEquals(1, cs.getHiddenColumnsCopyAsList().size()); one.set(2); cs = new HiddenColumns(); cs.hideMarkedBits(one); - assertEquals(1, cs.getHiddenRegions().size()); + assertEquals(1, cs.getHiddenColumnsCopyAsList().size()); one.set(3); cs = new HiddenColumns(); cs.hideMarkedBits(one); - assertEquals(1, cs.getHiddenRegions().size()); + assertEquals(1, cs.getHiddenColumnsCopyAsList().size()); // split one.clear(2); cs = new HiddenColumns(); cs.hideMarkedBits(one); - assertEquals(2, cs.getHiddenRegions().size()); + assertEquals(2, cs.getHiddenColumnsCopyAsList().size()); assertEquals(0, cs.adjustForHiddenColumns(0)); assertEquals(2, cs.adjustForHiddenColumns(1)); @@ -558,7 +572,7 @@ public class HiddenColumnsTest cs = new HiddenColumns(); cs.hideMarkedBits(one); - assertEquals(1, cs.getHiddenRegions().size()); + assertEquals(1, cs.getHiddenColumnsCopyAsList().size()); assertEquals(0, cs.adjustForHiddenColumns(0)); assertEquals(1, cs.adjustForHiddenColumns(1));