summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Sudheer Shanka <sudheersai@google.com> 2023-03-28 21:58:28 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-03-28 21:58:28 +0000
commit015186f2c708b9ab37544d2441c7a33384ca429e (patch)
tree8be5cfc3d8f696f60ba2795be9492561c17ea5c9
parent4e97becaa4619b08abfde49d4b14b8c3b1c431c3 (diff)
parent00dd85a12e10e8687ff146d1d9e871e510816417 (diff)
Merge "Add a new test to verify delivery group policy." into udc-dev
-rw-r--r--services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueModernImplTest.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueModernImplTest.java b/services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueModernImplTest.java
index 390119c968cd..36d191b466ba 100644
--- a/services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueModernImplTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueModernImplTest.java
@@ -1008,6 +1008,42 @@ public final class BroadcastQueueModernImplTest {
dropboxEntryBroadcast2.first, expectedMergedBroadcast.first));
}
+ @Test
+ public void testDeliveryGroupPolicy_sameAction_differentMatchingCriteria() {
+ final Intent closeSystemDialogs1 = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
+ final BroadcastOptions optionsCloseSystemDialog1 = BroadcastOptions.makeBasic()
+ .setDeliveryGroupPolicy(BroadcastOptions.DELIVERY_GROUP_POLICY_MOST_RECENT);
+
+ final Intent closeSystemDialogs2 = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)
+ .putExtra("reason", "testing");
+ final BroadcastOptions optionsCloseSystemDialog2 = BroadcastOptions.makeBasic()
+ .setDeliveryGroupPolicy(BroadcastOptions.DELIVERY_GROUP_POLICY_MOST_RECENT)
+ .setDeliveryGroupMatchingKey(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, "testing");
+
+ // Halt all processing so that we get a consistent view
+ mHandlerThread.getLooper().getQueue().postSyncBarrier();
+
+ mImpl.enqueueBroadcastLocked(makeBroadcastRecord(
+ closeSystemDialogs1, optionsCloseSystemDialog1));
+ mImpl.enqueueBroadcastLocked(makeBroadcastRecord(
+ closeSystemDialogs2, optionsCloseSystemDialog2));
+ mImpl.enqueueBroadcastLocked(makeBroadcastRecord(
+ closeSystemDialogs1, optionsCloseSystemDialog1));
+ // Verify that only the older broadcast with no extras was removed.
+ final BroadcastProcessQueue queue = mImpl.getProcessQueue(PACKAGE_GREEN,
+ getUidForPackage(PACKAGE_GREEN));
+ verifyPendingRecords(queue, List.of(closeSystemDialogs2, closeSystemDialogs1));
+
+ mImpl.enqueueBroadcastLocked(makeBroadcastRecord(
+ closeSystemDialogs2, optionsCloseSystemDialog2));
+ mImpl.enqueueBroadcastLocked(makeBroadcastRecord(
+ closeSystemDialogs1, optionsCloseSystemDialog1));
+ mImpl.enqueueBroadcastLocked(makeBroadcastRecord(
+ closeSystemDialogs2, optionsCloseSystemDialog2));
+ // Verify that only the older broadcast with no extras was removed.
+ verifyPendingRecords(queue, List.of(closeSystemDialogs1, closeSystemDialogs2));
+ }
+
private Pair<Intent, BroadcastOptions> createDropboxBroadcast(String tag, long timestampMs,
int droppedCount) {
final Intent dropboxEntryAdded = new Intent(DropBoxManager.ACTION_DROPBOX_ENTRY_ADDED);