WindowLayoutInfoPublisherRule

public final class WindowLayoutInfoPublisherRule implements 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
public WindowLayoutInfoPublisherRule()

Public methods

apply

Added in 1.0.0
public @NonNull Statement apply(@NonNull Statement base, @NonNull Description description)

overrideWindowLayoutInfo

Added in 1.0.0
public final void overrideWindowLayoutInfo(@NonNull WindowLayoutInfo info)

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