示例#1
0
  public void testGetOptionWithSorting() {
    final ITableRidget ridget = getRidget();

    assertEquals(0, ridget.indexOfOption(person1));
    assertEquals(person1, ridget.getOption(0));

    ridget.setComparator(1, new StringComparator());
    ridget.setSortedColumn(1); // sort by last name
    ridget.setSortedAscending(false);

    final int last = ridget.getOptionCount() - 1;
    assertEquals(last, ridget.indexOfOption(person1));
    assertEquals(person1, ridget.getOption(last));

    ridget.setSortedAscending(true);

    assertEquals(0, ridget.indexOfOption(person1));
    assertEquals(person1, ridget.getOption(0));
  }
示例#2
0
  public void testSetSelectionWithSorting() {
    final ITableRidget ridget = getRidget();

    assertEquals(-1, ridget.getSelectionIndex());
    assertTrue(ridget.getSelection().isEmpty());

    ridget.setSelection(0);

    assertEquals(0, ridget.getSelectionIndex());
    assertEquals(person1, ridget.getSelection().get(0));

    ridget.setComparator(1, new StringComparator());
    ridget.setSortedColumn(1); // sort by last name
    ridget.setSortedAscending(false);

    final int last = ridget.getOptionCount() - 1;
    assertEquals(last, ridget.getSelectionIndex());
    assertEquals(person1, ridget.getSelection().get(0));

    ridget.setSortedAscending(true);

    assertEquals(0, ridget.getSelectionIndex());
    assertEquals(person1, ridget.getSelection().get(0));
  }