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

Commit 397dfb6e authored by Richard MacGregor's avatar Richard MacGregor Committed by Gerrit Code Review
Browse files

Merge "Don't register NLS in test" into main

parents 2e83a961 4c020eff
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -22,9 +22,10 @@ import static android.permission.flags.Flags.FLAG_SENSITIVE_NOTIFICATION_APP_PRO
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doCallRealMethod;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.never;
@@ -36,6 +37,7 @@ import android.content.pm.PackageManagerInternal;
import android.media.projection.MediaProjectionInfo;
import android.media.projection.MediaProjectionManager;
import android.os.Process;
import android.os.RemoteException;
import android.platform.test.annotations.RequiresFlagsDisabled;
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.platform.test.flag.junit.CheckFlagsRule;
@@ -137,9 +139,17 @@ public class SensitiveContentProtectionManagerServiceNotificationTest {

        mSensitiveContentProtectionManagerService.mNotificationListener =
                spy(mSensitiveContentProtectionManagerService.mNotificationListener);
        doCallRealMethod()
                .when(mSensitiveContentProtectionManagerService.mNotificationListener)
                .onListenerConnected();

        // Unexpected NLS interactions when registered cause test flakes. For purposes of this test,
        // the test will control any NLS calls.
        try {
            doNothing().when(mSensitiveContentProtectionManagerService.mNotificationListener)
                    .registerAsSystemService(any(), any(), anyInt());
            doNothing().when(mSensitiveContentProtectionManagerService.mNotificationListener)
                    .unregisterAsSystemService();
        } catch (RemoteException e) {
            // Intra-process call, should never happen.
        }

        // Setup RankingMap and two possilbe rankings
        when(mSensitiveRanking.hasSensitiveContent()).thenReturn(true);