use of org.eclipse.jface.databinding.conformance.util.CurrentRealm in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableArrayBasedSetTest 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.setArray(new Object[] { "old" });
IObservableSet observable = BeansObservables.observeSet(new CurrentRealm(true), bean, "array");
SetChangeEventTracker tracker = SetChangeEventTracker.observe(observable);
bean.setArray(new Object[] { "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.CurrentRealm in project eclipse.platform.ui by eclipse-platform.
the class ObservableContractTest method testConstruction_CallsObservableCreated.
@Test
public void testConstruction_CallsObservableCreated() {
final IObservable[] created = new IObservable[1];
IObservable[] collected = ObservableTracker.runAndCollect(() -> created[0] = delegate.createObservable(new CurrentRealm(true)));
assertTrue(collected.length > 0);
boolean wasCollected = false;
for (IObservable c : collected) {
if (c == created[0]) {
wasCollected = true;
break;
}
}
assertTrue(wasCollected);
}
use of org.eclipse.jface.databinding.conformance.util.CurrentRealm in project eclipse.platform.ui by eclipse-platform.
the class ObservableListContractTest method testGet_GetterCalled.
@Test
public void testGet_GetterCalled() throws Exception {
list = (IObservableList) delegate.createObservableCollection(new CurrentRealm(true), 1);
assertGetterCalled(() -> list.get(0), "List.get(int)", list);
}
use of org.eclipse.jface.databinding.conformance.util.CurrentRealm in project eclipse.platform.ui by eclipse-platform.
the class ObservableListContractTest method testListIteratorAtIndex_GetterCalled.
@Test
public void testListIteratorAtIndex_GetterCalled() throws Exception {
// Create a new list instead of adding an item because the list might
// not be mutable
list = (IObservableList) delegate.createObservableCollection(new CurrentRealm(true), 1);
assertGetterCalled(() -> list.listIterator(0), "List.listIterator(int)", list);
}
use of org.eclipse.jface.databinding.conformance.util.CurrentRealm in project eclipse.platform.ui by eclipse-platform.
the class ObservableListContractTest method testSubList_GetterCalled.
@Test
public void testSubList_GetterCalled() throws Exception {
list = (IObservableList) delegate.createObservableCollection(new CurrentRealm(true), 1);
assertGetterCalled(() -> list.subList(0, 1), "List.subList(int, int)", list);
}
Aggregations