Added unit test for activity start interceptor
Short test to catch regressions, only the suspended by an app with
SUSPEND_APPS case was missing.
Test: atest com.android.server.am.ActivityStartInterceptorTest
Bug: 74336673
Change-Id: I23e37580451c1c28dc5d4d37a72f9b776c779314
diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityStartInterceptorTest.java b/services/tests/servicestests/src/com/android/server/am/ActivityStartInterceptorTest.java
index a14b950..b4b34c5 100644
--- a/services/tests/servicestests/src/com/android/server/am/ActivityStartInterceptorTest.java
+++ b/services/tests/servicestests/src/com/android/server/am/ActivityStartInterceptorTest.java
@@ -40,6 +40,7 @@
import android.support.test.filters.SmallTest;
import android.testing.DexmakerShareClassLoaderRule;
+import com.android.internal.app.SuspendedAppActivity;
import com.android.internal.app.UnlaunchableAppActivity;
import com.android.server.LocalServices;
import com.android.server.pm.PackageManagerService;
@@ -150,6 +151,28 @@
}
@Test
+ public void testSuspendedPackage() {
+ mAInfo.applicationInfo.flags = FLAG_SUSPENDED;
+ final String suspendingPackage = "com.test.suspending.package";
+ final String dialogMessage = "Test Message";
+ when(mPackageManagerInternal.getSuspendingPackage(TEST_PACKAGE_NAME, TEST_USER_ID))
+ .thenReturn(suspendingPackage);
+ when(mPackageManagerInternal.getSuspendedDialogMessage(TEST_PACKAGE_NAME, TEST_USER_ID))
+ .thenReturn(dialogMessage);
+ // THEN calling intercept returns true
+ assertTrue(mInterceptor.intercept(null, null, mAInfo, null, null, 0, 0, null));
+
+ // Check intent parameters
+ assertEquals(dialogMessage,
+ mInterceptor.mIntent.getStringExtra(SuspendedAppActivity.EXTRA_DIALOG_MESSAGE));
+ assertEquals(suspendingPackage,
+ mInterceptor.mIntent.getStringExtra(SuspendedAppActivity.EXTRA_SUSPENDING_PACKAGE));
+ assertEquals(TEST_PACKAGE_NAME,
+ mInterceptor.mIntent.getStringExtra(SuspendedAppActivity.EXTRA_SUSPENDED_PACKAGE));
+ assertEquals(TEST_USER_ID, mInterceptor.mIntent.getIntExtra(Intent.EXTRA_USER_ID, -1000));
+ }
+
+ @Test
public void testInterceptQuietProfile() {
// GIVEN that the user the activity is starting as is currently in quiet mode
when(mUserManager.isQuietModeEnabled(eq(UserHandle.of(TEST_USER_ID)))).thenReturn(true);