Merge "Skip test if notification policy is not supported" into pi-dev
diff --git a/hostsidetests/appsecurity/test-apps/NoRestartApp/feature/Android.mk b/hostsidetests/appsecurity/test-apps/NoRestartApp/feature/Android.mk
index 08fa1bd..3558eb7 100644
--- a/hostsidetests/appsecurity/test-apps/NoRestartApp/feature/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/NoRestartApp/feature/Android.mk
@@ -24,7 +24,7 @@
LOCAL_SDK_VERSION := current
LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests cts_instant
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_DEX_PREOPT := false
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/feature/Android.mk b/hostsidetests/appsecurity/test-apps/SplitApp/feature/Android.mk
index 06901d8..46abb3c 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/feature/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/feature/Android.mk
@@ -30,7 +30,7 @@
LOCAL_MODULE_TAGS := tests
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests cts_instant
featureOf := CtsSplitApp
featureOfApk := $(call intermediates-dir-for,APPS,$(featureOf))/package.apk
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/libs/arm64-v8a/Android.mk b/hostsidetests/appsecurity/test-apps/SplitApp/libs/arm64-v8a/Android.mk
index 5337057..e2e059c 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/libs/arm64-v8a/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/libs/arm64-v8a/Android.mk
@@ -24,7 +24,7 @@
LOCAL_JAVA_RESOURCE_DIRS := raw
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests cts_instant
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
LOCAL_AAPT_FLAGS := --version-code 100 --replace-version
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/libs/armeabi-v7a/Android.mk b/hostsidetests/appsecurity/test-apps/SplitApp/libs/armeabi-v7a/Android.mk
index 7fceede..ff827b9 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/libs/armeabi-v7a/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/libs/armeabi-v7a/Android.mk
@@ -24,7 +24,7 @@
LOCAL_JAVA_RESOURCE_DIRS := raw
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests cts_instant
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
LOCAL_AAPT_FLAGS := --version-code 100 --replace-version
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/libs/armeabi/Android.mk b/hostsidetests/appsecurity/test-apps/SplitApp/libs/armeabi/Android.mk
index 9149930..29bc859 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/libs/armeabi/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/libs/armeabi/Android.mk
@@ -24,7 +24,7 @@
LOCAL_JAVA_RESOURCE_DIRS := raw
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests cts_instant
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
LOCAL_AAPT_FLAGS := --version-code 100 --replace-version
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/libs/mips/Android.mk b/hostsidetests/appsecurity/test-apps/SplitApp/libs/mips/Android.mk
index 95d02d0..3c6cc22 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/libs/mips/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/libs/mips/Android.mk
@@ -24,7 +24,7 @@
LOCAL_JAVA_RESOURCE_DIRS := raw
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests cts_instant
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
LOCAL_AAPT_FLAGS := --version-code 100 --replace-version
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/libs/mips64/Android.mk b/hostsidetests/appsecurity/test-apps/SplitApp/libs/mips64/Android.mk
index ad10be0..acb545f 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/libs/mips64/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/libs/mips64/Android.mk
@@ -24,7 +24,7 @@
LOCAL_JAVA_RESOURCE_DIRS := raw
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests cts_instant
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
LOCAL_AAPT_FLAGS := --version-code 100 --replace-version
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/libs/x86/Android.mk b/hostsidetests/appsecurity/test-apps/SplitApp/libs/x86/Android.mk
index f008564..8f3b381 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/libs/x86/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/libs/x86/Android.mk
@@ -24,7 +24,7 @@
LOCAL_JAVA_RESOURCE_DIRS := raw
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests cts_instant
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
LOCAL_AAPT_FLAGS := --version-code 100 --replace-version
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/libs/x86_64/Android.mk b/hostsidetests/appsecurity/test-apps/SplitApp/libs/x86_64/Android.mk
index ded5b29..76ef050 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/libs/x86_64/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/libs/x86_64/Android.mk
@@ -24,7 +24,7 @@
LOCAL_JAVA_RESOURCE_DIRS := raw
# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests cts_instant
LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
LOCAL_AAPT_FLAGS := --version-code 100 --replace-version
diff --git a/tests/JobScheduler/src/android/jobscheduler/cts/BatteryConstraintTest.java b/tests/JobScheduler/src/android/jobscheduler/cts/BatteryConstraintTest.java
index e28675d..e03d4ae 100644
--- a/tests/JobScheduler/src/android/jobscheduler/cts/BatteryConstraintTest.java
+++ b/tests/JobScheduler/src/android/jobscheduler/cts/BatteryConstraintTest.java
@@ -129,6 +129,13 @@
assertJobNotReady(BATTERY_JOB_ID);
}
+ static void waitFor(long waitMillis) throws Exception {
+ final long deadline = SystemClock.uptimeMillis() + waitMillis;
+ do {
+ Thread.sleep(500L);
+ } while (SystemClock.uptimeMillis() < deadline);
+ }
+
// --------------------------------------------------------------------------------------------
// Positives - schedule jobs under conditions that require them to pass.
// --------------------------------------------------------------------------------------------
@@ -157,6 +164,7 @@
*/
public void testBatteryNotLowConstraintExecutes_withPower() throws Exception {
setBatteryState(true, 100);
+ waitFor(2_000);
verifyChargingState(true);
verifyBatteryNotLowState(true);
@@ -176,6 +184,7 @@
*/
public void testBatteryNotLowConstraintExecutes_withoutPower() throws Exception {
setBatteryState(false, 100);
+ waitFor(2_000);
verifyChargingState(false);
verifyBatteryNotLowState(true);
@@ -238,6 +247,10 @@
*/
public void testBatteryNotLowConstraintFails_withoutPower() throws Exception {
setBatteryState(false, 15);
+ // setBatteryState() waited for the charging/not-charging state to formally settle,
+ // but battery level reporting lags behind that. wait a moment to let that happen
+ // before proceeding.
+ waitFor(2_000);
verifyChargingState(false);
verifyBatteryNotLowState(false);
@@ -258,6 +271,7 @@
kTestEnvironment.setExpectedWaitForRun();
kTestEnvironment.setContinueAfterStart();
setBatteryState(false, 50);
+ waitFor(2_000);
verifyChargingState(false);
verifyBatteryNotLowState(true);
kTestEnvironment.setExpectedStopped();
@@ -269,6 +283,7 @@
// And check that the job is stopped if battery goes low again.
setBatteryState(false, 15);
setBatteryState(false, 14);
+ waitFor(2_000);
verifyChargingState(false);
verifyBatteryNotLowState(false);
assertTrue("Job with not low constraint did not stop when battery went low.",
diff --git a/tests/tests/secure_element/access_control/AccessControlApp1/Android.mk b/tests/tests/secure_element/access_control/AccessControlApp1/Android.mk
index 37e7a10..c9b40f4 100644
--- a/tests/tests/secure_element/access_control/AccessControlApp1/Android.mk
+++ b/tests/tests/secure_element/access_control/AccessControlApp1/Android.mk
@@ -24,7 +24,9 @@
LOCAL_MODULE_TAGS := optional
# When built, explicitly put it in the data partition.
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ ctstestrunner \
+ compatibility-device-util
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SDK_VERSION := current
LOCAL_JAVA_LIBRARIES += android.test.runner
diff --git a/tests/tests/secure_element/access_control/AccessControlApp1/src/android/omapi/accesscontrol1/cts/AccessControlTest.java b/tests/tests/secure_element/access_control/AccessControlApp1/src/android/omapi/accesscontrol1/cts/AccessControlTest.java
index 3727c60..9fe37ea 100644
--- a/tests/tests/secure_element/access_control/AccessControlApp1/src/android/omapi/accesscontrol1/cts/AccessControlTest.java
+++ b/tests/tests/secure_element/access_control/AccessControlApp1/src/android/omapi/accesscontrol1/cts/AccessControlTest.java
@@ -18,20 +18,30 @@
package android.omapi.accesscontrol1.cts;
+import static org.junit.Assert.*;
+import static org.junit.Assume.assumeTrue;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeoutException;
+import android.content.pm.PackageManager;
import android.os.RemoteException;
import android.se.omapi.Channel;
import android.se.omapi.Reader;
import android.se.omapi.SEService;
import android.se.omapi.SEService.OnConnectedListener;
import android.se.omapi.Session;
-import android.test.AndroidTestCase;
+import android.support.test.InstrumentationRegistry;
-public class AccessControlTest extends AndroidTestCase {
+import com.android.compatibility.common.util.PropertyUtil;
+
+public class AccessControlTest {
private final static String UICC_READER_PREFIX = "SIM";
private final static String ESE_READER_PREFIX = "eSE";
private final static String SD_READER_PREFIX = "SD";
@@ -144,15 +154,22 @@
}
}
- @Override
- protected void setUp() throws Exception {
- seService = new SEService(getContext(), new SynchronousExecutor(), mListener);
+ private boolean supportsHardware() {
+ final PackageManager pm = InstrumentationRegistry.getContext().getPackageManager();
+ boolean lowRamDevice = PropertyUtil.propertyEquals("ro.config.low_ram", "true");
+ return !lowRamDevice || (lowRamDevice && pm.hasSystemFeature("android.hardware.type.watch"));
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ assumeTrue(supportsHardware());
+ seService = new SEService(InstrumentationRegistry.getContext(), new SynchronousExecutor(), mListener);
connectionTimer = new Timer();
connectionTimer.schedule(mTimerTask, SERVICE_CONNECTION_TIME_OUT);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
if (seService != null && seService.isConnected()) {
seService.shutdown();
connected = false;
@@ -179,36 +196,42 @@
}
}
+ @Test
public void testAuthorizedAID() {
for (byte[] aid : AUTHORIZED_AID) {
testSelectableAid(aid);
}
}
+ @Test
public void testUnauthorizedAID() {
for (byte[] aid : UNAUTHORIZED_AID) {
testUnauthorisedAid(aid);
}
}
+ @Test
public void testAuthorizedAPDUAID40() {
for (byte[] apdu : AUTHORIZED_APDU_AID_40) {
testTransmitAPDU(AID_40, apdu);
}
}
+ @Test
public void testUnauthorisedAPDUAID40() {
for (byte[] apdu : UNAUTHORIZED_APDU_AID_40) {
testUnauthorisedAPDU(AID_40, apdu);
}
}
+ @Test
public void testAuthorizedAPDUAID41() {
for (byte[] apdu : AUTHORIZED_APDU_AID_41) {
testTransmitAPDU(AID_41, apdu);
}
}
+ @Test
public void testUnauthorisedAPDUAID41() {
for (byte[] apdu : UNAUTHORIZED_APDU_AID_41) {
testUnauthorisedAPDU(AID_41, apdu);
diff --git a/tests/tests/secure_element/access_control/AccessControlApp2/Android.mk b/tests/tests/secure_element/access_control/AccessControlApp2/Android.mk
index 2e9b107..eff645d 100644
--- a/tests/tests/secure_element/access_control/AccessControlApp2/Android.mk
+++ b/tests/tests/secure_element/access_control/AccessControlApp2/Android.mk
@@ -24,7 +24,9 @@
LOCAL_MODULE_TAGS := optional
# When built, explicitly put it in the data partition.
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ ctstestrunner \
+ compatibility-device-util
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SDK_VERSION := current
LOCAL_JAVA_LIBRARIES += android.test.runner
diff --git a/tests/tests/secure_element/access_control/AccessControlApp2/src/android/omapi/accesscontrol2/cts/AccessControlTest.java b/tests/tests/secure_element/access_control/AccessControlApp2/src/android/omapi/accesscontrol2/cts/AccessControlTest.java
index 8b51205..74021c3 100644
--- a/tests/tests/secure_element/access_control/AccessControlApp2/src/android/omapi/accesscontrol2/cts/AccessControlTest.java
+++ b/tests/tests/secure_element/access_control/AccessControlApp2/src/android/omapi/accesscontrol2/cts/AccessControlTest.java
@@ -18,20 +18,30 @@
package android.omapi.accesscontrol2.cts;
+import static org.junit.Assert.*;
+import static org.junit.Assume.assumeTrue;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeoutException;
+import android.content.pm.PackageManager;
import android.os.RemoteException;
import android.se.omapi.Channel;
import android.se.omapi.Reader;
import android.se.omapi.SEService;
import android.se.omapi.SEService.OnConnectedListener;
import android.se.omapi.Session;
-import android.test.AndroidTestCase;
+import android.support.test.InstrumentationRegistry;
-public class AccessControlTest extends AndroidTestCase {
+import com.android.compatibility.common.util.PropertyUtil;
+
+public class AccessControlTest {
private final static String UICC_READER_PREFIX = "SIM";
private final static String ESE_READER_PREFIX = "eSE";
private final static String SD_READER_PREFIX = "SD";
@@ -143,15 +153,22 @@
}
}
- @Override
- protected void setUp() throws Exception {
- seService = new SEService(getContext(), new SynchronousExecutor(), mListener);
+ private boolean supportsHardware() {
+ final PackageManager pm = InstrumentationRegistry.getContext().getPackageManager();
+ boolean lowRamDevice = PropertyUtil.propertyEquals("ro.config.low_ram", "true");
+ return !lowRamDevice || (lowRamDevice && pm.hasSystemFeature("android.hardware.type.watch"));
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ assumeTrue(supportsHardware());
+ seService = new SEService(InstrumentationRegistry.getContext(), new SynchronousExecutor(), mListener);
connectionTimer = new Timer();
connectionTimer.schedule(mTimerTask, SERVICE_CONNECTION_TIME_OUT);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
if (seService != null && seService.isConnected()) {
seService.shutdown();
connected = false;
@@ -178,36 +195,42 @@
}
}
+ @Test
public void testAuthorizedAID() {
for (byte[] aid : AUTHORIZED_AID) {
testSelectableAid(aid);
}
}
+ @Test
public void testUnauthorizedAID() {
for (byte[] aid : UNAUTHORIZED_AID) {
testUnauthorisedAid(aid);
}
}
+ @Test
public void testAuthorizedAPDUAID40() {
for (byte[] apdu : AUTHORIZED_APDU_AID_40) {
testTransmitAPDU(AID_40, apdu);
}
}
+ @Test
public void testUnauthorisedAPDUAID40() {
for (byte[] apdu : UNAUTHORIZED_APDU_AID_40) {
testUnauthorisedAPDU(AID_40, apdu);
}
}
+ @Test
public void testAuthorizedAPDUAID41() {
for (byte[] apdu : AUTHORIZED_APDU_AID_41) {
testTransmitAPDU(AID_41, apdu);
}
}
+ @Test
public void testUnauthorisedAPDUAID41() {
for (byte[] apdu : UNAUTHORIZED_APDU_AID_41) {
testUnauthorisedAPDU(AID_41, apdu);
diff --git a/tests/tests/secure_element/access_control/AccessControlApp3/Android.mk b/tests/tests/secure_element/access_control/AccessControlApp3/Android.mk
index cd3f132..29e38f3 100644
--- a/tests/tests/secure_element/access_control/AccessControlApp3/Android.mk
+++ b/tests/tests/secure_element/access_control/AccessControlApp3/Android.mk
@@ -24,7 +24,9 @@
LOCAL_MODULE_TAGS := optional
# When built, explicitly put it in the data partition.
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ ctstestrunner \
+ compatibility-device-util
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SDK_VERSION := current
LOCAL_JAVA_LIBRARIES += android.test.runner
diff --git a/tests/tests/secure_element/access_control/AccessControlApp3/src/android/omapi/accesscontrol3/cts/AccessControlTest.java b/tests/tests/secure_element/access_control/AccessControlApp3/src/android/omapi/accesscontrol3/cts/AccessControlTest.java
index 5ca0c51..51483e9 100644
--- a/tests/tests/secure_element/access_control/AccessControlApp3/src/android/omapi/accesscontrol3/cts/AccessControlTest.java
+++ b/tests/tests/secure_element/access_control/AccessControlApp3/src/android/omapi/accesscontrol3/cts/AccessControlTest.java
@@ -18,20 +18,30 @@
package android.omapi.accesscontrol3.cts;
+import static org.junit.Assert.*;
+import static org.junit.Assume.assumeTrue;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeoutException;
+import android.content.pm.PackageManager;
import android.os.RemoteException;
import android.se.omapi.Channel;
import android.se.omapi.Reader;
import android.se.omapi.SEService;
import android.se.omapi.SEService.OnConnectedListener;
import android.se.omapi.Session;
-import android.test.AndroidTestCase;
+import android.support.test.InstrumentationRegistry;
-public class AccessControlTest extends AndroidTestCase {
+import com.android.compatibility.common.util.PropertyUtil;
+
+public class AccessControlTest {
private final static String UICC_READER_PREFIX = "SIM";
private final static String ESE_READER_PREFIX = "eSE";
private final static String SD_READER_PREFIX = "SD";
@@ -153,15 +163,22 @@
}
}
- @Override
- protected void setUp() throws Exception {
- seService = new SEService(getContext(), new SynchronousExecutor(), mListener);
+ private boolean supportsHardware() {
+ final PackageManager pm = InstrumentationRegistry.getContext().getPackageManager();
+ boolean lowRamDevice = PropertyUtil.propertyEquals("ro.config.low_ram", "true");
+ return !lowRamDevice || (lowRamDevice && pm.hasSystemFeature("android.hardware.type.watch"));
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ assumeTrue(supportsHardware());
+ seService = new SEService(InstrumentationRegistry.getContext(), new SynchronousExecutor(), mListener);
connectionTimer = new Timer();
connectionTimer.schedule(mTimerTask, SERVICE_CONNECTION_TIME_OUT);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
if (seService != null && seService.isConnected()) {
seService.shutdown();
connected = false;
@@ -188,30 +205,35 @@
}
}
+ @Test
public void testAuthorizedAID() {
for (byte[] aid : AUTHORIZED_AID) {
testSelectableAid(aid);
}
}
+ @Test
public void testUnauthorizedAID() {
for (byte[] aid : UNAUTHORIZED_AID) {
testUnauthorisedAid(aid);
}
}
+ @Test
public void testAuthorizedAPDUAID40() {
for (byte[] apdu : AUTHORIZED_APDU_AID_40) {
testTransmitAPDU(AID_40, apdu);
}
}
+ @Test
public void testAuthorizedAPDUAID41() {
for (byte[] apdu : AUTHORIZED_APDU_AID_41) {
testTransmitAPDU(AID_41, apdu);
}
}
+ @Test
public void testUnauthorisedAPDUAID41() {
for (byte[] apdu : UNAUTHORIZED_APDU_AID_41) {
testUnauthorisedAPDU(AID_41, apdu);
diff --git a/tests/tests/secure_element/omapi/Android.mk b/tests/tests/secure_element/omapi/Android.mk
index f12aa75..4378136 100644
--- a/tests/tests/secure_element/omapi/Android.mk
+++ b/tests/tests/secure_element/omapi/Android.mk
@@ -24,7 +24,9 @@
# When built, explicitly put it in the data partition.
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ ctstestrunner \
+ compatibility-device-util
LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/tests/tests/secure_element/omapi/src/android/omapi/cts/OmapiTest.java b/tests/tests/secure_element/omapi/src/android/omapi/cts/OmapiTest.java
index e6a3456..34b6411 100644
--- a/tests/tests/secure_element/omapi/src/android/omapi/cts/OmapiTest.java
+++ b/tests/tests/secure_element/omapi/src/android/omapi/cts/OmapiTest.java
@@ -18,6 +18,13 @@
package android.omapi.cts;
+import static org.junit.Assert.*;
+import static org.junit.Assume.assumeTrue;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
@@ -28,14 +35,17 @@
import java.util.concurrent.Executor;
import java.util.concurrent.TimeoutException;
+import android.content.pm.PackageManager;
import android.se.omapi.Channel;
import android.se.omapi.Reader;
import android.se.omapi.SEService;
import android.se.omapi.SEService.OnConnectedListener;
import android.se.omapi.Session;
-import android.test.AndroidTestCase;
+import android.support.test.InstrumentationRegistry;
-public class OmapiTest extends AndroidTestCase {
+import com.android.compatibility.common.util.PropertyUtil;
+
+public class OmapiTest {
private final static String UICC_READER_PREFIX = "SIM";
private final static String ESE_READER_PREFIX = "eSE";
@@ -136,20 +146,27 @@
}
}
+ private boolean supportsHardware() {
+ final PackageManager pm = InstrumentationRegistry.getContext().getPackageManager();
+ boolean lowRamDevice = PropertyUtil.propertyEquals("ro.config.low_ram", "true");
+ return !lowRamDevice || (lowRamDevice && pm.hasSystemFeature("android.hardware.type.watch"));
+ }
+
private void assertGreaterOrEqual(long greater, long lesser) {
assertTrue("" + greater + " expected to be greater than or equal to " + lesser,
greater >= lesser);
}
- @Override
- protected void setUp() throws Exception {
- seService = new SEService(getContext(), new SynchronousExecutor(), mListener);
+ @Before
+ public void setUp() throws Exception {
+ assumeTrue(supportsHardware());
+ seService = new SEService(InstrumentationRegistry.getContext(), new SynchronousExecutor(), mListener);
connectionTimer = new Timer();
connectionTimer.schedule(mTimerTask, SERVICE_CONNECTION_TIME_OUT);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
if (seService != null && seService.isConnected()) {
seService.shutdown();
connected = false;
@@ -177,6 +194,7 @@
}
/** Tests getReaders API */
+ @Test
public void testGetReaders() {
try {
waitForConnection();
@@ -197,6 +215,7 @@
}
/** Tests getATR API */
+ @Test
public void testATR() {
try {
waitForConnection();
@@ -228,6 +247,7 @@
}
/** Tests OpenBasicChannel API when aid is null */
+ @Test
public void testOpenBasicChannelNullAid() {
try {
waitForConnection();
@@ -253,6 +273,7 @@
}
/** Tests OpenBasicChannel API when aid is provided */
+ @Test
public void testOpenBasicChannelNonNullAid() {
try {
waitForConnection();
@@ -278,10 +299,12 @@
}
/** Tests Select API */
+ @Test
public void testSelectableAid() {
testSelectableAid(SELECTABLE_AID);
}
+ @Test
public void testLongSelectResponse() {
byte[] selectResponse = testSelectableAid(LONG_SELECT_RESPONSE_AID);
if (selectResponse == null) {
@@ -318,6 +341,7 @@
}
/** Tests if NoSuchElementException in Select */
+ @Test
public void testWrongAid() {
try {
waitForConnection();
@@ -330,7 +354,7 @@
}
}
- public void testNonSelectableAid(Reader reader, byte[] aid) {
+ private void testNonSelectableAid(Reader reader, byte[] aid) {
boolean exception = false;
Session session = null;
try {
@@ -350,6 +374,7 @@
}
/** Tests if Security Exception in Transmit */
+ @Test
public void testSecurityExceptionInTransmit() {
boolean exception = false;
Session session;
@@ -412,6 +437,7 @@
* Checks the return status and verifies the size of the
* response.
*/
+ @Test
public void testTransmitApdu() {
try {
waitForConnection();
@@ -446,6 +472,7 @@
* - the warning code is properly received by the application layer as SW answer
* - the verify that the application layer can fetch the additionnal data (when present)
*/
+ @Test
public void testStatusWordTransmit() {
try {
waitForConnection();
@@ -491,6 +518,7 @@
}
/** Test if the responses are segmented by the underlying implementation */
+ @Test
public void testSegmentedResponseTransmit() {
try {
waitForConnection();
@@ -514,6 +542,7 @@
}
/** Test the P2 value of the select command sent by the underlying implementation */
+ @Test
public void testP2Value() {
try {
waitForConnection();
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/HardwareBitmapTests.java b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/HardwareBitmapTests.java
index 2f8823a..3391bb9 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/HardwareBitmapTests.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/HardwareBitmapTests.java
@@ -17,6 +17,7 @@
package android.uirendering.cts.testclasses;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -106,6 +107,7 @@
public void testReadbackThroughPicture() {
Bitmap hardwareBitmap = BitmapFactory.decodeResource(mRes, R.drawable.robot,
HARDWARE_OPTIONS);
+ assertEquals(Bitmap.Config.HARDWARE, hardwareBitmap.getConfig());
Picture picture = new Picture();
{
Canvas canvas = picture.beginRecording(TEST_WIDTH, TEST_HEIGHT);
@@ -121,6 +123,27 @@
}
@Test
+ public void testReadbackThroughPictureNoEndRecording() {
+ // Exact same test as #testReadbackThroughPicture but with an omitted endRecording
+ Bitmap hardwareBitmap = BitmapFactory.decodeResource(mRes, R.drawable.robot,
+ HARDWARE_OPTIONS);
+ assertEquals(Bitmap.Config.HARDWARE, hardwareBitmap.getConfig());
+ Picture picture = new Picture();
+ {
+ Canvas canvas = picture.beginRecording(TEST_WIDTH, TEST_HEIGHT);
+ canvas.drawColor(Color.WHITE);
+ canvas.drawBitmap(hardwareBitmap, 0, 0, null);
+ }
+ // It will be true, but as endRecording hasn't been called yet it's still in the
+ // "false" state from beginRecording()
+ assertFalse(picture.requiresHardwareAcceleration());
+ Bitmap result = Bitmap.createBitmap(picture, picture.getWidth(), picture.getHeight(),
+ Bitmap.Config.ARGB_8888);
+ assertTrue(new GoldenImageVerifier(getActivity(),
+ R.drawable.golden_robot, new MSSIMComparer(0.95)).verify(result));
+ }
+
+ @Test
public void testCreateScaledBitmapFromPicture() {
Picture picture = new Picture();
{