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(Build a |
<T extends TileService> TestTileClient(Build a |
Public methods |
|
|---|---|
@NonNull ListenableFuture<@NonNull Integer> |
Gets the API version supported by the connected TileService. |
@NonNull ListenableFuture<@NonNull ResourceBuilders.Resources> |
This method is deprecated. Use |
@NonNull ListenableFuture<@NonNull TileBuilders.Tile> |
requestTile(@NonNull RequestBuilders.TileRequest requestParams)Request a tile payload from the connected TileService. |
@NonNull ListenableFuture<@NonNull ResourceBuilders.Resources> |
requestTileResourcesAsync(Request a resource bundle from the connected TileService. |
@NonNull ListenableFuture<Void> |
Send a Tile Added notification to the connected TileService. |
@NonNull ListenableFuture<Void> |
Send a Tile Enter notification to the connected TileService. |
@NonNull ListenableFuture<Void> |
Send a Tile Leave notification to the connected TileService. |
@NonNull ListenableFuture<Void> |
Send a Tile Removed notification to the connected TileService. |
Public constructors
TestTileClient
public <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 |
@NonNull Executor executor |
An |
TestTileClient
public <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 |
@NonNull CoroutineScope coroutineScope |
A |
@NonNull CoroutineDispatcher coroutineDispatcher |
A |
Public methods
requestApiVersion
public @NonNull ListenableFuture<@NonNull Integer> requestApiVersion()
Gets the API version supported by the connected TileService.
public @NonNull ListenableFuture<@NonNull ResourceBuilders.Resources>requestResources(
@NonNull RequestBuilders.ResourcesRequest requestParams
)
Request a resource bundle from the connected TileService.
requestTile
public @NonNull ListenableFuture<@NonNull TileBuilders.Tile> requestTile(@NonNull RequestBuilders.TileRequest requestParams)
Request a tile payload from the connected TileService.
requestTileResourcesAsync
public @NonNull ListenableFuture<@NonNull ResourceBuilders.Resources> requestTileResourcesAsync(
@NonNull RequestBuilders.ResourcesRequest requestParams
)
Request a resource bundle from the connected TileService.
sendOnTileAddedEvent
public @NonNull ListenableFuture<Void> sendOnTileAddedEvent()
Send a Tile Added notification to the connected TileService.
sendOnTileEnterEvent
public @NonNull ListenableFuture<Void> sendOnTileEnterEvent()
Send a Tile Enter notification to the connected TileService.
sendOnTileLeaveEvent
public @NonNull ListenableFuture<Void> sendOnTileLeaveEvent()
Send a Tile Leave notification to the connected TileService.
sendOnTileRemovedEvent
public @NonNull ListenableFuture<Void> sendOnTileRemovedEvent()
Send a Tile Removed notification to the connected TileService.