From 09dc16c6519bdd40841c445c42b2f40293621b34 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Mon, 2 Dec 2019 10:44:06 +0100 Subject: [PATCH] Fixed asset not being found --- .../service/playback/PlaybackServiceMediaPlayerTest.java | 8 ++++---- .../java/de/test/antennapod/ui/SpeedChangeTest.java | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java b/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java index 00fc68598..c17324750 100644 --- a/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java +++ b/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java @@ -2,8 +2,8 @@ package de.test.antennapod.service.playback; import android.content.Context; -import androidx.test.InstrumentationRegistry; import androidx.test.filters.MediumTest; +import androidx.test.platform.app.InstrumentationRegistry; import de.test.antennapod.EspressoTestUtils; import junit.framework.AssertionFailedError; @@ -32,7 +32,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import static androidx.test.InstrumentationRegistry.getInstrumentation; +import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -66,7 +66,7 @@ public class PlaybackServiceMediaPlayerTest { EspressoTestUtils.makeNotFirstRun(); EspressoTestUtils.clearDatabase(); - final Context context = InstrumentationRegistry.getTargetContext(); + final Context context = getInstrumentation().getTargetContext(); httpServer = new HTTPBin(); httpServer.start(); @@ -81,7 +81,7 @@ public class PlaybackServiceMediaPlayerTest { assertTrue(cacheDir.canWrite()); assertTrue(cacheDir.canRead()); if (!dest.exists()) { - InputStream i = InstrumentationRegistry.getContext().getAssets().open("3sec.mp3"); + InputStream i = getInstrumentation().getTargetContext().getAssets().open("3sec.mp3"); OutputStream o = new FileOutputStream(new File(cacheDir, PLAYABLE_DEST_URL)); IOUtils.copy(i, o); o.flush(); diff --git a/app/src/androidTest/java/de/test/antennapod/ui/SpeedChangeTest.java b/app/src/androidTest/java/de/test/antennapod/ui/SpeedChangeTest.java index d28858f72..84a7a23bb 100644 --- a/app/src/androidTest/java/de/test/antennapod/ui/SpeedChangeTest.java +++ b/app/src/androidTest/java/de/test/antennapod/ui/SpeedChangeTest.java @@ -88,7 +88,7 @@ public class SpeedChangeTest { public void testChangeSpeedPlaying() { onView(isRoot()).perform(waitForView(withId(R.id.butPlay), 1000)); onView(withId(R.id.butPlay)).perform(click()); - Awaitility.await().atMost(1, TimeUnit.SECONDS).until(() + Awaitility.await().atMost(2, TimeUnit.SECONDS).until(() -> activityRule.getActivity().getPlaybackController().getStatus() == PlayerStatus.PLAYING); clickThroughSpeeds(); } @@ -97,10 +97,10 @@ public class SpeedChangeTest { public void testChangeSpeedPaused() { onView(isRoot()).perform(waitForView(withId(R.id.butPlay), 1000)); onView(withId(R.id.butPlay)).perform(click()); - Awaitility.await().atMost(1, TimeUnit.SECONDS).until(() + Awaitility.await().atMost(2, TimeUnit.SECONDS).until(() -> activityRule.getActivity().getPlaybackController().getStatus() == PlayerStatus.PLAYING); onView(withId(R.id.butPlay)).perform(click()); - Awaitility.await().atMost(1, TimeUnit.SECONDS).until(() + Awaitility.await().atMost(2, TimeUnit.SECONDS).until(() -> activityRule.getActivity().getPlaybackController().getStatus() == PlayerStatus.PAUSED); clickThroughSpeeds(); }