Exemplo n.º 1
0
 /**
  * Incorrect test assumption: updates to the items don't change the indices, no event to fire from
  * the indices. They are immutable, anyway.
  *
  * <p>The assumption had some meaning as long as IndexMappedList didn't get the real change from
  * the backing list - now it doesn't and can fire on its own as needed.
  *
  * @see IndexMappedListTest#testItemsUpdate()
  */
 @Test
 @Ignore
 public void testItemsUpdate() {
   ObservableList<Person> base = Person.persons();
   ObservableList<Person> persons =
       FXCollections.observableList(base, p -> new Observable[] {p.firstNameProperty()});
   IndicesBase<Person> indicesList = new IndicesList<>(persons);
   int[] indices = new int[] {1, 3, 5};
   indicesList.addIndices(indices);
   ListChangeReport report = new ListChangeReport(indicesList);
   //        new PrintingListChangeListener("Set item at 3", indicesList);
   persons.get(3).setFirstName("newName");
   assertEquals(1, report.getEventCount());
 }
Exemplo n.º 2
0
  /** Sanity: quick check that using a ListProperty as source doesn't interfere. */
  @Test
  public void testItemsIsListProperty() {
    ObjectProperty<ObservableList<String>> itemsProperty = new SimpleObjectProperty(items);
    ListProperty<String> listItems = new SimpleListProperty<>();
    listItems.bind(itemsProperty);
    IndicesBase indicesList = new IndicesList(listItems);
    ListChangeReport report = new ListChangeReport(indicesList);
    int[] indices = new int[] {3, 5, 1};
    indicesList.addIndices(indices);
    report.clear();
    // new PrintingListChangeListener("SetAll Same size", indicesList);
    ObservableList<String> other = createObservableList(true);
    // make it not equal
    other.set(0, "otherItem");
    items.setAll(other);

    assertEquals("all cleared", 0, indicesList.size());
    assertEquals(1, report.getEventCount());
    assertTrue(
        "expected single removed, but was " + report.getLastChange(),
        wasSingleRemoved(report.getLastChange()));
  }