DO NOT MERGE: Skip running Slices CTS test suite for Wear devices
Use FEATURE_WATCH to skip the execution of Slices test cases as feature
is not applicable for Wear devices
Bug: 142022263
Test: Tried running CTS with change; test skipped for Wear devices and
passing for Mobile devices
Change-Id: I0ff1a33e1d9d6dbdac5cc95812dbbf7d0bf5b75f
diff --git a/tests/tests/slice/src/android/slice/cts/SliceBindingTest.java b/tests/tests/slice/src/android/slice/cts/SliceBindingTest.java
index 8a655cd..ae17b46 100644
--- a/tests/tests/slice/src/android/slice/cts/SliceBindingTest.java
+++ b/tests/tests/slice/src/android/slice/cts/SliceBindingTest.java
@@ -16,6 +16,8 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assume.assumeFalse;
+import android.content.pm.PackageManager;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
@@ -54,9 +56,12 @@
private static final Uri BASE_URI = Uri.parse("content://android.slice.cts/");
private final Context mContext = InstrumentationRegistry.getContext();
private final SliceManager mSliceManager = mContext.getSystemService(SliceManager.class);
+ private static final String FEATURE_WATCH = "android.hardware.type.watch";
+ private final boolean isWatch = mContext.getPackageManager().hasSystemFeature(FEATURE_WATCH);
@Test
public void testProcess() {
+ assumeFalse(isWatch);
sFlag = false;
mSliceManager.bindSlice(BASE_URI.buildUpon().appendPath("set_flag").build(),
Collections.emptySet());
@@ -71,6 +76,7 @@
@Test
public void testSliceUri() {
+ assumeFalse(isWatch);
Slice s = mSliceManager.bindSlice(BASE_URI,
Collections.emptySet());
assertEquals(BASE_URI, s.getUri());
@@ -78,6 +84,7 @@
@Test
public void testSubSlice() {
+ assumeFalse(isWatch);
Uri uri = BASE_URI.buildUpon().appendPath("subslice").build();
Slice s = mSliceManager.bindSlice(uri, Collections.emptySet());
assertEquals(uri, s.getUri());
@@ -93,6 +100,7 @@
@Test
public void testText() {
+ assumeFalse(isWatch);
Uri uri = BASE_URI.buildUpon().appendPath("text").build();
Slice s = mSliceManager.bindSlice(uri,
Collections.emptySet());
@@ -107,6 +115,7 @@
@Test
public void testIcon() {
+ assumeFalse(isWatch);
Uri uri = BASE_URI.buildUpon().appendPath("icon").build();
Slice s = mSliceManager.bindSlice(uri,
Collections.emptySet());
@@ -121,6 +130,7 @@
@Test
public void testAction() {
+ assumeFalse(isWatch);
sFlag = false;
CountDownLatch latch = new CountDownLatch(1);
BroadcastReceiver receiver = new BroadcastReceiver() {
@@ -155,6 +165,7 @@
@Test
public void testInt() {
+ assumeFalse(isWatch);
Uri uri = BASE_URI.buildUpon().appendPath("int").build();
Slice s = mSliceManager.bindSlice(uri, Collections.emptySet());
assertEquals(uri, s.getUri());
@@ -167,6 +178,7 @@
@Test
public void testTimestamp() {
+ assumeFalse(isWatch);
Uri uri = BASE_URI.buildUpon().appendPath("timestamp").build();
Slice s = mSliceManager.bindSlice(uri,
Collections.emptySet());
@@ -180,6 +192,7 @@
@Test
public void testHints() {
+ assumeFalse(isWatch);
// Note this tests that hints are propagated through to the client but not that any specific
// hints have any effects.
Uri uri = BASE_URI.buildUpon().appendPath("hints").build();
@@ -194,6 +207,7 @@
@Test
public void testHasHints() {
+ assumeFalse(isWatch);
Uri uri = BASE_URI.buildUpon().appendPath("hints").build();
Slice s = mSliceManager.bindSlice(uri, Collections.emptySet());
@@ -203,6 +217,7 @@
@Test
public void testBundle() {
+ assumeFalse(isWatch);
Uri uri = BASE_URI.buildUpon().appendPath("bundle").build();
Slice s = mSliceManager.bindSlice(uri, Collections.emptySet());
assertEquals(uri, s.getUri());
@@ -217,6 +232,7 @@
@Test
public void testGetDescendants() {
+ assumeFalse(isWatch);
Collection<Uri> allUris = mSliceManager.getSliceDescendants(BASE_URI);
assertEquals(SliceProvider.PATHS.length, allUris.size());
Iterator<Uri> it = allUris.iterator();
@@ -230,6 +246,7 @@
@Test
public void testGetSliceSpec() {
+ assumeFalse(isWatch);
Uri uri = BASE_URI.buildUpon().appendPath("spec").build();
Slice s = mSliceManager.bindSlice(uri, Collections.emptySet());
assertEquals(new SliceSpec(SliceProvider.SPEC_TYPE, SliceProvider.SPEC_REV), s.getSpec());
diff --git a/tests/tests/slice/src/android/slice/cts/SliceManagerTest.java b/tests/tests/slice/src/android/slice/cts/SliceManagerTest.java
index 69d8d80..37ced3d 100644
--- a/tests/tests/slice/src/android/slice/cts/SliceManagerTest.java
+++ b/tests/tests/slice/src/android/slice/cts/SliceManagerTest.java
@@ -16,6 +16,8 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeFalse;
+import android.content.pm.PackageManager;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
@@ -54,9 +56,12 @@
private static final Uri BASE_URI = Uri.parse("content://android.slice.cts.local/main");
private final Context mContext = InstrumentationRegistry.getContext();
private final SliceManager mSliceManager = mContext.getSystemService(SliceManager.class);
+ private static final String FEATURE_WATCH = "android.hardware.type.watch";
+ private final boolean isWatch = mContext.getPackageManager().hasSystemFeature(FEATURE_WATCH);
@Before
public void setup() {
+ assumeFalse(isWatch);
LocalSliceProvider.sProxy = mock(SliceProvider.class);
try {
mSliceManager.unpinSlice(BASE_URI);
@@ -66,6 +71,9 @@
@After
public void teardown() throws Exception {
+ if (isWatch) {
+ return;
+ }
try {
mSliceManager.unpinSlice(BASE_URI);
} catch (Exception e) {
@@ -74,6 +82,7 @@
@Test
public void testPinSlice() throws Exception {
+ assumeFalse(isWatch);
mSliceManager.pinSlice(BASE_URI, Collections.emptySet());
verify(LocalSliceProvider.sProxy, timeout(2000)).onSlicePinned(eq(BASE_URI));
@@ -81,6 +90,7 @@
@Test
public void testUnpinSlice() throws Exception {
+ assumeFalse(isWatch);
mSliceManager.pinSlice(BASE_URI, Collections.emptySet());
verify(LocalSliceProvider.sProxy, timeout(2000)).onSlicePinned(eq(BASE_URI));
@@ -92,6 +102,7 @@
@Test
public void testPinList() {
+ assumeFalse(isWatch);
Uri uri = BASE_URI;
Uri longerUri = uri.buildUpon().appendPath("something").build();
try {
@@ -111,6 +122,7 @@
@Test
public void testMapIntentToUri() {
+ assumeFalse(isWatch);
Intent intent = new Intent("android.slice.cts.action.TEST_ACTION");
intent.setPackage("android.slice.cts");
intent.putExtra("path", "intent");
@@ -127,6 +139,7 @@
@Test
public void testOnCreatePermissionSlice() {
+ assumeFalse(isWatch);
LocalSliceProvider.sAnswer = invocation -> {
throw new SecurityException("No slices allowed");
};
diff --git a/tests/tests/slice/src/android/slice/cts/SlicePermissionsTest.java b/tests/tests/slice/src/android/slice/cts/SlicePermissionsTest.java
index 5081943..15ffab3 100644
--- a/tests/tests/slice/src/android/slice/cts/SlicePermissionsTest.java
+++ b/tests/tests/slice/src/android/slice/cts/SlicePermissionsTest.java
@@ -18,6 +18,8 @@
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assume.assumeFalse;
+import android.content.pm.PackageManager;
import android.app.slice.SliceManager;
import android.content.Context;
@@ -42,9 +44,12 @@
private int mTestUid;
private int mTestPid;
private SliceManager mSliceManager;
+ private static final String FEATURE_WATCH = "android.hardware.type.watch";
+ private final boolean isWatch = mContext.getPackageManager().hasSystemFeature(FEATURE_WATCH);
@Before
public void setup() throws NameNotFoundException {
+ assumeFalse(isWatch);
mSliceManager = mContext.getSystemService(SliceManager.class);
mTestPkg = mContext.getPackageName();
mTestUid = mContext.getPackageManager().getPackageUid(mTestPkg, 0);
@@ -53,11 +58,15 @@
@After
public void tearDown() {
+ if (isWatch) {
+ return;
+ }
mSliceManager.revokeSlicePermission(mTestPkg, BASE_URI);
}
@Test
public void testGrant() {
+ assumeFalse(isWatch);
assertEquals(PERMISSION_DENIED,
mSliceManager.checkSlicePermission(BASE_URI, mTestPid, mTestUid));
@@ -69,6 +78,7 @@
@Test
public void testGrantParent() {
+ assumeFalse(isWatch);
Uri uri = BASE_URI.buildUpon()
.appendPath("something")
.build();
@@ -84,6 +94,7 @@
@Test
public void testGrantParentExpands() {
+ assumeFalse(isWatch);
Uri uri = BASE_URI.buildUpon()
.appendPath("something")
.build();
@@ -110,6 +121,7 @@
@Test
public void testGrantChild() {
+ assumeFalse(isWatch);
Uri uri = BASE_URI.buildUpon()
.appendPath("something")
.build();
@@ -126,6 +138,7 @@
@Test
public void testRevoke() {
+ assumeFalse(isWatch);
assertEquals(PERMISSION_DENIED,
mSliceManager.checkSlicePermission(BASE_URI, mTestPid, mTestUid));
@@ -142,6 +155,7 @@
@Test
public void testRevokeParent() {
+ assumeFalse(isWatch);
Uri uri = BASE_URI.buildUpon()
.appendPath("something")
.build();
@@ -162,6 +176,7 @@
@Test
public void testRevokeChild() {
+ assumeFalse(isWatch);
Uri uri = BASE_URI.buildUpon()
.appendPath("something")
.build();