Fixed asset not being found

This commit is contained in:
ByteHamster 2019-12-02 10:44:06 +01:00
parent a20ef049e1
commit 09dc16c651
2 changed files with 7 additions and 7 deletions

View File

@ -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();

View File

@ -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();
}