Search in sources :

Example 31 with CurrentRealm

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

the class WritableListTest method testRemoveByIndexRealmChecks.

@Test
public void testRemoveByIndexRealmChecks() throws Exception {
    RealmTester.setDefault(new CurrentRealm(true));
    final WritableList<String> list = new WritableList<>();
    list.add("");
    list.add("");
    RealmTester.exerciseCurrent(() -> list.remove(list.size() - 1));
    RealmTester.setDefault(null);
}
Also used : WritableList(org.eclipse.core.databinding.observable.list.WritableList) 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 32 with CurrentRealm

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

the class AbstractObservableMapTest method setUp.

@Before
public void setUp() throws Exception {
    RealmTester.setDefault(new CurrentRealm(true));
    map = new AbstractObservableMapStub<>();
}
Also used : CurrentRealm(org.eclipse.jface.databinding.conformance.util.CurrentRealm) Before(org.junit.Before)

Example 33 with CurrentRealm

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

the class WritableMapTest method testRemoveRealmChecks.

@Test
public void testRemoveRealmChecks() throws Exception {
    RealmTester.exerciseCurrent(() -> {
        WritableMap<String, String> map = new WritableMap<>();
        CurrentRealm realm = (CurrentRealm) Realm.getDefault();
        boolean current = realm.isCurrent();
        realm.setCurrent(true);
        map.put("", "");
        realm.setCurrent(current);
        map.remove("");
    });
}
Also used : WritableMap(org.eclipse.core.databinding.observable.map.WritableMap) CurrentRealm(org.eclipse.jface.databinding.conformance.util.CurrentRealm) Test(org.junit.Test)

Example 34 with CurrentRealm

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

the class AbstractObservableTest method testFireChangeRealmChecks.

@Test
public void testFireChangeRealmChecks() throws Exception {
    RealmTester.setDefault(new CurrentRealm(true));
    RealmTester.exerciseCurrent(() -> {
        observable = new ObservableStub();
        observable.fireChange();
    });
}
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 35 with CurrentRealm

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

the class AbstractObservableValueTest method testSetValueInvokesDoSetValue.

@Test
public void testSetValueInvokesDoSetValue() throws Exception {
    class ValueStub extends ObservableValueStub {

        int doSetValue;

        ValueStub(Realm realm) {
            super(realm);
        }

        @Override
        protected void doSetValue(Object value) {
            doSetValue++;
        }
    }
    Realm realm = new CurrentRealm(true);
    ValueStub stub = new ValueStub(realm);
    assertEquals(0, stub.doSetValue);
    stub.setValue(new Object());
    assertEquals("doSetValue should have been invoked", 1, stub.doSetValue);
}
Also used : Realm(org.eclipse.core.databinding.observable.Realm) CurrentRealm(org.eclipse.jface.databinding.conformance.util.CurrentRealm) CurrentRealm(org.eclipse.jface.databinding.conformance.util.CurrentRealm) Test(org.junit.Test)

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