TestWorkerBuilder

class TestWorkerBuilder<W : Worker?> : TestListenableWorkerBuilder


Builds instances of Worker which can be used for testing.

Parameters
<W : Worker?>

The actual subtype of Worker

Summary

Public functions

java-static TestWorkerBuilder<Worker!>
from(context: Context, workRequest: WorkRequest, executor: Executor)

Creates a new instance of a TestWorkerBuilder from a WorkRequest that runs on the given Executor.

java-static TestWorkerBuilder<W!>
<W : Worker?> from(context: Context, workerClass: Class<W!>, executor: Executor)

Creates a new instance of a TestWorkerBuilder with the worker Class that runs on the given Executor.

Inherited functions

From androidx.work.testing.TestListenableWorkerBuilder
W

Builds the ListenableWorker.

java-static TestListenableWorkerBuilder<ListenableWorker!>
from(context: Context, workRequest: WorkRequest)

Creates a new instance of a TestListenableWorkerBuilder from a WorkRequest.

java-static TestListenableWorkerBuilder<W!>
<W : ListenableWorker?> from(context: Context, workerClass: Class<W!>)

Creates a new instance of a TestListenableWorkerBuilder the worker Class.

TestListenableWorkerBuilder<W!>

Sets the ForegroundUpdater to be used to construct the androidx.work.ListenableWorker.

TestListenableWorkerBuilder<W!>
setId(id: UUID)

Sets the id for this unit of work.

TestListenableWorkerBuilder<W!>
setInputData(inputData: Data)

Adds input Data to the work.

TestListenableWorkerBuilder<W!>
@RequiresApi(value = 28)
setNetwork(network: Network)

Sets the network associated with this unit of work.

TestListenableWorkerBuilder<W!>

Sets the ProgressUpdater to be used to construct the androidx.work.ListenableWorker.

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!>

Sets the authorities for content Uri's associated with this unit of work.

TestListenableWorkerBuilder<W!>
@RequiresApi(value = 24)
setTriggeredContentUris(contentUris: (Mutable)List<Uri!>)

Sets the list of Content Uris associated with this unit of work.

TestListenableWorkerBuilder<W!>

Sets the WorkerFactory to be used to construct the androidx.work.ListenableWorker.

Public functions

from

Added in 2.1.0
java-static fun from(context: Context, workRequest: WorkRequest, executor: Executor): TestWorkerBuilder<Worker!>

Creates a new instance of a TestWorkerBuilder from a WorkRequest that runs on the given Executor.

Parameters
context: Context

The Context

workRequest: WorkRequest

The WorkRequest

executor: Executor

The Executor

Returns
TestWorkerBuilder<Worker!>

The new instance of a TestWorkerBuilder

from

Added in 2.1.0
java-static fun <W : Worker?> from(context: Context, workerClass: Class<W!>, executor: Executor): TestWorkerBuilder<W!>

Creates a new instance of a TestWorkerBuilder with the worker Class that runs on the given Executor.

Parameters
context: Context

The Context

workerClass: Class<W!>

The subtype of Worker being built

executor: Executor

The Executor

Returns
TestWorkerBuilder<W!>

The new instance of a TestWorkerBuilder