Merge "Tests for PopupWindow public API change"
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskHostDrivenTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskHostDrivenTest.java
index 1d6105d..b2ae2cc 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskHostDrivenTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskHostDrivenTest.java
@@ -20,6 +20,7 @@
import android.app.ActivityManager;
import android.app.admin.DevicePolicyManager;
+import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -29,6 +30,7 @@
import android.support.test.uiautomator.UiDevice;
import android.util.Log;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -45,6 +47,8 @@
private static final String TAG = LockTaskHostDrivenTest.class.getName();
+ private static final int ACTIVITY_RESUMED_TIMEOUT_MILLIS = 20000; // 20 seconds
+
private static final String LOCK_TASK_ACTIVITY
= LockTaskUtilityActivityIfWhitelisted.class.getName();
@@ -53,14 +57,45 @@
private ActivityManager mActivityManager;
private DevicePolicyManager mDevicePolicyManager;
+ private volatile boolean mIsActivityResumed;
+ private final Object mActivityResumedLock = new Object();
+
+ private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ Log.d(TAG, "onReceive: " + action);
+ if (LockTaskUtilityActivity.RESUME_ACTION.equals(action)) {
+ synchronized (mActivityResumedLock) {
+ mIsActivityResumed = true;
+ mActivityResumedLock.notify();
+ }
+ } else if (LockTaskUtilityActivity.PAUSE_ACTION.equals(action)) {
+ synchronized (mActivityResumedLock) {
+ mIsActivityResumed = false;
+ mActivityResumedLock.notify();
+ }
+ }
+ }
+ };
+
@Before
public void setUp() {
mContext = InstrumentationRegistry.getContext();
mDevicePolicyManager = mContext.getSystemService(DevicePolicyManager.class);
mActivityManager = mContext.getSystemService(ActivityManager.class);
mUiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(LockTaskUtilityActivity.RESUME_ACTION);
+ filter.addAction(LockTaskUtilityActivity.PAUSE_ACTION);
+ mContext.registerReceiver(mReceiver, filter);
}
+ @After
+ public void tearDown() {
+ mContext.unregisterReceiver(mReceiver);
+ }
+
@Test
public void startLockTask() throws Exception {
Log.d(TAG, "startLockTask on host-driven test (no cleanup)");
@@ -77,6 +112,13 @@
public void testLockTaskIsActiveAndCantBeInterrupted() throws Exception {
mUiDevice.waitForIdle();
+ // We need to wait until the LockTaskActivity is ready
+ // since com.android.cts.deviceowner can be killed by AMS for reason "start instr".
+ synchronized (mActivityResumedLock) {
+ if (!mIsActivityResumed) {
+ mActivityResumedLock.wait(ACTIVITY_RESUMED_TIMEOUT_MILLIS);
+ }
+ }
checkLockedActivityIsRunning();
mUiDevice.pressBack();
diff --git a/tests/tests/media/src/android/media/cts/CodecUtils.java b/tests/tests/media/src/android/media/cts/CodecUtils.java
index ae785b2..15314ef 100644
--- a/tests/tests/media/src/android/media/cts/CodecUtils.java
+++ b/tests/tests/media/src/android/media/cts/CodecUtils.java
@@ -54,6 +54,8 @@
for (int i = 0; i < planes.length; i++) {
mPlanes[i] = new PlaneWrapper(planes[i]);
}
+
+ setCropRect(image.getCropRect());
}
public static ImageWrapper createFromImage(Image image) {
diff --git a/tests/tests/media/src/android/media/cts/MediaFormatTest.java b/tests/tests/media/src/android/media/cts/MediaFormatTest.java
index c5b3ed4..2beae2b 100644
--- a/tests/tests/media/src/android/media/cts/MediaFormatTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaFormatTest.java
@@ -585,4 +585,54 @@
} catch (IllegalArgumentException e) {
}
}
+
+ public void testMediaFormatConstructors() {
+ MediaFormat format;
+ {
+ format = MediaFormat.createAudioFormat(MediaFormat.MIMETYPE_AUDIO_AAC, 48000, 6);
+ assertEquals(MediaFormat.MIMETYPE_AUDIO_AAC, format.getString(MediaFormat.KEY_MIME));
+ assertEquals(48000, format.getInteger(MediaFormat.KEY_SAMPLE_RATE));
+ assertEquals(6, format.getInteger(MediaFormat.KEY_CHANNEL_COUNT));
+ assertEquals(3, format.getKeys().size());
+ assertEquals(0, format.getFeatures().size());
+ }
+
+ {
+ format = MediaFormat.createVideoFormat(MediaFormat.MIMETYPE_VIDEO_AVC, 1920, 1080);
+ assertEquals(MediaFormat.MIMETYPE_VIDEO_AVC, format.getString(MediaFormat.KEY_MIME));
+ assertEquals(1920, format.getInteger(MediaFormat.KEY_WIDTH));
+ assertEquals(1080, format.getInteger(MediaFormat.KEY_HEIGHT));
+ assertEquals(3, format.getKeys().size());
+ assertEquals(0, format.getFeatures().size());
+ }
+
+ {
+ format = MediaFormat.createSubtitleFormat(MediaFormat.MIMETYPE_TEXT_VTT, "und");
+ assertEquals(MediaFormat.MIMETYPE_TEXT_VTT, format.getString(MediaFormat.KEY_MIME));
+ assertEquals("und", format.getString(MediaFormat.KEY_LANGUAGE));
+ assertEquals(2, format.getKeys().size());
+ assertEquals(0, format.getFeatures().size());
+
+ format.setFeatureEnabled("feature1", false);
+
+ // also test dup
+ MediaFormat other = new MediaFormat(format);
+ format.setString(MediaFormat.KEY_LANGUAGE, "un");
+ other.setInteger(MediaFormat.KEY_IS_DEFAULT, 1);
+ other.setFeatureEnabled("feature1", true);
+
+ assertEquals(MediaFormat.MIMETYPE_TEXT_VTT, format.getString(MediaFormat.KEY_MIME));
+ assertEquals("un", format.getString(MediaFormat.KEY_LANGUAGE));
+ assertEquals(2, format.getKeys().size());
+ assertFalse(format.getFeatureEnabled("feature1"));
+ assertEquals(1, format.getFeatures().size());
+
+ assertEquals(MediaFormat.MIMETYPE_TEXT_VTT, other.getString(MediaFormat.KEY_MIME));
+ assertEquals("und", other.getString(MediaFormat.KEY_LANGUAGE));
+ assertEquals(1, other.getInteger(MediaFormat.KEY_IS_DEFAULT));
+ assertEquals(3, other.getKeys().size());
+ assertTrue(other.getFeatureEnabled("feature1"));
+ assertEquals(1, other.getFeatures().size());
+ }
+ }
}
diff --git a/tests/tests/util/AndroidTest.xml b/tests/tests/util/AndroidTest.xml
index 92c1e14..7f11f18 100644
--- a/tests/tests/util/AndroidTest.xml
+++ b/tests/tests/util/AndroidTest.xml
@@ -16,6 +16,8 @@
<configuration description="Config for CTS Util test cases">
<option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="framework" />
+ <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
+ <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsUtilTestCases.apk" />