Snap for 9552684 from 3a9ca304f41a13c42f13f8f26eb9a714de24a267 to tm-d3-release
Change-Id: I0a59e51e79b3fc6b87a05c784cc598f8446f8a9f
diff --git a/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java b/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java
index f06812f..2d8a74b 100644
--- a/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java
+++ b/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java
@@ -1785,6 +1785,64 @@
}
@Test
+ public void testLaunchWithPayloadReselection() throws InterruptedException {
+ ChooserActivityOverrideData.getInstance().featureFlagRepository =
+ new FeatureFlagRepository() {
+ @Override
+ public boolean isEnabled(@NonNull UnreleasedFlag flag) {
+ return Flags.SHARESHEET_RESELECTION_ACTION.equals(flag)
+ || flag.getDefault();
+ }
+
+ @Override
+ public boolean isEnabled(@NonNull ReleasedFlag flag) {
+ return false;
+ }
+ };
+ List<ResolvedComponentInfo> resolvedComponentInfos = createResolvedComponentsForTest(2);
+ when(
+ ChooserActivityOverrideData
+ .getInstance()
+ .resolverListController
+ .getResolversForIntent(
+ Mockito.anyBoolean(),
+ Mockito.anyBoolean(),
+ Mockito.anyBoolean(),
+ Mockito.isA(List.class)))
+ .thenReturn(resolvedComponentInfos);
+
+ Context testContext = InstrumentationRegistry.getInstrumentation().getContext();
+ final String reselectionAction = "test-broadcast-receiver-action";
+ Intent chooserIntent = Intent.createChooser(createSendTextIntent(), null);
+ chooserIntent.putExtra(
+ Intent.EXTRA_CHOOSER_PAYLOAD_RESELECTION_ACTION,
+ PendingIntent.getBroadcast(
+ testContext,
+ 123,
+ new Intent(reselectionAction),
+ PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_ONE_SHOT));
+ // Start activity
+ mActivityRule.launchActivity(chooserIntent);
+ waitForIdle();
+
+ final CountDownLatch broadcastInvoked = new CountDownLatch(1);
+ BroadcastReceiver testReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ broadcastInvoked.countDown();
+ }
+ };
+ testContext.registerReceiver(testReceiver, new IntentFilter(reselectionAction));
+
+ try {
+ onView(withText(R.string.select_text)).perform(click());
+ broadcastInvoked.await();
+ } finally {
+ testContext.unregisterReceiver(testReceiver);
+ }
+ }
+
+ @Test
public void testUpdateMaxTargetsPerRow_columnCountIsUpdated() throws InterruptedException {
updateMaxTargetsPerRowResource(/* targetsPerRow= */ 4);
givenAppTargets(/* appCount= */ 16);