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

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

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

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

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 WorkRequest: 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 Class<W>: The subtype of ListenableWorker being built
Return
TestListenableWorkerBuilder<W> The new instance of a ListenableWorker

setForegroundUpdater

@NonNull open fun setForegroundUpdater(@NonNull updater: ForegroundUpdater): TestListenableWorkerBuilder<ListenableWorker!>

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

Parameters
updater ForegroundUpdater: The ForegroundUpdater which can handle notification updates.
Return
TestListenableWorkerBuilder<ListenableWorker!> The current TestListenableWorkerBuilder

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

@RequiresApi(28) @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

setProgressUpdater

@NonNull open fun setProgressUpdater(@NonNull updater: ProgressUpdater): TestListenableWorkerBuilder<ListenableWorker!>

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

Parameters
updater ProgressUpdater: The ProgressUpdater which can handle progress updates.
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

@RequiresApi(24) @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

@RequiresApi(24) @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