TestListenableWorkerBuilder
public class TestListenableWorkerBuilder<W extends ListenableWorker>
TestWorkerBuilder |
Builds instances of |
Builds instances of androidx.work.ListenableWorker which can be used for testing.
| Parameters | |
|---|---|
<W extends ListenableWorker> |
The actual |
Summary
Public methods
build
public @NonNull W build()
Builds the ListenableWorker.
| Returns | |
|---|---|
@NonNull W |
the instance of a |
build
public @NonNull W build(@NonNull Class<ListenableWorker> enqueuedClass)
Builds the ListenableWorker by passing in the enqueued ListenableWorker class to the WorkerFactory. This can be useful to test custom createWorker implementations as the enqueued ListenableWorker class may not be the same as the one that is built.
| Parameters | |
|---|---|
@NonNull Class<ListenableWorker> enqueuedClass |
the |
| Returns | |
|---|---|
@NonNull W |
the instance of a |
from
public static @NonNull TestListenableWorkerBuilder<ListenableWorker> from(@NonNull Context context, @NonNull WorkRequest workRequest)
Creates a new instance of a TestListenableWorkerBuilder from a WorkRequest.
| Parameters | |
|---|---|
@NonNull Context context |
The |
@NonNull WorkRequest workRequest |
The |
| Returns | |
|---|---|
@NonNull TestListenableWorkerBuilder<ListenableWorker> |
The new instance of a |
from
public static @NonNull TestListenableWorkerBuilder<W> <W extends ListenableWorker> from(
@NonNull Context context,
@NonNull Class<W> workerClass
)
Creates a new instance of a TestListenableWorkerBuilder the worker Class.
| Parameters | |
|---|---|
@NonNull Context context |
The |
@NonNull Class<W> workerClass |
The subtype of |
| Returns | |
|---|---|
@NonNull TestListenableWorkerBuilder<W> |
The new instance of a |
setForegroundUpdater
public @NonNull TestListenableWorkerBuilder<W> setForegroundUpdater(@NonNull ForegroundUpdater updater)
Sets the ForegroundUpdater to be used to construct the androidx.work.ListenableWorker.
| Parameters | |
|---|---|
@NonNull ForegroundUpdater updater |
The |
| Returns | |
|---|---|
@NonNull TestListenableWorkerBuilder<W> |
The current |
setId
public @NonNull TestListenableWorkerBuilder<W> setId(@NonNull UUID id)
Sets the id for this unit of work.
| Returns | |
|---|---|
@NonNull TestListenableWorkerBuilder<W> |
The current |
setInputData
public @NonNull TestListenableWorkerBuilder<W> setInputData(@NonNull Data inputData)
Adds input Data to the work.
| Returns | |
|---|---|
@NonNull TestListenableWorkerBuilder<W> |
The current |
setNetwork
@RequiresApi(value = 28)
public @NonNull TestListenableWorkerBuilder<W> setNetwork(@NonNull Network network)
Sets the network associated with this unit of work.
| Returns | |
|---|---|
@NonNull TestListenableWorkerBuilder<W> |
The current |
setProgressUpdater
public @NonNull TestListenableWorkerBuilder<W> setProgressUpdater(@NonNull ProgressUpdater updater)
Sets the ProgressUpdater to be used to construct the androidx.work.ListenableWorker.
| Parameters | |
|---|---|
@NonNull ProgressUpdater updater |
The |
| Returns | |
|---|---|
@NonNull TestListenableWorkerBuilder<W> |
The current |
setRunAttemptCount
public @NonNull TestListenableWorkerBuilder<W> setRunAttemptCount(int runAttemptCount)
Sets the initial run attempt count for this work.
| Parameters | |
|---|---|
int runAttemptCount |
The initial run attempt count |
| Returns | |
|---|---|
@NonNull TestListenableWorkerBuilder<W> |
The current |
setTags
public @NonNull TestListenableWorkerBuilder<W> setTags(@NonNull List<String> tags)
Sets the tags associated with this unit of work.
| Returns | |
|---|---|
@NonNull TestListenableWorkerBuilder<W> |
The current |
setTriggeredContentAuthorities
@RequiresApi(value = 24)
public @NonNull TestListenableWorkerBuilder<W> setTriggeredContentAuthorities(@NonNull List<String> authorities)
Sets the authorities for content Uri's associated with this unit of work.
| Returns | |
|---|---|
@NonNull TestListenableWorkerBuilder<W> |
The current |
setTriggeredContentUris
@RequiresApi(value = 24)
public @NonNull TestListenableWorkerBuilder<W> setTriggeredContentUris(@NonNull List<Uri> contentUris)
Sets the list of Content Uris associated with this unit of work.
| Returns | |
|---|---|
@NonNull TestListenableWorkerBuilder<W> |
The current |
setWorkerFactory
public @NonNull TestListenableWorkerBuilder<W> setWorkerFactory(@NonNull WorkerFactory workerFactory)
Sets the WorkerFactory to be used to construct the androidx.work.ListenableWorker.
| Parameters | |
|---|---|
@NonNull WorkerFactory workerFactory |
The |
| Returns | |
|---|---|
@NonNull TestListenableWorkerBuilder<W> |
The current |