// 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/FragmentEvent.java
// public enum FragmentEvent {
// 
//     ATTACH,
//     CREATE,
//     CREATE_VIEW,
//     START,
//     RESUME,
//     PAUSE,
//     STOP,
//     DESTROY_VIEW,
//     DESTROY,
//     DETACH
// 
// }


import static com.trello.rxlifecycle4.android.FragmentEvent.STOP;
import static org.robolectric.util.FragmentTestUtil.startFragment;
import android.app.Fragment;
import com.trello.rxlifecycle4.LifecycleProvider;
import com.trello.rxlifecycle4.android.FragmentEvent;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.util.FragmentTestUtil;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.observers.TestObserver;
import io.reactivex.rxjava3.subjects.PublishSubject;
        testBindUntilEvent(new TestRxDialogFragment());
        testBindToLifecycle(new TestRxDialogFragment());
    }

    @Test
    public void testRxPreferenceFragment() {
        testLifecycle(new TestRxPreferenceFragment());
        testBindUntilEvent(new TestRxPreferenceFragment());
        testBindToLifecycle(new TestRxPreferenceFragment());
    }

    private void testLifecycle(LifecycleProvider<FragmentEvent> provider) {
        Fragment fragment = (Fragment) provider;
        FragmentTestUtil.startFragment(fragment);

        TestObserver<FragmentEvent> testObserver = provider.lifecycle().skip(1).test();

        fragment.onAttach(null);
        fragment.onCreate(null);
        fragment.onViewCreated(null, null);
        fragment.onStart();
        fragment.onResume();
        fragment.onPause();
        fragment.onStop();
        fragment.onDestroyView();
        fragment.onDestroy();
        fragment.onDetach();

        testObserver.assertValues(
            FragmentEvent.ATTACH,
// 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/FragmentEvent.java
// public enum FragmentEvent {
// 
//     ATTACH,
//     CREATE,
//     CREATE_VIEW,
//     START,
//     RESUME,
//     PAUSE,
//     STOP,
//     DESTROY_VIEW,
//     DESTROY,
//     DETACH
// 
// }


// Path: rxlifecycle-components/src/test/java/com/trello/rxlifecycle4/components/RxFragmentLifecycleTest.java
import static com.trello.rxlifecycle4.android.FragmentEvent.STOP;
import static org.robolectric.util.FragmentTestUtil.startFragment;
import android.app.Fragment;
import com.trello.rxlifecycle4.LifecycleProvider;
import com.trello.rxlifecycle4.android.FragmentEvent;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.util.FragmentTestUtil;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.observers.TestObserver;
import io.reactivex.rxjava3.subjects.PublishSubject;

        testBindUntilEvent(new TestRxDialogFragment());
        testBindToLifecycle(new TestRxDialogFragment());
    }

    @Test
    public void testRxPreferenceFragment() {
        testLifecycle(new TestRxPreferenceFragment());
        testBindUntilEvent(new TestRxPreferenceFragment());
        testBindToLifecycle(new TestRxPreferenceFragment());
    }

    private void testLifecycle(LifecycleProvider<FragmentEvent> provider) {
        Fragment fragment = (Fragment) provider;
        FragmentTestUtil.startFragment(fragment);

        TestObserver<FragmentEvent> testObserver = provider.lifecycle().skip(1).test();

        fragment.onAttach(null);
        fragment.onCreate(null);
        fragment.onViewCreated(null, null);
        fragment.onStart();
        fragment.onResume();
        fragment.onPause();
        fragment.onStop();
        fragment.onDestroyView();
        fragment.onDestroy();
        fragment.onDetach();

        testObserver.assertValues(
            FragmentEvent.ATTACH,
            FragmentEvent.CREATE,