Search in sources :

Example 1 with OSObservable

use of com.onesignal.OneSignalPackagePrivateHelper.OSObservable in project OneSignal-Android-SDK by OneSignal.

the class MainOneSignalClassRunner method shouldNotThrowWhenRemovingWeakReferenceObservableThatHasBeenGarbageCollected.

@Test
public void shouldNotThrowWhenRemovingWeakReferenceObservableThatHasBeenGarbageCollected() {
    OSObservable<Object, Object> observer = new OSObservable<>("", false);
    WeakReference<Object> weakObject = new WeakReference<>(new Object());
    observer.addObserver(weakObject.get());
    // Force cleaning up WeakReference above
    Runtime.getRuntime().gc();
    observer.removeObserver(weakObject.get());
}
Also used : OSObservable(com.onesignal.OneSignalPackagePrivateHelper.OSObservable) WeakReference(java.lang.ref.WeakReference) JSONObject(org.json.JSONObject) Test(org.junit.Test)

Aggregations

OSObservable (com.onesignal.OneSignalPackagePrivateHelper.OSObservable)1 WeakReference (java.lang.ref.WeakReference)1 JSONObject (org.json.JSONObject)1 Test (org.junit.Test)1