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());
}
Aggregations