# HostActivity.HostedTest

# HostActivity.HostedTest

Artifact:[androidx.media3:media3-test-utils](https://developer.android.com/jetpack/androidx/releases/media3)  
[View Source](https://cs.android.com/search?q=file:androidx/media3/test/utils/HostActivity.java+class:androidx.media3.test.utils.HostActivity.HostedTest)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/test/utils/HostActivity.HostedTest "View this page in Java")

<br />

```
interface HostActivity.HostedTest
```

<br />

Known direct subclasses  
[ExoHostedTest](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExoHostedTest)  

|----------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ExoHostedTest](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExoHostedTest) | A[HostedTest](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/HostActivity.HostedTest)for[ExoPlayer](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlayer)playback tests. |

*** ** * ** ***

Interface for tests that run inside of a[HostActivity](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/HostActivity).

## Summary

|                                ### Public functions                                 |
|-------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [blockUntilStopped](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/HostActivity.HostedTest#blockUntilStopped(long))`(timeoutMs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` Called on the main thread to block until the test has stopped or[forceStop](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/HostActivity.HostedTest#forceStop())is called.                                                                                                                                                          |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [forceStop](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/HostActivity.HostedTest#forceStop())`()` Called on the main thread to force stop the test (if it is not stopped already).                                                                                                                                                                                                                                                                                                                                                                                            |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)       | [onFinished](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/HostActivity.HostedTest#onFinished())`()` Called on the test thread after the test has finished and been stopped.                                                                                                                                                                                                                                                                                                                                                                                                   |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)       | [onStart](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/HostActivity.HostedTest#onStart(androidx.media3.test.utils.HostActivity,android.view.Surface,android.widget.FrameLayout))`(` ` host: `[HostActivity](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/HostActivity)`!,` ` surface: `[Surface](https://developer.android.com/reference/android/view/Surface.html)`!,` ` overlayFrameLayout: `[FrameLayout](https://developer.android.com/reference/android/widget/FrameLayout.html)`!` `)` Called on the main thread when the test is started. |

## Public functions

### blockUntilStopped

```
fun blockUntilStopped(timeoutMs: Long): Boolean
```

Called on the main thread to block until the test has stopped or[forceStop](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/HostActivity.HostedTest#forceStop())is called.  

|                                         Parameters                                         |
|--------------------------------------------------------------------------------------------|--------------------------------------------|
| `timeoutMs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | The maximum time to block in milliseconds. |

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | Whether the test has stopped successful. |

### forceStop

```
fun forceStop(): Boolean
```

Called on the main thread to force stop the test (if it is not stopped already).  

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|--------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | Whether the test was forced stopped. |

### onFinished

```
fun onFinished(): Unit
```

Called on the test thread after the test has finished and been stopped.

Implementations may use this method to assert that test criteria were met.  

### onStart

```
fun onStart(
    host: HostActivity!,
    surface: Surface!,
    overlayFrameLayout: FrameLayout!
): Unit
```

Called on the main thread when the test is started.

The test will not be started until the[HostActivity](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/HostActivity)has been resumed and its[Surface](https://developer.android.com/reference/android/view/Surface.html)has been created.  

|                                                    Parameters                                                     |
|-------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------|
| `host: `[HostActivity](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/HostActivity)`!` | The[HostActivity](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/HostActivity)in which the test is being run. |
| `surface: `[Surface](https://developer.android.com/reference/android/view/Surface.html)`!`                        | The[Surface](https://developer.android.com/reference/android/view/Surface.html).                                                         |
| `overlayFrameLayout: `[FrameLayout](https://developer.android.com/reference/android/widget/FrameLayout.html)`!`   | A[FrameLayout](https://developer.android.com/reference/android/widget/FrameLayout.html)that is on top of the surface.                    |