WindowMetricsCalculatorRule


public final class WindowMetricsCalculatorRule implements TestRule


A TestRule that will sub out the actual WindowMetricsCalculator with a more simple one that will support testing independent of the current platform. The fake WindowMetricsCalculator that is used will return the width and height from the android.util.DisplayMetrics associated to an Activity. The result of WindowMetricsCalculator.computeCurrentWindowMetrics and WindowMetricsCalculator.computeMaximumWindowMetrics will be the same. For accurate results use the Espresso Test framework with an actual Activity and use the actual WindowMetricsCalculator.

Summary

Public constructors

Public methods

@NonNull Statement
apply(@NonNull Statement base, @NonNull Description description)
final void

Overrides the window bounds with a new WindowMetrics.

final void
overrideCurrentWindowBounds(int left, int top, int right, int bottom)

Overrides the window bounds with a new rectangle defined by the specified coordinates.

Public constructors

WindowMetricsCalculatorRule

Added in 1.2.0
public WindowMetricsCalculatorRule()

Public methods

apply

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

overrideCurrentWindowBounds

Added in 1.4.0-beta01
public final void overrideCurrentWindowBounds(@NonNull WindowMetrics windowMetrics)

Overrides the window bounds with a new WindowMetrics.

overrideCurrentWindowBounds

Added in 1.4.0-beta01
public final void overrideCurrentWindowBounds(int left, int top, int right, int bottom)

Overrides the window bounds with a new rectangle defined by the specified coordinates.