Search in sources :

Example 1 with CurrentRealm

use of org.eclipse.jface.databinding.conformance.util.CurrentRealm in project eclipse.platform.ui by eclipse-platform.

the class PojoObservablesTest method testObservableValueWithRealm_ReturnsIBeanObservable.

@Test
public void testObservableValueWithRealm_ReturnsIBeanObservable() throws Exception {
    CurrentRealm realm = new CurrentRealm(true);
    IObservableValue value = PojoObservables.observeValue(realm, pojo, propertyName);
    assertNotNull(value);
    assertTrue(value instanceof IBeanObservable);
}
Also used : IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue) CurrentRealm(org.eclipse.jface.databinding.conformance.util.CurrentRealm) IBeanObservable(org.eclipse.core.databinding.beans.IBeanObservable) Test(org.junit.Test)

Example 2 with CurrentRealm

use of org.eclipse.jface.databinding.conformance.util.CurrentRealm in project eclipse.platform.ui by eclipse-platform.

the class AbstractObservableTest method testFireStaleRealmChecks.

@Test
public void testFireStaleRealmChecks() throws Exception {
    RealmTester.setDefault(new CurrentRealm(true));
    RealmTester.exerciseCurrent(() -> {
        observable = new ObservableStub();
        observable.fireStale();
    });
}
Also used : CurrentRealm(org.eclipse.jface.databinding.conformance.util.CurrentRealm) Test(org.junit.Test) ObservableStaleContractTest(org.eclipse.jface.databinding.conformance.ObservableStaleContractTest) ObservableContractTest(org.eclipse.jface.databinding.conformance.ObservableContractTest)

Example 3 with CurrentRealm

use of org.eclipse.jface.databinding.conformance.util.CurrentRealm in project eclipse.platform.ui by eclipse-platform.

the class ObservableTrackerTest method testGetterCalled_ObservableRealmNotCurrent.

@Test
public void testGetterCalled_ObservableRealmNotCurrent() throws Exception {
    try {
        IObservable observable = new ObservableStub(new CurrentRealm(false));
        ObservableTracker.getterCalled(observable);
        fail("expected AssertionFailedException");
    } catch (AssertionFailedException expected) {
    }
}
Also used : IObservable(org.eclipse.core.databinding.observable.IObservable) CurrentRealm(org.eclipse.jface.databinding.conformance.util.CurrentRealm) AssertionFailedException(org.eclipse.core.runtime.AssertionFailedException) Test(org.junit.Test)

Example 4 with CurrentRealm

use of org.eclipse.jface.databinding.conformance.util.CurrentRealm in project eclipse.platform.ui by eclipse-platform.

the class WritableListTest method testListConstructorsDoNotCopy_2.

@Test
public void testListConstructorsDoNotCopy_2() {
    List<String> list = new ArrayList<>(Arrays.asList("a", "b", "c"));
    WritableList<String> wlist = new WritableList<>(new CurrentRealm(true), list, Object.class);
    wlist.remove(1);
    assertEquals(2, list.size());
    list.add("d");
    assertEquals(3, wlist.size());
}
Also used : WritableList(org.eclipse.core.databinding.observable.list.WritableList) ArrayList(java.util.ArrayList) CurrentRealm(org.eclipse.jface.databinding.conformance.util.CurrentRealm) Test(org.junit.Test) ObservableListContractTest(org.eclipse.jface.databinding.conformance.ObservableListContractTest) MutableObservableListContractTest(org.eclipse.jface.databinding.conformance.MutableObservableListContractTest)

Example 5 with CurrentRealm

use of org.eclipse.jface.databinding.conformance.util.CurrentRealm in project eclipse.platform.ui by eclipse-platform.

the class WritableListTest method testListConstructorsDoNotCopy_1.

@Test
public void testListConstructorsDoNotCopy_1() {
    RealmTester.setDefault(new CurrentRealm(true));
    List<String> list = new ArrayList<>(Arrays.asList("a", "b", "c"));
    WritableList<String> wlist = new WritableList<>(list, Object.class);
    wlist.remove(1);
    assertEquals(2, list.size());
    list.add("d");
    assertEquals(3, wlist.size());
}
Also used : WritableList(org.eclipse.core.databinding.observable.list.WritableList) ArrayList(java.util.ArrayList) CurrentRealm(org.eclipse.jface.databinding.conformance.util.CurrentRealm) Test(org.junit.Test) ObservableListContractTest(org.eclipse.jface.databinding.conformance.ObservableListContractTest) MutableObservableListContractTest(org.eclipse.jface.databinding.conformance.MutableObservableListContractTest)

Aggregations

CurrentRealm (org.eclipse.jface.databinding.conformance.util.CurrentRealm)39 Test (org.junit.Test)35 MutableObservableListContractTest (org.eclipse.jface.databinding.conformance.MutableObservableListContractTest)10 ObservableListContractTest (org.eclipse.jface.databinding.conformance.ObservableListContractTest)10 ArrayList (java.util.ArrayList)7 Realm (org.eclipse.core.databinding.observable.Realm)6 WritableList (org.eclipse.core.databinding.observable.list.WritableList)6 IObservableMap (org.eclipse.core.databinding.observable.map.IObservableMap)5 IObservableList (org.eclipse.core.databinding.observable.list.IObservableList)4 IObservableSet (org.eclipse.core.databinding.observable.set.IObservableSet)4 MutableObservableSetContractTest (org.eclipse.jface.databinding.conformance.MutableObservableSetContractTest)4 ListChangeEventTracker (org.eclipse.jface.databinding.conformance.util.ListChangeEventTracker)4 SetChangeEventTracker (org.eclipse.jface.databinding.conformance.util.SetChangeEventTracker)4 Before (org.junit.Before)4 WritableSet (org.eclipse.core.databinding.observable.set.WritableSet)3 IObservableValue (org.eclipse.core.databinding.observable.value.IObservableValue)3 MapChangeEventTracker (org.eclipse.jface.databinding.conformance.util.MapChangeEventTracker)3 List (java.util.List)2 IObservable (org.eclipse.core.databinding.observable.IObservable)2 AssertionFailedException (org.eclipse.core.runtime.AssertionFailedException)2