use of org.eclipse.jface.databinding.conformance.util.SetChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class ComputedSetTest method testDependency_SetChangeEventFiresOnlyWhenNotDirty.
@Test
public void testDependency_SetChangeEventFiresOnlyWhenNotDirty() {
SetChangeEventTracker tracker = SetChangeEventTracker.observe(set);
set.dependency.fireChange();
assertEquals("ComputedSet should fire set change event when its dependency changes", 1, tracker.count);
set.dependency.fireChange();
assertEquals("ComputedSet should not fire set change events when dirty", 1, tracker.count);
// Force set to recompute.
set.size();
set.dependency.fireChange();
assertEquals("ComputedSet should fire set change event when its dependency changes", 2, tracker.count);
}
use of org.eclipse.jface.databinding.conformance.util.SetChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableSetTest method testSetBeanPropertyOutsideRealm_FiresEventInsideRealm.
@Test
public void testSetBeanPropertyOutsideRealm_FiresEventInsideRealm() {
Bean bean = new Bean(Collections.EMPTY_SET);
CurrentRealm realm = new CurrentRealm(true);
IObservableSet observable = BeansObservables.observeSet(realm, bean, "set");
SetChangeEventTracker tracker = SetChangeEventTracker.observe(observable);
realm.setCurrent(false);
bean.setSet(Collections.singleton("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 JavaBeanObservableSetTest method testModifyObservableSet_FiresSetChange.
@Test
public void testModifyObservableSet_FiresSetChange() {
Bean bean = new Bean(new HashSet());
IObservableSet observable = BeansObservables.observeSet(bean, "set");
SetChangeEventTracker tracker = SetChangeEventTracker.observe(observable);
Object element = new Object();
observable.add(element);
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 testRemoveAll_SetChangeEvent.
@Test
public void testRemoveAll_SetChangeEvent() throws Exception {
Collection elements = Arrays.asList(new String[] { "1", "2" });
set.addAll(elements);
SetChangeEventTracker listener = SetChangeEventTracker.observe(set);
assertEquals(0, listener.count);
set.removeAll(elements);
SetChangeEvent event = listener.event;
assertEquals(set, event.getObservableSet());
assertEquals(Collections.EMPTY_SET, event.diff.getAdditions());
assertEquals(new HashSet(elements), event.diff.getRemovals());
}
use of org.eclipse.jface.databinding.conformance.util.SetChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableArrayBasedSetTest method testModifyObservableSet_FiresSetChange.
@Test
public void testModifyObservableSet_FiresSetChange() {
Bean bean = new Bean(new Object[] {});
IObservableSet observable = BeansObservables.observeSet(bean, "array");
SetChangeEventTracker tracker = SetChangeEventTracker.observe(observable);
observable.add("new");
assertEquals(1, tracker.count);
assertDiff(tracker.event.diff, Collections.EMPTY_SET, Collections.singleton("new"));
}
Aggregations