# 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)

*** ** * ** ***


```
public interface HostActivity.HostedTest
```

<br />

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

|---|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/ExoHostedTest` | A `https://developer.android.com/reference/androidx/media3/test/utils/HostActivity.HostedTest` for `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer` playback tests. |

*** ** * ** ***

Interface for tests that run inside of a `https://developer.android.com/reference/androidx/media3/test/utils/HostActivity`.

## Summary

| ### Public methods |
|---|---|
| `abstract boolean` | `https://developer.android.com/reference/androidx/media3/test/utils/HostActivity.HostedTest#blockUntilStopped(long)(long timeoutMs)` Called on the main thread to block until the test has stopped or `https://developer.android.com/reference/androidx/media3/test/utils/HostActivity.HostedTest#forceStop()` is called. |
| `abstract boolean` | `https://developer.android.com/reference/androidx/media3/test/utils/HostActivity.HostedTest#forceStop()()` Called on the main thread to force stop the test (if it is not stopped already). |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/test/utils/HostActivity.HostedTest#onFinished()()` Called on the test thread after the test has finished and been stopped. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/test/utils/HostActivity.HostedTest#onStart(androidx.media3.test.utils.HostActivity,android.view.Surface,android.widget.FrameLayout)( https://developer.android.com/reference/androidx/media3/test/utils/HostActivity host, https://developer.android.com/reference/android/view/Surface.html surface, https://developer.android.com/reference/android/widget/FrameLayout.html overlayFrameLayout )` Called on the main thread when the test is started. |

## Public methods

### blockUntilStopped

```
abstract boolean blockUntilStopped(long timeoutMs)
```

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

| Parameters |
|---|---|
| `long timeoutMs` | The maximum time to block in milliseconds. |

| Returns |
|---|---|
| `boolean` | Whether the test has stopped successful. |

### forceStop

```
abstract boolean forceStop()
```

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

| Returns |
|---|---|
| `boolean` | Whether the test was forced stopped. |

### onFinished

```
abstract void onFinished()
```

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

```
abstract void onStart(
    HostActivity host,
    Surface surface,
    FrameLayout overlayFrameLayout
)
```

Called on the main thread when the test is started.

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

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