summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Matías Hernández <matiashe@google.com> 2024-03-02 00:47:41 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-03-02 00:47:41 +0000
commitc02c5e899b2d14e630d9abfc3976a8c35c83e40e (patch)
tree7a13288450679f248953020a9d34ec63f955c311
parentb5cfbf4f2bfd7cad4caef8876adcbee451ba88a3 (diff)
parent2f105d40854bb1f708093362bce477081d509187 (diff)
Merge "Fix unit tests to correctly consider CompatChanges" into main
-rwxr-xr-xservices/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java2
-rw-r--r--services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java22
2 files changed, 20 insertions, 4 deletions
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
index 85c3132ba96f..e3ea55a67e71 100755
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
@@ -14334,6 +14334,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
@Test
@EnableFlags(android.app.Flags.FLAG_MODES_API)
+ @EnableCompatChanges(NotificationManagerService.MANAGE_GLOBAL_ZEN_VIA_IMPLICIT_RULES)
public void requestInterruptionFilterFromListener_fromApp_doesNotSetGlobalZen()
throws Exception {
mService.setCallerIsNormalPackage();
@@ -14351,6 +14352,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
@Test
@EnableFlags(android.app.Flags.FLAG_MODES_API)
+ @EnableCompatChanges(NotificationManagerService.MANAGE_GLOBAL_ZEN_VIA_IMPLICIT_RULES)
public void requestInterruptionFilterFromListener_fromSystem_setsGlobalZen()
throws Exception {
mService.isSystemUid = true;
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
index 0539e1a85a77..495e01a640de 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java
@@ -22,6 +22,7 @@ import static android.app.NotificationManager.AUTOMATIC_RULE_STATUS_ACTIVATED;
import static android.app.NotificationManager.AUTOMATIC_RULE_STATUS_DEACTIVATED;
import static android.app.NotificationManager.AUTOMATIC_RULE_STATUS_DISABLED;
import static android.app.NotificationManager.AUTOMATIC_RULE_STATUS_ENABLED;
+import static android.app.NotificationManager.AUTOMATIC_RULE_STATUS_UNKNOWN;
import static android.app.NotificationManager.INTERRUPTION_FILTER_ALARMS;
import static android.app.NotificationManager.INTERRUPTION_FILTER_ALL;
import static android.app.NotificationManager.INTERRUPTION_FILTER_NONE;
@@ -108,6 +109,7 @@ import android.app.AutomaticZenRule;
import android.app.Flags;
import android.app.NotificationManager;
import android.app.NotificationManager.Policy;
+import android.app.compat.CompatChanges;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.pm.ActivityInfo;
@@ -4674,7 +4676,11 @@ public class ZenModeHelperTest extends UiServiceTestCase {
UPDATE_ORIGIN_SYSTEM_OR_SYSTEMUI, Process.SYSTEM_UID);
assertTrue(latch.await(500, TimeUnit.MILLISECONDS));
- assertEquals(AUTOMATIC_RULE_STATUS_ACTIVATED, actualStatus[0]);
+ if (CompatChanges.isChangeEnabled(ZenModeHelper.SEND_ACTIVATION_AZR_STATUSES)) {
+ assertEquals(AUTOMATIC_RULE_STATUS_ACTIVATED, actualStatus[0]);
+ } else {
+ assertEquals(AUTOMATIC_RULE_STATUS_UNKNOWN, actualStatus[0]);
+ }
}
@Test
@@ -4715,7 +4721,11 @@ public class ZenModeHelperTest extends UiServiceTestCase {
null, "", Process.SYSTEM_UID);
assertTrue(latch.await(500, TimeUnit.MILLISECONDS));
- assertEquals(AUTOMATIC_RULE_STATUS_DEACTIVATED, actualStatus[1]);
+ if (CompatChanges.isChangeEnabled(ZenModeHelper.SEND_ACTIVATION_AZR_STATUSES)) {
+ assertEquals(AUTOMATIC_RULE_STATUS_DEACTIVATED, actualStatus[1]);
+ } else {
+ assertEquals(AUTOMATIC_RULE_STATUS_UNKNOWN, actualStatus[1]);
+ }
}
@Test
@@ -4754,10 +4764,14 @@ public class ZenModeHelperTest extends UiServiceTestCase {
mZenModeHelper.setAutomaticZenRuleState(createdId,
new Condition(zenRule.getConditionId(), "", STATE_FALSE),
- UPDATE_ORIGIN_SYSTEM_OR_SYSTEMUI, Process.SYSTEM_UID);
+ UPDATE_ORIGIN_APP, Process.SYSTEM_UID);
assertTrue(latch.await(500, TimeUnit.MILLISECONDS));
- assertEquals(AUTOMATIC_RULE_STATUS_DEACTIVATED, actualStatus[1]);
+ if (CompatChanges.isChangeEnabled(ZenModeHelper.SEND_ACTIVATION_AZR_STATUSES)) {
+ assertEquals(AUTOMATIC_RULE_STATUS_DEACTIVATED, actualStatus[1]);
+ } else {
+ assertEquals(AUTOMATIC_RULE_STATUS_UNKNOWN, actualStatus[1]);
+ }
}
@Test