# WindowLayoutInfoPublisherRule

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

*** ** * ** ***


```
class WindowLayoutInfoPublisherRule : TestRule
```

<br />

*** ** * ** ***

A `https://junit.org/junit4/javadoc/latest/org/junit/rules/TestRule.html` to help test consuming a stream of `https://developer.android.com/reference/kotlin/androidx/window/layout/WindowLayoutInfo` values. `https://developer.android.com/reference/kotlin/androidx/window/testing/layout/WindowLayoutInfoPublisherRule` allows you to push through different `https://developer.android.com/reference/kotlin/androidx/window/layout/WindowLayoutInfo` values on demand.

Here are some recommended testing scenarios.

To test the scenario where no `https://developer.android.com/reference/kotlin/androidx/window/layout/WindowLayoutInfo` is ever emitted. Just set the rule as a standard rule.

To test sending a generic feature build your own `https://developer.android.com/reference/kotlin/androidx/window/layout/WindowLayoutInfo` and publish it through the method `https://developer.android.com/reference/kotlin/androidx/window/testing/layout/WindowLayoutInfoPublisherRule#overrideWindowLayoutInfo(androidx.window.layout.WindowLayoutInfo)`.

Some helper methods are provided to test the following scenarios.

- A fold in the middle and the dimension matches the shortest window dimension.
- A fold in the middle and the dimension matches the longest window dimension.
- A fold in the middle and has vertical orientation.
- A fold in the middle and has horizontal orientation.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/window/testing/layout/WindowLayoutInfoPublisherRule#WindowLayoutInfoPublisherRule()()` |

| ### Public functions |
|---|---|
| `open https://junit.org/junit4/javadoc/latest/org/junit/runners/model/Statement.html` | `https://developer.android.com/reference/kotlin/androidx/window/testing/layout/WindowLayoutInfoPublisherRule#apply(org.junit.runners.model.Statement,org.junit.runner.Description)(base: https://junit.org/junit4/javadoc/latest/org/junit/runners/model/Statement.html, description: https://junit.org/junit4/javadoc/latest/org/junit/runner/Description.html)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/window/testing/layout/WindowLayoutInfoPublisherRule#overrideWindowLayoutInfo(androidx.window.layout.WindowLayoutInfo)(info: https://developer.android.com/reference/kotlin/androidx/window/layout/WindowLayoutInfo)` Send an arbitrary `https://developer.android.com/reference/kotlin/androidx/window/layout/WindowLayoutInfo` through `https://developer.android.com/reference/kotlin/androidx/window/layout/WindowInfoTracker#windowLayoutInfo(android.content.Context)`. |

## Public constructors

### WindowLayoutInfoPublisherRule

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

```
WindowLayoutInfoPublisherRule()
```

## Public functions

### apply

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

```
open fun apply(base: Statement, description: Description): Statement
```

### overrideWindowLayoutInfo

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

```
fun overrideWindowLayoutInfo(info: WindowLayoutInfo): Unit
```

Send an arbitrary `https://developer.android.com/reference/kotlin/androidx/window/layout/WindowLayoutInfo` through `https://developer.android.com/reference/kotlin/androidx/window/layout/WindowInfoTracker#windowLayoutInfo(android.content.Context)`. Each event is sent only once.