TestListenableWorkerBuilder
class TestListenableWorkerBuilder<W : ListenableWorker?>
TestWorkerBuilder |
Builds instances of |
Builds instances of androidx.work.ListenableWorker which can be used for testing.
| Parameters | |
|---|---|
<W : ListenableWorker?> |
The actual |
Summary
Public functions |
|
|---|---|
W |
build()Builds the |
W |
build(enqueuedClass: Class<ListenableWorker!>)Builds the |
java-static TestListenableWorkerBuilder<ListenableWorker!> |
from(context: Context, workRequest: WorkRequest)Creates a new instance of a |
java-static TestListenableWorkerBuilder<W!> |
<W : ListenableWorker?> from(context: Context, workerClass: Class<W!>)Creates a new instance of a |
TestListenableWorkerBuilder<W!> |
setForegroundUpdater(updater: ForegroundUpdater)Sets the |
TestListenableWorkerBuilder<W!> |
Sets the id for this unit of work. |
TestListenableWorkerBuilder<W!> |
setInputData(inputData: Data)Adds input |
TestListenableWorkerBuilder<W!> |
@RequiresApi(value = 28)Sets the network associated with this unit of work. |
TestListenableWorkerBuilder<W!> |
setProgressUpdater(updater: ProgressUpdater)Sets the |
TestListenableWorkerBuilder<W!> |
setRunAttemptCount(runAttemptCount: Int)Sets the initial run attempt count for this work. |
TestListenableWorkerBuilder<W!> |
Sets the tags associated with this unit of work. |
TestListenableWorkerBuilder<W!> |
@RequiresApi(value = 24)Sets the authorities for content |
TestListenableWorkerBuilder<W!> |
@RequiresApi(value = 24)Sets the list of Content |
TestListenableWorkerBuilder<W!> |
setWorkerFactory(workerFactory: WorkerFactory)Sets the |
Public functions
build
fun build(): W
Builds the ListenableWorker.
| Returns | |
|---|---|
W |
the instance of a |
build
fun build(enqueuedClass: Class<ListenableWorker!>): W
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 | |
|---|---|
enqueuedClass: Class<ListenableWorker!> |
the |
| Returns | |
|---|---|
W |
the instance of a |
from
java-static fun from(context: Context, workRequest: WorkRequest): TestListenableWorkerBuilder<ListenableWorker!>
Creates a new instance of a TestListenableWorkerBuilder from a WorkRequest.
| Parameters | |
|---|---|
context: Context |
The |
workRequest: WorkRequest |
The |
| Returns | |
|---|---|
TestListenableWorkerBuilder<ListenableWorker!> |
The new instance of a |
from
java-static fun <W : ListenableWorker?> from(context: Context, workerClass: Class<W!>): TestListenableWorkerBuilder<W!>
Creates a new instance of a TestListenableWorkerBuilder the worker Class.
| Parameters | |
|---|---|
context: Context |
The |
workerClass: Class<W!> |
The subtype of |
| Returns | |
|---|---|
TestListenableWorkerBuilder<W!> |
The new instance of a |
setForegroundUpdater
fun setForegroundUpdater(updater: ForegroundUpdater): TestListenableWorkerBuilder<W!>
Sets the ForegroundUpdater to be used to construct the androidx.work.ListenableWorker.
| Parameters | |
|---|---|
updater: ForegroundUpdater |
The |
| Returns | |
|---|---|
TestListenableWorkerBuilder<W!> |
The current |
setId
fun setId(id: UUID): TestListenableWorkerBuilder<W!>
Sets the id for this unit of work.
| Returns | |
|---|---|
TestListenableWorkerBuilder<W!> |
The current |
setInputData
fun setInputData(inputData: Data): TestListenableWorkerBuilder<W!>
Adds input Data to the work.
| Parameters | |
|---|---|
inputData: Data |
key/value pairs that will be provided to the worker |
| Returns | |
|---|---|
TestListenableWorkerBuilder<W!> |
The current |
setNetwork
@RequiresApi(value = 28)
fun setNetwork(network: Network): TestListenableWorkerBuilder<W!>
Sets the network associated with this unit of work.
| Returns | |
|---|---|
TestListenableWorkerBuilder<W!> |
The current |
setProgressUpdater
fun setProgressUpdater(updater: ProgressUpdater): TestListenableWorkerBuilder<W!>
Sets the ProgressUpdater to be used to construct the androidx.work.ListenableWorker.
| Parameters | |
|---|---|
updater: ProgressUpdater |
The |
| Returns | |
|---|---|
TestListenableWorkerBuilder<W!> |
The current |
setRunAttemptCount
fun setRunAttemptCount(runAttemptCount: Int): TestListenableWorkerBuilder<W!>
Sets the initial run attempt count for this work.
| Parameters | |
|---|---|
runAttemptCount: Int |
The initial run attempt count |
| Returns | |
|---|---|
TestListenableWorkerBuilder<W!> |
The current |
setTags
fun setTags(tags: (Mutable)List<String!>): TestListenableWorkerBuilder<W!>
Sets the tags associated with this unit of work.
| Returns | |
|---|---|
TestListenableWorkerBuilder<W!> |
The current |
setTriggeredContentAuthorities
@RequiresApi(value = 24)
fun setTriggeredContentAuthorities(authorities: (Mutable)List<String!>): TestListenableWorkerBuilder<W!>
Sets the authorities for content Uri's associated with this unit of work.
| Returns | |
|---|---|
TestListenableWorkerBuilder<W!> |
The current |
setTriggeredContentUris
@RequiresApi(value = 24)
fun setTriggeredContentUris(contentUris: (Mutable)List<Uri!>): TestListenableWorkerBuilder<W!>
Sets the list of Content Uris associated with this unit of work.
| Returns | |
|---|---|
TestListenableWorkerBuilder<W!> |
The current |
setWorkerFactory
fun setWorkerFactory(workerFactory: WorkerFactory): TestListenableWorkerBuilder<W!>
Sets the WorkerFactory to be used to construct the androidx.work.ListenableWorker.
| Parameters | |
|---|---|
workerFactory: WorkerFactory |
The |
| Returns | |
|---|---|
TestListenableWorkerBuilder<W!> |
The current |