TestDriver


public interface TestDriver


Additional functionality exposed for androidx.work.WorkManager that are useful in the context of testing.

Summary

Public methods

abstract void

Tells TestDriver to pretend that all constraints on the androidx.work.WorkRequest with the given workSpecId are met.

abstract void

Tells TestDriver to pretend that the initial delay the androidx.work.OneTimeWorkRequest with the given workSpecId is met.

abstract void

Tells TestDriver to pretend that the period delay on the androidx.work.PeriodicWorkRequest with the given workSpecId is met.

Public methods

setAllConstraintsMet

Added in 1.0.0
abstract void setAllConstraintsMet(@NonNull UUID workSpecId)

Tells TestDriver to pretend that all constraints on the androidx.work.WorkRequest with the given workSpecId are met. This may trigger execution of the work.

Parameters
@NonNull UUID workSpecId

The androidx.work.WorkRequest's id

Throws
java.lang.IllegalArgumentException

if workSpecId is not enqueued

setInitialDelayMet

Added in 1.0.0
abstract void setInitialDelayMet(@NonNull UUID workSpecId)

Tells TestDriver to pretend that the initial delay the androidx.work.OneTimeWorkRequest with the given workSpecId is met. This may trigger execution of the work.

Parameters
@NonNull UUID workSpecId

The androidx.work.OneTimeWorkRequest's id

Throws
java.lang.IllegalArgumentException

if workSpecId is not enqueued

setPeriodDelayMet

Added in 1.0.0
abstract void setPeriodDelayMet(@NonNull UUID workSpecId)

Tells TestDriver to pretend that the period delay on the androidx.work.PeriodicWorkRequest with the given workSpecId is met. This may trigger execution of the work.

Parameters
@NonNull UUID workSpecId

The androidx.work.PeriodicWorkRequest's id

Throws
java.lang.IllegalArgumentException

if workSpecId is not enqueued