use of org.eclipse.jface.databinding.conformance.util.CurrentRealm in project eclipse.platform.ui by eclipse-platform.
the class ValidatedObservableValueTest method testConstructor_RequireObservablesOnSameRealm.
@Test
public void testConstructor_RequireObservablesOnSameRealm() {
CurrentRealm realm1 = new CurrentRealm(true);
CurrentRealm realm2 = new CurrentRealm(true);
target = new ObservableValueStub(realm1);
validationStatus = new WritableValue(realm2);
try {
new ValidatedObservableValue(target, validationStatus);
fail("Expected exception--target and validation status should have the same realm");
} catch (RuntimeException expected) {
}
}
use of org.eclipse.jface.databinding.conformance.util.CurrentRealm in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableListTest method testSetBeanPropertyOutsideRealm_FiresEventInsideRealm.
@Test
public void testSetBeanPropertyOutsideRealm_FiresEventInsideRealm() {
Bean bean = new Bean(Collections.EMPTY_LIST);
CurrentRealm realm = new CurrentRealm(true);
IObservableList observable = BeansObservables.observeList(realm, bean, "list");
ListChangeEventTracker tracker = ListChangeEventTracker.observe(observable);
realm.setCurrent(false);
bean.setList(Collections.singletonList("element"));
assertEquals(0, tracker.count);
realm.setCurrent(true);
assertEquals(1, tracker.count);
assertDiff(tracker.event.diff, Collections.EMPTY_LIST, Collections.singletonList("element"));
}
use of org.eclipse.jface.databinding.conformance.util.CurrentRealm in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableMapTest method testConstructor_SkipRegisterListeners.
@Test
public void testConstructor_SkipRegisterListeners() throws Exception {
Realm realm = new CurrentRealm(true);
WritableSet set = new WritableSet(realm);
Bean bean = new Bean();
set.add(bean);
IObservableMap observable = PojoObservables.observeMap(set, Bean.class, "value");
assertFalse(bean.hasListeners("value"));
ChangeEventTracker.observe(observable);
assertFalse(bean.hasListeners("value"));
}
use of org.eclipse.jface.databinding.conformance.util.CurrentRealm in project eclipse.platform.ui by eclipse-platform.
the class JavaBeanObservableMapTest method testConstructor_RegistersListeners.
@Test
public void testConstructor_RegistersListeners() throws Exception {
Realm realm = new CurrentRealm(true);
WritableSet set = new WritableSet(realm);
Bean bean = new Bean();
set.add(bean);
IObservableMap observable = BeansObservables.observeMap(set, Bean.class, "value");
assertFalse(bean.hasListeners("value"));
ChangeEventTracker.observe(observable);
assertTrue(bean.hasListeners("value"));
}
use of org.eclipse.jface.databinding.conformance.util.CurrentRealm 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());
}
Aggregations