Migrate MediaMetadataRetrieverTest to JUnit4

Removed MediaMetadataRetrieverTest from MediaFrameworkUnitTestRunner

Bug: 305324235
Test: atest com.android.mediaframeworktest.unit.MediaMetadataRetrieverTest

Change-Id: I9bbd0a278c7c1b9e6cb14b3a79bde113837bd4c1
This commit is contained in:
Harish Mahendrakar 2023-10-14 00:45:13 +00:00
parent d053371e10
commit 20dabc8c90
2 changed files with 21 additions and 14 deletions

View File

@ -44,7 +44,6 @@ public class MediaFrameworkUnitTestRunner extends InstrumentationTestRunner {
@Override @Override
public TestSuite getAllTests() { public TestSuite getAllTests() {
TestSuite suite = new InstrumentationTestSuite(this); TestSuite suite = new InstrumentationTestSuite(this);
addMediaMetadataRetrieverStateUnitTests(suite);
addMediaRecorderStateUnitTests(suite); addMediaRecorderStateUnitTests(suite);
addMediaPlayerStateUnitTests(suite); addMediaPlayerStateUnitTests(suite);
addMediaScannerUnitTests(suite); addMediaScannerUnitTests(suite);
@ -69,11 +68,6 @@ public class MediaFrameworkUnitTestRunner extends InstrumentationTestRunner {
suite.addTestSuite(ImageReaderTest.class); suite.addTestSuite(ImageReaderTest.class);
} }
// Running all unit tests checking the state machine may be time-consuming.
private void addMediaMetadataRetrieverStateUnitTests(TestSuite suite) {
suite.addTestSuite(MediaMetadataRetrieverTest.class);
}
// Running all unit tests checking the state machine may be time-consuming. // Running all unit tests checking the state machine may be time-consuming.
private void addMediaRecorderStateUnitTests(TestSuite suite) { private void addMediaRecorderStateUnitTests(TestSuite suite) {
suite.addTestSuite(MediaRecorderPrepareStateUnitTest.class); suite.addTestSuite(MediaRecorderPrepareStateUnitTest.class);

View File

@ -16,26 +16,34 @@
package com.android.mediaframeworktest.unit; package com.android.mediaframeworktest.unit;
import static org.junit.Assert.assertTrue;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.media.MediaMetadataRetriever; import android.media.MediaMetadataRetriever;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.MediumTest;
import android.util.Log; import android.util.Log;
import androidx.test.runner.AndroidJUnit4;
import com.android.mediaframeworktest.MediaNames; import com.android.mediaframeworktest.MediaNames;
import com.android.mediaframeworktest.MediaProfileReader; import com.android.mediaframeworktest.MediaProfileReader;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
public class MediaMetadataRetrieverTest extends AndroidTestCase { @RunWith(AndroidJUnit4.class)
public class MediaMetadataRetrieverTest {
private static final String TAG = "MediaMetadataRetrieverTest"; private static final String TAG = "MediaMetadataRetrieverTest";
// Test album art extraction. // Test album art extraction.
@MediumTest @MediumTest
public static void testGetEmbeddedPicture() throws Exception { @Test
public void testGetEmbeddedPicture() throws Exception {
Log.v(TAG, "testGetEmbeddedPicture starts."); Log.v(TAG, "testGetEmbeddedPicture starts.");
MediaMetadataRetriever retriever = new MediaMetadataRetriever(); MediaMetadataRetriever retriever = new MediaMetadataRetriever();
boolean supportWMA = MediaProfileReader.getWMAEnable(); boolean supportWMA = MediaProfileReader.getWMAEnable();
@ -78,7 +86,8 @@ public class MediaMetadataRetrieverTest extends AndroidTestCase {
// Test frame capture // Test frame capture
@LargeTest @LargeTest
public static void testThumbnailCapture() throws Exception { @Test
public void testThumbnailCapture() throws Exception {
MediaMetadataRetriever retriever = new MediaMetadataRetriever(); MediaMetadataRetriever retriever = new MediaMetadataRetriever();
boolean supportWMA = MediaProfileReader.getWMAEnable(); boolean supportWMA = MediaProfileReader.getWMAEnable();
boolean supportWMV = MediaProfileReader.getWMVEnable(); boolean supportWMV = MediaProfileReader.getWMVEnable();
@ -134,7 +143,8 @@ public class MediaMetadataRetrieverTest extends AndroidTestCase {
} }
@LargeTest @LargeTest
public static void testMetadataRetrieval() throws Exception { @Test
public void testMetadataRetrieval() throws Exception {
boolean supportWMA = MediaProfileReader.getWMAEnable(); boolean supportWMA = MediaProfileReader.getWMAEnable();
boolean supportWMV = MediaProfileReader.getWMVEnable(); boolean supportWMV = MediaProfileReader.getWMVEnable();
boolean hasFailed = false; boolean hasFailed = false;
@ -169,7 +179,8 @@ public class MediaMetadataRetrieverTest extends AndroidTestCase {
// If the specified call order and valid media file is used, no exception // If the specified call order and valid media file is used, no exception
// should be thrown. // should be thrown.
@MediumTest @MediumTest
public static void testBasicNormalMethodCallSequence() throws Exception { @Test
public void testBasicNormalMethodCallSequence() throws Exception {
boolean hasFailed = false; boolean hasFailed = false;
MediaMetadataRetriever retriever = new MediaMetadataRetriever(); MediaMetadataRetriever retriever = new MediaMetadataRetriever();
try { try {
@ -197,7 +208,8 @@ public class MediaMetadataRetrieverTest extends AndroidTestCase {
// If setDataSource() has not been called, both getFrameAtTime() and extractMetadata() must // If setDataSource() has not been called, both getFrameAtTime() and extractMetadata() must
// return null. // return null.
@MediumTest @MediumTest
public static void testBasicAbnormalMethodCallSequence() { @Test
public void testBasicAbnormalMethodCallSequence() {
boolean hasFailed = false; boolean hasFailed = false;
MediaMetadataRetriever retriever = new MediaMetadataRetriever(); MediaMetadataRetriever retriever = new MediaMetadataRetriever();
if (retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM) != null) { if (retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM) != null) {
@ -213,7 +225,8 @@ public class MediaMetadataRetrieverTest extends AndroidTestCase {
// Test setDataSource() // Test setDataSource()
@MediumTest @MediumTest
public static void testSetDataSource() throws IOException { @Test
public void testSetDataSource() throws IOException {
MediaMetadataRetriever retriever = new MediaMetadataRetriever(); MediaMetadataRetriever retriever = new MediaMetadataRetriever();
boolean hasFailed = false; boolean hasFailed = false;