Re-use test runner in each loop of RepeatedTranscodeTransformationTest
PiperOrigin-RevId: 438542239
This commit is contained in:
parent
839f342e55
commit
d8e5e2de7a
@ -40,13 +40,17 @@ 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 =
|
|
||||||
new Transformer.Builder(context)
|
TransformerAndroidTestRunner transformerRunner =
|
||||||
.setTransformationRequest(
|
new TransformerAndroidTestRunner.Builder(
|
||||||
new TransformationRequest.Builder()
|
context,
|
||||||
.setRotationDegrees(45)
|
new Transformer.Builder(context)
|
||||||
// Video MIME type is H264.
|
.setTransformationRequest(
|
||||||
.setAudioMimeType(MimeTypes.AUDIO_AAC)
|
new TransformationRequest.Builder()
|
||||||
|
.setRotationDegrees(45)
|
||||||
|
// Video MIME type is H264.
|
||||||
|
.setAudioMimeType(MimeTypes.AUDIO_AAC)
|
||||||
|
.build())
|
||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@ -54,11 +58,9 @@ public final class RepeatedTranscodeTransformationTest {
|
|||||||
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()
|
/* testId= */ "repeatedTranscode_givesConsistentLengthOutput_" + i,
|
||||||
.run(
|
AndroidTestUtil.MP4_REMOTE_H264_MP3_URI_STRING);
|
||||||
/* testId= */ "repeatedTranscode_givesConsistentLengthOutput_" + i,
|
|
||||||
AndroidTestUtil.MP4_REMOTE_H264_MP3_URI_STRING);
|
|
||||||
differentOutputSizesBytes.add(checkNotNull(testResult.transformationResult.fileSizeBytes));
|
differentOutputSizesBytes.add(checkNotNull(testResult.transformationResult.fileSizeBytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,13 +73,16 @@ 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 Transformer.Builder(context)
|
new TransformerAndroidTestRunner.Builder(
|
||||||
.setRemoveAudio(true)
|
context,
|
||||||
.setTransformationRequest(
|
new Transformer.Builder(context)
|
||||||
new TransformationRequest.Builder()
|
.setRemoveAudio(true)
|
||||||
// Video MIME type is H264.
|
.setTransformationRequest(
|
||||||
.setRotationDegrees(45)
|
new TransformationRequest.Builder()
|
||||||
|
// Video MIME type is H264.
|
||||||
|
.setRotationDegrees(45)
|
||||||
|
.build())
|
||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@ -85,11 +90,9 @@ public final class RepeatedTranscodeTransformationTest {
|
|||||||
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()
|
/* testId= */ "repeatedTranscodeNoAudio_givesConsistentLengthOutput_" + i,
|
||||||
.run(
|
AndroidTestUtil.MP4_REMOTE_H264_MP3_URI_STRING);
|
||||||
/* testId= */ "repeatedTranscodeNoAudio_givesConsistentLengthOutput_" + i,
|
|
||||||
AndroidTestUtil.MP4_REMOTE_H264_MP3_URI_STRING);
|
|
||||||
differentOutputSizesBytes.add(checkNotNull(testResult.transformationResult.fileSizeBytes));
|
differentOutputSizesBytes.add(checkNotNull(testResult.transformationResult.fileSizeBytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,22 +105,25 @@ 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 Transformer.Builder(context)
|
new TransformerAndroidTestRunner.Builder(
|
||||||
.setRemoveVideo(true)
|
context,
|
||||||
.setTransformationRequest(
|
new Transformer.Builder(context)
|
||||||
new TransformationRequest.Builder().setAudioMimeType(MimeTypes.AUDIO_AAC).build())
|
.setRemoveVideo(true)
|
||||||
|
.setTransformationRequest(
|
||||||
|
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()
|
/* testId= */ "repeatedTranscodeNoVideo_givesConsistentLengthOutput_" + i,
|
||||||
.run(
|
AndroidTestUtil.MP4_REMOTE_H264_MP3_URI_STRING);
|
||||||
/* testId= */ "repeatedTranscodeNoVideo_givesConsistentLengthOutput_" + i,
|
|
||||||
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