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
This commit is contained in:
Matt Casey
2022-03-03 11:57:26 -05:00
parent 7a53fdf6f7
commit fdfb05e384
2 changed files with 35 additions and 0 deletions

View File

@@ -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;

View File

@@ -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