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

Commit c87646be authored by Yuichiro Hanada's avatar Yuichiro Hanada
Browse files

Fix NPEs in ShareTargetPredictorTest.setUp()

Bug: 380315215
Flag: EXEMPT test only change
Test: atest ShareTargetPredictorTest
Change-Id: I0a57069b2ec70d447a91271f6bb80c2e7f555e45
parent 66a5ee3b
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -40,11 +40,13 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutManager.ShareShortcutInfo;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.UserHandle;
import android.provider.DeviceConfig;
import android.util.Range;

import com.android.internal.R;
import com.android.internal.app.ChooserActivity;
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
import com.android.server.people.data.ConversationInfo;
@@ -87,6 +89,7 @@ public final class ShareTargetPredictorTest {
    private static final IntentFilter INTENT_FILTER = IntentFilter.create("SEND", "text/plain");

    @Mock private Context mContext;
    @Mock private Resources mResources;
    @Mock private DataManager mDataManager;
    @Mock private Consumer<List<AppTarget>> mUpdatePredictionsMethod;
    @Mock private PackageData mPackageData1;
@@ -116,11 +119,14 @@ public final class ShareTargetPredictorTest {
        when(mDataManager.getShareShortcuts(any(), anyInt())).thenReturn(mShareShortcuts);
        when(mDataManager.getPackage(PACKAGE_1, USER_ID)).thenReturn(mPackageData1);
        when(mDataManager.getPackage(PACKAGE_2, USER_ID)).thenReturn(mPackageData2);
        when(mContext.createContextAsUser(any(), any())).thenReturn(mContext);
        when(mContext.createContextAsUser(any(), anyInt())).thenReturn(mContext);
        when(mContext.getSystemServiceName(AppPredictionManager.class)).thenReturn(
                Context.APP_PREDICTION_SERVICE);
        when(mContext.getSystemService(AppPredictionManager.class))
                .thenReturn(new AppPredictionManager(mContext));
        when(mContext.getResources()).thenReturn(mResources);
        when(mResources.getString(R.string.config_chooserActivity))
                .thenReturn("com.android.intentresolver/.ChooserActivity");

        Bundle bundle = new Bundle();
        bundle.putObject(ChooserActivity.APP_PREDICTION_INTENT_FILTER_KEY, INTENT_FILTER);