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