diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheWriterTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheWriterTest.java index 6064783e08..4c2fd3f765 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheWriterTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheWriterTest.java @@ -17,7 +17,6 @@ package com.google.android.exoplayer2.upstream.cache; import static com.google.android.exoplayer2.testutil.CacheAsserts.assertCachedData; import static com.google.common.truth.Truth.assertThat; -import static java.lang.Math.min; import static org.junit.Assert.assertThrows; import android.net.Uri; @@ -36,65 +35,18 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Answers; -import org.mockito.Mock; import org.mockito.MockitoAnnotations; /** Unit tests for {@link CacheWriter}. */ @RunWith(AndroidJUnit4.class) public final class CacheWriterTest { - /** - * Abstract fake Cache implementation used by the test. This class must be public so Mockito can - * create a proxy for it. - */ - public abstract static class AbstractFakeCache implements Cache { - - // This array is set to alternating length of cached and not cached regions in tests: - // spansAndGaps = {, , - // , , ... } - // Ideally it should end with a cached region but it shouldn't matter for any code. - private int[] spansAndGaps; - private long contentLength; - - private void init() { - spansAndGaps = new int[] {}; - contentLength = C.LENGTH_UNSET; - } - - @Override - public long getCachedLength(String key, long position, long length) { - if (length == C.LENGTH_UNSET) { - length = Long.MAX_VALUE; - } - for (int i = 0; i < spansAndGaps.length; i++) { - int spanOrGap = spansAndGaps[i]; - if (position < spanOrGap) { - long left = min(spanOrGap - position, length); - return (i & 1) == 1 ? -left : left; - } - position -= spanOrGap; - } - return -length; - } - - @Override - public ContentMetadata getContentMetadata(String key) { - DefaultContentMetadata metadata = new DefaultContentMetadata(); - ContentMetadataMutations mutations = new ContentMetadataMutations(); - ContentMetadataMutations.setContentLength(mutations, contentLength); - return metadata.copyWithMutationsApplied(mutations); - } - } - - @Mock(answer = Answers.CALLS_REAL_METHODS) private AbstractFakeCache mockCache; private File tempFolder; private SimpleCache cache; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - mockCache.init(); tempFolder = Util.createTempDirectory(ApplicationProvider.getApplicationContext(), "ExoPlayerTest"); cache =