diff options
| author | 2023-02-01 04:32:07 +0000 | |
|---|---|---|
| committer | 2023-02-01 04:32:07 +0000 | |
| commit | 3a9ca304f41a13c42f13f8f26eb9a714de24a267 (patch) | |
| tree | 7fe41048b2e4ee1af592a33b1076e4e668cf454d /java | |
| parent | d250d1dabc19f0ec5bdddd11bb1caa04bdcbe3d7 (diff) | |
| parent | a9bdc945c5623673a0ed630c548d7e561cb71e2c (diff) | |
Merge "A payload re-selection test" into tm-qpr-dev
Diffstat (limited to 'java')
| -rw-r--r-- | java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java b/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java index f06812f1..2d8a74b9 100644 --- a/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java +++ b/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java @@ -1785,6 +1785,64 @@ public class UnbundledChooserActivityTest { } @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); |