TestListenableWorkerBuilder

public class TestListenableWorkerBuilder
extends Object

java.lang.Object
   ↳ androidx.work.testing.TestListenableWorkerBuilder<W extends androidx.work.ListenableWorker>


Builds instances of ListenableWorker which can be used for testing.

Summary

Public methods

W build()

Builds the ListenableWorker.

static TestListenableWorkerBuilder<? extends ListenableWorker> from(Context context, WorkRequest workRequest)

Creates a new instance of a TestListenableWorkerBuilder from a WorkRequest.

static <W extends ListenableWorker> TestListenableWorkerBuilder<W> from(Context context, Class<W> workerClass)

Creates a new instance of a TestListenableWorkerBuilder the worker Class.

TestListenableWorkerBuilder<W> setForegroundUpdater(ForegroundUpdater updater)

Sets the ForegroundUpdater to be used to construct the ListenableWorker.

TestListenableWorkerBuilder<W> setId(UUID id)

Sets the id for this unit of work.

TestListenableWorkerBuilder<W> setInputData(Data inputData)

Adds input Data to the work.

TestListenableWorkerBuilder<W> setNetwork(Network network)

Sets the network associated with this unit of work.

TestListenableWorkerBuilder<W> setProgressUpdater(ProgressUpdater updater)

Sets the ProgressUpdater to be used to construct the ListenableWorker.

TestListenableWorkerBuilder<W> setRunAttemptCount(int runAttemptCount)

Sets the initial run attempt count for this work.

TestListenableWorkerBuilder<W> setTags(List<String> tags)

Sets the tags associated with this unit of work.

TestListenableWorkerBuilder<W> setTriggeredContentAuthorities(List<String> authorities)

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

TestListenableWorkerBuilder<W> setTriggeredContentUris(List<Uri> contentUris)

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

TestListenableWorkerBuilder<W> setWorkerFactory(WorkerFactory workerFactory)

Sets the WorkerFactory to be used to construct the ListenableWorker.

Inherited methods

Public methods

build

public W build ()

Builds the ListenableWorker.

Returns
W the instance of a ListenableWorker.

from

public static TestListenableWorkerBuilder<? extends ListenableWorker> from (Context context, 
                WorkRequest workRequest)

Creates a new instance of a TestListenableWorkerBuilder from a WorkRequest.

Parameters
context Context: The Context

workRequest WorkRequest: The WorkRequest

Returns
TestListenableWorkerBuilder<? extends ListenableWorker> The new instance of a ListenableWorker

from

public static TestListenableWorkerBuilder<W> from (Context