TestTileClient

public final class TestTileClient<T extends TileService> implements 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 extends TileService> TestTileClient(
    @NonNull T service,
    @NonNull Executor executor
)

Build a TestTileClient for use with a given Executor

<T extends TileService> TestTileClient(
    @NonNull T service,
    @NonNull CoroutineScope coroutineScope,
    @NonNull CoroutineDispatcher coroutineDispatcher
)

Build a TestTileClient for use with a coroutine dispatcher.

Public methods

@NonNull ListenableFuture<@NonNull Integer>

Gets the API version supported by the connected TileService.

@NonNull ListenableFuture<@NonNull ResourceBuilders.Resources>

Request a resource bundle from the connected TileService.

@NonNull ListenableFuture<@NonNull TileBuilders.Tile>

Request a tile payload from the connected TileService.

@NonNull ListenableFuture<@NonNull Void>

Send a Tile Added notification to the connected TileService.

@NonNull ListenableFuture<@NonNull Void>

Send a Tile Enter notification to the connected TileService.

@NonNull ListenableFuture<@NonNull Void>

Send a Tile Leave notification to the connected TileService.

@NonNull ListenableFuture<@NonNull Void>

Send a Tile Removed notification to the connected TileService.

Public constructors

TestTileClient

public final <T extends TileService> TestTileClient(
    @NonNull T service,
    @NonNull Executor executor
)

Build a TestTileClient for use with a given Executor

Parameters
@NonNull T service

An instance of the TileService class to bind to.

@NonNull Executor executor

An Executor to use when dispatching calls to the TileService.

TestTileClient

public final <T extends TileService> TestTileClient(
    @NonNull T service,
    @NonNull CoroutineScope coroutineScope,
    @NonNull CoroutineDispatcher coroutineDispatcher
)

Build a TestTileClient for use with a coroutine dispatcher.

Parameters
@NonNull T service

An instance of the TileService class to bind to.

@NonNull 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.

@NonNull CoroutineDispatcher coroutineDispatcher

A CoroutineDispatcher to use when dispatching work from this class.

Public methods

requestApiVersion

@NonNull
public ListenableFuture<@NonNull IntegerrequestApiVersion()

Gets the API version supported by the connected TileService.

requestResources

@NonNull
public ListenableFuture<@NonNull ResourceBuilders.ResourcesrequestResources(
    @NonNull RequestBuilders.ResourcesRequest requestParams
)

Request a resource bundle from the connected TileService.

requestTile

@NonNull
public ListenableFuture<@NonNull TileBuilders.TilerequestTile(@NonNull RequestBuilders.TileRequest requestParams)

Request a tile payload from the connected TileService.

sendOnTileAddedEvent

@NonNull
public ListenableFuture<@NonNull VoidsendOnTileAddedEvent()

Send a Tile Added notification to the connected TileService.

sendOnTileEnterEvent

@NonNull
public ListenableFuture<@NonNull VoidsendOnTileEnterEvent()

Send a Tile Enter notification to the connected TileService.

sendOnTileLeaveEvent

@