use of org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableListTest method testAddAtIndexListChangeEvent.
@Test
public void testAddAtIndexListChangeEvent() throws Exception {
String element = "1";
assertEquals(0, list.size());
ListChangeEventTracker listener = new ListChangeEventTracker();
list.addListChangeListener(listener);
list.add(0, element);
ListChangeEvent event = listener.event;
assertDiff(event.diff, Collections.EMPTY_LIST, Collections.singletonList("1"));
}
use of org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableListTest method testRetainAllListChangeEvent.
@Test
public void testRetainAllListChangeEvent() throws Exception {
List elements = Arrays.asList(new String[] { "0", "1", "2", "3" });
list.addAll(elements);
ListChangeEventTracker listener = new ListChangeEventTracker();
list.addListChangeListener(listener);
assertEquals(0, listener.count);
list.retainAll(elements.subList(0, 2));
assertEquals(1, listener.count);
ListChangeEvent event = listener.event;
assertSame(list, event.getObservableList());
assertDiff(event.diff, Arrays.asList(new Object[] { "0", "1", "2", "3" }), Arrays.asList(new Object[] { "0", "1" }));
}
use of org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableListTest method testAddAllAtIndexListChangeEvent.
@Test
public void testAddAllAtIndexListChangeEvent() throws Exception {
List elements = Arrays.asList(new String[] { "1", "2" });
list.addAll(elements);
ListChangeEventTracker listener = new ListChangeEventTracker();
list.addListChangeListener(listener);
assertEquals(0, listener.count);
list.addAll(2, elements);
assertEquals(1, listener.count);
ListChangeEvent event = listener.event;
assertSame(list, event.getObservableList());
assertDiff(event.diff, Arrays.asList(new Object[] { "1", "2" }), Arrays.asList(new Object[] { "1", "2", "1", "2" }));
}
use of org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableListTest method testModifyObservableList_FiresListChange.
@Test
public void testModifyObservableList_FiresListChange() {
Bean bean = new Bean(new ArrayList());
IObservableList observable = BeansObservables.observeList(bean, "list");
ListChangeEventTracker tracker = ListChangeEventTracker.observe(observable);
Object element = new Object();
observable.add(element);
assertEquals(1, tracker.count);
assertDiff(tracker.event.diff, Collections.EMPTY_LIST, Collections.singletonList(element));
}
use of org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableListTest method testListChangeEventFiresWhenNewListIsSet.
@Test
public void testListChangeEventFiresWhenNewListIsSet() throws Exception {
List elements = Arrays.asList(new String[] { "1", "2" });
ListChangeEventTracker listener = new ListChangeEventTracker();
list.addListChangeListener(listener);
assertEquals(0, listener.count);
bean.setList(elements);
assertEquals(1, listener.count);
}
Aggregations