public class TestActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(com.pspdfkit.labs.vangogh.test.R.layout.activity_test);
    }

} static final long DURATION_DEFAULT = new ValueAnimator().getDuration(); static final long DURATION_QUICK = (long) (DURATION_DEFAULT * 0.6f); public static final long DURATION_SLOW = DURATION_DEFAULT * 3; public static AnimationCompletable fadeIn(@NonNull View view) {
    return fadeToAlpha(view, ALPHA_VISIBLE);
} public static AnimationCompletable fadeInQuickly(@NonNull View view) {
    return fadeIn(view, DURATION_QUICK);
} public static AnimationCompletable fadeInSlowly(@NonNull View view) {
    return fadeIn(view, DURATION_SLOW);
} public static AnimationCompletable fadeOut(@NonNull View view) {
    return fadeToAlpha(view, ALPHA_INVISIBLE);
} public static AnimationCompletable fadeOutQuickly(@NonNull View view) {
    return fadeOut(view, DURATION_QUICK);
} public static AnimationCompletable fadeOutSlowly(@NonNull View view) {
    return fadeOut(view, DURATION_SLOW);
} public static AnimationCompletable fadeToAlpha(@NonNull View view, float targetAlpha) {
    return fadeToAlpha(view, targetAlpha, DURATION_DEFAULT, INTERPOLATOR);
}
import com.pspdfkit.labs.vangogh.view.TestActivity;
import androidx.test.core.app.ActivityScenario;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_DEFAULT;
import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_QUICK;
import static com.pspdfkit.labs.vangogh.api.AnimationConstants.DURATION_SLOW;
import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn;
import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInQuickly;
import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeInSlowly;
import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut;
import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutQuickly;
import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOutSlowly;
import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeToAlpha;
import static org.junit.Assert.assertEquals;
package com.pspdfkit.labs.vangogh.api;





@RunWith(AndroidJUnit4.class)
public class FadeAnimationsTest extends BaseAnimationsTest {

    @Test
    public void testFadeIn() throws Throwable {
        activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() {
            @Override
            public void perform(TestActivity activity) {
                view.setAlpha(0f);
            }
        });
        fadeIn(view).subscribe(o);
        assertTestObserverCompletedAfterDuration(AnimationConstants.DURATION_DEFAULT);
        assertEquals(1f, view.getAlpha(), 0f);
    }


    @Test
    public void testFadeInWithDuration() throws Throwable {
        activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() {
            @Override
            public void perform(TestActivity activity) {
                view.setAlpha(0f);
            }
        });
        fadeIn(view, CUSTOM_TEST_DURATION_MS).subscribe(o);
        assertTestObserverCompletedAfterDuration(CUSTOM_TEST_DURATION_MS);
        assertEquals(1f, view.getAlpha(), 0f);
    }

    @Test
    public void testFadeInWithInterpolator() {
        // TODO Find a way to test interpolator.
    }

    @Test
    public void testFadeInWithDurationAndInterpolator() {
        // TODO Find a way to test interpolator.
    }

    @Test
    public void testFadeInQuickly() throws Throwable {
        activityScenarioRule.getScenario().onActivity(new ActivityScenario.ActivityAction<TestActivity>() {
            @Override
            public void perform(TestActivity activity) {
                view.setAlpha(0f);
            }
        });
        fadeInQuickly(view).subscribe(o);
        assertTestObserverCompletedAfterDuration(DURATION_QUICK);