Search in sources :

Example 36 with CurrentRealm

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

the class AbstractVetoableValueTest method testSetValueInvokesDoSetApprovedValue.

@Test
public void testSetValueInvokesDoSetApprovedValue() throws Exception {
    class VetoableValue extends VetoableValueStub {

        int count;

        Object value;

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

        @Override
        protected void doSetApprovedValue(Object value) {
            count++;
            this.value = value;
        }
    }
    Realm realm = new CurrentRealm(true);
    VetoableValue vetoableValue = new VetoableValue(realm);
    assertEquals(0, vetoableValue.count);
    assertEquals(null, vetoableValue.value);
    Object value = new Object();
    vetoableValue.setValue(value);
    assertEquals(1, vetoableValue.count);
    assertEquals(value, vetoableValue.value);
}
Also used : AbstractVetoableValue(org.eclipse.core.databinding.observable.value.AbstractVetoableValue) 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)

Example 37 with CurrentRealm

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

the class RealmTest method testSetDefaultWithRunnable.

@Test
public void testSetDefaultWithRunnable() throws Exception {
    Realm oldRealm = new CurrentRealm(true);
    final Realm newRealm = new CurrentRealm(true);
    RealmTester.setDefault(oldRealm);
    Realm.runWithDefault(newRealm, () -> assertEquals("new realm should be default", newRealm, Realm.getDefault()));
    assertEquals("old realm should have been restored", oldRealm, Realm.getDefault());
}
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)

Example 38 with CurrentRealm

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

the class AbstractObservableListTest method setUp.

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

Example 39 with CurrentRealm

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

the class ObservableListTest method setUp.

@Before
public void setUp() throws Exception {
    RealmTester.setDefault(new CurrentRealm(true));
    list = new ObservableListStub<>(new ArrayList<>(0), Object.class);
}
Also used : ArrayList(java.util.ArrayList) CurrentRealm(org.eclipse.jface.databinding.conformance.util.CurrentRealm) Before(org.junit.Before)

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