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

Commit 9149dcaf authored by Hakan Seyalioglu's avatar Hakan Seyalioglu
Browse files

Add ResolverActivity testing

Still very basic, but will be adding as we find more issues pop up.

Test: Ran the tests
Change-Id: Ib9863509d140ff425ce446ecc876f53494d4fd0e
parent 1eb7161f
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -749,10 +749,7 @@ public class ResolverActivity extends Activity {
                    }
                } else {
                    try {
                        AppGlobals.getPackageManager().setLastChosenActivity(intent,
                                intent.resolveType(getContentResolver()),
                                PackageManager.MATCH_DEFAULT_ONLY,
                                filter, bestMatch, intent.getComponent());
                        mAdapter.mResolverListController.setLastChosen(intent, filter, bestMatch);
                    } catch (RemoteException re) {
                        Log.d(TAG, "Error calling setLastChosenActivity\n" + re);
                    }
@@ -1312,10 +1309,7 @@ public class ResolverActivity extends Activity {
        protected boolean rebuildList() {
            List<ResolvedComponentInfo> currentResolveList = null;
            try {
                final Intent primaryIntent = getTargetIntent();
                mLastChosen = AppGlobals.getPackageManager().getLastChosenActivity(
                        primaryIntent, primaryIntent.resolveTypeIfNeeded(getContentResolver()),
                        PackageManager.MATCH_DEFAULT_ONLY);
                mLastChosen = mResolverListController.getLastChosen();
            } catch (RemoteException re) {
                Log.d(TAG, "Error calling getLastChosenActivity\n" + re);
            }
+19 −0
Original line number Diff line number Diff line
@@ -19,13 +19,16 @@ package com.android.internal.app;

import android.annotation.WorkerThread;
import android.app.ActivityManager;
import android.app.AppGlobals;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.RemoteException;
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;

@@ -65,6 +68,22 @@ public class ResolverListController {
        mReferrerPackage = referrerPackage;
    }

    @VisibleForTesting
    ResolveInfo getLastChosen() throws RemoteException {
        return AppGlobals.getPackageManager().getLastChosenActivity(
                mTargetIntent, mTargetIntent.resolveTypeIfNeeded(mContext.getContentResolver()),
                PackageManager.MATCH_DEFAULT_ONLY);
    }

    @VisibleForTesting
    void setLastChosen(Intent intent, IntentFilter filter, int match)
            throws RemoteException {
        AppGlobals.getPackageManager().setLastChosenActivity(intent,
                intent.resolveType(mContext.getContentResolver()),
                PackageManager.MATCH_DEFAULT_ONLY,
                filter, match, intent.getComponent());
    }

    @VisibleForTesting
    public List<ResolverActivity.ResolvedComponentInfo> getResolversForIntent(
            boolean shouldGetResolvedFilter,
+1 −0
Original line number Diff line number Diff line
@@ -1168,6 +1168,7 @@
        <activity android:name="android.app.EmptyActivity">
        </activity>
        <activity android:name="com.android.internal.app.ChooserWrapperActivity"/>
        <activity android:name="com.android.internal.app.ResolverWrapperActivity"/>

        <receiver android:name="android.app.activity.AbortReceiver">
            <intent-filter android:priority="1">
+1 −1
Original line number Diff line number Diff line
@@ -222,7 +222,7 @@ public class ChooserActivityTest {
    private List<ResolvedComponentInfo> createResolvedComponentsForTest(int numberOfResults) {
        List<ResolvedComponentInfo> infoList = new ArrayList<>(numberOfResults);
        for (int i = 0; i < numberOfResults; i++) {
            infoList.add(ChooserDataProvider.createResolvedComponentInfo(i));
            infoList.add(ResolverDataProvider.createResolvedComponentInfo(i));
        }
        return infoList;
    }
+4 −5
Original line number Diff line number Diff line
@@ -24,11 +24,10 @@ import java.util.function.Function;

import static org.mockito.Mockito.mock;


/**
public class ChooserWrapperActivity extends ChooserActivity {
    /*
     * Simple wrapper around chooser activity to be able to initiate it under test
     */
public class ChooserWrapperActivity extends ChooserActivity {
    static final OverrideData sOverrides = new OverrideData();
    private UsageStatsManager mUsm;

Loading