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

Commit fdfb05e3 authored by Matt Casey's avatar Matt Casey
Browse files

Don't show mini resolver if no same-profile targets

Previously we assumed there was at least one.

Test: atest ResolverActivityTests
Bug: 222497968
Change-Id: I4a5c43fe32e533841cb55cdfef6fc9aaea43f8cf
parent 7a53fdf6
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1603,6 +1603,11 @@ public class ResolverActivity extends Activity implements
        List<DisplayResolveInfo> otherProfileList =
                mMultiProfilePagerAdapter.getInactiveListAdapter().mDisplayList;

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

        if (otherProfileList.size() != 1) {
            Log.d(TAG, "Found " + otherProfileList.size() + " resolvers in the other profile");
            return false;
+30 −0
Original line number 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.Mockito.when;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.fail;

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

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

@@ -749,6 +751,34 @@ public class ResolverActivityTest {
        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
    public void testWorkTab_noAppsAvailable_workOff_noAppsAvailableEmptyStateShown() {
        // enable the work tab feature flag