use of org.eclipse.jface.databinding.conformance.util.SetChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableArrayBasedSetTest method testRemove_SetChangeEvent.
@Test
public void testRemove_SetChangeEvent() throws Exception {
String element = "1";
set.add(element);
assertEquals(1, set.size());
SetChangeEventTracker listener = SetChangeEventTracker.observe(set);
assertEquals(0, listener.count);
set.remove(element);
assertEquals(1, listener.count);
SetChangeEvent event = listener.event;
assertEquals(set, event.getObservableSet());
assertEquals(Collections.singleton(element), event.diff.getRemovals());
assertEquals(Collections.EMPTY_SET, event.diff.getAdditions());
}
use of org.eclipse.jface.databinding.conformance.util.SetChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableArrayBasedSetTest method testRetainAll_SetChangeEvent.
@Test
public void testRetainAll_SetChangeEvent() throws Exception {
set.addAll(Arrays.asList(new String[] { "0", "1", "2", "3" }));
SetChangeEventTracker listener = SetChangeEventTracker.observe(set);
assertEquals(0, listener.count);
set.retainAll(Arrays.asList(new String[] { "0", "1" }));
assertEquals(1, listener.count);
SetChangeEvent event = listener.event;
assertEquals(set, event.getObservableSet());
assertEquals(Collections.EMPTY_SET, event.diff.getAdditions());
assertEquals(new HashSet(Arrays.asList(new String[] { "2", "3" })), event.diff.getRemovals());
}
use of org.eclipse.jface.databinding.conformance.util.SetChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableArrayBasedSetTest method testSetBeanPropertyOutsideRealm_FiresEventInsideRealm.
@Test
public void testSetBeanPropertyOutsideRealm_FiresEventInsideRealm() {
Bean bean = new Bean(new Object[0]);
CurrentRealm realm = new CurrentRealm(true);
IObservableSet observable = BeansObservables.observeSet(realm, bean, "array");
SetChangeEventTracker tracker = SetChangeEventTracker.observe(observable);
realm.setCurrent(false);
bean.setArray(new Object[] { "element" });
assertEquals(0, tracker.count);
realm.setCurrent(true);
assertEquals(1, tracker.count);
assertDiff(tracker.event.diff, Collections.EMPTY_SET, Collections.singleton("element"));
}
use of org.eclipse.jface.databinding.conformance.util.SetChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableArrayBasedSetTest method testRemovesListenerAfterLastListenerIsRemoved.
@Test
public void testRemovesListenerAfterLastListenerIsRemoved() throws Exception {
SetChangeEventTracker listener = SetChangeEventTracker.observe(set);
assertTrue(bean.changeSupport.hasListeners(propertyName));
set.removeSetChangeListener(listener);
assertFalse(bean.changeSupport.hasListeners(propertyName));
}
use of org.eclipse.jface.databinding.conformance.util.SetChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableArrayBasedSetTest method testAddAll_SetChangeEvent.
@Test
public void testAddAll_SetChangeEvent() throws Exception {
Collection elements = Arrays.asList(new String[] { "1", "2" });
assertEquals(0, set.size());
SetChangeEventTracker listener = SetChangeEventTracker.observe(set);
assertEquals(0, listener.count);
set.addAll(elements);
assertEquals(1, listener.count);
SetChangeEvent event = listener.event;
assertEquals(set, event.getObservableSet());
assertEquals(new HashSet(elements), event.diff.getAdditions());
assertEquals(Collections.EMPTY_SET, event.diff.getRemovals());
}
Aggregations