use of org.eclipse.jface.databinding.conformance.util.CurrentRealm 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.CurrentRealm in project eclipse.platform.ui by eclipse-platform.
the class MultiValidatorTest method testObserveValidatedValue_WrongRealm.
@Test
public void testObserveValidatedValue_WrongRealm() {
Realm otherRealm = new CurrentRealm(true);
try {
validator.observeValidatedValue(new WritableValue<>(otherRealm));
fail("Expected AssertionFailedException");
} catch (AssertionFailedException expected) {
}
}
use of org.eclipse.jface.databinding.conformance.util.CurrentRealm in project eclipse.platform.ui by eclipse-platform.
the class WritableListTest method testCollectionConstructorsCopy_2.
@Test
public void testCollectionConstructorsCopy_2() {
List<String> list = new ArrayList<>(Arrays.asList("a", "b", "c"));
WritableList<String> wlist = new WritableList<String>(new CurrentRealm(true), (Collection<String>) list, Object.class);
wlist.remove(1);
assertEquals(3, list.size());
list.add("d");
assertEquals(2, wlist.size());
}
use of org.eclipse.jface.databinding.conformance.util.CurrentRealm in project eclipse.platform.ui by eclipse-platform.
the class WritableListTest method testRemoveRealmChecks.
@Test
public void testRemoveRealmChecks() throws Exception {
RealmTester.setDefault(new CurrentRealm(true));
final WritableList<String> list = new WritableList<>();
list.add("");
list.add("");
RealmTester.exerciseCurrent(() -> list.remove(""));
RealmTester.setDefault(null);
}
use of org.eclipse.jface.databinding.conformance.util.CurrentRealm in project eclipse.platform.ui by eclipse-platform.
the class WritableListTest method testCollectionConstructorsCopy_1.
@Test
public void testCollectionConstructorsCopy_1() {
RealmTester.setDefault(new CurrentRealm(true));
List<String> list = new ArrayList<>(Arrays.asList("a", "b", "c"));
WritableList<String> wlist = new WritableList<>((Collection<String>) list, Object.class);
wlist.remove(1);
assertEquals(3, list.size());
list.add("d");
assertEquals(2, wlist.size());
}
Aggregations