Search in sources :

Example 6 with JobParameters

use of android.app.job.JobParameters in project android-priority-jobqueue by yigit.

the class FrameworkJobSchedulerServiceTest method onStopJob.

@Test
public void onStopJob() {
    JobParameters params = mock(JobParameters.class);
    service.onStopJob(params);
    verify(mockScheduler).onStopJob(params);
}
Also used : JobParameters(android.app.job.JobParameters) Test(org.junit.Test)

Example 7 with JobParameters

use of android.app.job.JobParameters in project android-priority-jobqueue by yigit.

the class FrameworkSchedulerTest method triggerOnStart.

private SchedulerConstraint triggerOnStart(SchedulerConstraint constraint, JobParameters[] outParams) {
    ArgumentCaptor<SchedulerConstraint> constraintCaptor = ArgumentCaptor.forClass(SchedulerConstraint.class);
    when(mockCallback.start(constraintCaptor.capture())).thenReturn(true);
    JobParameters params = prepareJobParameters(constraint);
    outParams[0] = params;
    fwScheduler.onStartJob(params);
    verify(mockCallback).start(Mockito.any(SchedulerConstraint.class));
    return constraintCaptor.getValue();
}
Also used : JobParameters(android.app.job.JobParameters)

Example 8 with JobParameters

use of android.app.job.JobParameters in project android-priority-jobqueue by yigit.

the class FrameworkSchedulerTest method badBundleOnStop.

@Test
public void badBundleOnStop() {
    // see https://github.com/yigit/android-priority-jobqueue/issues/254
    JobParameters params = mock(JobParameters.class);
    PersistableBundle badBundle = mock(PersistableBundle.class);
    when(badBundle.getString(anyString(), anyString())).thenThrow(new NullPointerException());
    when(badBundle.getString(anyString())).thenThrow(new NullPointerException());
    assertThat(fwScheduler.onStopJob(params), is(false));
}
Also used : PersistableBundle(android.os.PersistableBundle) JobParameters(android.app.job.JobParameters) Test(org.junit.Test)

Example 9 with JobParameters

use of android.app.job.JobParameters in project android-priority-jobqueue by yigit.

the class FrameworkSchedulerTest method badBundleOnStart.

@Test
public void badBundleOnStart() {
    // see https://github.com/yigit/android-priority-jobqueue/issues/254
    JobParameters params = mock(JobParameters.class);
    PersistableBundle badBundle = mock(PersistableBundle.class);
    when(badBundle.getString(anyString(), anyString())).thenThrow(new NullPointerException());
    when(badBundle.getString(anyString())).thenThrow(new NullPointerException());
    assertThat(fwScheduler.onStartJob(params), is(false));
}
Also used : PersistableBundle(android.os.PersistableBundle) JobParameters(android.app.job.JobParameters) Test(org.junit.Test)

Example 10 with JobParameters

use of android.app.job.JobParameters in project android_frameworks_base by ResurrectionRemix.

the class SyncJobService method callJobFinished.

public void callJobFinished(int jobId, boolean needsReschedule) {
    synchronized (jobParamsMap) {
        JobParameters params = jobParamsMap.get(jobId);
        if (params != null) {
            jobFinished(params, needsReschedule);
            jobParamsMap.remove(jobId);
        } else {
            Slog.e(TAG, "Job params not found for " + String.valueOf(jobId));
        }
    }
}
Also used : JobParameters(android.app.job.JobParameters)

Aggregations

JobParameters (android.app.job.JobParameters)24 Test (org.junit.Test)7 Intent (android.content.Intent)5 Uri (android.net.Uri)5 RemoteException (android.os.RemoteException)5 UserHandle (android.os.UserHandle)5 PersistableBundle (android.os.PersistableBundle)2 JobInfo (android.app.job.JobInfo)1 JobService (android.app.job.JobService)1 NonNull (android.support.annotation.NonNull)1