AndroidObservable { public static <T> Observable<T> fromFragment(Object fragment, Observable<T> sourceObservable) { if (USES_SUPPORT_FRAGMENTS && fragment instanceof android.support.v4.app.Fragment) { return OperationObserveFromAndroidComponent.observeFromAndroidComponent(sourceObservable, (android.support.v4.app.Fragment) fragment); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && fragment instanceof Fragment) { return OperationObserveFromAndroidComponent.observeFromAndroidComponent(sourceObservable, (Fragment) fragment); } else { throw new IllegalArgumentException("Target fragment is neither a native nor support library Fragment"); } } private  AndroidObservable(); static Observable<T> fromActivity(Activity activity, Observable<T> sourceObservable); static Observable<T> fromFragment(Object fragment, Observable<T> sourceObservable);  }
@Test public void itSupportsFragmentsFromTheSupportV4Library() { AndroidObservable.fromFragment(supportFragment, Observable.just("success")).subscribe(new TestObserver<String>(observer)); verify(observer).onNext("success"); verify(observer).onCompleted(); }
@Test public void itSupportsNativeFragments() { AndroidObservable.fromFragment(fragment, Observable.just("success")).subscribe(new TestObserver<String>(observer)); verify(observer).onNext("success"); verify(observer).onCompleted(); }
@Test(expected = IllegalArgumentException.class) public void itThrowsIfObjectPassedIsNotAFragment() { AndroidObservable.fromFragment("not a fragment", Observable.never()); }