// Path: rxlifecycle/src/main/java/com/trello/rxlifecycle4/LifecycleProvider.java
// public interface LifecycleProvider<E> {
//     /**
//      * @return a sequence of lifecycle events
//      */
//     @Nonnull
//     @CheckReturnValue
//     Observable<E> lifecycle();
// 
//     /**
//      * Binds a source until a specific event occurs.
//      *
//      * @param event the event that triggers unsubscription
//      * @return a reusable {@link LifecycleTransformer} which unsubscribes when the event triggers.
//      */
//     @Nonnull
//     @CheckReturnValue
//     <T> LifecycleTransformer<T> bindUntilEvent(@Nonnull E event);
// 
//     /**
//      * Binds a source until the next reasonable event occurs.
//      *
//      * @return a reusable {@link LifecycleTransformer} which unsubscribes at the correct time.
//      */
//     @Nonnull
//     @CheckReturnValue
//     <T> LifecycleTransformer<T> bindToLifecycle();
// }
// 
// Path: rxlifecycle-android/src/main/java/com/trello/rxlifecycle4/android/ActivityEvent.java
// public enum ActivityEvent {
// 
//     CREATE,
//     START,
//     RESUME,
//     PAUSE,
//     STOP,
//     DESTROY
// 
// }
// 
// Path: rxlifecycle-components/src/main/java/com/trello/rxlifecycle4/components/support/RxFragmentActivity.java
// public abstract class RxFragmentActivity extends FragmentActivity implements LifecycleProvider<ActivityEvent> {
// 
//     private final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();
// 
//     public RxFragmentActivity() {
//         super();
//     }
// 
//     @ContentView
//     public RxFragmentActivity(@LayoutRes int contentLayoutId) {
//         super(contentLayoutId);
//     }
// 
//     @Override
//     @NonNull
//     @CheckResult
//     public final Observable<ActivityEvent> lifecycle() {
//         return lifecycleSubject.hide();
//     }
// 
//     @Override
//     @NonNull
//     @CheckResult
//     public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull ActivityEvent event) {
//         return RxLifecycle.bindUntilEvent(lifecycleSubject, event);
//     }
// 
//     @Override
//     @NonNull
//     @CheckResult
//     public final <T> LifecycleTransformer<T> bindToLifecycle() {
//         return RxLifecycleAndroid.bindActivity(lifecycleSubject);
//     }
// 
//     @Override
//     @CallSuper
//     protected void onCreate(@Nullable Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         lifecycleSubject.onNext(ActivityEvent.CREATE);
//     }
// 
//     @Override
//     @CallSuper
//     protected void onStart() {
//         super.onStart();
//         lifecycleSubject.onNext(ActivityEvent.START);
//     }
// 
//     @Override
//     @CallSuper
//     protected void onResume() {
//         super.onResume();
//         lifecycleSubject.onNext(ActivityEvent.RESUME);
//     }
// 
//     @Override
//     @CallSuper
//     protected void onPause() {
//         lifecycleSubject.onNext(ActivityEvent.PAUSE);
//         super.onPause();
//     }
// 
//     @Override
//     @CallSuper
//     protected void onStop() {
//         lifecycleSubject.onNext(ActivityEvent.STOP);
//         super.onStop();
//     }
// 
//     @Override
//     @CallSuper
//     protected void onDestroy() {
//         lifecycleSubject.onNext(ActivityEvent.DESTROY);
//         super.onDestroy();
//     }
// }


import static com.trello.rxlifecycle4.android.ActivityEvent.STOP;
import com.trello.rxlifecycle4.LifecycleProvider;
import com.trello.rxlifecycle4.android.ActivityEvent;
import com.trello.rxlifecycle4.components.support.RxFragmentActivity;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.android.controller.ActivityController;
import org.robolectric.annotation.Config;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.observers.TestObserver;
import io.reactivex.rxjava3.subjects.PublishSubject;

        testObserver.assertValues(
            ActivityEvent.CREATE,
            ActivityEvent.START,
            ActivityEvent.RESUME,
            ActivityEvent.PAUSE,
            ActivityEvent.STOP,
            ActivityEvent.DESTROY
        );
    }

    // Tests bindUntil for any given RxActivityLifecycle implementation
    private void testBindUntilEvent(ActivityController<? extends LifecycleProvider<ActivityEvent>> controller) {
        LifecycleProvider<ActivityEvent> activity = controller.get();

        TestObserver<Object> testObserver = observable.compose(activity.bindUntilEvent(STOP)).test();

        controller.create();
        testObserver.assertNotComplete();
        controller.start();
        testObserver.assertNotComplete();
        controller.resume();
        testObserver.assertNotComplete();
        controller.pause();
        testObserver.assertNotComplete();
        controller.stop();
        testObserver.assertComplete();
    }

    // Tests bindToLifecycle for any given RxActivityLifecycle implementation
// Path: rxlifecycle/src/main/java/com/trello/rxlifecycle4/LifecycleProvider.java
// public interface LifecycleProvider<E> {
//     /**
//      * @return a sequence of lifecycle events
//      */
//     @Nonnull
//     @CheckReturnValue
//     Observable<E> lifecycle();
// 
//     /**
//      * Binds a source until a specific event occurs.
//      *
//      * @param event the event that triggers unsubscription
//      * @return a reusable {@link LifecycleTransformer} which unsubscribes when the event triggers.
//      */
//     @Nonnull
//     @CheckReturnValue
//     <T> LifecycleTransformer<T> bindUntilEvent(@Nonnull E event);
// 
//     /**
//      * Binds a source until the next reasonable event occurs.
//      *
//      * @return a reusable {@link LifecycleTransformer} which unsubscribes at the correct time.
//      */
//     @Nonnull
//     @CheckReturnValue
//     <T> LifecycleTransformer<T> bindToLifecycle();
// }
// 
// Path: rxlifecycle-android/src/main/java/com/trello/rxlifecycle4/android/ActivityEvent.java
// public enum ActivityEvent {
// 
//     CREATE,
//     START,
//     RESUME,
//     PAUSE,
//     STOP,
//     DESTROY
// 
// }
// 
// Path: rxlifecycle-components/src/main/java/com/trello/rxlifecycle4/components/support/RxFragmentActivity.java
// public abstract class RxFragmentActivity extends FragmentActivity implements LifecycleProvider<ActivityEvent> {
// 
//     private final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();
// 
//     public RxFragmentActivity() {
//         super();
//     }
// 
//     @ContentView
//     public RxFragmentActivity(@LayoutRes int contentLayoutId) {
//         super(contentLayoutId);
//     }
// 
//     @Override
//     @NonNull
//     @CheckResult
//     public final Observable<ActivityEvent> lifecycle() {
//         return lifecycleSubject.hide();
//     }
// 
//     @Override
//     @NonNull
//     @CheckResult
//     public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull ActivityEvent event) {
//         return RxLifecycle.bindUntilEvent(lifecycleSubject, event);
//     }
// 
//     @Override
//     @NonNull
//     @CheckResult
//     public final <T> LifecycleTransformer<T> bindToLifecycle() {
//         return RxLifecycleAndroid.bindActivity(lifecycleSubject);
//     }
// 
//     @Override
//     @CallSuper
//     protected void onCreate(@Nullable Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         lifecycleSubject.onNext(ActivityEvent.CREATE);
//     }
// 
//     @Override
//     @CallSuper
//     protected void onStart() {
//         super.onStart();
//         lifecycleSubject.onNext(ActivityEvent.START);
//     }
// 
//     @Override
//     @CallSuper
//     protected void onResume() {
//         super.onResume();
//         lifecycleSubject.onNext(ActivityEvent.RESUME);
//     }
// 
//     @Override
//     @CallSuper
//     protected void onPause() {
//         lifecycleSubject.onNext(ActivityEvent.PAUSE);
//         super.onPause();
//     }
// 
//     @Override
//     @CallSuper
//     protected void onStop() {
//         lifecycleSubject.onNext(ActivityEvent.STOP);
//         super.onStop();
//     }
// 
//     @Override
//     @CallSuper
//     protected void onDestroy() {
//         lifecycleSubject.onNext(ActivityEvent.DESTROY);
//         super.onDestroy();
//     }
// }


// Path: rxlifecycle-components/src/test/java/com/trello/rxlifecycle4/components/RxActivityLifecycleTest.java
import static com.trello.rxlifecycle4.android.ActivityEvent.STOP;
import com.trello.rxlifecycle4.LifecycleProvider;
import com.trello.rxlifecycle4.android.ActivityEvent;
import com.trello.rxlifecycle4.components.support.RxFragmentActivity;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.android.controller.ActivityController;
import org.robolectric.annotation.Config;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.observers.TestObserver;
import io.reactivex.rxjava3.subjects.PublishSubject;


        testObserver.assertValues(
            ActivityEvent.CREATE,
            ActivityEvent.START,
            ActivityEvent.RESUME,
            ActivityEvent.PAUSE,
            ActivityEvent.STOP,
            ActivityEvent.DESTROY
        );
    }

    // Tests bindUntil for any given RxActivityLifecycle implementation
    private void testBindUntilEvent(ActivityController<? extends LifecycleProvider<ActivityEvent>> controller) {
        LifecycleProvider<ActivityEvent> activity = controller.get();

        TestObserver<Object> testObserver = observable.compose(activity.bindUntilEvent(STOP)).test();

        controller.create();
        testObserver.assertNotComplete();
        controller.start();
        testObserver.assertNotComplete();
        controller.resume();
        testObserver.assertNotComplete();
        controller.pause();
        testObserver.assertNotComplete();
        controller.stop();
        testObserver.assertComplete();
    }

    // Tests bindToLifecycle for any given RxActivityLifecycle implementation
    private void testBindToLifecycle(ActivityController<? extends LifecycleProvider<ActivityEvent>> controller) {