diff options
author | Scott Lobdell <slobdell@google.com> | 2021-07-09 05:33:36 +0000 |
---|---|---|
committer | Scott Lobdell <slobdell@google.com> | 2021-07-09 05:33:36 +0000 |
commit | 8507fe74dccb3114f7942bb3ca2087dab2c890e6 (patch) | |
tree | 5d15051c03662b66bb54d04f158eb1b0ca623c44 /tests | |
parent | 70ec282c1bd5e68015ed9412a730f5254ee6585c (diff) | |
parent | 9dd561f2a032908f6c916be577f6a7136c9b03ef (diff) |
Merge SP1A.210624.001
Change-Id: I96a39cdca22771b76e89caebd53ed52416005092
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Internal/src/android/app/WallpaperColorsTest.java | 23 | ||||
-rw-r--r-- | tests/vcn/java/com/android/server/vcn/VcnTest.java | 21 |
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/Internal/src/android/app/WallpaperColorsTest.java b/tests/Internal/src/android/app/WallpaperColorsTest.java index 45d3dade82b6..9ffb236d3f59 100644 --- a/tests/Internal/src/android/app/WallpaperColorsTest.java +++ b/tests/Internal/src/android/app/WallpaperColorsTest.java @@ -20,6 +20,7 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; +import android.os.Parcel; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; @@ -106,4 +107,26 @@ public class WallpaperColorsTest { // This would crash: canvas.drawBitmap(image, 0, 0, new Paint()); } + + /** + * Parcelled WallpaperColors object should equal the original. + */ + @Test + public void testParcelUnparcel() { + Bitmap image = Bitmap.createBitmap(300, 300, Bitmap.Config.ARGB_8888); + WallpaperColors colors = WallpaperColors.fromBitmap(image); + Parcel parcel = Parcel.obtain(); + colors.writeToParcel(parcel, 0); + parcel.setDataPosition(0); + WallpaperColors reconstructed = new WallpaperColors(parcel); + parcel.recycle(); + Assert.assertEquals("WallpaperColors recreated from Parcel should equal original", + colors, reconstructed); + Assert.assertEquals("getAllColors() on WallpaperColors recreated from Parcel should" + + "return the same as the original", + colors.getAllColors(), reconstructed.getAllColors()); + Assert.assertEquals("getMainColors() on WallpaperColors recreated from Parcel should" + + "return the same as the original", + colors.getMainColors(), reconstructed.getMainColors()); + } } diff --git a/tests/vcn/java/com/android/server/vcn/VcnTest.java b/tests/vcn/java/com/android/server/vcn/VcnTest.java index f681ee19ab12..5d2f9d748581 100644 --- a/tests/vcn/java/com/android/server/vcn/VcnTest.java +++ b/tests/vcn/java/com/android/server/vcn/VcnTest.java @@ -242,6 +242,27 @@ public class VcnTest { verifyUpdateSubscriptionSnapshotNotifiesGatewayConnections(VCN_STATUS_CODE_SAFE_MODE); } + @Test + public void testSubscriptionSnapshotUpdatesMobileDataState() { + final NetworkRequestListener requestListener = verifyAndGetRequestListener(); + startVcnGatewayWithCapabilities(requestListener, TEST_CAPS[0]); + + // Expect mobile data enabled from setUp() + assertTrue(mVcn.isMobileDataEnabled()); + + final TelephonySubscriptionSnapshot updatedSnapshot = + mock(TelephonySubscriptionSnapshot.class); + doReturn(TEST_SUB_IDS_IN_GROUP) + .when(updatedSnapshot) + .getAllSubIdsInGroup(eq(TEST_SUB_GROUP)); + doReturn(false).when(mTelephonyManager).isDataEnabled(); + + mVcn.updateSubscriptionSnapshot(updatedSnapshot); + mTestLooper.dispatchAll(); + + assertFalse(mVcn.isMobileDataEnabled()); + } + private void triggerVcnRequestListeners(NetworkRequestListener requestListener) { for (final int[] caps : TEST_CAPS) { startVcnGatewayWithCapabilities(requestListener, caps); |