Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 49828732 authored by Ben Gruver's avatar Ben Gruver
Browse files

Add new ActivityStartInterceptor test for the harmful app warnings

Test: atest ActivityStartInterceptorTest
Change-Id: Ia8d5fbd569d75da364fc978e432f504a70479a65
parent eb8fd1c6
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.platform.test.annotations.Presubmit;
import android.support.test.filters.SmallTest;

import com.android.internal.app.UnlaunchableAppActivity;
import com.android.internal.app.HarmfulAppWarningActivity;
import com.android.server.LocalServices;
import com.android.server.pm.PackageManagerService;

@@ -163,6 +164,20 @@ public class ActivityStartInterceptorTest {
        assertTrue(CONFIRM_CREDENTIALS_INTENT.filterEquals(mInterceptor.mIntent));
    }

    @Test
    public void testHarmfulAppWarning() {
        // GIVEN the package we're about to launch has a harmful app warning set
        when(mPackageManager.getHarmfulAppWarning(TEST_PACKAGE_NAME, TEST_USER_ID))
                .thenReturn("This app is bad");

        // THEN calling intercept returns true
        assertTrue(mInterceptor.intercept(null, null, mAInfo, null, null, 0, 0, null));

        // THEN the returned intent is the harmful app warning intent
        assertTrue(mInterceptor.mIntent.getComponent().getClassName().equals(
                HarmfulAppWarningActivity.class.getName()));
    }

    @Test
    public void testNoInterception() {
        // GIVEN that none of the interception conditions are met