Migrate parameterized tests to the standard parameterized runner
The only caveat is that a name attribute for the `@Parameters` annotation is required, as otherwise the test infrastructure doesn’t find test results. Bug: webrtc:13662 Change-Id: Ib3e2a6671d1045b0e19746ce78dd434fbee78b87 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256462 Reviewed-by: Linus Nilsson <lnilsson@webrtc.org> Auto-Submit: Xavier Lepaul <xalep@webrtc.org> Reviewed-by: Björn Terelius <terelius@webrtc.org> Commit-Queue: Björn Terelius <terelius@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36322}
This commit is contained in:
parent
75e19ed421
commit
ed4a5763f8
@ -16,40 +16,29 @@ import static org.junit.Assert.assertNotNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.test.filters.SmallTest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.chromium.base.test.params.BaseJUnit4RunnerDelegate;
|
||||
import org.chromium.base.test.params.ParameterAnnotations.ClassParameter;
|
||||
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
|
||||
import org.chromium.base.test.params.ParameterSet;
|
||||
import org.chromium.base.test.params.ParameterizedRunner;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
/** Unit tests for {@link AndroidVideoDecoder}. */
|
||||
@RunWith(ParameterizedRunner.class)
|
||||
@UseRunnerDelegate(BaseJUnit4RunnerDelegate.class)
|
||||
@RunWith(Parameterized.class)
|
||||
public final class AndroidVideoDecoderInstrumentationTest {
|
||||
@ClassParameter private static List<ParameterSet> CLASS_PARAMS = new ArrayList<>();
|
||||
|
||||
static {
|
||||
CLASS_PARAMS.add(new ParameterSet()
|
||||
.value(/* codecName= */ "VP8", false /* useEglContext */)
|
||||
.name("VP8WithoutEglContext"));
|
||||
CLASS_PARAMS.add(new ParameterSet()
|
||||
.value(/* codecName= */ "VP8", true /* useEglContext */)
|
||||
.name("VP8WithEglContext"));
|
||||
CLASS_PARAMS.add(new ParameterSet()
|
||||
.value(/* codecName= */ "H264", false /* useEglContext */)
|
||||
.name("H264WithoutEglContext"));
|
||||
CLASS_PARAMS.add(new ParameterSet()
|
||||
.value(/* codecName= */ "H264", true /* useEglContext */)
|
||||
.name("H264WithEglContext"));
|
||||
@Parameters(name = "{0};useEglContext={1}")
|
||||
public static Collection<Object[]> parameters() {
|
||||
return Arrays.asList(new Object[] {/*codecName=*/"VP8", /*useEglContext=*/false},
|
||||
new Object[] {/*codecName=*/"VP8", /*useEglContext=*/true},
|
||||
new Object[] {/*codecName=*/"H264", /*useEglContext=*/false},
|
||||
new Object[] {/*codecName=*/"H264", /*useEglContext=*/true});
|
||||
}
|
||||
|
||||
private final VideoCodecInfo codecType;
|
||||
|
||||
@ -23,35 +23,26 @@ import androidx.annotation.Nullable;
|
||||
import androidx.test.filters.SmallTest;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.chromium.base.test.params.BaseJUnit4RunnerDelegate;
|
||||
import org.chromium.base.test.params.ParameterAnnotations.ClassParameter;
|
||||
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
|
||||
import org.chromium.base.test.params.ParameterSet;
|
||||
import org.chromium.base.test.params.ParameterizedRunner;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
@RunWith(ParameterizedRunner.class)
|
||||
@UseRunnerDelegate(BaseJUnit4RunnerDelegate.class)
|
||||
@RunWith(Parameterized.class)
|
||||
public class HardwareVideoEncoderTest {
|
||||
@ClassParameter private static List<ParameterSet> CLASS_PARAMS = new ArrayList<>();
|
||||
|
||||
static {
|
||||
CLASS_PARAMS.add(new ParameterSet()
|
||||
.value(false /* useTextures */, false /* useEglContext */)
|
||||
.name("I420WithoutEglContext"));
|
||||
CLASS_PARAMS.add(new ParameterSet()
|
||||
.value(true /* useTextures */, false /* useEglContext */)
|
||||
.name("TextureWithoutEglContext"));
|
||||
CLASS_PARAMS.add(new ParameterSet()
|
||||
.value(true /* useTextures */, true /* useEglContext */)
|
||||
.name("TextureWithEglContext"));
|
||||
@Parameters(name = "textures={0};eglContext={1}")
|
||||
public static Collection<Object[]> parameters() {
|
||||
return Arrays.asList(new Object[] {/*textures=*/false, /*eglContext=*/false},
|
||||
new Object[] {/*textures=*/true, /*eglContext=*/false},
|
||||
new Object[] {/*textures=*/true, /*eglContext=*/true});
|
||||
}
|
||||
|
||||
private final boolean useTextures;
|
||||
|
||||
@ -22,16 +22,15 @@ import android.os.HandlerThread;
|
||||
import androidx.test.filters.SmallTest;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.chromium.base.test.params.BaseJUnit4RunnerDelegate;
|
||||
import org.chromium.base.test.params.ParameterAnnotations.ClassParameter;
|
||||
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
|
||||
import org.chromium.base.test.params.ParameterSet;
|
||||
import org.chromium.base.test.params.ParameterizedRunner;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
import org.webrtc.VideoFrame;
|
||||
|
||||
/**
|
||||
@ -40,21 +39,16 @@ import org.webrtc.VideoFrame;
|
||||
* GlRectDrawer and we are testing the full chain I420 -> OES/RGB texture -> I420, with and without
|
||||
* cropping in the middle. Reading textures back to I420 also exercises the YuvConverter code.
|
||||
*/
|
||||
@RunWith(ParameterizedRunner.class)
|
||||
@UseRunnerDelegate(BaseJUnit4RunnerDelegate.class)
|
||||
@RunWith(Parameterized.class)
|
||||
public class VideoFrameBufferTest {
|
||||
/**
|
||||
* These tests are parameterized on this enum which represents the different VideoFrame.Buffers.
|
||||
*/
|
||||
private static enum BufferType { I420_JAVA, I420_NATIVE, RGB_TEXTURE, OES_TEXTURE, NV21, NV12 }
|
||||
|
||||
@ClassParameter private static List<ParameterSet> CLASS_PARAMS = new ArrayList<>();
|
||||
|
||||
static {
|
||||
for (BufferType bufferType : BufferType.values()) {
|
||||
// The parameterization framework can not send Enums, so we pass it as a string instead.
|
||||
CLASS_PARAMS.add(new ParameterSet().value(bufferType.name()).name(bufferType.name()));
|
||||
}
|
||||
@Parameters(name = "{0}")
|
||||
public static Collection<BufferType> parameters() {
|
||||
return Arrays.asList(BufferType.values());
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
@ -65,9 +59,8 @@ public class VideoFrameBufferTest {
|
||||
|
||||
private final BufferType bufferType;
|
||||
|
||||
public VideoFrameBufferTest(String bufferTypeName) {
|
||||
// Parse the string back to an enum.
|
||||
bufferType = BufferType.valueOf(bufferTypeName);
|
||||
public VideoFrameBufferTest(BufferType bufferType) {
|
||||
this.bufferType = bufferType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user