transcoding: Rework mediatranscoding test.
Create a sperate directory for all tests associated with
mediatranscoding.
This CL is a preparation of hooking with actual service,
adding perf benchamrk, power measurement.
Bug: 145628554
Test: MediaTranscodingTest.
Change-Id: Ifcdb26eae2e71599e2e19bb92b991f88809ec5e0
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java
index 2d1820e..dfadf5f 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java
@@ -24,7 +24,6 @@
import com.android.mediaframeworktest.functional.MediaMetadataTest;
import com.android.mediaframeworktest.functional.MediaMimeTest;
import com.android.mediaframeworktest.functional.MediaPlayerInvokeTest;
-import com.android.mediaframeworktest.functional.MediaTranscodeManagerTest;
import com.android.mediaframeworktest.functional.audio.MediaAudioEffectTest;
import com.android.mediaframeworktest.functional.audio.MediaAudioManagerTest;
import com.android.mediaframeworktest.functional.audio.MediaAudioTrackTest;
@@ -71,7 +70,6 @@
suite.addTestSuite(MediaEnvReverbTest.class);
suite.addTestSuite(MediaEqualizerTest.class);
suite.addTestSuite(MediaPresetReverbTest.class);
- suite.addTestSuite(MediaTranscodeManagerTest.class);
suite.addTestSuite(MediaVirtualizerTest.class);
suite.addTestSuite(MediaVisualizerTest.class);
return suite;
diff --git a/media/tests/MediaTranscodingTest/Android.bp b/media/tests/MediaTranscodingTest/Android.bp
new file mode 100644
index 0000000..fcf8f11
--- /dev/null
+++ b/media/tests/MediaTranscodingTest/Android.bp
@@ -0,0 +1,15 @@
+android_test {
+ name: "mediatranscodingtest",
+ srcs: ["**/*.java"],
+ libs: [
+ "android.test.runner",
+ "android.test.base",
+ ],
+ static_libs: [
+ "androidx.test.ext.junit",
+ "androidx.test.rules",
+ "android-support-test",
+ "testng"
+ ],
+ platform_apis: true,
+}
diff --git a/media/tests/MediaTranscodingTest/AndroidManifest.xml b/media/tests/MediaTranscodingTest/AndroidManifest.xml
new file mode 100644
index 0000000..07674da
--- /dev/null
+++ b/media/tests/MediaTranscodingTest/AndroidManifest.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2020 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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.mediatranscodingtest">
+
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+ <uses-permission android:name="android.permission.WAKE_LOCK"/>
+
+ <application android:label="@string/app_name">
+ <uses-library android:name="android.test.runner"/>
+ <activity android:label="@string/app_name"
+ android:name="MediaTranscodingTest"
+ android:screenOrientation="landscape"
+ android:exported="true">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ </activity>
+ </application>
+
+ <instrumentation android:name=".MediaTranscodingTestRunner"
+ android:targetPackage="com.android.mediatranscodingtest"
+ android:label="MediaTranscoding tests InstrumentationRunner">
+ </instrumentation>
+</manifest>
diff --git a/media/tests/MediaTranscodingTest/AndroidTest.xml b/media/tests/MediaTranscodingTest/AndroidTest.xml
new file mode 100644
index 0000000..c2167e8
--- /dev/null
+++ b/media/tests/MediaTranscodingTest/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2020 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.
+-->
+<configuration description="Runs MediaTranscoding Tests">
+ <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
+ <option name="test-file-name" value="mediatranscodingtest.apk" />
+ </target_preparer>
+
+ <option name="test-tag" value="MediaTranscodingTest" />
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="package" value="com.android.mediatranscodingtest" />
+ <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
+ <option name="hidden-api-checks" value="false"/>
+ </test>
+</configuration>
diff --git a/media/tests/MediaTranscodingTest/Readme.txt b/media/tests/MediaTranscodingTest/Readme.txt
new file mode 100644
index 0000000..e3b835b
--- /dev/null
+++ b/media/tests/MediaTranscodingTest/Readme.txt
@@ -0,0 +1,8 @@
+MediaTranscodingTest/
+ Uses instrumentation and so can be run with runtest.
+ It assumes /sdcard/media_api/ has been populated.
+
+contents/media_api/
+ Push to /sdcard/media_api/ for use with MediaTranscodingTest:
+ adb shell mkdir /sdcard/media_api
+ adb push contents/media_api/ /sdcard/media_api/
diff --git a/media/tests/MediaTranscodingTest/res/drawable-hdpi/icon.png b/media/tests/MediaTranscodingTest/res/drawable-hdpi/icon.png
new file mode 100644
index 0000000..a02138e
--- /dev/null
+++ b/media/tests/MediaTranscodingTest/res/drawable-hdpi/icon.png
Binary files differ
diff --git a/media/tests/MediaTranscodingTest/res/drawable-mdpi/icon.png b/media/tests/MediaTranscodingTest/res/drawable-mdpi/icon.png
new file mode 100644
index 0000000..64e3601
--- /dev/null
+++ b/media/tests/MediaTranscodingTest/res/drawable-mdpi/icon.png
Binary files differ
diff --git a/media/tests/MediaTranscodingTest/res/layout/surface_view.xml b/media/tests/MediaTranscodingTest/res/layout/surface_view.xml
new file mode 100644
index 0000000..3b49db0
--- /dev/null
+++ b/media/tests/MediaTranscodingTest/res/layout/surface_view.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2020 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <SurfaceView
+ android:id="@+id/surface_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_centerInParent="true"
+ />
+
+ </FrameLayout>
+
+</LinearLayout>
diff --git a/media/tests/MediaTranscodingTest/res/raw/VideoOnlyHEVC.mp4 b/media/tests/MediaTranscodingTest/res/raw/VideoOnlyHEVC.mp4
new file mode 100644
index 0000000..7ac0024
--- /dev/null
+++ b/media/tests/MediaTranscodingTest/res/raw/VideoOnlyHEVC.mp4
Binary files differ
diff --git a/media/tests/MediaTranscodingTest/res/values/strings.xml b/media/tests/MediaTranscodingTest/res/values/strings.xml
new file mode 100644
index 0000000..0e1f8eb
--- /dev/null
+++ b/media/tests/MediaTranscodingTest/res/values/strings.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <!-- Test application name [CHAR LIMIT=32] -->
+ <string name="app_name">MediaTranscodingTest</string>
+</resources>
diff --git a/media/tests/MediaTranscodingTest/src/com/android/mediatranscodingtest/MediaConstants.java b/media/tests/MediaTranscodingTest/src/com/android/mediatranscodingtest/MediaConstants.java
new file mode 100644
index 0000000..52f2787
--- /dev/null
+++ b/media/tests/MediaTranscodingTest/src/com/android/mediatranscodingtest/MediaConstants.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2020 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.android.mediatranscodingtest;
+
+/**
+ *
+ * This class has the names of the all the activity name and variables in the
+ * instrumentation test.
+ *
+ */
+public class MediaConstants {
+ /*
+ * Source test files.
+ */
+ public static final String[] SOURCE_HEVC_VIDEO_ONLY_TEST_FILES = {
+ "/sdcard/media_api/video/VideoOnlyHEVC.mp4",
+ };
+}
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediatranscodemanager/MediaTranscodeManagerTest.java b/media/tests/MediaTranscodingTest/src/com/android/mediatranscodingtest/MediaTranscodeManagerWithMockServiceTest.java
similarity index 94%
rename from media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediatranscodemanager/MediaTranscodeManagerTest.java
rename to media/tests/MediaTranscodingTest/src/com/android/mediatranscodingtest/MediaTranscodeManagerWithMockServiceTest.java
index c07e38f..e886331 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediatranscodemanager/MediaTranscodeManagerTest.java
+++ b/media/tests/MediaTranscodingTest/src/com/android/mediatranscodingtest/MediaTranscodeManagerWithMockServiceTest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.mediaframeworktest.functional;
+package com.android.mediatranscodingtest;
import static org.testng.Assert.assertThrows;
@@ -35,9 +35,6 @@
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
-import com.android.mediaframeworktest.MediaFrameworkTest;
-import com.android.mediaframeworktest.R;
-
import org.junit.Test;
import java.io.File;
@@ -54,21 +51,22 @@
/*
* Functional tests for MediaTranscodeManager in the media framework.
+ * The test uses a mock Transcoding service as backend to test the API functionality.
*
* To run this test suite:
- make frameworks/base/media/tests/MediaFrameworkTest
- make mediaframeworktest
+ make frameworks/base/media/tests/MediaTranscodingTest
+ make mediatranscodingtest
- adb install -r out/target/product/dream/data/app/mediaframeworktest.apk
+ adb install -r testcases/mediatranscodingtest/arm64/mediatranscodingtest.apk
adb shell am instrument -e class \
- com.android.mediaframeworktest.functional.MediaTranscodeManagerTest \
- -w com.android.mediaframeworktest/.MediaFrameworkTestRunner
+ com.android.mediatranscodingtest.MediaTranscodeManagerWithMockServiceTest \
+ -w com.android.mediatranscodingtest/.MediaTranscodingTestRunner
*
*/
-public class MediaTranscodeManagerTest
- extends ActivityInstrumentationTestCase2<MediaFrameworkTest> {
- private static final String TAG = "MediaTranscodeManagerTest";
+public class MediaTranscodeManagerWithMockServiceTest
+ extends ActivityInstrumentationTestCase2<MediaTranscodingTest> {
+ private static final String TAG = "MediaTranscodeManagerWithMockServiceTest";
/** The time to wait for the transcode operation to complete before failing the test. */
private static final int TRANSCODE_TIMEOUT_SECONDS = 2;
private Context mContext;
@@ -194,8 +192,8 @@
}
}
- public MediaTranscodeManagerTest() {
- super("com.android.MediaTranscodeManagerTest", MediaFrameworkTest.class);
+ public MediaTranscodeManagerWithMockServiceTest() {
+ super("com.android.MediaTranscodeManagerWithMockServiceTest", MediaTranscodingTest.class);
}
diff --git a/media/tests/MediaTranscodingTest/src/com/android/mediatranscodingtest/MediaTranscodingTest.java b/media/tests/MediaTranscodingTest/src/com/android/mediatranscodingtest/MediaTranscodingTest.java
new file mode 100644
index 0000000..6f83bad
--- /dev/null
+++ b/media/tests/MediaTranscodingTest/src/com/android/mediatranscodingtest/MediaTranscodingTest.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2020 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.android.mediatranscodingtest;
+
+import android.app.Activity;
+import android.content.Context;
+import android.os.Bundle;
+import android.os.PowerManager;
+
+public class MediaTranscodingTest extends Activity {
+ private PowerManager.WakeLock mWakeLock = null;
+
+ public MediaTranscodingTest() {
+ }
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ setContentView(R.layout.surface_view);
+
+ //Acquire the full wake lock to keep the device up
+ PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
+ mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "MediaTranscodingTest");
+ mWakeLock.acquire();
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ mWakeLock.release();
+ }
+}
diff --git a/media/tests/MediaTranscodingTest/src/com/android/mediatranscodingtest/MediaTranscodingTestRunner.java b/media/tests/MediaTranscodingTest/src/com/android/mediatranscodingtest/MediaTranscodingTestRunner.java
new file mode 100644
index 0000000..af0a754
--- /dev/null
+++ b/media/tests/MediaTranscodingTest/src/com/android/mediatranscodingtest/MediaTranscodingTestRunner.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2020 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.android.mediatranscodingtest;
+
+import android.os.Bundle;
+import android.test.InstrumentationTestRunner;
+import android.test.InstrumentationTestSuite;
+
+import junit.framework.TestSuite;
+
+
+/**
+ * Instrumentation Test Runner for all MediaTranscoding tests.
+ *
+ * Running all tests:
+ *
+ * adb shell am instrument \
+ * -w com.android.mediatranscodingtest/.MediaTranscodingTestRunner
+ */
+
+public class MediaTranscodingTestRunner extends InstrumentationTestRunner {
+ @Override
+ public TestSuite getAllTests() {
+ TestSuite suite = new InstrumentationTestSuite(this);
+ suite.addTestSuite(MediaTranscodeManagerWithMockServiceTest.class);
+ return suite;
+ }
+
+ @Override
+ public ClassLoader getLoader() {
+ return MediaTranscodingTestRunner.class.getClassLoader();
+ }
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ }
+}