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

*** ** * ** ***


```
public final class WindowLayoutInfoPublisherRule implements 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/androidx/window/layout/WindowLayoutInfo` values. `https://developer.android.com/reference/androidx/window/testing/layout/WindowLayoutInfoPublisherRule` allows you to push through different `https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo` values on demand.

Here are some recommended testing scenarios.

To test the scenario where no `https://developer.android.com/reference/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/androidx/window/layout/WindowLayoutInfo` and publish it through the method `https://developer.android.com/reference/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/androidx/window/testing/layout/WindowLayoutInfoPublisherRule#WindowLayoutInfoPublisherRule()()` |

| ### Public methods |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://junit.org/junit4/javadoc/latest/org/junit/runners/model/Statement.html` | `https://developer.android.com/reference/androidx/window/testing/layout/WindowLayoutInfoPublisherRule#apply(org.junit.runners.model.Statement,org.junit.runner.Description)(@https://developer.android.com/reference/androidx/annotation/NonNull https://junit.org/junit4/javadoc/latest/org/junit/runners/model/Statement.html base, @https://developer.android.com/reference/androidx/annotation/NonNull https://junit.org/junit4/javadoc/latest/org/junit/runner/Description.html description)` |
| `final void` | `https://developer.android.com/reference/androidx/window/testing/layout/WindowLayoutInfoPublisherRule#overrideWindowLayoutInfo(androidx.window.layout.WindowLayoutInfo)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo info)` Send an arbitrary `https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo` through `https://developer.android.com/reference/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)

```
public WindowLayoutInfoPublisherRule()
```

## Public methods

### apply

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

```
public @NonNull Statement apply(@NonNull Statement base, @NonNull Description description)
```

### overrideWindowLayoutInfo

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

```
public final void overrideWindowLayoutInfo(@NonNull WindowLayoutInfo info)
```

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