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

Commit 69308a06 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix the RemoteInputViewTest mock user context"

parents 2740724e 63a2ede1
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -17,9 +17,15 @@ package com.android.systemui.statusbar.policy;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;

import android.app.ActivityManager;
import android.app.PendingIntent;
import android.app.RemoteInput;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ShortcutManager;
@@ -130,8 +136,18 @@ public class RemoteInputViewTest extends SysuiTestCase {

    private UserHandle getTargetInputMethodUser(UserHandle fromUser, UserHandle toUser)
            throws Exception {
        /**
         * RemoteInputView, Icon, and Bubble have the situation need to handle the other user.
         * SystemUI cross multiple user but this test(com.android.systemui.tests) doesn't cross
         * multiple user. It needs some of mocking multiple user environment to ensure the
         * createContextAsUser without throwing IllegalStateException.
         */
        Context contextSpy = spy(mContext);
        doReturn(contextSpy).when(contextSpy).createContextAsUser(any(), anyInt());
        doReturn(toUser.getIdentifier()).when(contextSpy).getUserId();

        NotificationTestHelper helper = new NotificationTestHelper(
                mContext,
                contextSpy,
                mDependency,
                TestableLooper.get(this));
        ExpandableNotificationRow row = helper.createRow(