mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
ImageAssetLoaderTest minor fixes
PiperOrigin-RevId: 514436359
This commit is contained in:
parent
f4b88cd8a2
commit
fe38901028
1 changed files with 8 additions and 19 deletions
|
|
@ -22,10 +22,8 @@ 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.media3.common.Format;
|
import androidx.media3.common.Format;
|
||||||
import androidx.media3.common.MediaItem;
|
import androidx.media3.common.MediaItem;
|
||||||
import androidx.media3.decoder.DecoderInputBuffer;
|
|
||||||
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 java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
@ -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…
Reference in a new issue