From 084bde2d914878bfb8d410b98171c82ccc9a463d Mon Sep 17 00:00:00 2001 From: samrobinson Date: Mon, 28 Feb 2022 20:02:29 +0000 Subject: [PATCH] Restructure regression androidTests, adding a 4k60 video and test. Test list can be structured so tests don't need to be in different classes, cleaning up the location of new test cases. PiperOrigin-RevId: 431492941 --- .../transformer/AndroidTestUtil.java | 12 ++- .../mh/RemoveAudioTransformationTest.java | 46 ----------- .../mh/RemoveVideoTransformationTest.java | 43 ---------- .../RepeatedTranscodeTransformationTest.java | 6 +- .../transformer/mh/SefTransformationTest.java | 59 ------------- ...ransformationMatrixTransformationTest.java | 4 +- .../transformer/mh/TransformationTest.java | 82 ++++++++++++++++++- 7 files changed, 93 insertions(+), 159 deletions(-) delete mode 100644 library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/RemoveAudioTransformationTest.java delete mode 100644 library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/RemoveVideoTransformationTest.java delete mode 100644 library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/SefTransformationTest.java diff --git a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/AndroidTestUtil.java b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/AndroidTestUtil.java index abcd9b5371..68f42c625d 100644 --- a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/AndroidTestUtil.java +++ b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/AndroidTestUtil.java @@ -42,13 +42,17 @@ public final class AndroidTestUtil { public static final String MP4_ASSET_URI_STRING = "asset:///media/mp4/sample.mp4"; public static final String MP4_ASSET_WITH_INCREASING_TIMESTAMPS_URI_STRING = "asset:///media/mp4/sample_with_increasing_timestamps.mp4"; - public static final String SEF_ASSET_URI_STRING = "asset:///media/mp4/sample_sef_slow_motion.mp4"; - public static final String REMOTE_MP4_10_SECONDS_URI_STRING = + public static final String MP4_ASSET_SEF_URI_STRING = + "asset:///media/mp4/sample_sef_slow_motion.mp4"; + public static final String MP4_REMOTE_10_SECONDS_URI_STRING = "https://storage.googleapis.com/exoplayer-test-media-1/mp4/android-screens-10s.mp4"; - /** Test clip transcoded from {@link #REMOTE_MP4_10_SECONDS_URI_STRING} with H264 and MP3. */ - public static final String REMOTE_MP4_10_SECONDS_H264_MP3_URI_STRING = + /** Test clip transcoded from {@link #MP4_REMOTE_10_SECONDS_URI_STRING} with H264 and MP3. */ + public static final String MP4_REMOTE_H264_MP3_URI_STRING = "https://storage.googleapis.com/exoplayer-test-media-1/mp4/%20android-screens-10s-h264-mp3.mp4"; + public static final String MP4_REMOTE_4K60_PORTRAIT_URI_STRING = + "https://storage.googleapis.com/exoplayer-test-media-1/mp4/portrait_4k60.mp4"; + /** * Transforms the {@code uriString} with the {@link Transformer}, saving a summary of the * transformation to the application cache. diff --git a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/RemoveAudioTransformationTest.java b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/RemoveAudioTransformationTest.java deleted file mode 100644 index 696b80b180..0000000000 --- a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/RemoveAudioTransformationTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.android.exoplayer2.transformer.mh; - -import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_URI_STRING; -import static com.google.android.exoplayer2.transformer.AndroidTestUtil.runTransformer; - -import android.content.Context; -import androidx.test.core.app.ApplicationProvider; -import androidx.test.ext.junit.runners.AndroidJUnit4; -import com.google.android.exoplayer2.transformer.Transformer; -import org.junit.Test; -import org.junit.runner.RunWith; - -/** {@link Transformer} instrumentation test for removing audio. */ -@RunWith(AndroidJUnit4.class) -public class RemoveAudioTransformationTest { - - private static final String TAG = "RemoveAudioTransformationTest"; - - @Test - public void removeAudioTransform() throws Exception { - Context context = ApplicationProvider.getApplicationContext(); - Transformer transformer = new Transformer.Builder(context).setRemoveAudio(true).build(); - runTransformer( - context, - /* testId= */ "removeAudioTransform", - transformer, - MP4_ASSET_WITH_INCREASING_TIMESTAMPS_URI_STRING, - /* timeoutSeconds= */ 120, - /* calculateSsim= */ false); - } -} diff --git a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/RemoveVideoTransformationTest.java b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/RemoveVideoTransformationTest.java deleted file mode 100644 index 1ee67917cb..0000000000 --- a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/RemoveVideoTransformationTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.android.exoplayer2.transformer.mh; - -import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_ASSET_URI_STRING; -import static com.google.android.exoplayer2.transformer.AndroidTestUtil.runTransformer; - -import android.content.Context; -import androidx.test.core.app.ApplicationProvider; -import androidx.test.ext.junit.runners.AndroidJUnit4; -import com.google.android.exoplayer2.transformer.Transformer; -import org.junit.Test; -import org.junit.runner.RunWith; - -/** {@link Transformer} instrumentation test for removing video. */ -@RunWith(AndroidJUnit4.class) -public class RemoveVideoTransformationTest { - @Test - public void removeVideoTransform() throws Exception { - Context context = ApplicationProvider.getApplicationContext(); - Transformer transformer = new Transformer.Builder(context).setRemoveVideo(true).build(); - runTransformer( - context, - /* testId= */ "removeVideoTransform", - transformer, - MP4_ASSET_URI_STRING, - /* timeoutSeconds= */ 120, - /* calculateSsim= */ false); - } -} diff --git a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/RepeatedTranscodeTransformationTest.java b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/RepeatedTranscodeTransformationTest.java index 26c8817bbf..c862f6f29d 100644 --- a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/RepeatedTranscodeTransformationTest.java +++ b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/RepeatedTranscodeTransformationTest.java @@ -61,7 +61,7 @@ public final class RepeatedTranscodeTransformationTest { context, /* testId= */ "repeatedTranscode_givesConsistentLengthOutput_" + i, transformer, - AndroidTestUtil.REMOTE_MP4_10_SECONDS_H264_MP3_URI_STRING, + AndroidTestUtil.MP4_REMOTE_H264_MP3_URI_STRING, /* timeoutSeconds= */ 120, /* calculateSsim= */ false); differentOutputSizesBytes.add(checkNotNull(testResult.transformationResult.fileSizeBytes)); @@ -96,7 +96,7 @@ public final class RepeatedTranscodeTransformationTest { context, /* testId= */ "repeatedTranscodeNoAudio_givesConsistentLengthOutput_" + i, transformer, - AndroidTestUtil.REMOTE_MP4_10_SECONDS_H264_MP3_URI_STRING, + AndroidTestUtil.MP4_REMOTE_H264_MP3_URI_STRING, /* timeoutSeconds= */ 120, /* calculateSsim= */ false); differentOutputSizesBytes.add(checkNotNull(testResult.transformationResult.fileSizeBytes)); @@ -126,7 +126,7 @@ public final class RepeatedTranscodeTransformationTest { context, /* testId= */ "repeatedTranscodeNoVideo_givesConsistentLengthOutput_" + i, transformer, - AndroidTestUtil.REMOTE_MP4_10_SECONDS_H264_MP3_URI_STRING, + AndroidTestUtil.MP4_REMOTE_H264_MP3_URI_STRING, /* timeoutSeconds= */ 120, /* calculateSsim= */ false); differentOutputSizesBytes.add(checkNotNull(testResult.transformationResult.fileSizeBytes)); diff --git a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/SefTransformationTest.java b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/SefTransformationTest.java deleted file mode 100644 index 7330afb7ff..0000000000 --- a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/SefTransformationTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.android.exoplayer2.transformer.mh; - -import static com.google.android.exoplayer2.transformer.AndroidTestUtil.SEF_ASSET_URI_STRING; -import static com.google.android.exoplayer2.transformer.AndroidTestUtil.runTransformer; - -import android.content.Context; -import androidx.test.core.app.ApplicationProvider; -import androidx.test.ext.junit.runners.AndroidJUnit4; -import com.google.android.exoplayer2.transformer.TransformationRequest; -import com.google.android.exoplayer2.transformer.Transformer; -import com.google.android.exoplayer2.util.Log; -import com.google.android.exoplayer2.util.Util; -import org.junit.Test; -import org.junit.runner.RunWith; - -/** {@link Transformer} instrumentation test for SEF. */ -@RunWith(AndroidJUnit4.class) -public class SefTransformationTest { - - private static final String TAG = "SefTransformationTest"; - - @Test - public void sefTransform() throws Exception { - if (Util.SDK_INT < 25) { - // TODO(b/210593256): Remove test skipping after removing the MediaMuxer dependency. - Log.i(TAG, "Skipping on this API version due to lack of muxing support"); - return; - } - - Context context = ApplicationProvider.getApplicationContext(); - Transformer transformer = - new Transformer.Builder(context) - .setTransformationRequest( - new TransformationRequest.Builder().setFlattenForSlowMotion(true).build()) - .build(); - runTransformer( - context, - /* testId = */ "sefTransform", - transformer, - SEF_ASSET_URI_STRING, - /* timeoutSeconds= */ 120, - /* calculateSsim= */ false); - } -} diff --git a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/SetTransformationMatrixTransformationTest.java b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/SetTransformationMatrixTransformationTest.java index 96eca86ab1..f74f41ae4b 100644 --- a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/SetTransformationMatrixTransformationTest.java +++ b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/SetTransformationMatrixTransformationTest.java @@ -15,7 +15,7 @@ */ package com.google.android.exoplayer2.transformer.mh; -import static com.google.android.exoplayer2.transformer.AndroidTestUtil.REMOTE_MP4_10_SECONDS_URI_STRING; +import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_REMOTE_10_SECONDS_URI_STRING; import static com.google.android.exoplayer2.transformer.AndroidTestUtil.runTransformer; import android.content.Context; @@ -47,7 +47,7 @@ public class SetTransformationMatrixTransformationTest { context, /* testId= */ "setTransformationMatrixTransform", transformer, - REMOTE_MP4_10_SECONDS_URI_STRING, + MP4_REMOTE_10_SECONDS_URI_STRING, /* timeoutSeconds= */ 120, /* calculateSsim= */ false); } diff --git a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/TransformationTest.java b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/TransformationTest.java index 67ed39a21b..b69d5483b7 100644 --- a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/TransformationTest.java +++ b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/TransformationTest.java @@ -15,17 +15,23 @@ */ package com.google.android.exoplayer2.transformer.mh; +import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_ASSET_SEF_URI_STRING; +import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_ASSET_URI_STRING; import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_URI_STRING; +import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_REMOTE_4K60_PORTRAIT_URI_STRING; import static com.google.android.exoplayer2.transformer.AndroidTestUtil.runTransformer; import android.content.Context; import androidx.test.core.app.ApplicationProvider; import androidx.test.ext.junit.runners.AndroidJUnit4; +import com.google.android.exoplayer2.transformer.TransformationRequest; import com.google.android.exoplayer2.transformer.Transformer; +import com.google.android.exoplayer2.util.Log; +import com.google.android.exoplayer2.util.Util; import org.junit.Test; import org.junit.runner.RunWith; -/** {@link Transformer} instrumentation test. */ +/** {@link Transformer} instrumentation tests. */ @RunWith(AndroidJUnit4.class) public class TransformationTest { @@ -33,14 +39,86 @@ public class TransformationTest { @Test public void transform() throws Exception { + final String testId = TAG + "_transform"; + Context context = ApplicationProvider.getApplicationContext(); Transformer transformer = new Transformer.Builder(context).build(); runTransformer( context, - /* testId= */ "transform", + testId, transformer, MP4_ASSET_WITH_INCREASING_TIMESTAMPS_URI_STRING, /* timeoutSeconds= */ 120, /* calculateSsim= */ false); } + + @Test + public void transform4K60() throws Exception { + final String testId = TAG + "_transform4K60"; + + Context context = ApplicationProvider.getApplicationContext(); + Transformer transformer = new Transformer.Builder(context).build(); + runTransformer( + context, + testId, + transformer, + MP4_REMOTE_4K60_PORTRAIT_URI_STRING, + /* timeoutSeconds= */ 120, + /* calculateSsim= */ false); + } + + @Test + public void transformNoAudio() throws Exception { + final String testId = TAG + "_transformNoAudio"; + + Context context = ApplicationProvider.getApplicationContext(); + Transformer transformer = new Transformer.Builder(context).setRemoveAudio(true).build(); + runTransformer( + context, + testId, + transformer, + MP4_ASSET_WITH_INCREASING_TIMESTAMPS_URI_STRING, + /* timeoutSeconds= */ 120, + /* calculateSsim= */ false); + } + + @Test + public void transformNoVideo() throws Exception { + final String testId = TAG + "_transformNoVideo"; + + Context context = ApplicationProvider.getApplicationContext(); + Transformer transformer = new Transformer.Builder(context).setRemoveVideo(true).build(); + runTransformer( + context, + testId, + transformer, + MP4_ASSET_URI_STRING, + /* timeoutSeconds= */ 120, + /* calculateSsim= */ false); + } + + @Test + public void transformSef() throws Exception { + final String testId = TAG + "_transformSef"; + + if (Util.SDK_INT < 25) { + // TODO(b/210593256): Remove test skipping after removing the MediaMuxer dependency. + Log.i(testId, "Skipping on this API version due to lack of muxing support"); + return; + } + + Context context = ApplicationProvider.getApplicationContext(); + Transformer transformer = + new Transformer.Builder(context) + .setTransformationRequest( + new TransformationRequest.Builder().setFlattenForSlowMotion(true).build()) + .build(); + runTransformer( + context, + testId, + transformer, + MP4_ASSET_SEF_URI_STRING, + /* timeoutSeconds= */ 120, + /* calculateSsim= */ false); + } }