assertFalse(selectionModel.isSelectedIndex(1));
assertFalse(selectionModel.isSelectedIndex(2));
}
public void testMultipleSelection() {
DefaultListSelectionModel selectionModel = new DefaultListSelectionModel();
selectionModel.setSelectionMode(DefaultListSelectionModel.MULTIPLE_SELECTION);
assertEquals(DefaultListSelectionModel.MULTIPLE_SELECTION, selectionModel.getSelectionMode());
TestChangeListener changeListener = new TestChangeListener();
selectionModel.addChangeListener(changeListener);
selectionModel.setSelectedIndex(50, true);
assertFalse(selectionModel.isSelectionEmpty());
assertTrue(selectionModel.isSelectedIndex(50));
assertFalse(selectionModel.isSelectedIndex(0));
assertFalse(selectionModel.isSelectedIndex(5));
assertFalse(selectionModel.isSelectedIndex(49));
assertFalse(selectionModel.isSelectedIndex(51));
assertEquals(50, selectionModel.getMinSelectedIndex());
assertEquals(50, selectionModel.getMaxSelectedIndex());
assertNotNull(changeListener.e);
assertEquals(selectionModel, changeListener.e.getSource());
changeListener.e = null;
selectionModel.setSelectedIndex(75, true);
assertFalse(selectionModel.isSelectionEmpty());
assertTrue(selectionModel.isSelectedIndex(50));
assertTrue(selectionModel.isSelectedIndex(75));
assertEquals(50, selectionModel.getMinSelectedIndex());
assertEquals(75, selectionModel.getMaxSelectedIndex());
assertNotNull(changeListener.e);
assertEquals(selectionModel, changeListener.e.getSource());
changeListener.e = null;
selectionModel.setSelectedIndex(67, true);
assertFalse(selectionModel.isSelectionEmpty());
assertTrue(selectionModel.isSelectedIndex(50));
assertTrue(selectionModel.isSelectedIndex(67));
assertTrue(selectionModel.isSelectedIndex(75));
assertEquals(50, selectionModel.getMinSelectedIndex());
assertEquals(75, selectionModel.getMaxSelectedIndex());
assertNotNull(changeListener.e);
assertEquals(selectionModel, changeListener.e.getSource());
changeListener.e = null;
selectionModel.setSelectedIndex(21, true);
assertFalse(selectionModel.isSelectionEmpty());
assertTrue(selectionModel.isSelectedIndex(21));
assertTrue(selectionModel.isSelectedIndex(50));
assertTrue(selectionModel.isSelectedIndex(67));
assertTrue(selectionModel.isSelectedIndex(75));
assertEquals(21, selectionModel.getMinSelectedIndex());
assertEquals(75, selectionModel.getMaxSelectedIndex());
assertNotNull(changeListener.e);
assertEquals(selectionModel, changeListener.e.getSource());
changeListener.e = null;
selectionModel.setSelectedIndex(75, false);
assertFalse(selectionModel.isSelectionEmpty());
assertTrue(selectionModel.isSelectedIndex(21));
assertTrue(selectionModel.isSelectedIndex(50));
assertTrue(selectionModel.isSelectedIndex(67));
assertFalse(selectionModel.isSelectedIndex(75));
assertEquals(21, selectionModel.getMinSelectedIndex());
assertEquals(67, selectionModel.getMaxSelectedIndex());
assertNotNull(changeListener.e);
assertEquals(selectionModel, changeListener.e.getSource());
changeListener.e = null;
selectionModel.setSelectedIndex(21, false);
assertFalse(selectionModel.isSelectionEmpty());
assertFalse(selectionModel.isSelectedIndex(21));
assertTrue(selectionModel.isSelectedIndex(50));
assertTrue(selectionModel.isSelectedIndex(67));
assertFalse(selectionModel.isSelectedIndex(75));
assertEquals(50, selectionModel.getMinSelectedIndex());
assertEquals(67, selectionModel.getMaxSelectedIndex());
assertNotNull(changeListener.e);
assertEquals(selectionModel, changeListener.e.getSource());
changeListener.e = null;
selectionModel.clearSelection();
assertTrue(selectionModel.isSelectionEmpty());
assertFalse(selectionModel.isSelectedIndex(21));
assertFalse(selectionModel.isSelectedIndex(50));
assertFalse(selectionModel.isSelectedIndex(67));
assertFalse(selectionModel.isSelectedIndex(75));
assertEquals(-1, selectionModel.getMinSelectedIndex());
assertEquals(-1, selectionModel.getMaxSelectedIndex());
assertNotNull(changeListener.e);
assertEquals(selectionModel, changeListener.e.getSource());
changeListener.e = null;
}