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

Commit 9d3dff4a authored by Michael Wachenschwanz's avatar Michael Wachenschwanz
Browse files

Mock the setOomAdj path in OomAdjuster

Bug: 314181833
Test: atest BroadcastQueueTest
Change-Id: I1f52a6629324b4a0388a72699a4f8341e24752ff
parent 8689962f
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.server.am;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.eq;
@@ -44,6 +43,9 @@ import android.util.SparseArray;

import androidx.test.platform.app.InstrumentationRegistry;

import com.android.dx.mockito.inline.extended.ExtendedMockito;
import com.android.internal.util.FrameworkStatsLog;
import com.android.modules.utils.testing.ExtendedMockitoRule;
import com.android.server.AlarmManagerInternal;
import com.android.server.DropBoxManagerInternal;
import com.android.server.LocalServices;
@@ -85,6 +87,12 @@ public abstract class BaseBroadcastQueueTest {
    public final ApplicationExitInfoTest.ServiceThreadRule
            mServiceThreadRule = new ApplicationExitInfoTest.ServiceThreadRule();

    @Rule
    public final ExtendedMockitoRule mExtendedMockitoRule = new ExtendedMockitoRule.Builder(this)
            .spyStatic(FrameworkStatsLog.class)
            .spyStatic(ProcessList.class)
            .build();

    @Mock
    AppOpsService mAppOpsService;
    @Mock
@@ -140,6 +148,7 @@ public abstract class BaseBroadcastQueueTest {
        realAms.mActivityTaskManager.initialize(null, null, mContext.getMainLooper());
        realAms.mAtmInternal = spy(realAms.mActivityTaskManager.getAtmInternal());
        realAms.mOomAdjuster = spy(realAms.mOomAdjuster);
        ExtendedMockito.doNothing().when(() -> ProcessList.setOomAdj(anyInt(), anyInt(), anyInt()));
        realAms.mPackageManagerInt = mPackageManagerInt;
        realAms.mUsageStatsService = mUsageStatsManagerInt;
        realAms.mProcessesReady = true;
+0 −7
Original line number Diff line number Diff line
@@ -79,11 +79,9 @@ import androidx.test.filters.SmallTest;
import androidx.test.platform.app.InstrumentationRegistry;

import com.android.internal.util.FrameworkStatsLog;
import com.android.modules.utils.testing.ExtendedMockitoRule;

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mock;

@@ -112,11 +110,6 @@ public final class BroadcastQueueModernImplTest extends BaseBroadcastQueueTest {

    BroadcastProcessQueue mHead;

    @Rule
    public final ExtendedMockitoRule mExtendedMockitoRule = new ExtendedMockitoRule.Builder(this)
            .spyStatic(FrameworkStatsLog.class)
            .build();

    @Before
    public void setUp() throws Exception {
        super.setUp();