* @param harness the test harness.
*/
private void testSingleInterval(TestHarness harness)
{
harness.checkPoint("SINGLE_INTERVAL_SELECTION (1)");
DefaultListSelectionModel m = new DefaultListSelectionModel();
m.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
events.clear();
m.addListSelectionListener(this);
m.setSelectionInterval(6, 7);
harness.check(m.isSelectedIndex(5), false);
harness.check(m.isSelectedIndex(6), true);
harness.check(m.isSelectedIndex(7), true);
harness.check(m.isSelectedIndex(8), false);
harness.check(m.getAnchorSelectionIndex(), 6);
harness.check(m.getLeadSelectionIndex(), 7);
harness.check(events.size(), 1);
ListSelectionEvent lastEvent = (ListSelectionEvent) events.get(0);
harness.check(lastEvent.getSource(), m);
harness.check(lastEvent.getFirstIndex(), 6);
harness.check(lastEvent.getLastIndex(), 7);
// no event is generated if we update the same again
harness.checkPoint("SINGLE_INTERVAL_SELECTION (2)");
events.clear();
m.setSelectionInterval(6, 7);
harness.check(events.size(), 0);
// now if we set another selection, the event range should cover the old
// index too
harness.checkPoint("SINGLE_INTERVAL_SELECTION (3)");
events.clear();
m.setSelectionInterval(3, 3);
harness.check(m.isSelectedIndex(3), true);
harness.check(m.isSelectedIndex(6), false);
harness.check(m.isSelectedIndex(7), false);
harness.check(events.size(), 1);
lastEvent = (ListSelectionEvent) events.get(0);
harness.check(lastEvent.getSource(), m);
harness.check(lastEvent.getFirstIndex(), 3);
harness.check(lastEvent.getLastIndex(), 7);
// the anchor can move around independently of the selection, is it
// included in the event range? YES
harness.checkPoint("SINGLE_INTERVAL_SELECTION (3)");
m.setAnchorSelectionIndex(5);
events.clear();
m.setSelectionInterval(4, 4);
harness.check(m.isSelectedIndex(3), false);
harness.check(m.isSelectedIndex(4), true);
harness.check(m.isSelectedIndex(5), false);
lastEvent = (ListSelectionEvent) events.get(0);
harness.check(lastEvent.getSource(), m);
harness.check(lastEvent.getFirstIndex(), 3);
harness.check(lastEvent.getLastIndex(), 5);
}