# TestTileClient

Artifact: [androidx.wear.tiles:tiles-testing](https://developer.android.com/jetpack/androidx/releases/wear-tiles) [View Source](https://cs.android.com/search?q=file:androidx/wear/tiles/testing/TestTileClient.kt+class:androidx.wear.tiles.testing.TestTileClient) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.0.0)

*** ** * ** ***

<br />

```
class TestTileClient<T : TileService> : TileClient
```

<br />

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/wear/tiles/client/TileClient` for testing purposes. This will pass calls through to the given instance of `https://developer.android.com/reference/kotlin/androidx/wear/tiles/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 `https://developer.android.com/reference/android/app/Service.html#onCreate()` method, however, it will never call `https://developer.android.com/reference/android/app/Service.html#onDestroy()`. Equally, where `https://developer.android.com/reference/kotlin/androidx/wear/tiles/connection/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 `https://developer.android.com/reference/android/app/Service.html#onDestroy()` on the passed in `service` instance.

## Summary

| ### Public constructors |
|---|
| `<T : https://developer.android.com/reference/kotlin/androidx/wear/tiles/TileService> https://developer.android.com/reference/kotlin/androidx/wear/tiles/testing/TestTileClient#TestTileClient(androidx.wear.tiles.TileService,java.util.concurrent.Executor)(service: T, executor: https://developer.android.com/reference/java/util/concurrent/Executor.html)` Build a `https://developer.android.com/reference/kotlin/androidx/wear/tiles/testing/TestTileClient` for use with a given `https://developer.android.com/reference/java/util/concurrent/Executor.html` |
| `<T : https://developer.android.com/reference/kotlin/androidx/wear/tiles/TileService> https://developer.android.com/reference/kotlin/androidx/wear/tiles/testing/TestTileClient#TestTileClient(androidx.wear.tiles.TileService,kotlinx.coroutines.CoroutineScope,kotlinx.coroutines.CoroutineDispatcher)( service: T, coroutineScope: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html, coroutineDispatcher: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html )` Build a `https://developer.android.com/reference/kotlin/androidx/wear/tiles/testing/TestTileClient` for use with a coroutine dispatcher. |

| ### Public functions |
|---|---|
| `open https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>` | `https://developer.android.com/reference/kotlin/androidx/wear/tiles/testing/TestTileClient#requestApiVersion()()` Gets the API version supported by the connected TileService. |
| `open https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/kotlin/androidx/wear/tiles/ResourceBuilders.Resources>` | `[requestResources](https://developer.android.com/reference/kotlin/androidx/wear/tiles/testing/TestTileClient#requestResources(androidx.wear.tiles.RequestBuilders.ResourcesRequest))(requestParams: https://developer.android.com/reference/kotlin/androidx/wear/tiles/RequestBuilders.ResourcesRequest)` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/wear/tiles/client/TileClient#requestTileResourcesAsync(androidx.wear.tiles.RequestBuilders.ResourcesRequest)` instead. <br /> |
| `open https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/kotlin/androidx/wear/tiles/TileBuilders.Tile>` | `https://developer.android.com/reference/kotlin/androidx/wear/tiles/testing/TestTileClient#requestTile(androidx.wear.tiles.RequestBuilders.TileRequest)(requestParams: https://developer.android.com/reference/kotlin/androidx/wear/tiles/RequestBuilders.TileRequest)` Request a tile payload from the connected TileService. |
| `open https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ResourceBuilders.Resources>` | `https://developer.android.com/reference/kotlin/androidx/wear/tiles/testing/TestTileClient#requestTileResourcesAsync(androidx.wear.tiles.RequestBuilders.ResourcesRequest)( requestParams: https://developer.android.com/reference/kotlin/androidx/wear/tiles/RequestBuilders.ResourcesRequest )` Request a resource bundle from the connected TileService. |
| `open https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/java/lang/Void.html?>` | `https://developer.android.com/reference/kotlin/androidx/wear/tiles/testing/TestTileClient#sendOnTileAddedEvent()()` Send a Tile Added notification to the connected TileService. |
| `open https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/java/lang/Void.html?>` | `https://developer.android.com/reference/kotlin/androidx/wear/tiles/testing/TestTileClient#sendOnTileEnterEvent()()` Send a Tile Enter notification to the connected TileService. |
| `open https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/java/lang/Void.html?>` | `https://developer.android.com/reference/kotlin/androidx/wear/tiles/testing/TestTileClient#sendOnTileLeaveEvent()()` Send a Tile Leave notification to the connected TileService. |
| `open https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/java/lang/Void.html?>` | `https://developer.android.com/reference/kotlin/androidx/wear/tiles/testing/TestTileClient#sendOnTileRemovedEvent()()` Send a Tile Removed notification to the connected TileService. |

## Public constructors

### TestTileClient

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

Build a `https://developer.android.com/reference/kotlin/androidx/wear/tiles/testing/TestTileClient` for use with a given `https://developer.android.com/reference/java/util/concurrent/Executor.html`

| Parameters |
|---|---|
| `service: T` | An instance of the `https://developer.android.com/reference/kotlin/androidx/wear/tiles/TileService` class to bind to. |
| `executor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | An `https://developer.android.com/reference/java/util/concurrent/Executor.html` to use when dispatching calls to the `https://developer.android.com/reference/kotlin/androidx/wear/tiles/TileService`. |

### TestTileClient

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

Build a `https://developer.android.com/reference/kotlin/androidx/wear/tiles/testing/TestTileClient` for use with a coroutine dispatcher.

| Parameters |
|---|---|
| `service: T` | An instance of the `https://developer.android.com/reference/kotlin/androidx/wear/tiles/TileService` class to bind to. |
| `coroutineScope: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html` | A `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html` to use when dispatching calls to the `https://developer.android.com/reference/kotlin/androidx/wear/tiles/TileService`. Cancelling the passed `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html` will also cancel any pending work in this class. |
| `coroutineDispatcher: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html` | A `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html` to use when dispatching work from this class. |

## Public functions

### requestApiVersion

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.0.0)

```
open fun requestApiVersion(): ListenableFuture<Int>
```

Gets the API version supported by the connected TileService.

### requestResources

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.0.0) Deprecated in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.2.0)

```
open fun [requestResources](https://developer.android.com/reference/kotlin/androidx/wear/tiles/testing/TestTileClient#requestResources(androidx.wear.tiles.RequestBuilders.ResourcesRequest))(requestParams: RequestBuilders.ResourcesRequest): ListenableFuture<ResourceBuilders.Resources>
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/wear/tiles/client/TileClient#requestTileResourcesAsync(androidx.wear.tiles.RequestBuilders.ResourcesRequest)` instead.

Request a resource bundle from the connected TileService.

### requestTile

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#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](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.0.0)

```
open fun sendOnTileAddedEvent(): ListenableFuture<Void?>
```

Send a Tile Added notification to the connected TileService.

### sendOnTileEnterEvent

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.0.0)

```
open fun sendOnTileEnterEvent(): ListenableFuture<Void?>
```

Send a Tile Enter notification to the connected TileService.

### sendOnTileLeaveEvent

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.0.0)

```
open fun sendOnTileLeaveEvent(): ListenableFuture<Void?>
```

Send a Tile Leave notification to the connected TileService.

### sendOnTileRemovedEvent

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.0.0)

```
open fun sendOnTileRemovedEvent(): ListenableFuture<Void?>
```

Send a Tile Removed notification to the connected TileService.