use of org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableArrayBasedListTest method testRemoveListChangeEvent.
@Test
public void testRemoveListChangeEvent() throws Exception {
String element = "1";
list.add(element);
assertEquals(1, list.size());
ListChangeEventTracker listener = new ListChangeEventTracker();
list.addListChangeListener(listener);
list.remove(element);
assertEquals(1, listener.count);
ListChangeEvent event = listener.event;
assertSame(list, event.getObservableList());
assertDiff(event.diff, Collections.singletonList("1"), Collections.EMPTY_LIST);
}
use of org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableArrayBasedListTest method testFiresListChangeEvents.
@Test
public void testFiresListChangeEvents() throws Exception {
ListChangeEventTracker listener = new ListChangeEventTracker();
list.addListChangeListener(listener);
assertEquals(0, listener.count);
bean.setArray(new Bean[] { new Bean() });
assertEquals(1, listener.count);
}
use of org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableArrayBasedListTest method testRemovesListenerAfterLastListenerIsRemoved.
@Test
public void testRemovesListenerAfterLastListenerIsRemoved() throws Exception {
ListChangeEventTracker listener = new ListChangeEventTracker();
list.addListChangeListener(listener);
assertTrue(bean.changeSupport.hasListeners(propertyName));
list.removeListChangeListener(listener);
assertFalse(bean.changeSupport.hasListeners(propertyName));
}
use of org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableArrayBasedListTest method testAddListChangeEvent.
@Test
public void testAddListChangeEvent() throws Exception {
ListChangeEventTracker listener = new ListChangeEventTracker();
list.addListChangeListener(listener);
assertEquals(0, listener.count);
String element = "1";
list.add(element);
assertEquals(1, listener.count);
ListChangeEvent event = listener.event;
assertSame(list, event.getObservableList());
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 testRemoveAllListChangeEvent.
@Test
public void testRemoveAllListChangeEvent() throws Exception {
List elements = Arrays.asList(new String[] { "1", "2" });
list.addAll(elements);
list.addAll(elements);
ListChangeEventTracker listener = new ListChangeEventTracker();
list.addListChangeListener(listener);
assertEquals(0, listener.count);
list.removeAll(elements);
ListChangeEvent event = listener.event;
assertEquals(list, event.getObservableList());
assertSame(list, event.getObservableList());
assertDiff(event.diff, Arrays.asList(new Object[] { "1", "2", "1", "2" }), Collections.EMPTY_LIST);
}
Aggregations