TestTileClient


class TestTileClient<T : TileService> : TileClient


TileClient for testing purposes. This will pass calls through to the given instance of TileService, handling all the service binding (via Robolectric), and serialization/deserialization.

Note that this class will not drive the full service lifecycle for the passed service instance. On the first call to any of these methods, it will call your service's Service.onCreate method, however, it will never call Service.onDestroy. Equally, where DefaultTileClient will unbind after a period of time, potentially destroying the service, this class wil Client will unbind, but not destroy the service. If you wish to test service destruction, you can instead call Service.onDestroy on the passed in service instance.

Summary

Public constructors

<T : TileService> TestTileClient(service: T, executor: Executor)

Build a TestTileClient for use with a given Executor

<T : TileService> TestTileClient(
    service: T,
    coroutineScope: CoroutineScope,
    coroutineDispatcher: CoroutineDispatcher
)

Build a TestTileClient for use with a coroutine dispatcher.

Public functions

open ListenableFuture<Int>

Gets the API version supported by the connected TileService.

open ListenableFuture<ResourceBuilders.Resources>

This function is deprecated.

Use requestTileResourcesAsync instead.

open ListenableFuture<TileBuilders.Tile>

Request a tile payload from the connected TileService.

open ListenableFuture<ResourceBuilders.Resources>

Request a resource bundle from the connected TileService.

open ListenableFuture<Void?>

Send a Tile Added notification to the connected TileService.

open ListenableFuture<Void?>

Send a Tile Enter notification to the connected TileService.

open ListenableFuture<Void?>

Send a Tile Leave notification to the connected TileService.

open ListenableFuture<Void?>

Send a Tile Removed notification to the connected TileService.

Public constructors

TestTileClient

<T : TileService> TestTileClient(service: T, executor: Executor)

Build a TestTileClient for use with a given Executor

Parameters
service: T

An instance of the TileService class to bind to.

executor: Executor

An Executor to use when dispatching calls to the TileService.

TestTileClient

<T : TileService> TestTileClient(
    service: T,
    coroutineScope: CoroutineScope,
    coroutineDispatcher: CoroutineDispatcher
)

Build a TestTileClient for use with a coroutine dispatcher.

Parameters
service: T

An instance of the TileService class to bind to.

coroutineScope: CoroutineScope

A CoroutineScope to use when dispatching calls to the TileService. Cancelling the passed CoroutineScope will also cancel any pending work in this class.

coroutineDispatcher: CoroutineDispatcher

A CoroutineDispatcher to use when dispatching work from this class.

Public functions

requestApiVersion

Added in 1.0.0
open fun requestApiVersion(): ListenableFuture<Int>

Gets the API version supported by the connected TileService.

requestResources

Added in 1.0.0
Deprecated in 1.2.0
open fun requestResources(requestParams: RequestBuilders.ResourcesRequest): ListenableFuture<ResourceBuilders.Resources>

Request a resource bundle from the connected TileService.

requestTile

Added in 1.0.0
open fun requestTile(requestParams: RequestBuilders.TileRequest): ListenableFuture<TileBuilders.Tile>

Request a tile payload from the connected TileService.

requestTileResourcesAsync

open fun requestTileResourcesAsync(
    requestParams: RequestBuilders.ResourcesRequest
): ListenableFuture<ResourceBuilders.Resources>

Request a resource bundle from the connected TileService.

sendOnTileAddedEvent

Added in 1.0.0
open fun sendOnTileAddedEvent(): ListenableFuture<Void?>

Send a Tile Added notification to the connected TileService.

sendOnTileEnterEvent

Added in 1.0.0
open fun sendOnTileEnterEvent(): ListenableFuture<Void?>

Send a Tile Enter notification to the connected TileService.

sendOnTileLeaveEvent

Added in 1.0.0
open fun sendOnTileLeaveEvent(): ListenableFuture<Void?>

Send a Tile Leave notification to the connected TileService.

sendOnTileRemovedEvent

Added in 1.0.0
open fun sendOnTileRemovedEvent(): ListenableFuture<Void?>

Send a Tile Removed notification to the connected TileService.