TestDriver
interface TestDriver
Additional functionality exposed for androidx.work.WorkManager that are useful in the context of testing.
Summary
Public functions |
|
|---|---|
Unit |
setAllConstraintsMet(workSpecId: UUID)Tells |
Unit |
setInitialDelayMet(workSpecId: UUID)Tells |
Unit |
setPeriodDelayMet(workSpecId: UUID)Tells |
Unit |
stopRunningWorkWithReason(workSpecId: UUID, reason: Int)Tells |
Public functions
setAllConstraintsMet
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 |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if |
setInitialDelayMet
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 |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if |
setPeriodDelayMet
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 |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if |
stopRunningWorkWithReason
fun stopRunningWorkWithReason(workSpecId: UUID, reason: Int): Unit
Tells TestDriver to pretend that a running worker should be stopped with the provided StopReason.
| Parameters | |
|---|---|
workSpecId: UUID |
The |
reason: Int |
The |