Re-use test runner in each loop of RepeatedTranscodeTransformationTest
PiperOrigin-RevId: 438542239
This commit is contained in:
parent
839f342e55
commit
d8e5e2de7a
@ -40,7 +40,10 @@ public final class RepeatedTranscodeTransformationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void repeatedTranscode_givesConsistentLengthOutput() throws Exception {
|
public void repeatedTranscode_givesConsistentLengthOutput() throws Exception {
|
||||||
Context context = ApplicationProvider.getApplicationContext();
|
Context context = ApplicationProvider.getApplicationContext();
|
||||||
Transformer transformer =
|
|
||||||
|
TransformerAndroidTestRunner transformerRunner =
|
||||||
|
new TransformerAndroidTestRunner.Builder(
|
||||||
|
context,
|
||||||
new Transformer.Builder(context)
|
new Transformer.Builder(context)
|
||||||
.setTransformationRequest(
|
.setTransformationRequest(
|
||||||
new TransformationRequest.Builder()
|
new TransformationRequest.Builder()
|
||||||
@ -48,15 +51,14 @@ public final class RepeatedTranscodeTransformationTest {
|
|||||||
// Video MIME type is H264.
|
// Video MIME type is H264.
|
||||||
.setAudioMimeType(MimeTypes.AUDIO_AAC)
|
.setAudioMimeType(MimeTypes.AUDIO_AAC)
|
||||||
.build())
|
.build())
|
||||||
|
.build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Set<Long> differentOutputSizesBytes = new HashSet<>();
|
Set<Long> differentOutputSizesBytes = new HashSet<>();
|
||||||
for (int i = 0; i < TRANSCODE_COUNT; i++) {
|
for (int i = 0; i < TRANSCODE_COUNT; i++) {
|
||||||
// Use a long video in case an error occurs a while after the start of the video.
|
// Use a long video in case an error occurs a while after the start of the video.
|
||||||
TransformationTestResult testResult =
|
TransformationTestResult testResult =
|
||||||
new TransformerAndroidTestRunner.Builder(context, transformer)
|
transformerRunner.run(
|
||||||
.build()
|
|
||||||
.run(
|
|
||||||
/* testId= */ "repeatedTranscode_givesConsistentLengthOutput_" + i,
|
/* testId= */ "repeatedTranscode_givesConsistentLengthOutput_" + i,
|
||||||
AndroidTestUtil.MP4_REMOTE_H264_MP3_URI_STRING);
|
AndroidTestUtil.MP4_REMOTE_H264_MP3_URI_STRING);
|
||||||
differentOutputSizesBytes.add(checkNotNull(testResult.transformationResult.fileSizeBytes));
|
differentOutputSizesBytes.add(checkNotNull(testResult.transformationResult.fileSizeBytes));
|
||||||
@ -71,7 +73,9 @@ public final class RepeatedTranscodeTransformationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void repeatedTranscodeNoAudio_givesConsistentLengthOutput() throws Exception {
|
public void repeatedTranscodeNoAudio_givesConsistentLengthOutput() throws Exception {
|
||||||
Context context = ApplicationProvider.getApplicationContext();
|
Context context = ApplicationProvider.getApplicationContext();
|
||||||
Transformer transformer =
|
TransformerAndroidTestRunner transformerRunner =
|
||||||
|
new TransformerAndroidTestRunner.Builder(
|
||||||
|
context,
|
||||||
new Transformer.Builder(context)
|
new Transformer.Builder(context)
|
||||||
.setRemoveAudio(true)
|
.setRemoveAudio(true)
|
||||||
.setTransformationRequest(
|
.setTransformationRequest(
|
||||||
@ -79,15 +83,14 @@ public final class RepeatedTranscodeTransformationTest {
|
|||||||
// Video MIME type is H264.
|
// Video MIME type is H264.
|
||||||
.setRotationDegrees(45)
|
.setRotationDegrees(45)
|
||||||
.build())
|
.build())
|
||||||
|
.build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Set<Long> differentOutputSizesBytes = new HashSet<>();
|
Set<Long> differentOutputSizesBytes = new HashSet<>();
|
||||||
for (int i = 0; i < TRANSCODE_COUNT; i++) {
|
for (int i = 0; i < TRANSCODE_COUNT; i++) {
|
||||||
// Use a long video in case an error occurs a while after the start of the video.
|
// Use a long video in case an error occurs a while after the start of the video.
|
||||||
TransformationTestResult testResult =
|
TransformationTestResult testResult =
|
||||||
new TransformerAndroidTestRunner.Builder(context, transformer)
|
transformerRunner.run(
|
||||||
.build()
|
|
||||||
.run(
|
|
||||||
/* testId= */ "repeatedTranscodeNoAudio_givesConsistentLengthOutput_" + i,
|
/* testId= */ "repeatedTranscodeNoAudio_givesConsistentLengthOutput_" + i,
|
||||||
AndroidTestUtil.MP4_REMOTE_H264_MP3_URI_STRING);
|
AndroidTestUtil.MP4_REMOTE_H264_MP3_URI_STRING);
|
||||||
differentOutputSizesBytes.add(checkNotNull(testResult.transformationResult.fileSizeBytes));
|
differentOutputSizesBytes.add(checkNotNull(testResult.transformationResult.fileSizeBytes));
|
||||||
@ -102,20 +105,23 @@ public final class RepeatedTranscodeTransformationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void repeatedTranscodeNoVideo_givesConsistentLengthOutput() throws Exception {
|
public void repeatedTranscodeNoVideo_givesConsistentLengthOutput() throws Exception {
|
||||||
Context context = ApplicationProvider.getApplicationContext();
|
Context context = ApplicationProvider.getApplicationContext();
|
||||||
Transformer transformer =
|
TransformerAndroidTestRunner transformerRunner =
|
||||||
|
new TransformerAndroidTestRunner.Builder(
|
||||||
|
context,
|
||||||
new Transformer.Builder(context)
|
new Transformer.Builder(context)
|
||||||
.setRemoveVideo(true)
|
.setRemoveVideo(true)
|
||||||
.setTransformationRequest(
|
.setTransformationRequest(
|
||||||
new TransformationRequest.Builder().setAudioMimeType(MimeTypes.AUDIO_AAC).build())
|
new TransformationRequest.Builder()
|
||||||
|
.setAudioMimeType(MimeTypes.AUDIO_AAC)
|
||||||
|
.build())
|
||||||
|
.build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Set<Long> differentOutputSizesBytes = new HashSet<>();
|
Set<Long> differentOutputSizesBytes = new HashSet<>();
|
||||||
for (int i = 0; i < TRANSCODE_COUNT; i++) {
|
for (int i = 0; i < TRANSCODE_COUNT; i++) {
|
||||||
// Use a long video in case an error occurs a while after the start of the video.
|
// Use a long video in case an error occurs a while after the start of the video.
|
||||||
TransformationTestResult testResult =
|
TransformationTestResult testResult =
|
||||||
new TransformerAndroidTestRunner.Builder(context, transformer)
|
transformerRunner.run(
|
||||||
.build()
|
|
||||||
.run(
|
|
||||||
/* testId= */ "repeatedTranscodeNoVideo_givesConsistentLengthOutput_" + i,
|
/* testId= */ "repeatedTranscodeNoVideo_givesConsistentLengthOutput_" + i,
|
||||||
AndroidTestUtil.MP4_REMOTE_H264_MP3_URI_STRING);
|
AndroidTestUtil.MP4_REMOTE_H264_MP3_URI_STRING);
|
||||||
differentOutputSizesBytes.add(checkNotNull(testResult.transformationResult.fileSizeBytes));
|
differentOutputSizesBytes.add(checkNotNull(testResult.transformationResult.fileSizeBytes));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user