{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

BoundsAssertionsKt

public final class BoundsAssertionsKt


Summary

Public methods

static final @NonNull SemanticsNodeInteraction
assertHeightIsAtLeast(
    @NonNull SemanticsNodeInteraction receiver,
    @NonNull Dp expectedMinHeight
)

Asserts that the layout of this node has height that is greater than or equal to expectedMinHeight.

static final @NonNull SemanticsNodeInteraction
assertHeightIsEqualTo(
    @NonNull SemanticsNodeInteraction receiver,
    @NonNull Dp expectedHeight
)

Asserts that the layout of this node has height equal to expectedHeight.

static final void
assertIsEqualTo(
    @NonNull Dp receiver,
    @NonNull Dp expected,
    @NonNull String subject,
    @NonNull Dp tolerance
)

Asserts that this value is equal to the given expected value.

static final @NonNull SemanticsNodeInteraction

Asserts that the layout of this node has the left position in the root composable that is equal to the given position.

static final @NonNull SemanticsNodeInteraction
assertPositionInRootIsEqualTo(
    @NonNull SemanticsNodeInteraction receiver,
    @NonNull Dp expectedLeft,
    @NonNull Dp expectedTop
)

Asserts that the layout of this node has position in the root composable that is equal to the given position.

static final @NonNull SemanticsNodeInteraction

Asserts that the layout of this node has the top position in the root composable that is equal to the given position.

static final @NonNull SemanticsNodeInteraction
assertTouchHeightIsEqualTo(
    @NonNull SemanticsNodeInteraction receiver,
    @NonNull Dp expectedHeight
)

Asserts that the touch bounds of this node has height equal to expectedHeight.

static final @NonNull SemanticsNodeInteraction
assertTouchWidthIsEqualTo(
    @NonNull SemanticsNodeInteraction receiver,
    @NonNull Dp expectedWidth
)

Asserts that the touch bounds of this node has width equal to expectedWidth.

static final @NonNull SemanticsNodeInteraction
assertWidthIsAtLeast(
    @NonNull SemanticsNodeInteraction receiver,
    @NonNull Dp expectedMinWidth
)

Asserts that the layout of this node has width that is greater than or equal to expectedMinWidth.

static final @NonNull SemanticsNodeInteraction
assertWidthIsEqualTo(
    @NonNull SemanticsNodeInteraction receiver,
    @NonNull Dp expectedWidth
)

Asserts that the layout of this node has width equal to expectedWidth.

static final @NonNull Dp

Returns the position of an alignment line, or Dp.Unspecified if the line is not provided.

static final @NonNull DpRect

Returns the bounds of the layout of this node as clipped to the root.

static final @NonNull DpRect

Returns the bounds of the layout of this node.

Public methods

assertHeightIsAtLeast

public static final @NonNull SemanticsNodeInteraction assertHeightIsAtLeast(
    @NonNull SemanticsNodeInteraction receiver,
    @NonNull Dp expectedMinHeight
)

Asserts that the layout of this node has height that is greater than or equal to expectedMinHeight.

Throws
kotlin.AssertionError

if comparison fails.

assertHeightIsEqualTo

public static final @NonNull SemanticsNodeInteraction assertHeightIsEqualTo(
    @NonNull SemanticsNodeInteraction receiver,
    @NonNull Dp expectedHeight
)

Asserts that the layout of this node has height equal to expectedHeight.

Throws
kotlin.AssertionError

if comparison fails.

assertIsEqualTo

public static final void assertIsEqualTo(
    @NonNull Dp receiver,
    @NonNull Dp expected,
    @NonNull String subject,
    @NonNull Dp tolerance
)

Asserts that this value is equal to the given expected value.

Performs the comparison with the given tolerance or the default one if none is provided. It is recommended to use tolerance when comparing positions and size coming from the framework as there can be rounding operation performed by individual layouts so the values can be slightly off from the expected ones.

Parameters
@NonNull Dp expected

The expected value to which this one should be equal to.

@NonNull String subject

Used in the error message to identify which item this assertion failed on.

@NonNull Dp tolerance

The tolerance within which the values should be treated as equal.

Throws
kotlin.AssertionError

if comparison fails.

assertLeftPositionInRootIsEqualTo

public static final @NonNull SemanticsNodeInteraction assertLeftPositionInRootIsEqualTo(
    @NonNull SemanticsNodeInteraction receiver,
    @NonNull Dp expectedLeft
)

Asserts that the layout of this node has the left position in the root composable that is equal to the given position.

Parameters
@NonNull Dp expectedLeft

The left (x) position to assert.

Throws
kotlin.AssertionError

if comparison fails.

assertPositionInRootIsEqualTo

public static final @NonNull SemanticsNodeInteraction assertPositionInRootIsEqualTo(
    @NonNull SemanticsNodeInteraction receiver,
    @NonNull Dp expectedLeft,
    @NonNull Dp expectedTop
)

Asserts that the layout of this node has position in the root composable that is equal to the given position.

Parameters
@NonNull Dp expectedLeft

The left (x) position to assert.

@NonNull Dp expectedTop

The top (y) position to assert.

Throws
kotlin.AssertionError

if comparison fails.

assertTopPositionInRootIsEqualTo

public static final @NonNull SemanticsNodeInteraction assertTopPositionInRootIsEqualTo(
    @NonNull SemanticsNodeInteraction receiver,
    @NonNull Dp expectedTop
)

Asserts that the layout of this node has the top position in the root composable that is equal to the given position.

Parameters
@NonNull Dp expectedTop

The top (y) position to assert.

Throws
kotlin.AssertionError

if comparison fails.

assertTouchHeightIsEqualTo

public static final @NonNull SemanticsNodeInteraction assertTouchHeightIsEqualTo(
    @NonNull SemanticsNodeInteraction receiver,
    @NonNull Dp expectedHeight
)

Asserts that the touch bounds of this node has height equal to expectedHeight.

Throws
kotlin.AssertionError

if comparison fails.

assertTouchWidthIsEqualTo

public static final @NonNull SemanticsNodeInteraction assertTouchWidthIsEqualTo(
    @NonNull SemanticsNodeInteraction receiver,
    @NonNull Dp expectedWidth
)

Asserts that the touch bounds of this node has width equal to expectedWidth.

Throws
kotlin.AssertionError

if comparison fails.

assertWidthIsAtLeast

public static final @NonNull SemanticsNodeInteraction assertWidthIsAtLeast(
    @NonNull SemanticsNodeInteraction receiver,
    @NonNull Dp expectedMinWidth
)

Asserts that the layout of this node has width that is greater than or equal to expectedMinWidth.

Throws
kotlin.AssertionError

if comparison fails.

assertWidthIsEqualTo

public static final @NonNull SemanticsNodeInteraction assertWidthIsEqualTo(
    @NonNull SemanticsNodeInteraction receiver,
    @NonNull Dp expectedWidth
)

Asserts that the layout of this node has width equal to expectedWidth.

Throws
kotlin.AssertionError

if comparison fails.

getAlignmentLinePosition

public static final @NonNull Dp getAlignmentLinePosition(
    @NonNull SemanticsNodeInteraction receiver,
    @NonNull AlignmentLine alignmentLine
)

Returns the position of an alignment line, or Dp.Unspecified if the line is not provided.

getBoundsInRoot

public static final @NonNull DpRect getBoundsInRoot(@NonNull SemanticsNodeInteraction receiver)

Returns the bounds of the layout of this node as clipped to the root. The bounds are relative to the root composable.

getUnclippedBoundsInRoot

public static final @NonNull DpRect getUnclippedBoundsInRoot(@NonNull SemanticsNodeInteraction receiver)

Returns the bounds of the layout of this node. The bounds are relative to the root composable.