ImageAssetLoaderTest minor fixes
PiperOrigin-RevId: 514436359
This commit is contained in:
parent
6188952682
commit
f94d3cf6c4
@ -22,12 +22,10 @@ import android.graphics.Bitmap;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
import com.google.android.exoplayer2.MediaItem;
|
import com.google.android.exoplayer2.MediaItem;
|
||||||
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
@ -35,7 +33,7 @@ import org.junit.Test;
|
|||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.robolectric.shadows.ShadowSystemClock;
|
import org.robolectric.shadows.ShadowSystemClock;
|
||||||
|
|
||||||
/** Unit tests for {@link ExoPlayerAssetLoader}. */
|
/** Unit tests for {@link ImageAssetLoader}. */
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class ImageAssetLoaderTest {
|
public class ImageAssetLoaderTest {
|
||||||
|
|
||||||
@ -55,6 +53,7 @@ public class ImageAssetLoaderTest {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDurationUs(long durationUs) {
|
public void onDurationUs(long durationUs) {
|
||||||
|
// Sleep to increase the chances of the test failing.
|
||||||
sleep();
|
sleep();
|
||||||
isDurationSet = true;
|
isDurationSet = true;
|
||||||
}
|
}
|
||||||
@ -72,7 +71,10 @@ public class ImageAssetLoaderTest {
|
|||||||
@AssetLoader.SupportedOutputTypes int supportedOutputTypes,
|
@AssetLoader.SupportedOutputTypes int supportedOutputTypes,
|
||||||
long streamStartPositionUs,
|
long streamStartPositionUs,
|
||||||
long streamOffsetUs) {
|
long streamOffsetUs) {
|
||||||
if (!isTrackCountSet) {
|
if (!isDurationSet) {
|
||||||
|
exceptionRef.set(
|
||||||
|
new IllegalStateException("onTrackAdded() called before onDurationUs()"));
|
||||||
|
} else if (!isTrackCountSet) {
|
||||||
exceptionRef.set(
|
exceptionRef.set(
|
||||||
new IllegalStateException("onTrackAdded() called before onTrackCount()"));
|
new IllegalStateException("onTrackAdded() called before onTrackCount()"));
|
||||||
}
|
}
|
||||||
@ -83,11 +85,7 @@ public class ImageAssetLoaderTest {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SampleConsumer onOutputFormat(Format format) {
|
public SampleConsumer onOutputFormat(Format format) {
|
||||||
|
if (!isTrackAdded) {
|
||||||
if (!isDurationSet) {
|
|
||||||
exceptionRef.set(
|
|
||||||
new IllegalStateException("onTrackAdded() called before onDurationUs()"));
|
|
||||||
} else if (!isTrackAdded) {
|
|
||||||
exceptionRef.set(
|
exceptionRef.set(
|
||||||
new IllegalStateException("onOutputFormat() called before onTrackAdded()"));
|
new IllegalStateException("onOutputFormat() called before onTrackAdded()"));
|
||||||
}
|
}
|
||||||
@ -100,7 +98,7 @@ public class ImageAssetLoaderTest {
|
|||||||
exceptionRef.set(e);
|
exceptionRef.set(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sleep() {
|
private void sleep() {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(10);
|
Thread.sleep(10);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@ -134,15 +132,6 @@ public class ImageAssetLoaderTest {
|
|||||||
|
|
||||||
private static final class FakeSampleConsumer implements SampleConsumer {
|
private static final class FakeSampleConsumer implements SampleConsumer {
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public DecoderInputBuffer getInputBuffer() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void queueInputBuffer() {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void queueInputBitmap(Bitmap inputBitmap, long durationUs, int frameRate) {}
|
public void queueInputBitmap(Bitmap inputBitmap, long durationUs, int frameRate) {}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user