WindowLayoutInfoPublisherRule


class WindowLayoutInfoPublisherRule : TestRule


A TestRule to help test consuming a stream of WindowLayoutInfo values. WindowLayoutInfoPublisherRule allows you to push through different WindowLayoutInfo values on demand.

Here are some recommended testing scenarios.

To test the scenario where no WindowLayoutInfo is ever emitted. Just set the rule as a standard rule.

To test sending a generic feature build your own WindowLayoutInfo and publish it through the method WindowLayoutInfoPublisherRule.overrideWindowLayoutInfo.

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

Public constructors

WindowLayoutInfoPublisherRule

Added in 1.0.0
WindowLayoutInfoPublisherRule()

Public functions

apply

Added in 1.0.0
open fun apply(base: Statement, description: Description): Statement

overrideWindowLayoutInfo

Added in 1.0.0
fun overrideWindowLayoutInfo(info: WindowLayoutInfo): Unit

Send an arbitrary WindowLayoutInfo through androidx.window.layout.WindowInfoTracker.windowLayoutInfo. Each event is sent only once.