Loading services/tests/mockingservicestests/src/com/android/server/am/ApplicationExitInfoTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -127,11 +127,14 @@ public class ApplicationExitInfoTest { mAms.mAtmInternal = spy(mAms.mActivityTaskManager.getAtmInternal()); mAms.mPackageManagerInt = mPackageManagerInt; doReturn(new ComponentName("", "")).when(mPackageManagerInt).getSystemUiServiceComponent(); // Remove stale instance of PackageManagerInternal if there is any LocalServices.removeServiceForTest(PackageManagerInternal.class); LocalServices.addService(PackageManagerInternal.class, mPackageManagerInt); } @After public void tearDown() { LocalServices.removeServiceForTest(PackageManagerInternal.class); mHandlerThread.quit(); } Loading services/tests/mockingservicestests/src/com/android/server/am/MockingOomAdjusterTests.java +8 −0 Original line number Diff line number Diff line Loading @@ -94,6 +94,7 @@ import com.android.server.wm.ActivityServiceConnectionsHolder; import com.android.server.wm.ActivityTaskManagerService; import com.android.server.wm.WindowProcessController; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; Loading Loading @@ -141,6 +142,8 @@ public class MockingOomAdjusterTests { sPackageManagerInternal = mock(PackageManagerInternal.class); doReturn(new ComponentName("", "")).when(sPackageManagerInternal) .getSystemUiServiceComponent(); // Remove stale instance of PackageManagerInternal if there is any LocalServices.removeServiceForTest(PackageManagerInternal.class); LocalServices.addService(PackageManagerInternal.class, sPackageManagerInternal); sService = mock(ActivityManagerService.class); Loading Loading @@ -172,6 +175,11 @@ public class MockingOomAdjusterTests { sService.mOomAdjuster.mAdjSeq = 10000; } @AfterClass public static void tearDownOnce() { LocalServices.removeServiceForTest(PackageManagerInternal.class); } private static <T> void setFieldValue(Class clazz, Object obj, String fieldName, T val) { try { Field field = clazz.getDeclaredField(fieldName); Loading Loading
services/tests/mockingservicestests/src/com/android/server/am/ApplicationExitInfoTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -127,11 +127,14 @@ public class ApplicationExitInfoTest { mAms.mAtmInternal = spy(mAms.mActivityTaskManager.getAtmInternal()); mAms.mPackageManagerInt = mPackageManagerInt; doReturn(new ComponentName("", "")).when(mPackageManagerInt).getSystemUiServiceComponent(); // Remove stale instance of PackageManagerInternal if there is any LocalServices.removeServiceForTest(PackageManagerInternal.class); LocalServices.addService(PackageManagerInternal.class, mPackageManagerInt); } @After public void tearDown() { LocalServices.removeServiceForTest(PackageManagerInternal.class); mHandlerThread.quit(); } Loading
services/tests/mockingservicestests/src/com/android/server/am/MockingOomAdjusterTests.java +8 −0 Original line number Diff line number Diff line Loading @@ -94,6 +94,7 @@ import com.android.server.wm.ActivityServiceConnectionsHolder; import com.android.server.wm.ActivityTaskManagerService; import com.android.server.wm.WindowProcessController; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; Loading Loading @@ -141,6 +142,8 @@ public class MockingOomAdjusterTests { sPackageManagerInternal = mock(PackageManagerInternal.class); doReturn(new ComponentName("", "")).when(sPackageManagerInternal) .getSystemUiServiceComponent(); // Remove stale instance of PackageManagerInternal if there is any LocalServices.removeServiceForTest(PackageManagerInternal.class); LocalServices.addService(PackageManagerInternal.class, sPackageManagerInternal); sService = mock(ActivityManagerService.class); Loading Loading @@ -172,6 +175,11 @@ public class MockingOomAdjusterTests { sService.mOomAdjuster.mAdjSeq = 10000; } @AfterClass public static void tearDownOnce() { LocalServices.removeServiceForTest(PackageManagerInternal.class); } private static <T> void setFieldValue(Class clazz, Object obj, String fieldName, T val) { try { Field field = clazz.getDeclaredField(fieldName); Loading