WindowLayoutInfoPublisherRule

public final class WindowLayoutInfoPublisherRule


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

public final WindowLayoutInfoPublisherRule()

Public methods

overrideWindowLayoutInfo

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

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