TestDriver


interface TestDriver


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

Summary

Public functions

Unit

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

Unit
setInitialDelayMet(workSpecId: UUID)

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

Unit
setPeriodDelayMet(workSpecId: UUID)

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

Public functions

setAllConstraintsMet

Added in 1.0.0
fun setAllConstraintsMet(workSpecId: UUID): Unit

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
workSpecId: UUID

The androidx.work.WorkRequest's id

Throws
java.lang.IllegalArgumentException

if workSpecId is not enqueued

setInitialDelayMet

Added in 1.0.0
fun setInitialDelayMet(workSpecId: UUID): Unit

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
workSpecId: UUID

The androidx.work.OneTimeWorkRequest's id

Throws
java.lang.IllegalArgumentException

if workSpecId is not enqueued

setPeriodDelayMet

Added in 1.0.0
fun setPeriodDelayMet(workSpecId: UUID): Unit

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
workSpecId: UUID

The androidx.work.PeriodicWorkRequest's id

Throws
java.lang.IllegalArgumentException

if workSpecId is not enqueued