Commit bec8b44b by Dustin

BitmapFactoryVideoRenderer Tests

parent df9e51de
...@@ -21,7 +21,11 @@ android { ...@@ -21,7 +21,11 @@ android {
testInstrumentationRunnerArguments clearPackageData: 'true' testInstrumentationRunnerArguments clearPackageData: 'true'
multiDexEnabled true multiDexEnabled true
} }
testOptions{
unitTests.all {
jvmArgs '-noverify'
}
}
buildTypes { buildTypes {
debug { debug {
testCoverageEnabled = true testCoverageEnabled = true
......
package com.google.android.exoplayer2.video;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.decoder.DecoderCounters;
public class FakeEventListener implements VideoRendererEventListener {
@Nullable
VideoSize videoSize;
@Nullable
DecoderCounters decoderCounters;
private long firstFrameRenderMs = Long.MIN_VALUE;
private int droppedFrames;
private Exception videoCodecError;
@Override
public void onVideoSizeChanged(VideoSize videoSize) {
this.videoSize = videoSize;
}
public boolean isVideoEnabled() {
return decoderCounters != null;
}
@Override
public void onVideoEnabled(DecoderCounters counters) {
decoderCounters = counters;
}
@Override
public void onVideoDisabled(DecoderCounters counters) {
decoderCounters = null;
}
public long getFirstFrameRenderMs() {
return firstFrameRenderMs;
}
@Override
public void onRenderedFirstFrame(Object output, long renderTimeMs) {
firstFrameRenderMs = renderTimeMs;
}
public int getDroppedFrames() {
return droppedFrames;
}
@Override
public void onDroppedFrames(int count, long elapsedMs) {
droppedFrames+=count;
}
public Exception getVideoCodecError() {
return videoCodecError;
}
@Override
public void onVideoCodecError(Exception videoCodecError) {
this.videoCodecError = videoCodecError;
}
}
package com.google.android.exoplayer2.video;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.view.Surface;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import org.robolectric.annotation.Implements;
import org.robolectric.shadow.api.Shadow;
import org.robolectric.shadows.ShadowSurface;
@Implements(Surface.class)
public class ShadowSurfaceExtended extends ShadowSurface {
private final Semaphore postSemaphore = new Semaphore(0);
private int width;
private int height;
public static Surface newInstance() {
return Shadow.newInstanceOf(Surface.class);
}
public void setSize(final int width, final int height) {
this.width = width;
this.height = height;
}
public Canvas lockCanvas(Rect canvas) {
return new Canvas(Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888));
}
public void unlockCanvasAndPost(Canvas canvas) {
postSemaphore.release();
}
public boolean waitForPost(long millis) {
try {
return postSemaphore.tryAcquire(millis, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
return false;
}
}
}
...@@ -32,7 +32,8 @@ import java.util.List; ...@@ -32,7 +32,8 @@ import java.util.List;
* A {@link SubtitleView.Output} that uses Android's native layout framework via {@link * A {@link SubtitleView.Output} that uses Android's native layout framework via {@link
* SubtitlePainter}. * SubtitlePainter}.
*/ */
/* package */ final class CanvasSubtitleOutput extends View implements SubtitleView.Output { /* package */ final class
CanvasSubtitleOutput extends View implements SubtitleView.Output {
private final List<SubtitlePainter> painters; private final List<SubtitlePainter> painters;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment