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

Commit 54b06a3e authored by Brian Lee's avatar Brian Lee Committed by Automerger Merge Worker
Browse files

Merge "Add unit test for...

Merge "Add unit test for createConfirmDeviceCredentialForRemoteValidationIntent" into udc-dev am: 6b7009fa

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23089895



Change-Id: I5b0ae0f8e961de9983ded79e90f2d03356e57365
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 205e61b1 6b7009fa
Loading
Loading
Loading
Loading
+38 −0
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ package android.app;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doReturn;
@@ -26,6 +27,7 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.when;


import android.app.admin.DevicePolicyManager;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;


@@ -209,6 +211,42 @@ public class KeyguardManagerTest {
        verifyDeviceLockedAndRemoveLock();
        verifyDeviceLockedAndRemoveLock();
    }
    }


    @Test
    public void createConfirmDeviceCredentialForRemoteValidationIntent() {
        RemoteLockscreenValidationSession remoteLockscreenValidationSession =
                new RemoteLockscreenValidationSession.Builder()
                        .setSourcePublicKey("sourcePublicKey".getBytes())
                        .build();
        ComponentName componentName = new ComponentName("pkg", "cls");
        String title = "title";
        String description = "description";
        String checkboxLabel = "checkboxLabel";
        String alternateButtonLabel = "alternateButtonLabel";

        Intent intent = mKeyguardManager.createConfirmDeviceCredentialForRemoteValidationIntent(
                remoteLockscreenValidationSession,
                componentName,
                title,
                description,
                checkboxLabel,
                alternateButtonLabel
        );

        assertNotNull(intent);
        assertEquals(KeyguardManager.ACTION_CONFIRM_REMOTE_DEVICE_CREDENTIAL, intent.getAction());
        assertEquals(remoteLockscreenValidationSession,
                intent.getParcelableExtra(
                        KeyguardManager.EXTRA_REMOTE_LOCKSCREEN_VALIDATION_SESSION,
                        RemoteLockscreenValidationSession.class));
        assertEquals(componentName,
                intent.getParcelableExtra(Intent.EXTRA_COMPONENT_NAME, ComponentName.class));
        assertEquals(title, intent.getStringExtra(KeyguardManager.EXTRA_TITLE));
        assertEquals(description, intent.getStringExtra(KeyguardManager.EXTRA_DESCRIPTION));
        assertEquals(checkboxLabel, intent.getStringExtra(KeyguardManager.EXTRA_CHECKBOX_LABEL));
        assertEquals(alternateButtonLabel,
                intent.getStringExtra(KeyguardManager.EXTRA_ALTERNATE_BUTTON_LABEL));
    }

    private void verifyDeviceLockedAndRemoveLock() {
    private void verifyDeviceLockedAndRemoveLock() {
        assertTrue(mKeyguardManager.isDeviceSecure());
        assertTrue(mKeyguardManager.isDeviceSecure());
        assertTrue("Failed to remove new password that was set in the test case.",
        assertTrue("Failed to remove new password that was set in the test case.",