Loading services/tests/mockingservicestests/src/com/android/server/job/restrictions/ThermalStatusRestrictionTest.java +6 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static android.os.PowerManager.THERMAL_STATUS_NONE; import static android.os.PowerManager.THERMAL_STATUS_SEVERE; import static android.os.PowerManager.THERMAL_STATUS_SHUTDOWN; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.inOrder; import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock; import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession; Loading Loading @@ -55,6 +56,7 @@ import android.util.DebugUtils; import androidx.test.runner.AndroidJUnit4; import com.android.server.LocalServices; import com.android.server.job.JobSchedulerInternal; import com.android.server.job.JobSchedulerService; import com.android.server.job.controllers.JobStatus; Loading Loading @@ -251,6 +253,10 @@ public class ThermalStatusRestrictionTest { PowerManager powerManager = mock(PowerManager.class); when(mContext.getSystemService(PowerManager.class)).thenReturn(powerManager); // Used by JobStatus. doReturn(mock(JobSchedulerInternal.class)) .when(() -> LocalServices.getService(JobSchedulerInternal.class)); // Initialize real objects. // Capture the listeners. ArgumentCaptor<PowerManager.OnThermalStatusChangedListener> listenerCaptor = Loading services/tests/servicestests/src/com/android/server/job/PendingJobQueueTest.java +21 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import android.app.job.JobInfo; import android.content.ComponentName; Loading @@ -36,6 +37,7 @@ import android.util.SparseLongArray; import androidx.test.filters.LargeTest; import com.android.server.LocalServices; import com.android.server.job.controllers.JobStatus; import org.junit.Test; Loading Loading @@ -434,6 +436,10 @@ public class PendingJobQueueTest { @Test public void testPendingJobSorting_namespacing() { // Used by JobStatus. LocalServices.removeServiceForTest(JobSchedulerInternal.class); JobSchedulerInternal jobSchedulerInternal = mock(JobSchedulerInternal.class); LocalServices.addService(JobSchedulerInternal.class, jobSchedulerInternal); PendingJobQueue jobQueue = new PendingJobQueue(); // First letter in job variable name indicate regular (r) or expedited (e). Loading Loading @@ -608,6 +614,11 @@ public class PendingJobQueueTest { @Test public void testPendingJobSorting_Random_WithPriority() { // Used by JobStatus. LocalServices.removeServiceForTest(JobSchedulerInternal.class); JobSchedulerInternal jobSchedulerInternal = mock(JobSchedulerInternal.class); LocalServices.addService(JobSchedulerInternal.class, jobSchedulerInternal); PendingJobQueue jobQueue = new PendingJobQueue(); Random random = new Random(1); // Always use the same series of pseudo random values. Loading @@ -631,6 +642,11 @@ public class PendingJobQueueTest { @Test public void testPendingJobSortingTransitivity_WithPriority() { // Used by JobStatus. LocalServices.removeServiceForTest(JobSchedulerInternal.class); JobSchedulerInternal jobSchedulerInternal = mock(JobSchedulerInternal.class); LocalServices.addService(JobSchedulerInternal.class, jobSchedulerInternal); PendingJobQueue jobQueue = new PendingJobQueue(); // Always use the same series of pseudo random values. for (int seed : new int[]{1337, 7357, 606, 6357, 41106010, 3, 2, 1}) { Loading Loading @@ -661,6 +677,11 @@ public class PendingJobQueueTest { @Test @LargeTest public void testPendingJobSortingTransitivity_Concentrated_WithPriority() { // Used by JobStatus. LocalServices.removeServiceForTest(JobSchedulerInternal.class); JobSchedulerInternal jobSchedulerInternal = mock(JobSchedulerInternal.class); LocalServices.addService(JobSchedulerInternal.class, jobSchedulerInternal); PendingJobQueue jobQueue = new PendingJobQueue(); // Always use the same series of pseudo random values. for (int seed : new int[]{1337, 6000, 637739, 6357, 1, 7, 13}) { Loading Loading
services/tests/mockingservicestests/src/com/android/server/job/restrictions/ThermalStatusRestrictionTest.java +6 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static android.os.PowerManager.THERMAL_STATUS_NONE; import static android.os.PowerManager.THERMAL_STATUS_SEVERE; import static android.os.PowerManager.THERMAL_STATUS_SHUTDOWN; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.inOrder; import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock; import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession; Loading Loading @@ -55,6 +56,7 @@ import android.util.DebugUtils; import androidx.test.runner.AndroidJUnit4; import com.android.server.LocalServices; import com.android.server.job.JobSchedulerInternal; import com.android.server.job.JobSchedulerService; import com.android.server.job.controllers.JobStatus; Loading Loading @@ -251,6 +253,10 @@ public class ThermalStatusRestrictionTest { PowerManager powerManager = mock(PowerManager.class); when(mContext.getSystemService(PowerManager.class)).thenReturn(powerManager); // Used by JobStatus. doReturn(mock(JobSchedulerInternal.class)) .when(() -> LocalServices.getService(JobSchedulerInternal.class)); // Initialize real objects. // Capture the listeners. ArgumentCaptor<PowerManager.OnThermalStatusChangedListener> listenerCaptor = Loading
services/tests/servicestests/src/com/android/server/job/PendingJobQueueTest.java +21 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import android.app.job.JobInfo; import android.content.ComponentName; Loading @@ -36,6 +37,7 @@ import android.util.SparseLongArray; import androidx.test.filters.LargeTest; import com.android.server.LocalServices; import com.android.server.job.controllers.JobStatus; import org.junit.Test; Loading Loading @@ -434,6 +436,10 @@ public class PendingJobQueueTest { @Test public void testPendingJobSorting_namespacing() { // Used by JobStatus. LocalServices.removeServiceForTest(JobSchedulerInternal.class); JobSchedulerInternal jobSchedulerInternal = mock(JobSchedulerInternal.class); LocalServices.addService(JobSchedulerInternal.class, jobSchedulerInternal); PendingJobQueue jobQueue = new PendingJobQueue(); // First letter in job variable name indicate regular (r) or expedited (e). Loading Loading @@ -608,6 +614,11 @@ public class PendingJobQueueTest { @Test public void testPendingJobSorting_Random_WithPriority() { // Used by JobStatus. LocalServices.removeServiceForTest(JobSchedulerInternal.class); JobSchedulerInternal jobSchedulerInternal = mock(JobSchedulerInternal.class); LocalServices.addService(JobSchedulerInternal.class, jobSchedulerInternal); PendingJobQueue jobQueue = new PendingJobQueue(); Random random = new Random(1); // Always use the same series of pseudo random values. Loading @@ -631,6 +642,11 @@ public class PendingJobQueueTest { @Test public void testPendingJobSortingTransitivity_WithPriority() { // Used by JobStatus. LocalServices.removeServiceForTest(JobSchedulerInternal.class); JobSchedulerInternal jobSchedulerInternal = mock(JobSchedulerInternal.class); LocalServices.addService(JobSchedulerInternal.class, jobSchedulerInternal); PendingJobQueue jobQueue = new PendingJobQueue(); // Always use the same series of pseudo random values. for (int seed : new int[]{1337, 7357, 606, 6357, 41106010, 3, 2, 1}) { Loading Loading @@ -661,6 +677,11 @@ public class PendingJobQueueTest { @Test @LargeTest public void testPendingJobSortingTransitivity_Concentrated_WithPriority() { // Used by JobStatus. LocalServices.removeServiceForTest(JobSchedulerInternal.class); JobSchedulerInternal jobSchedulerInternal = mock(JobSchedulerInternal.class); LocalServices.addService(JobSchedulerInternal.class, jobSchedulerInternal); PendingJobQueue jobQueue = new PendingJobQueue(); // Always use the same series of pseudo random values. for (int seed : new int[]{1337, 6000, 637739, 6357, 1, 7, 13}) { Loading