TestListenableWorkerBuilder

open class TestListenableWorkerBuilder<W : ListenableWorker!>
kotlin.Any
   ↳ androidx.work.testing.TestListenableWorkerBuilder

Builds instances of androidx.work.ListenableWorker which can be used for testing.

Summary

Public methods

open W

Builds the ListenableWorker.

open static TestListenableWorkerBuilder<ListenableWorker!>
from(@NonNull context: Context, @NonNull workRequest: WorkRequest)

Creates a new instance of a TestListenableWorkerBuilder from a WorkRequest.

open static TestListenableWorkerBuilder<W>
from(@NonNull context: Context, @NonNull workerClass: Class<W>)

Creates a new instance of a TestListenableWorkerBuilder the worker Class.

open TestListenableWorkerBuilder<ListenableWorker!>
setId(@NonNull id: UUID)

Sets the id for this unit of work.

open TestListenableWorkerBuilder<ListenableWorker!>
setInputData(@NonNull inputData: Data)

Adds input Data to the work.

open TestListenableWorkerBuilder<ListenableWorker!>
setNetwork(@NonNull network: Network)

Sets the network associated with this unit of work.

open TestListenableWorkerBuilder<ListenableWorker!>
setRunAttemptCount(runAttemptCount: Int)

Sets the initial run attempt count for this work.

open TestListenableWorkerBuilder<ListenableWorker!>
setTags(@NonNull tags: MutableList<String!>)

Sets the tags associated with this unit of work.

open TestListenableWorkerBuilder<ListenableWorker!>

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

open TestListenableWorkerBuilder<ListenableWorker!>
setTriggeredContentUris(@NonNull contentUris: MutableList<Uri!>)

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

open TestListenableWorkerBuilder<ListenableWorker!>
setWorkerFactory(@NonNull workerFactory: WorkerFactory)

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

Public methods

build

@NonNull open fun build(): W

Builds the ListenableWorker.

Return
W: the instance of a ListenableWorker.

from

@NonNull open static fun from(@NonNull context: Context, @NonNull workRequest: WorkRequest): TestListenableWorkerBuilder<ListenableWorker!>

Creates a new instance of a TestListenableWorkerBuilder from a WorkRequest.

Parameters
context Context: The Context
workRequest Context: The WorkRequest
Return
TestListenableWorkerBuilder<ListenableWorker!>: The new instance of a ListenableWorker

from

@NonNull open static fun <W : ListenableWorker!> from(@NonNull context: Context, @NonNull workerClass: Class<W>): TestListenableWorkerBuilder<W>

Creates a new instance of a TestListenableWorkerBuilder the worker Class.

Parameters
context Context: The Context
workerClass Context: The subtype of ListenableWorker being built
Return
TestListenableWorkerBuilder<W>: The new instance of a ListenableWorker

setId

@NonNull open fun setId(@NonNull id: UUID): TestListenableWorkerBuilder<ListenableWorker!>

Sets the id for this unit of work.

Parameters
id UUID: The UUID
Return
TestListenableWorkerBuilder<ListenableWorker!>: The current TestListenableWorkerBuilder

setInputData

@NonNull open fun setInputData(@NonNull inputData: Data): TestListenableWorkerBuilder<ListenableWorker!>

Adds input Data to the work.

Parameters
inputData Data: key/value pairs that will be provided to the worker
Return
TestListenableWorkerBuilder<ListenableWorker!>: The current TestListenableWorkerBuilder

setNetwork

@NonNull open fun setNetwork(@NonNull network: Network): TestListenableWorkerBuilder<ListenableWorker!>

Sets the network associated with this unit of work.

Parameters
network Network: The Network associated with this unit of work
Return
TestListenableWorkerBuilder<ListenableWorker!>: The current TestListenableWorkerBuilder

setRunAttemptCount

@NonNull open fun setRunAttemptCount(runAttemptCount: Int): TestListenableWorkerBuilder<ListenableWorker!>

Sets the initial run attempt count for this work.

Parameters
runAttemptCount Int: The initial run attempt count
Return
TestListenableWorkerBuilder<ListenableWorker!>: The current TestListenableWorkerBuilder

setTags

@NonNull open fun setTags(@NonNull tags: MutableList<String!>): TestListenableWorkerBuilder<ListenableWorker!>

Sets the tags associated with this unit of work.

Parameters
tags MutableList<String!>: The List of tags to be used
Return
TestListenableWorkerBuilder<ListenableWorker!>: The current TestListenableWorkerBuilder

setTriggeredContentAuthorities

@NonNull open fun setTriggeredContentAuthorities(@NonNull authorities: MutableList<String!>): TestListenableWorkerBuilder<ListenableWorker!>

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

Parameters
authorities MutableList<String!>: The List of authorities
Return
TestListenableWorkerBuilder<ListenableWorker!>: The current TestListenableWorkerBuilder

setTriggeredContentUris

@NonNull open fun setTriggeredContentUris(@NonNull contentUris: MutableList<Uri!>): TestListenableWorkerBuilder<ListenableWorker!>

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

Parameters
contentUris MutableList<Uri!>: The list of content Uris
Return
TestListenableWorkerBuilder<ListenableWorker!>: The current TestListenableWorkerBuilder

setWorkerFactory

@NonNull open fun setWorkerFactory(@NonNull workerFactory: WorkerFactory): TestListenableWorkerBuilder<ListenableWorker!>

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

Parameters
workerFactory WorkerFactory: The WorkerFactory to use to construct the androidx.work.ListenableWorker
Return
TestListenableWorkerBuilder<ListenableWorker!>: The current TestListenableWorkerBuilder