diff --git a/app/src/androidTest/java/de/christinecoenen/code/zapp/app/mediathek/ui/detail/MediathekPlayerActivityTest.java b/app/src/androidTest/java/de/christinecoenen/code/zapp/app/mediathek/ui/detail/MediathekPlayerActivityTest.java index dc2c555c..bfc2ed58 100644 --- a/app/src/androidTest/java/de/christinecoenen/code/zapp/app/mediathek/ui/detail/MediathekPlayerActivityTest.java +++ b/app/src/androidTest/java/de/christinecoenen/code/zapp/app/mediathek/ui/detail/MediathekPlayerActivityTest.java @@ -1,5 +1,6 @@ package de.christinecoenen.code.zapp.app.mediathek.ui.detail; +import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; @@ -8,20 +9,37 @@ import androidx.test.core.app.ActivityScenario; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.platform.app.InstrumentationRegistry; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import de.christinecoenen.code.zapp.app.ZappApplication; import de.christinecoenen.code.zapp.app.mediathek.MediathekData; +import de.christinecoenen.code.zapp.app.mediathek.model.PersistedMediathekShow; @RunWith(AndroidJUnit4.class) public class MediathekPlayerActivityTest { + private PersistedMediathekShow persistedShow; + + @Before + public void Setup() { + ZappApplication zappApplication = (ZappApplication) InstrumentationRegistry + .getInstrumentation() + .getTargetContext() + .getApplicationContext(); + + persistedShow = zappApplication.getMediathekRepository() + .persistOrUpdateShow(MediathekData.getTestShow()) + .blockingFirst(); + } + @Test public void testRecreation() { Context context = InstrumentationRegistry.getInstrumentation().getTargetContext(); - Intent intent = MediathekPlayerActivity.getStartIntent(context, MediathekData.getTestShow()); + Intent intent = MediathekPlayerActivity.getStartIntent(context, persistedShow.getId()); - ActivityScenario scenario = ActivityScenario.launch(intent); + ActivityScenario scenario = ActivityScenario.launch(intent); scenario.recreate(); scenario.onActivity(activity -> activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE));