* this fails, HideSelectedColumns may also fail
*/
@Test(groups = { "Functional" })
- public void testgetSelectedRanges()
+ public void testGetSelectedRanges()
{
+ /*
+ * getSelectedRanges returns ordered columns regardless
+ * of the order in which they are added
+ */
ColumnSelection cs = new ColumnSelection();
- int[] sel = { 2, 3, 4, 7, 8, 9, 20, 21, 22 };
+ int[] sel = { 4, 3, 7, 21, 9, 20, 8, 22, 2 };
for (int col : sel)
{
cs.addElement(col);
cs.addElement(88);
assertTrue(cs.equals(cs2));
}
+
+ /**
+ * Test the method that returns selected columns, in the order in which they
+ * were added
+ */
+ @Test(groups = { "Functional" })
+ public void testGetSelection()
+ {
+ ColumnSelection cs = new ColumnSelection();
+ int[] sel = { 4, 3, 7, 21 };
+ for (int col : sel)
+ {
+ cs.addElement(col);
+ }
+ List<Integer> selected = cs.getSelected();
+ assertEquals(4, selected.size());
+ int i = 0;
+ for (int col : sel)
+ {
+ assertEquals(col, selected.get(i++).intValue());
+ }
+
+ cs.removeElement(7);
+ cs.addElement(1);
+ cs.removeElement(4);
+ selected = cs.getSelected();
+ assertEquals(3, selected.size());
+ assertEquals(3, selected.get(0).intValue());
+ assertEquals(21, selected.get(1).intValue());
+ assertEquals(1, selected.get(2).intValue());
+ }
}