Merge "Improved ViewTest CTS test"
diff --git a/tests/app/src/android/app/cts/NotificationTest.java b/tests/app/src/android/app/cts/NotificationTest.java
index 3f76a47..c340032 100644
--- a/tests/app/src/android/app/cts/NotificationTest.java
+++ b/tests/app/src/android/app/cts/NotificationTest.java
@@ -670,22 +670,6 @@
}
}
- public void testBubbleMetadataBuilder_throwForNoTitle() {
- PendingIntent bubbleIntent = PendingIntent.getActivity(mContext, 0, new Intent(), 0);
- Icon icon = Icon.createWithResource(mContext, 1);
- Notification.BubbleMetadata.Builder metadataBuilder =
- new Notification.BubbleMetadata.Builder()
- .setDesiredHeight(BUBBLE_HEIGHT)
- .setIcon(icon)
- .setIntent(bubbleIntent);
- try {
- metadataBuilder.build();
- fail("Should have thrown IllegalStateException, no title");
- } catch (IllegalStateException e) {
- // expected
- }
- }
-
public void testBubbleMetadataBuilder_throwForNoIcon() {
PendingIntent bubbleIntent = PendingIntent.getActivity(mContext, 0, new Intent(), 0);
Notification.BubbleMetadata.Builder metadataBuilder =
diff --git a/tests/contentcaptureservice/src/android/contentcaptureservice/cts/Assertions.java b/tests/contentcaptureservice/src/android/contentcaptureservice/cts/Assertions.java
index 89d5510..488bddd 100644
--- a/tests/contentcaptureservice/src/android/contentcaptureservice/cts/Assertions.java
+++ b/tests/contentcaptureservice/src/android/contentcaptureservice/cts/Assertions.java
@@ -31,7 +31,6 @@
import android.content.LocusId;
import android.contentcaptureservice.cts.CtsContentCaptureService.Session;
-import android.net.Uri;
import android.util.Log;
import android.view.Display;
import android.view.View;
@@ -115,7 +114,7 @@
public static void assertChildSessionContext(@NonNull Session session,
@NonNull String expectedId) {
assertChildSessionContext(session);
- assertThat(session.context.getLocusId()).isEqualTo(new LocusId(Uri.parse(expectedId)));
+ assertThat(session.context.getLocusId()).isEqualTo(new LocusId(expectedId));
}
/**
diff --git a/tests/contentcaptureservice/src/android/contentcaptureservice/cts/ChildlessActivityTest.java b/tests/contentcaptureservice/src/android/contentcaptureservice/cts/ChildlessActivityTest.java
index cea22d6..1c89177 100644
--- a/tests/contentcaptureservice/src/android/contentcaptureservice/cts/ChildlessActivityTest.java
+++ b/tests/contentcaptureservice/src/android/contentcaptureservice/cts/ChildlessActivityTest.java
@@ -46,7 +46,6 @@
import android.contentcaptureservice.cts.CtsContentCaptureService.Session;
import android.contentcaptureservice.cts.common.ActivitiesWatcher.ActivityWatcher;
import android.contentcaptureservice.cts.common.ActivityLauncher;
-import android.net.Uri;
import android.os.SystemClock;
import android.platform.test.annotations.AppModeFull;
import android.provider.DeviceConfig;
@@ -1215,6 +1214,6 @@
@NonNull
private ContentCaptureContext.Builder newContentCaptureContextBuilder(@NonNull String id) {
- return new ContentCaptureContext.Builder(new LocusId(Uri.parse(id)));
+ return new ContentCaptureContext.Builder(new LocusId(id));
}
}
diff --git a/tests/contentcaptureservice/src/android/contentcaptureservice/cts/LoginActivityTest.java b/tests/contentcaptureservice/src/android/contentcaptureservice/cts/LoginActivityTest.java
index 2bb14e2..44e184f 100644
--- a/tests/contentcaptureservice/src/android/contentcaptureservice/cts/LoginActivityTest.java
+++ b/tests/contentcaptureservice/src/android/contentcaptureservice/cts/LoginActivityTest.java
@@ -33,6 +33,7 @@
import static android.contentcaptureservice.cts.Helper.newImportantView;
import static android.contentcaptureservice.cts.common.ActivitiesWatcher.ActivityLifecycle.DESTROYED;
import static android.contentcaptureservice.cts.common.ActivitiesWatcher.ActivityLifecycle.RESUMED;
+import static android.view.contentcapture.UserDataRemovalRequest.FLAG_IS_PREFIX;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
@@ -41,7 +42,6 @@
import android.contentcaptureservice.cts.CtsContentCaptureService.Session;
import android.contentcaptureservice.cts.common.ActivitiesWatcher.ActivityWatcher;
import android.contentcaptureservice.cts.common.DoubleVisitor;
-import android.net.Uri;
import android.os.Bundle;
import android.platform.test.annotations.AppModeFull;
import android.util.Log;
@@ -72,6 +72,8 @@
private static final String TAG = LoginActivityTest.class.getSimpleName();
+ private static final int NO_FLAGS = 0;
+
private static final ActivityTestRule<LoginActivity> sActivityRule = new ActivityTestRule<>(
LoginActivity.class, false, false);
@@ -512,15 +514,15 @@
}
@Test
- public void testUserDataRemovalRequest_oneUri() throws Exception {
+ public void testUserDataRemovalRequest_oneId() throws Exception {
final CtsContentCaptureService service = enableService();
final ActivityWatcher watcher = startWatcher();
- final LocusId locusId = new LocusId(Uri.parse("com.example"));
+ final LocusId locusId = new LocusId("com.example");
LoginActivity.onRootView((activity, rootView) -> activity.getContentCaptureManager()
.removeUserData(new UserDataRemovalRequest.Builder()
- .addLocusId(locusId, false)
+ .addLocusId(locusId, NO_FLAGS)
.build()));
final LoginActivity activity = launchActivity();
@@ -539,21 +541,21 @@
final LocusIdRequest actualRequest = requests.get(0);
assertThat(actualRequest.getLocusId()).isEqualTo(locusId);
- assertThat(actualRequest.isRecursive()).isFalse();
+ assertThat(actualRequest.getFlags()).isEqualTo(NO_FLAGS);
}
@Test
- public void testUserDataRemovalRequest_manyUris() throws Exception {
+ public void testUserDataRemovalRequest_manyIds() throws Exception {
final CtsContentCaptureService service = enableService();
final ActivityWatcher watcher = startWatcher();
- final LocusId locusId1 = new LocusId(Uri.parse("com.example"));
- final LocusId locusId2 = new LocusId(Uri.parse("com.example2"));
+ final LocusId locusId1 = new LocusId("com.example");
+ final LocusId locusId2 = new LocusId("com.example2");
LoginActivity.onRootView((activity, rootView) -> activity.getContentCaptureManager()
.removeUserData(new UserDataRemovalRequest.Builder()
- .addLocusId(locusId1, false)
- .addLocusId(locusId2, true)
+ .addLocusId(locusId1, NO_FLAGS)
+ .addLocusId(locusId2, FLAG_IS_PREFIX)
.build()));
final LoginActivity activity = launchActivity();
@@ -572,11 +574,11 @@
final LocusIdRequest actualRequest1 = requests.get(0);
assertThat(actualRequest1.getLocusId()).isEqualTo(locusId1);
- assertThat(actualRequest1.isRecursive()).isFalse();
+ assertThat(actualRequest1.getFlags()).isEqualTo(NO_FLAGS);
final LocusIdRequest actualRequest2 = requests.get(1);
assertThat(actualRequest2.getLocusId()).isEqualTo(locusId2);
- assertThat(actualRequest2.isRecursive()).isTrue();
+ assertThat(actualRequest2.getFlags()).isEqualTo(FLAG_IS_PREFIX);
}
@Test
@@ -698,10 +700,10 @@
* {@link #assertContentCaptureContext(ContentCaptureContext)}.
*/
private ContentCaptureContext newContentCaptureContext() {
- final Uri uri = Uri.parse("file://dev/null");
+ final String id = "file://dev/null";
final Bundle bundle = new Bundle();
bundle.putString("DUDE", "SWEET");
- return new ContentCaptureContext.Builder(new LocusId(uri)).setExtras(bundle).build();
+ return new ContentCaptureContext.Builder(new LocusId(id)).setExtras(bundle).build();
}
/**
@@ -709,8 +711,8 @@
*/
private void assertContentCaptureContext(@NonNull ContentCaptureContext context) {
assertWithMessage("null context").that(context).isNotNull();
- assertWithMessage("wrong URI on context %s", context).that(context.getLocusId().getUri())
- .isEqualTo(Uri.parse("file://dev/null"));
+ assertWithMessage("wrong ID on context %s", context).that(context.getLocusId().getId())
+ .isEqualTo("file://dev/null");
final Bundle extras = context.getExtras();
assertWithMessage("no extras on context %s", context).that(extras).isNotNull();
assertWithMessage("wrong number of extras on context %s", context).that(extras.size())
diff --git a/tests/contentcaptureservice/src/android/contentcaptureservice/cts/unit/ContentCaptureContextTest.java b/tests/contentcaptureservice/src/android/contentcaptureservice/cts/unit/ContentCaptureContextTest.java
index 4b83612..77ae053 100644
--- a/tests/contentcaptureservice/src/android/contentcaptureservice/cts/unit/ContentCaptureContextTest.java
+++ b/tests/contentcaptureservice/src/android/contentcaptureservice/cts/unit/ContentCaptureContextTest.java
@@ -21,7 +21,6 @@
import static org.testng.Assert.assertThrows;
import android.content.LocusId;
-import android.net.Uri;
import android.os.Bundle;
import android.os.Parcel;
import android.platform.test.annotations.AppModeFull;
@@ -39,11 +38,12 @@
@RunWith(JUnit4.class)
public class ContentCaptureContextTest {
- private static final Uri URI = Uri.parse("file://dev/null");
+ private static final String ID = "4815162342";
- private static final LocusId ID = new LocusId(URI);
+ private static final LocusId LOCUS_ID = new LocusId(ID);
- private final ContentCaptureContext.Builder mBuilder = new ContentCaptureContext.Builder(ID);
+ private final ContentCaptureContext.Builder mBuilder = new ContentCaptureContext.Builder(
+ LOCUS_ID);
private final Bundle mExtras = new Bundle();
@@ -83,7 +83,7 @@
public void testGetId() {
final ContentCaptureContext context = mBuilder.build();
assertThat(context).isNotNull();
- assertThat(context.getLocusId()).isEqualTo(ID);
+ assertThat(context.getLocusId()).isEqualTo(LOCUS_ID);
}
@Test
@@ -114,17 +114,17 @@
@Test
public void testForLocus_valid() {
- final ContentCaptureContext context = ContentCaptureContext.forLocusId(URI);
+ final ContentCaptureContext context = ContentCaptureContext.forLocusId(ID);
assertThat(context).isNotNull();
assertThat(context.getExtras()).isNull();
final LocusId locusId = context.getLocusId();
assertThat(locusId).isNotNull();
- assertThat(locusId.getUri()).isEqualTo(URI);
+ assertThat(locusId.getId()).isEqualTo(ID);
}
private void assertEverything(@NonNull ContentCaptureContext context) {
assertThat(context).isNotNull();
- assertThat(context.getLocusId()).isEqualTo(ID);
+ assertThat(context.getLocusId()).isEqualTo(LOCUS_ID);
assertExtras(context.getExtras());
}
diff --git a/tests/contentcaptureservice/src/android/contentcaptureservice/cts/unit/UserDataRemovalRequestTest.java b/tests/contentcaptureservice/src/android/contentcaptureservice/cts/unit/UserDataRemovalRequestTest.java
index 92edcf3..b3ad57a 100644
--- a/tests/contentcaptureservice/src/android/contentcaptureservice/cts/unit/UserDataRemovalRequestTest.java
+++ b/tests/contentcaptureservice/src/android/contentcaptureservice/cts/unit/UserDataRemovalRequestTest.java
@@ -15,48 +15,57 @@
*/
package android.contentcaptureservice.cts.unit;
+import static android.view.contentcapture.UserDataRemovalRequest.FLAG_IS_PREFIX;
+
import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth.assertWithMessage;
import static org.testng.Assert.assertThrows;
import android.content.LocusId;
-import android.net.Uri;
+import android.os.Parcel;
import android.platform.test.annotations.AppModeFull;
import android.view.contentcapture.UserDataRemovalRequest;
+import android.view.contentcapture.UserDataRemovalRequest.LocusIdRequest;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
+import java.util.List;
+
@AppModeFull(reason = "unit test")
@RunWith(MockitoJUnitRunner.class)
public class UserDataRemovalRequestTest {
- private final LocusId mLocusId = new LocusId(Uri.parse("content://com.example/"));
+ private static final int NO_FLAGS = 0;
+
+ private final LocusId mLocusId = new LocusId("content://com.example/");
private UserDataRemovalRequest.Builder mBuilder = new UserDataRemovalRequest.Builder();
@Test
public void testBuilder_addLocusId_invalid() {
- assertThrows(NullPointerException.class, () -> mBuilder.addLocusId(null, false));
+ assertThrows(NullPointerException.class, () -> mBuilder.addLocusId(null, NO_FLAGS));
+ assertThrows(NullPointerException.class, () -> mBuilder.addLocusId(null, 666));
}
@Test
public void testBuilder_addLocusId_valid() {
- assertThat(mBuilder.addLocusId(mLocusId, false)).isNotNull();
- assertThat(mBuilder.addLocusId(new LocusId(Uri.parse("content://com.example2")), true))
+ assertThat(mBuilder.addLocusId(mLocusId, NO_FLAGS)).isNotNull();
+ assertThat(mBuilder.addLocusId(new LocusId("content://com.example2"), FLAG_IS_PREFIX))
.isNotNull();
}
@Test
- public void testBuilder_addUriAfterForEverything() {
+ public void testBuilder_addLocusIdAfterForEverything() {
assertThat(mBuilder.forEverything()).isNotNull();
- assertThrows(IllegalStateException.class, () -> mBuilder.addLocusId(mLocusId, false));
+ assertThrows(IllegalStateException.class, () -> mBuilder.addLocusId(mLocusId, NO_FLAGS));
}
@Test
- public void testBuilder_forEverythingAfterAddingUri() {
- assertThat(mBuilder.addLocusId(mLocusId, false)).isNotNull();
+ public void testBuilder_forEverythingAfterAddingLocusId() {
+ assertThat(mBuilder.addLocusId(mLocusId, NO_FLAGS)).isNotNull();
assertThrows(IllegalStateException.class, () -> mBuilder.forEverything());
}
@@ -66,19 +75,96 @@
}
@Test
- public void testBuild_valid() {
- assertThat(new UserDataRemovalRequest.Builder().forEverything().build())
- .isNotNull();
- assertThat(new UserDataRemovalRequest.Builder().addLocusId(mLocusId, false).build())
- .isNotNull();
+ public void testBuild_validForEverything_directly() {
+ final UserDataRemovalRequest request = new UserDataRemovalRequest.Builder().forEverything()
+ .build();
+ assertForEverything(request);
+ }
+
+ @Test
+ public void testBuild_validForEverything_parcel() {
+ final UserDataRemovalRequest request = new UserDataRemovalRequest.Builder().forEverything()
+ .build();
+ final UserDataRemovalRequest clone = cloneThroughParcel(request);
+ assertForEverything(clone);
+ }
+
+ private void assertForEverything(final UserDataRemovalRequest request) {
+ assertThat(request).isNotNull();
+ assertThat(request.isForEverything()).isTrue();
+ assertThat(request.getLocusIdRequests()).isNull();
+ }
+
+ @Test
+ public void testBuild_validForIds_directly() {
+ final UserDataRemovalRequest request = buildForIds();
+ assertForIds(request);
+ }
+
+ @Test
+ public void testBuild_validForIds_parcel() {
+ final UserDataRemovalRequest request = buildForIds();
+ final UserDataRemovalRequest clone = cloneThroughParcel(request);
+ assertForIds(clone);
+ }
+
+ private UserDataRemovalRequest buildForIds() {
+ final UserDataRemovalRequest.Builder builder = new UserDataRemovalRequest.Builder();
+ assertThat(builder.addLocusId(new LocusId("prefix1True"), FLAG_IS_PREFIX)).isNotNull();
+ assertThat(builder.addLocusId(new LocusId("prefix2False"), NO_FLAGS)).isNotNull();
+
+ return builder.build();
+ }
+
+ private void assertForIds(UserDataRemovalRequest request) {
+ assertThat(request).isNotNull();
+ assertThat(request.isForEverything()).isFalse();
+ final List<LocusIdRequest> requests = request.getLocusIdRequests();
+ assertThat(requests).isNotNull();
+ assertThat(requests).hasSize(2);
+ assertRequest(requests, 0, "prefix1True", FLAG_IS_PREFIX);
+ assertRequest(requests, 1, "prefix2False", NO_FLAGS);
}
@Test
public void testNoMoreInteractionsAfterBuild() {
assertThat(mBuilder.forEverything().build()).isNotNull();
- assertThrows(IllegalStateException.class, () -> mBuilder.addLocusId(mLocusId, false));
+ assertThrows(IllegalStateException.class, () -> mBuilder.addLocusId(mLocusId, NO_FLAGS));
+ assertThrows(IllegalStateException.class,
+ () -> mBuilder.addLocusId(mLocusId, FLAG_IS_PREFIX));
assertThrows(IllegalStateException.class, () -> mBuilder.forEverything());
assertThrows(IllegalStateException.class, () -> mBuilder.build());
}
+
+ private void assertRequest(List<LocusIdRequest> requests, int index, String expectedId,
+ int expectedFlags) {
+ final LocusIdRequest request = requests.get(index);
+ assertWithMessage("no request at index %s: %s", index, requests).that(request).isNotNull();
+ final LocusId actualId = request.getLocusId();
+ assertWithMessage("no id at index %s: %s", index, request).that(actualId).isNotNull();
+ assertWithMessage("wrong id at index %s: %s", index, request).that(actualId.getId())
+ .isEqualTo(expectedId);
+ assertWithMessage("wrong flags at index %s: %s", index, request)
+ .that(request.getFlags()).isEqualTo(expectedFlags);
+ }
+
+ private UserDataRemovalRequest cloneThroughParcel(UserDataRemovalRequest request) {
+ final Parcel parcel = Parcel.obtain();
+
+ try {
+ // Write to parcel
+ parcel.setDataPosition(0); // Sanity / paranoid check
+ request.writeToParcel(parcel, 0);
+
+ // Read from parcel
+ parcel.setDataPosition(0);
+ final UserDataRemovalRequest clone = UserDataRemovalRequest.CREATOR
+ .createFromParcel(parcel);
+ assertThat(clone).isNotNull();
+ return clone;
+ } finally {
+ parcel.recycle();
+ }
+ }
}
diff --git a/tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java b/tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
index 2772e66..c1b13f4 100644
--- a/tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
+++ b/tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
@@ -60,6 +60,7 @@
import java.io.IOException;
import java.text.MessageFormat;
+import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -933,6 +934,15 @@
try {
mUsageStatsManager.registerAppUsageLimitObserver(observerId, packages,
+ Duration.ofHours(1), Duration.ofHours(1), null);
+ fail("Expected SecurityException for an app not holding OBSERVE_APP_USAGE permission.");
+ } catch (SecurityException e) {
+ // Exception expected
+ }
+
+ // STOPSHIP b/126917290: remove this check when deprecated method is removed.
+ try {
+ mUsageStatsManager.registerAppUsageLimitObserver(observerId, packages,
1, java.util.concurrent.TimeUnit.HOURS, null);
fail("Expected SecurityException for an app not holding OBSERVE_APP_USAGE permission.");
} catch (SecurityException e) {
diff --git a/tests/tests/content/src/android/content/cts/LocusIdTest.java b/tests/tests/content/src/android/content/cts/LocusIdTest.java
index 4f647df..89b33a4 100644
--- a/tests/tests/content/src/android/content/cts/LocusIdTest.java
+++ b/tests/tests/content/src/android/content/cts/LocusIdTest.java
@@ -20,7 +20,6 @@
import static org.testng.Assert.assertThrows;
import android.content.LocusId;
-import android.net.Uri;
import android.os.Parcel;
import android.platform.test.annotations.AppModeFull;
@@ -34,8 +33,8 @@
@RunWith(JUnit4.class)
public class LocusIdTest {
- private static final Uri URI = Uri.parse("file://dev/null");
- private static final Uri ANOTHER_URI = Uri.parse("http://h.t.t.p");
+ private static final String ID = "file://dev/null";
+ private static final String ANOTHER_ID = "http://h.t.t.p";
@Test
public void testConstructor_nullId() {
@@ -44,30 +43,30 @@
@Test
public void testParcel() {
- final LocusId clone = cloneThroughParcel(new LocusId(URI));
- assertThat(clone.getUri()).isEqualTo(URI);
+ final LocusId clone = cloneThroughParcel(new LocusId(ID));
+ assertThat(clone.getId()).isEqualTo(ID);
}
@Test
public void testEquals() {
- final LocusId id1 = new LocusId(URI);
- final LocusId id2 = new LocusId(URI);
+ final LocusId id1 = new LocusId(ID);
+ final LocusId id2 = new LocusId(ID);
assertThat(id1).isEqualTo(id2);
assertThat(id2).isEqualTo(id1);
- final LocusId id3 = new LocusId(ANOTHER_URI);
+ final LocusId id3 = new LocusId(ANOTHER_ID);
assertThat(id1).isNotEqualTo(id3);
assertThat(id3).isNotEqualTo(id1);
}
@Test
public void testHashcode() {
- final LocusId id1 = new LocusId(URI);
- final LocusId id2 = new LocusId(URI);
+ final LocusId id1 = new LocusId(ID);
+ final LocusId id2 = new LocusId(ID);
assertThat(id1.hashCode()).isEqualTo(id2.hashCode());
assertThat(id2.hashCode()).isEqualTo(id1.hashCode());
- final LocusId id3 = new LocusId(ANOTHER_URI);
+ final LocusId id3 = new LocusId(ANOTHER_ID);
assertThat(id1.hashCode()).isNotEqualTo(id3.hashCode());
assertThat(id3.hashCode()).isNotEqualTo(id1.hashCode());
}
diff --git a/tests/tests/content/src/android/content/pm/cts/LauncherAppsTest.java b/tests/tests/content/src/android/content/pm/cts/LauncherAppsTest.java
index 0a8df45..b5e9ec7 100644
--- a/tests/tests/content/src/android/content/pm/cts/LauncherAppsTest.java
+++ b/tests/tests/content/src/android/content/pm/cts/LauncherAppsTest.java
@@ -37,12 +37,14 @@
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
+@Ignore("Can be enabled only after b/126946674 is fixed")
@RunWith(AndroidJUnit4.class)
public class LauncherAppsTest {
diff --git a/tests/tests/graphics/src/android/graphics/cts/ImageDecoderTest.java b/tests/tests/graphics/src/android/graphics/cts/ImageDecoderTest.java
index aff5ea2..c8ca5af 100644
--- a/tests/tests/graphics/src/android/graphics/cts/ImageDecoderTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/ImageDecoderTest.java
@@ -2340,4 +2340,13 @@
ImageDecoder.Source src = mCreators[0].apply(R.drawable.animated);
testReuse(src, "animated.gif");
}
+
+ @Test
+ public void testIsMimeTypeSupported() {
+ for (Record record : RECORDS) {
+ assertTrue(record.mimeType, ImageDecoder.isMimeTypeSupported(record.mimeType));
+ }
+
+ assertFalse(ImageDecoder.isMimeTypeSupported("image/x-does-not-exist"));
+ }
}
diff --git a/tests/tests/location/src/android/location/cts/LocationTest.java b/tests/tests/location/src/android/location/cts/LocationTest.java
index 365b471..e7cadf2 100644
--- a/tests/tests/location/src/android/location/cts/LocationTest.java
+++ b/tests/tests/location/src/android/location/cts/LocationTest.java
@@ -422,20 +422,6 @@
assertEquals(12000, location.getElapsedRealtimeNanos());
}
- public void testAccessElapsedRealtimeUncertaintyNanos() {
- Location location = new Location("");
- assertFalse(location.hasElapsedRealtimeUncertaintyNanos());
- assertEquals(0, location.getElapsedRealtimeUncertaintyNanos());
-
- location.setElapsedRealtimeUncertaintyNanos(12000);
- assertEquals(12000, location.getElapsedRealtimeUncertaintyNanos());
- assertTrue(location.hasElapsedRealtimeUncertaintyNanos());
-
- location.reset();
- assertFalse(location.hasElapsedRealtimeUncertaintyNanos());
- assertEquals(0, location.getElapsedRealtimeUncertaintyNanos());
- }
-
public void testSet() {
Location location = new Location("");
diff --git a/tests/tests/net/src/android/net/wifi/aware/cts/SingleDeviceTest.java b/tests/tests/net/src/android/net/wifi/aware/cts/SingleDeviceTest.java
index 61b4f91..389621e 100644
--- a/tests/tests/net/src/android/net/wifi/aware/cts/SingleDeviceTest.java
+++ b/tests/tests/net/src/android/net/wifi/aware/cts/SingleDeviceTest.java
@@ -39,6 +39,7 @@
import android.net.wifi.aware.WifiAwareSession;
import android.os.Handler;
import android.os.HandlerThread;
+import android.os.SystemClock;
import android.test.AndroidTestCase;
import com.android.compatibility.common.util.SystemUtil;
@@ -58,8 +59,8 @@
public class SingleDeviceTest extends AndroidTestCase {
private static final String TAG = "WifiAwareCtsTests";
- // wait for Wi-Fi Aware to become available
- static private final int WAIT_FOR_AWARE_CHANGE_SECS = 10;
+ // wait for Wi-Fi Aware state changes & network requests callbacks
+ static private final int WAIT_FOR_AWARE_CHANGE_SECS = 10; // 10 seconds
private final Object mLock = new Object();
private final HandlerThread mHandlerThread = new HandlerThread("SingleDeviceTest");
@@ -704,7 +705,7 @@
/**
* Request an Aware data-path (open) as a Responder with an arbitrary peer MAC address. Validate
- * that times-out.
+ * that receive an onUnavailable() callback.
*/
public void testDataPathOpenOutOfBandFail() {
if (!TestUtils.shouldTestWifiAware(getContext())) {
@@ -712,28 +713,32 @@
}
MacAddress mac = MacAddress.fromString("00:01:02:03:04:05");
+ // 1. initialize Aware: only purpose is to make sure it is available for OOB data-path
WifiAwareSession session = attachAndGetSession();
PublishConfig publishConfig = new PublishConfig.Builder().setServiceName(
"ValidName").build();
DiscoverySessionCallbackTest discoveryCb = new DiscoverySessionCallbackTest();
- NetworkCallbackTest networkCb = new NetworkCallbackTest();
+ session.publish(publishConfig, discoveryCb, mHandler);
+ assertTrue("Publish started",
+ discoveryCb.waitForCallback(DiscoverySessionCallbackTest.ON_PUBLISH_STARTED));
- // 1. request an AWARE network
+ // 2. request an AWARE network
+ NetworkCallbackTest networkCb = new NetworkCallbackTest();
NetworkRequest nr = new NetworkRequest.Builder().addTransportType(
NetworkCapabilities.TRANSPORT_WIFI_AWARE).setNetworkSpecifier(
session.createNetworkSpecifierOpen(
- WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_RESPONDER,
+ WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR,
mac.toByteArray())).build();
- mConnectivityManager.requestNetwork(nr, networkCb, 2000);
- assertTrue("OnUnavailable received", networkCb.waitForOnUnavailable());
+ mConnectivityManager.requestNetwork(nr, networkCb);
+ assertTrue("OnUnavailable not received", networkCb.waitForOnUnavailable());
session.close();
}
/**
* Request an Aware data-path (encrypted) as a Responder with an arbitrary peer MAC address.
- * Validate that times-out.
+ * Validate that receive an onUnavailable() callback.
*/
public void testDataPathPassphraseOutOfBandFail() {
if (!TestUtils.shouldTestWifiAware(getContext())) {
@@ -741,21 +746,25 @@
}
MacAddress mac = MacAddress.fromString("00:01:02:03:04:05");
+ // 1. initialize Aware: only purpose is to make sure it is available for OOB data-path
WifiAwareSession session = attachAndGetSession();
PublishConfig publishConfig = new PublishConfig.Builder().setServiceName(
"ValidName").build();
DiscoverySessionCallbackTest discoveryCb = new DiscoverySessionCallbackTest();
- NetworkCallbackTest networkCb = new NetworkCallbackTest();
+ session.publish(publishConfig, discoveryCb, mHandler);
+ assertTrue("Publish started",
+ discoveryCb.waitForCallback(DiscoverySessionCallbackTest.ON_PUBLISH_STARTED));
- // 1. request an AWARE network
+ // 2. request an AWARE network
+ NetworkCallbackTest networkCb = new NetworkCallbackTest();
NetworkRequest nr = new NetworkRequest.Builder().addTransportType(
NetworkCapabilities.TRANSPORT_WIFI_AWARE).setNetworkSpecifier(
session.createNetworkSpecifierPassphrase(
- WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_RESPONDER, mac.toByteArray(),
+ WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR, mac.toByteArray(),
"abcdefghihk")).build();
- mConnectivityManager.requestNetwork(nr, networkCb, 2000);
- assertTrue("OnUnavailable received", networkCb.waitForOnUnavailable());
+ mConnectivityManager.requestNetwork(nr, networkCb);
+ assertTrue("OnUnavailable not received", networkCb.waitForOnUnavailable());
session.close();
}
diff --git a/tests/tests/os/src/android/os/cts/HwBinderTest.java b/tests/tests/os/src/android/os/cts/HwBinderTest.java
index d3ebe70..d555219 100644
--- a/tests/tests/os/src/android/os/cts/HwBinderTest.java
+++ b/tests/tests/os/src/android/os/cts/HwBinderTest.java
@@ -16,12 +16,19 @@
package android.os.cts;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import android.hidl.manager.V1_0.IServiceManager;
import android.hidl.manager.V1_0.IServiceNotification;
import android.os.HwBlob;
import android.os.RemoteException;
-import junit.framework.TestCase;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
import java.util.Calendar;
import java.util.concurrent.locks.Condition;
@@ -36,7 +43,8 @@
* because you can't take advantage of the versioning tools, the C++ and Java
* interoperability, etc..
*/
-public class HwBinderTest extends TestCase {
+@RunWith(AndroidJUnit4.class)
+public class HwBinderTest {
private static class MarshalCase {
interface DoMarshalCase {
@@ -86,11 +94,11 @@
}),
new MarshalCase("Float", 4, (blob, offset) -> {
blob.putFloat(offset, 3.0f);
- assertEquals(3.0f, blob.getFloat(offset));
+ assertEquals(3.0f, blob.getFloat(offset), 0.0f);
}),
new MarshalCase("Double", 8, (blob, offset) -> {
blob.putDouble(offset, 3.0);
- assertEquals(3.0, blob.getDouble(offset));
+ assertEquals(3.0, blob.getDouble(offset), 0.0);
}),
new MarshalCase("String", 16, (blob, offset) -> {
blob.putString(offset, "foo");
@@ -123,31 +131,35 @@
}),
new MarshalCase("FloatArray", 8, (blob, offset) -> {
blob.putFloatArray(offset, new float[]{3.0f, 2.0f});
- assertEquals(3.0f, blob.getFloat(offset));
- assertEquals(2.0f, blob.getFloat(offset + 4));
+ assertEquals(3.0f, blob.getFloat(offset), 0.0f);
+ assertEquals(2.0f, blob.getFloat(offset + 4), 0.0f);
}),
new MarshalCase("DoubleArray", 16, (blob, offset) -> {
blob.putDoubleArray(offset, new double[]{3.0, 2.0});
- assertEquals(3.0, blob.getDouble(offset));
- assertEquals(2.0, blob.getDouble(offset + 8));
+ assertEquals(3.0, blob.getDouble(offset), 0.0);
+ assertEquals(2.0, blob.getDouble(offset + 8), 0.0);
}),
};
+ @Test
public void testAccurateMarshall() {
for (MarshalCase marshalCase : sMarshalCases) {
marshalCase.test(0 /* deltaSize */, 0 /* offset */);
}
}
+ @Test
public void testAccurateMarshallWithExtraSpace() {
for (MarshalCase marshalCase : sMarshalCases) {
marshalCase.test(1 /* deltaSize */, 0 /* offset */);
}
}
+ @Test
public void testAccurateMarshallWithExtraSpaceAndOffset() {
for (MarshalCase marshalCase : sMarshalCases) {
marshalCase.test(1 /* deltaSize */, 1 /* offset */);
}
}
+ @Test
public void testNotEnoughSpaceBecauseOfSize() {
for (MarshalCase marshalCase : sMarshalCases) {
try {
@@ -158,6 +170,7 @@
}
}
}
+ @Test
public void testNotEnoughSpaceBecauseOfOffset() {
for (MarshalCase marshalCase : sMarshalCases) {
try {
@@ -168,6 +181,7 @@
}
}
}
+ @Test
public void testNotEnoughSpaceBecauseOfSizeAndOffset() {
for (MarshalCase marshalCase : sMarshalCases) {
try {
@@ -191,6 +205,7 @@
}
}
+ @Test
public void testHwBinder() throws RemoteException {
ServiceNotification notification = new ServiceNotification();
diff --git a/tests/tests/provider/src/android/provider/cts/MediaStoreTest.java b/tests/tests/provider/src/android/provider/cts/MediaStoreTest.java
index f0be336..33d2cf7 100644
--- a/tests/tests/provider/src/android/provider/cts/MediaStoreTest.java
+++ b/tests/tests/provider/src/android/provider/cts/MediaStoreTest.java
@@ -18,6 +18,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -103,6 +104,11 @@
public void testGetVersion() {
// Could be a version string or null...just check it doesn't blow up.
MediaStore.getVersion(getContext());
+
+ // Each volume should have a unique version to help detect data wipes
+ final String internal = MediaStore.getVersion(getContext(), MediaStore.VOLUME_INTERNAL);
+ final String external = MediaStore.getVersion(getContext(), MediaStore.VOLUME_EXTERNAL);
+ assertNotEquals(external, internal);
}
@Test
diff --git a/tests/tests/telephony2/AndroidTest.xml b/tests/tests/telephony2/AndroidTest.xml
index 27b9070..ed815e3 100644
--- a/tests/tests/telephony2/AndroidTest.xml
+++ b/tests/tests/telephony2/AndroidTest.xml
@@ -17,6 +17,8 @@
<option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="telecom" />
<option name="not-shardable" value="true" />
+ <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="CtsTelephony2TestCases.apk" />