Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c02c5e89 authored by Matías Hernández's avatar Matías Hernández Committed by Android (Google) Code Review
Browse files

Merge "Fix unit tests to correctly consider CompatChanges" into main

parents b5cfbf4f 2f105d40
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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;
+18 −4
Original line number Diff line number Diff line
@@ -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));
        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));
        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));
        if (CompatChanges.isChangeEnabled(ZenModeHelper.SEND_ACTIVATION_AZR_STATUSES)) {
            assertEquals(AUTOMATIC_RULE_STATUS_DEACTIVATED, actualStatus[1]);
        } else {
            assertEquals(AUTOMATIC_RULE_STATUS_UNKNOWN, actualStatus[1]);
        }
    }

    @Test