use of org.eclipse.jface.databinding.conformance.util.SetChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableSetTest method testSetBeanProperty_CorrectForNullOldAndNewValues.
@Test
public void testSetBeanProperty_CorrectForNullOldAndNewValues() {
// The java bean spec allows the old and new values in a
// PropertyChangeEvent to be null, which indicates that an unknown
// change occured.
// This test ensures that JavaBeanObservableValue fires the correct
// value diff even if the bean implementor is lazy :-P
Bean bean = new AnnoyingBean();
bean.setSet(Collections.singleton("old"));
IObservableSet observable = BeansObservables.observeSet(new CurrentRealm(true), bean, "set");
SetChangeEventTracker tracker = SetChangeEventTracker.observe(observable);
bean.setSet(Collections.singleton("new"));
assertEquals(1, tracker.count);
assertEquals(Collections.singleton("old"), tracker.event.diff.getRemovals());
assertEquals(Collections.singleton("new"), tracker.event.diff.getAdditions());
}
use of org.eclipse.jface.databinding.conformance.util.SetChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableSetTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
bean = new Bean();
propertyName = "set";
propertyDescriptor = ((IBeanProperty) BeanProperties.set(Bean.class, propertyName)).getPropertyDescriptor();
observableSet = BeansObservables.observeSet(DisplayRealm.getRealm(Display.getDefault()), bean, propertyName, Bean.class);
beanObservable = (IBeanObservable) observableSet;
listener = new SetChangeEventTracker();
}
use of org.eclipse.jface.databinding.conformance.util.SetChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class UnmodifiableObservableSetTest method testFiresSetChangeEvents.
@Test
public void testFiresSetChangeEvents() throws Exception {
SetChangeEventTracker mutableListener = new SetChangeEventTracker();
SetChangeEventTracker unmodifiableListener = new SetChangeEventTracker();
mutable.addSetChangeListener(mutableListener);
unmodifiable.addSetChangeListener(unmodifiableListener);
assertEquals(0, mutableListener.count);
assertEquals(0, unmodifiableListener.count);
String element = "3";
mutable.add(element);
assertEquals(1, mutableListener.count);
assertEquals(mutable, mutableListener.event.getObservableSet());
assertEquals(1, mutableListener.event.diff.getAdditions().size());
Object addition = mutableListener.event.diff.getAdditions().toArray()[0];
assertEquals(element, addition);
assertEquals(3, mutable.size());
assertEquals(1, unmodifiableListener.count);
assertEquals(unmodifiable, unmodifiableListener.event.getObservableSet());
assertEquals(1, unmodifiableListener.event.diff.getAdditions().size());
addition = unmodifiableListener.event.diff.getAdditions().toArray()[0];
assertEquals(element, addition);
assertEquals(3, unmodifiable.size());
}
use of org.eclipse.jface.databinding.conformance.util.SetChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableArrayBasedSetTest method testAdd_SetChangeEvent.
@Test
public void testAdd_SetChangeEvent() throws Exception {
SetChangeEventTracker listener = SetChangeEventTracker.observe(set);
assertEquals(0, listener.count);
String element = "1";
set.add(element);
assertEquals(1, listener.count);
SetChangeEvent event = listener.event;
assertSame(set, event.getObservableSet());
assertEquals(Collections.singleton(element), event.diff.getAdditions());
assertEquals(Collections.EMPTY_SET, event.diff.getRemovals());
}
use of org.eclipse.jface.databinding.conformance.util.SetChangeEventTracker in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableArrayBasedSetTest method testSetBeanProperty_FiresSetChangeEvents.
@Test
public void testSetBeanProperty_FiresSetChangeEvents() throws Exception {
SetChangeEventTracker listener = SetChangeEventTracker.observe(set);
assertEquals(0, listener.count);
bean.setArray(new String[] { "element" });
assertEquals(1, listener.count);
}
Aggregations