Merge "Add tests for single target with work profile and no work tab case" into rvc-dev am: 9404629621
Change-Id: I3db216c4b0c3350fb86bd3d17265623e11f1b109
This commit is contained in:
@@ -34,6 +34,8 @@ import static com.android.internal.app.ChooserListAdapter.SHORTCUT_TARGET_SCORE_
|
||||
import static com.android.internal.app.ChooserWrapperActivity.sOverrides;
|
||||
import static com.android.internal.app.MatcherUtils.first;
|
||||
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
@@ -1682,6 +1684,54 @@ public class ChooserActivityTest {
|
||||
.SharesheetStandardEvent.SHARESHEET_PROFILE_CHANGED.getId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAutolaunch_singleTarget_wifthWorkProfileAndTabbedViewOff_noAutolaunch() {
|
||||
ResolverActivity.ENABLE_TABBED_VIEW = false;
|
||||
List<ResolvedComponentInfo> personalResolvedComponentInfos =
|
||||
createResolvedComponentsForTestWithOtherProfile(2, /* userId */ 10);
|
||||
when(sOverrides.resolverListController.getResolversForIntent(Mockito.anyBoolean(),
|
||||
Mockito.anyBoolean(),
|
||||
Mockito.isA(List.class)))
|
||||
.thenReturn(new ArrayList<>(personalResolvedComponentInfos));
|
||||
Intent sendIntent = createSendTextIntent();
|
||||
sendIntent.setType("TestType");
|
||||
ResolveInfo[] chosen = new ResolveInfo[1];
|
||||
sOverrides.onSafelyStartCallback = targetInfo -> {
|
||||
chosen[0] = targetInfo.getResolveInfo();
|
||||
return true;
|
||||
};
|
||||
waitForIdle();
|
||||
|
||||
mActivityRule.launchActivity(Intent.createChooser(sendIntent, "work tab test"));
|
||||
waitForIdle();
|
||||
|
||||
assertTrue(chosen[0] == null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAutolaunch_singleTarget_noWorkProfile_autolaunch() {
|
||||
ResolverActivity.ENABLE_TABBED_VIEW = false;
|
||||
List<ResolvedComponentInfo> personalResolvedComponentInfos =
|
||||
createResolvedComponentsForTest(1);
|
||||
when(sOverrides.resolverListController.getResolversForIntent(Mockito.anyBoolean(),
|
||||
Mockito.anyBoolean(),
|
||||
Mockito.isA(List.class)))
|
||||
.thenReturn(new ArrayList<>(personalResolvedComponentInfos));
|
||||
Intent sendIntent = createSendTextIntent();
|
||||
sendIntent.setType("TestType");
|
||||
ResolveInfo[] chosen = new ResolveInfo[1];
|
||||
sOverrides.onSafelyStartCallback = targetInfo -> {
|
||||
chosen[0] = targetInfo.getResolveInfo();
|
||||
return true;
|
||||
};
|
||||
waitForIdle();
|
||||
|
||||
mActivityRule.launchActivity(Intent.createChooser(sendIntent, "work tab test"));
|
||||
waitForIdle();
|
||||
|
||||
assertThat(chosen[0], is(personalResolvedComponentInfos.get(0).getResolveInfoAt(0)));
|
||||
}
|
||||
|
||||
private Intent createSendTextIntent() {
|
||||
Intent sendIntent = new Intent();
|
||||
sendIntent.setAction(Intent.ACTION_SEND);
|
||||
|
||||
@@ -30,6 +30,8 @@ import static com.android.internal.app.MatcherUtils.first;
|
||||
import static com.android.internal.app.ResolverDataProvider.createPackageManagerMockedInfo;
|
||||
import static com.android.internal.app.ResolverWrapperActivity.sOverrides;
|
||||
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.allOf;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
@@ -710,6 +712,54 @@ public class ResolverActivityTest {
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAutolaunch_singleTarget_withWorkProfileAndTabbedViewOff_noAutolaunch() {
|
||||
ResolverActivity.ENABLE_TABBED_VIEW = false;
|
||||
List<ResolvedComponentInfo> personalResolvedComponentInfos =
|
||||
createResolvedComponentsForTestWithOtherProfile(2, /* userId */ 10);
|
||||
when(sOverrides.resolverListController.getResolversForIntent(Mockito.anyBoolean(),
|
||||
Mockito.anyBoolean(),
|
||||
Mockito.isA(List.class)))
|
||||
.thenReturn(new ArrayList<>(personalResolvedComponentInfos));
|
||||
Intent sendIntent = createSendImageIntent();
|
||||
sendIntent.setType("TestType");
|
||||
ResolveInfo[] chosen = new ResolveInfo[1];
|
||||
sOverrides.onSafelyStartCallback = targetInfo -> {
|
||||
chosen[0] = targetInfo.getResolveInfo();
|
||||
return true;
|
||||
};
|
||||
waitForIdle();
|
||||
|
||||
mActivityRule.launchActivity(sendIntent);
|
||||
waitForIdle();
|
||||
|
||||
assertTrue(chosen[0] == null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAutolaunch_singleTarget_noWorkProfile_autolaunch() {
|
||||
ResolverActivity.ENABLE_TABBED_VIEW = false;
|
||||
List<ResolvedComponentInfo> personalResolvedComponentInfos =
|
||||
createResolvedComponentsForTest(1);
|
||||
when(sOverrides.resolverListController.getResolversForIntent(Mockito.anyBoolean(),
|
||||
Mockito.anyBoolean(),
|
||||
Mockito.isA(List.class)))
|
||||
.thenReturn(new ArrayList<>(personalResolvedComponentInfos));
|
||||
Intent sendIntent = createSendImageIntent();
|
||||
sendIntent.setType("TestType");
|
||||
ResolveInfo[] chosen = new ResolveInfo[1];
|
||||
sOverrides.onSafelyStartCallback = targetInfo -> {
|
||||
chosen[0] = targetInfo.getResolveInfo();
|
||||
return true;
|
||||
};
|
||||
waitForIdle();
|
||||
|
||||
mActivityRule.launchActivity(sendIntent);
|
||||
waitForIdle();
|
||||
|
||||
assertThat(chosen[0], is(personalResolvedComponentInfos.get(0).getResolveInfoAt(0)));
|
||||
}
|
||||
|
||||
private Intent createSendImageIntent() {
|
||||
Intent sendIntent = new Intent();
|
||||
sendIntent.setAction(Intent.ACTION_SEND);
|
||||
|
||||
Reference in New Issue
Block a user