Loading core/tests/coretests/src/com/android/internal/app/ChooserActivityTest.java +50 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading core/tests/coretests/src/com/android/internal/app/ResolverActivityTest.java +50 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading Loading
core/tests/coretests/src/com/android/internal/app/ChooserActivityTest.java +50 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading
core/tests/coretests/src/com/android/internal/app/ResolverActivityTest.java +50 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading