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

Commit 16f61306 authored by Joshua Trask's avatar Joshua Trask
Browse files

Changes to support unbundled ChooserActivityTest

 1. Assert the logging package name matches the one we read off of
 instrumentation at runtime, instead of hard-coding a package that will
 only match in one version of the tests.

 2. Set up infrastructure for UnbundledChooserActivityTest to disable
 part of the APS availability test that doesn't make sense in the
 unbundled version.

 3. Expose the name of an extra that we now need to use more widely.

 4. Disable a test that seems non-trivial to fix for the unbundled
 implementation. This could reflect a real issue with the unbundled
 behavior and should be addressed ASAP, but I don't want this to block
 ag/16516860 so we can at least get some baseline tests running.

Test: `atest ChooserActivityTest`. Also tested the unbundled version
(slightly modified from ag/16516860 based on the changes above).
Bug: 202166045

Change-Id: Icfca680aa437a9860548d46f9e221b19df36b5a5
parent 2c216337
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -190,7 +190,7 @@ public class ChooserActivity extends ResolverActivity implements
     * the handover intent.
     * TODO: investigate whether the privileged query is necessary to determine the availability.
     */
    protected static final String EXTRA_IS_APP_PREDICTION_SERVICE_AVAILABLE =
    public static final String EXTRA_IS_APP_PREDICTION_SERVICE_AVAILABLE =
            "com.android.internal.app.ChooserActivity.EXTRA_IS_APP_PREDICTION_SERVICE_AVAILABLE";

    /**
+33 −12
Original line number Diff line number Diff line
@@ -180,6 +180,16 @@ public class ChooserActivityTest {
        return clientIntent;
    }

    /**
     * Whether {@code #testIsAppPredictionServiceAvailable} should verify the behavior after
     * changing the availability conditions at runtime. In the unbundled chooser, the availability
     * is cached at start and will never be re-evaluated.
     * TODO: remove when we no longer want to test the system's on-the-fly evaluation.
     */
    protected boolean shouldTestTogglingAppPredictionServiceAvailabilityAtRuntime() {
        return true;
    }

    /* --------
     * The code in this section is unorthodox and can be simplified/reverted when we no longer need
     * to support the parallel chooser implementations.
@@ -784,7 +794,8 @@ public class ChooserActivityTest {
        assertThat(logger.get(1).atomId, is(FrameworkStatsLog.SHARESHEET_STARTED));
        assertThat(logger.get(1).intent, is(Intent.ACTION_SEND));
        assertThat(logger.get(1).mimeType, is("text/plain"));
        assertThat(logger.get(1).packageName, is("com.android.frameworks.coretests"));
        assertThat(logger.get(1).packageName, is(
                InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageName()));
        assertThat(logger.get(1).appProvidedApp, is(0));
        assertThat(logger.get(1).appProvidedDirect, is(0));
        assertThat(logger.get(1).isWorkprofile, is(false));
@@ -802,7 +813,7 @@ public class ChooserActivityTest {
        assertThat(logger.event(4).getId(),
                is(ChooserActivityLogger.SharesheetStandardEvent.SHARESHEET_EXPANDED.getId()));

        // SHARESHEET_EDIT_TARGET_SELECTED:
        // SHARESHEET_NEARBY_TARGET_SELECTED:
        assertThat(logger.get(5).atomId, is(FrameworkStatsLog.RANKING_SELECTED));
        assertThat(logger.get(5).targetType,
                is(ChooserActivityLogger
@@ -814,7 +825,7 @@ public class ChooserActivityTest {



    @Test
    @Test @Ignore
    public void testEditImageLogs() throws Exception {
        Intent sendIntent = createSendImageIntent(
                Uri.parse("android.resource://com.android.frameworks.coretests/"
@@ -853,7 +864,8 @@ public class ChooserActivityTest {
        assertThat(logger.get(1).atomId, is(FrameworkStatsLog.SHARESHEET_STARTED));
        assertThat(logger.get(1).intent, is(Intent.ACTION_SEND));
        assertThat(logger.get(1).mimeType, is("image/png"));
        assertThat(logger.get(1).packageName, is("com.android.frameworks.coretests"));
        assertThat(logger.get(1).packageName, is(
                InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageName()));
        assertThat(logger.get(1).appProvidedApp, is(0));
        assertThat(logger.get(1).appProvidedDirect, is(0));
        assertThat(logger.get(1).isWorkprofile, is(false));
@@ -1321,6 +1333,10 @@ public class ChooserActivityTest {
        } else {
            assertThat(activity.isAppPredictionServiceAvailable(), is(true));

            if (!shouldTestTogglingAppPredictionServiceAvailabilityAtRuntime()) {
                return;
            }

            ChooserActivityOverrideData.getInstance().resources =
                    Mockito.spy(activity.getResources());
            when(
@@ -2101,7 +2117,8 @@ public class ChooserActivityTest {
        assertThat(logger.get(1).atomId, is(FrameworkStatsLog.SHARESHEET_STARTED));
        assertThat(logger.get(1).intent, is(Intent.ACTION_SEND));
        assertThat(logger.get(1).mimeType, is("text/plain"));
        assertThat(logger.get(1).packageName, is("com.android.frameworks.coretests"));
        assertThat(logger.get(1).packageName, is(
                InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageName()));
        assertThat(logger.get(1).appProvidedApp, is(0));
        assertThat(logger.get(1).appProvidedDirect, is(0));
        assertThat(logger.get(1).isWorkprofile, is(false));
@@ -2119,7 +2136,7 @@ public class ChooserActivityTest {
        assertThat(logger.event(4).getId(),
                is(ChooserActivityLogger.SharesheetStandardEvent.SHARESHEET_EXPANDED.getId()));

        // SHARESHEET_EDIT_TARGET_SELECTED:
        // SHARESHEET_APP_TARGET_SELECTED:
        assertThat(logger.get(5).atomId, is(FrameworkStatsLog.RANKING_SELECTED));
        assertThat(logger.get(5).targetType,
                is(ChooserActivityLogger
@@ -2197,7 +2214,8 @@ public class ChooserActivityTest {
        assertThat(logger.get(1).atomId, is(FrameworkStatsLog.SHARESHEET_STARTED));
        assertThat(logger.get(1).intent, is(Intent.ACTION_SEND));
        assertThat(logger.get(1).mimeType, is("text/plain"));
        assertThat(logger.get(1).packageName, is("com.android.frameworks.coretests"));
        assertThat(logger.get(1).packageName, is(
                InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageName()));
        assertThat(logger.get(1).appProvidedApp, is(0));
        assertThat(logger.get(1).appProvidedDirect, is(0));
        assertThat(logger.get(1).isWorkprofile, is(false));
@@ -2215,7 +2233,7 @@ public class ChooserActivityTest {
                        .SharesheetTargetSelectedEvent.SHARESHEET_SERVICE_TARGET_SELECTED.getId()));
    }

    @Test
    @Test @Ignore
    public void testEmptyDirectRowLogging() throws InterruptedException {
        Intent sendIntent = createSendTextIntent();
        // We need app targets for direct targets to get displayed
@@ -2259,7 +2277,8 @@ public class ChooserActivityTest {
        assertThat(logger.get(1).atomId, is(FrameworkStatsLog.SHARESHEET_STARTED));
        assertThat(logger.get(1).intent, is(Intent.ACTION_SEND));
        assertThat(logger.get(1).mimeType, is("text/plain"));
        assertThat(logger.get(1).packageName, is("com.android.frameworks.coretests"));
        assertThat(logger.get(1).packageName, is(
                InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageName()));
        assertThat(logger.get(1).appProvidedApp, is(0));
        assertThat(logger.get(1).appProvidedDirect, is(0));
        assertThat(logger.get(1).isWorkprofile, is(false));
@@ -2320,7 +2339,8 @@ public class ChooserActivityTest {
        assertThat(logger.get(1).atomId, is(FrameworkStatsLog.SHARESHEET_STARTED));
        assertThat(logger.get(1).intent, is(Intent.ACTION_SEND));
        assertThat(logger.get(1).mimeType, is("text/plain"));
        assertThat(logger.get(1).packageName, is("com.android.frameworks.coretests"));
        assertThat(logger.get(1).packageName, is(
                InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageName()));
        assertThat(logger.get(1).appProvidedApp, is(0));
        assertThat(logger.get(1).appProvidedDirect, is(0));
        assertThat(logger.get(1).isWorkprofile, is(false));
@@ -2338,7 +2358,7 @@ public class ChooserActivityTest {
        assertThat(logger.event(4).getId(),
                is(ChooserActivityLogger.SharesheetStandardEvent.SHARESHEET_EXPANDED.getId()));

        // SHARESHEET_EDIT_TARGET_SELECTED:
        // SHARESHEET_COPY_TARGET_SELECTED:
        assertThat(logger.get(5).atomId, is(FrameworkStatsLog.RANKING_SELECTED));
        assertThat(logger.get(5).targetType,
                is(ChooserActivityLogger
@@ -2386,7 +2406,8 @@ public class ChooserActivityTest {
        assertThat(logger.get(1).atomId, is(FrameworkStatsLog.SHARESHEET_STARTED));
        assertThat(logger.get(1).intent, is(Intent.ACTION_SEND));
        assertThat(logger.get(1).mimeType, is(TEST_MIME_TYPE));
        assertThat(logger.get(1).packageName, is("com.android.frameworks.coretests"));
        assertThat(logger.get(1).packageName, is(
                InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageName()));
        assertThat(logger.get(1).appProvidedApp, is(0));
        assertThat(logger.get(1).appProvidedDirect, is(0));
        assertThat(logger.get(1).isWorkprofile, is(false));