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

Commit 6fc95507 authored by Hyungtae Tim Kim's avatar Hyungtae Tim Kim
Browse files

Add TV apps to AppLaunch test

TV apps declare a launcher activity using a
CATEGORY_LEANBACK_LAUNCHER intent filter.

Bug: 27444470
Change-Id: I0d3e412dc0abf65f6eeed4e5d2c0784d08773620
parent 00694afd
Loading
Loading
Loading
Loading
+10 −3
Original line number Original line Diff line number Diff line
@@ -160,7 +160,7 @@ public class AppLaunch extends InstrumentationTestCase {
        for (String pair : appNames) {
        for (String pair : appNames) {
            String[] parts = pair.split("\\^");
            String[] parts = pair.split("\\^");
            if (parts.length != 2) {
            if (parts.length != 2) {
                Log.e(TAG, "The apps key is incorectly formatted");
                Log.e(TAG, "The apps key is incorrectly formatted");
                fail();
                fail();
            }
            }


@@ -176,6 +176,10 @@ public class AppLaunch extends InstrumentationTestCase {
        }
        }
    }
    }


    private boolean hasLeanback(Context context) {
        return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK);
    }

    private void createMappings() {
    private void createMappings() {
        mNameToIntent = new LinkedHashMap<String, Intent>();
        mNameToIntent = new LinkedHashMap<String, Intent>();
        mNameToProcess = new LinkedHashMap<String, String>();
        mNameToProcess = new LinkedHashMap<String, String>();
@@ -183,9 +187,12 @@ public class AppLaunch extends InstrumentationTestCase {
        PackageManager pm = getInstrumentation().getContext()
        PackageManager pm = getInstrumentation().getContext()
                .getPackageManager();
                .getPackageManager();
        Intent intentToResolve = new Intent(Intent.ACTION_MAIN);
        Intent intentToResolve = new Intent(Intent.ACTION_MAIN);
        intentToResolve.addCategory(Intent.CATEGORY_LAUNCHER);
        intentToResolve.addCategory(hasLeanback(getInstrumentation().getContext()) ?
                Intent.CATEGORY_LEANBACK_LAUNCHER :
                Intent.CATEGORY_LAUNCHER);
        List<ResolveInfo> ris = pm.queryIntentActivities(intentToResolve, 0);
        List<ResolveInfo> ris = pm.queryIntentActivities(intentToResolve, 0);
        resolveLoop(ris, intentToResolve, pm);
        resolveLoop(ris, intentToResolve, pm);
        // For Wear
        intentToResolve = new Intent(WEARABLE_ACTION_GOOGLE);
        intentToResolve = new Intent(WEARABLE_ACTION_GOOGLE);
        ris = pm.queryIntentActivities(intentToResolve, 0);
        ris = pm.queryIntentActivities(intentToResolve, 0);
        resolveLoop(ris, intentToResolve, pm);
        resolveLoop(ris, intentToResolve, pm);
@@ -232,7 +239,7 @@ public class AppLaunch extends InstrumentationTestCase {
        // report error if any of the following is true:
        // report error if any of the following is true:
        // * launch thread is alive
        // * launch thread is alive
        // * result is not null, but:
        // * result is not null, but:
        //   * result is not START_SUCESS
        //   * result is not START_SUCCESS
        //   * or in case of no force stop, result is not TASK_TO_FRONT either
        //   * or in case of no force stop, result is not TASK_TO_FRONT either
        if (t.isAlive() || (result != null
        if (t.isAlive() || (result != null
                && ((result.result != ActivityManager.START_SUCCESS)
                && ((result.result != ActivityManager.START_SUCCESS)