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

Commit edbf1f7a authored by Matt Casey's avatar Matt Casey Committed by Automerger Merge Worker
Browse files

Merge "Don't show mini resolver if no same-profile targets" into tm-dev am: 8da49290

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17069665

Change-Id: I95e7a7b8f6c7272e7ec0c8bd14e3299a2cba7287
parents d5152d2c 8da49290
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -1603,6 +1603,11 @@ public class ResolverActivity extends Activity implements
        List<DisplayResolveInfo> otherProfileList =
        List<DisplayResolveInfo> otherProfileList =
                mMultiProfilePagerAdapter.getInactiveListAdapter().mDisplayList;
                mMultiProfilePagerAdapter.getInactiveListAdapter().mDisplayList;


        if (sameProfileList.isEmpty()) {
            Log.d(TAG, "No targets in the current profile");
            return false;
        }

        if (otherProfileList.size() != 1) {
        if (otherProfileList.size() != 1) {
            Log.d(TAG, "Found " + otherProfileList.size() + " resolvers in the other profile");
            Log.d(TAG, "Found " + otherProfileList.size() + " resolvers in the other profile");
            return false;
            return false;
+30 −0
Original line number Original line Diff line number Diff line
@@ -39,6 +39,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.fail;


import android.content.Intent;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.content.pm.ResolveInfo;
@@ -52,6 +53,7 @@ import android.widget.TextView;


import androidx.test.InstrumentationRegistry;
import androidx.test.InstrumentationRegistry;
import androidx.test.espresso.Espresso;
import androidx.test.espresso.Espresso;
import androidx.test.espresso.NoMatchingViewException;
import androidx.test.rule.ActivityTestRule;
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import androidx.test.runner.AndroidJUnit4;


@@ -749,6 +751,34 @@ public class ResolverActivityTest {
        onView(withId(R.id.open_cross_profile)).check(matches(isDisplayed()));
        onView(withId(R.id.open_cross_profile)).check(matches(isDisplayed()));
    }
    }


    @Test
    public void testMiniResolver_noCurrentProfileTarget() {
        ResolverActivity.ENABLE_TABBED_VIEW = true;
        markWorkProfileUserAvailable();
        List<ResolvedComponentInfo> personalResolvedComponentInfos =
                createResolvedComponentsForTest(0);
        List<ResolvedComponentInfo> workResolvedComponentInfos =
                createResolvedComponentsForTest(1);
        setupResolverControllers(personalResolvedComponentInfos, workResolvedComponentInfos);
        Intent sendIntent = createSendImageIntent();
        sendIntent.setType("TestType");

        mActivityRule.launchActivity(sendIntent);
        waitForIdle();

        // Need to ensure mini resolver doesn't trigger here.
        assertNotMiniResolver();
    }

    private void assertNotMiniResolver() {
        try {
            onView(withId(R.id.open_cross_profile)).check(matches(isDisplayed()));
        } catch (NoMatchingViewException e) {
            return;
        }
        fail("Mini resolver present but shouldn't be");
    }

    @Test
    @Test
    public void testWorkTab_noAppsAvailable_workOff_noAppsAvailableEmptyStateShown() {
    public void testWorkTab_noAppsAvailable_workOff_noAppsAvailableEmptyStateShown() {
        // enable the work tab feature flag
        // enable the work tab feature flag