PositionAssertions

public final class PositionAssertions


A collection of ViewAssertions for checking relative position of elements on the screen.

These comparisons are on the x,y plane; they ignore the z plane.

Summary

Public constructors

Public methods

static ViewAssertion
isAbove(Matcher<View> matcher)

This method is deprecated.

Use isCompletelyAbove instead.

static ViewAssertion
isBelow(Matcher<View> matcher)

This method is deprecated.

Use isCompletelyBelow instead.

static ViewAssertion
isBottomAlignedWith(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is bottom aligned with the view matching the given matcher.

static ViewAssertion
isCompletelyAbove(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is completely above the view matching the given matcher.

static ViewAssertion
isCompletelyBelow(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is completely below the view matching the given matcher.

static ViewAssertion
isCompletelyLeftOf(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is completely left of the view matching the given matcher.

static ViewAssertion
isCompletelyRightOf(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is completely right of the view matching the given matcher.

static ViewAssertion
isLeftAlignedWith(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is left aligned with the view matching the given matcher.

static ViewAssertion
isLeftOf(Matcher<View> matcher)

This method is deprecated.

Use isCompletelyLeftOf instead.

static ViewAssertion
isPartiallyAbove(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is partially above the view matching the given matcher.

static ViewAssertion
isPartiallyBelow(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is partially below the view matching the given matcher.

static ViewAssertion
isPartiallyLeftOf(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is partially left of the view matching the given matcher.

static ViewAssertion
isPartiallyRightOf(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is partially right of the view matching the given matcher.

static ViewAssertion
isRightAlignedWith(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is right aligned with the view matching the given matcher.

static ViewAssertion
isRightOf(Matcher<View> matcher)

This method is deprecated.

Use isCompletelyRightOf instead.

static ViewAssertion
isTopAlignedWith(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is top aligned with the view matching the given matcher.

Public constructors

PositionAssertions

public PositionAssertions()

Public methods

isAbove

public static ViewAssertion isAbove(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is completely above the view matching the given matcher.

Throws
junit.framework.AssertionFailedError junit.framework.AssertionFailedError

if there is any vertical overlap.

androidx.test.espresso.AmbiguousViewMatcherException androidx.test.espresso.AmbiguousViewMatcherException

if more than one view matches the given matcher.

androidx.test.espresso.NoMatchingViewException androidx.test.espresso.NoMatchingViewException

if no views match the given matcher.

isBelow

public static ViewAssertion isBelow(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is completely below the view matching the given matcher.

Throws
junit.framework.AssertionFailedError junit.framework.AssertionFailedError

if there any vertical overlap.

androidx.test.espresso.AmbiguousViewMatcherException androidx.test.espresso.AmbiguousViewMatcherException

if more than one view matches the given matcher.

androidx.test.espresso.NoMatchingViewException androidx.test.espresso.NoMatchingViewException

if no views match the given matcher.

isBottomAlignedWith

public static ViewAssertion isBottomAlignedWith(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is bottom aligned with the view matching the given matcher.

The bottom 'y' coordinate of the view displayed must equal the bottom 'y' coordinate of the view matching the given matcher.

Throws
junit.framework.AssertionFailedError junit.framework.AssertionFailedError

if the views are not aligned bottom.

androidx.test.espresso.AmbiguousViewMatcherException androidx.test.espresso.AmbiguousViewMatcherException

if more than one view matches the given matcher.

androidx.test.espresso.NoMatchingViewException androidx.test.espresso.NoMatchingViewException

if no views match the given matcher.

isCompletelyAbove

public static ViewAssertion isCompletelyAbove(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is completely above the view matching the given matcher.

Throws
junit.framework.AssertionFailedError junit.framework.AssertionFailedError

if there is any vertical overlap.

androidx.test.espresso.AmbiguousViewMatcherException androidx.test.espresso.AmbiguousViewMatcherException

if more than one view matches the given matcher.

androidx.test.espresso.NoMatchingViewException androidx.test.espresso.NoMatchingViewException

if no views match the given matcher.

isCompletelyBelow

public static ViewAssertion isCompletelyBelow(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is completely below the view matching the given matcher.

Throws
junit.framework.AssertionFailedError junit.framework.AssertionFailedError

if there is any vertical overlap.

androidx.test.espresso.AmbiguousViewMatcherException androidx.test.espresso.AmbiguousViewMatcherException

if more than one view matches the given matcher.

androidx.test.espresso.NoMatchingViewException androidx.test.espresso.NoMatchingViewException

if no views match the given matcher.

isCompletelyLeftOf

public static ViewAssertion isCompletelyLeftOf(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is completely left of the view matching the given matcher.

Throws
junit.framework.AssertionFailedError junit.framework.AssertionFailedError

if there is any horizontal overlap.

androidx.test.espresso.AmbiguousViewMatcherException androidx.test.espresso.AmbiguousViewMatcherException

if more than one view matches the given matcher.

androidx.test.espresso.NoMatchingViewException androidx.test.espresso.NoMatchingViewException

if no views match the given matcher.

isCompletelyRightOf

public static ViewAssertion isCompletelyRightOf(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is completely right of the view matching the given matcher.

Throws
junit.framework.AssertionFailedError junit.framework.AssertionFailedError

if there is any horizontal overlap.

androidx.test.espresso.AmbiguousViewMatcherException androidx.test.espresso.AmbiguousViewMatcherException

if more than one view matches the given matcher.

androidx.test.espresso.NoMatchingViewException androidx.test.espresso.NoMatchingViewException

if no views match the given matcher.

isLeftAlignedWith

public static ViewAssertion isLeftAlignedWith(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is left aligned with the view matching the given matcher.

The left 'x' coordinate of the view displayed must equal the left 'x' coordinate of the view matching the given matcher.

Throws
junit.framework.AssertionFailedError junit.framework.AssertionFailedError

if the views are not aligned to the left.

androidx.test.espresso.AmbiguousViewMatcherException androidx.test.espresso.AmbiguousViewMatcherException

if more than one view matches the given matcher.

androidx.test.espresso.NoMatchingViewException androidx.test.espresso.NoMatchingViewException

if no views match the given matcher.

isLeftOf

public static ViewAssertion isLeftOf(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is completely left of the view matching the given matcher.

Throws
junit.framework.AssertionFailedError junit.framework.AssertionFailedError

if there is any horizontal overlap.

androidx.test.espresso.AmbiguousViewMatcherException androidx.test.espresso.AmbiguousViewMatcherException

if more than one view matches the given matcher.

androidx.test.espresso.NoMatchingViewException androidx.test.espresso.NoMatchingViewException

if no views match the given matcher.

isPartiallyAbove

public static ViewAssertion isPartiallyAbove(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is partially above the view matching the given matcher.

Throws
junit.framework.AssertionFailedError junit.framework.AssertionFailedError

if there is no vertical overlap.

androidx.test.espresso.AmbiguousViewMatcherException androidx.test.espresso.AmbiguousViewMatcherException

if more than one view matches the given matcher.

androidx.test.espresso.NoMatchingViewException androidx.test.espresso.NoMatchingViewException

if no views match the given matcher.

isPartiallyBelow

public static ViewAssertion isPartiallyBelow(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is partially below the view matching the given matcher.

Throws
junit.framework.AssertionFailedError junit.framework.AssertionFailedError

if there is no vertical overlap.

androidx.test.espresso.AmbiguousViewMatcherException androidx.test.espresso.AmbiguousViewMatcherException

if more than one view matches the given matcher.

androidx.test.espresso.NoMatchingViewException androidx.test.espresso.NoMatchingViewException

if no views match the given matcher.

isPartiallyLeftOf

public static ViewAssertion isPartiallyLeftOf(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is partially left of the view matching the given matcher.

Throws
junit.framework.AssertionFailedError junit.framework.AssertionFailedError

if there is no horizontal overlap.

androidx.test.espresso.AmbiguousViewMatcherException androidx.test.espresso.AmbiguousViewMatcherException

if more than one view matches the given matcher.

androidx.test.espresso.NoMatchingViewException androidx.test.espresso.NoMatchingViewException

if no views match the given matcher.

isPartiallyRightOf

public static ViewAssertion isPartiallyRightOf(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is partially right of the view matching the given matcher.

Throws
junit.framework.AssertionFailedError junit.framework.AssertionFailedError

if there is no horizontal overlap.

androidx.test.espresso.AmbiguousViewMatcherException androidx.test.espresso.AmbiguousViewMatcherException

if more than one view matches the given matcher.

androidx.test.espresso.NoMatchingViewException androidx.test.espresso.NoMatchingViewException

if no views match the given matcher.

isRightAlignedWith

public static ViewAssertion isRightAlignedWith(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is right aligned with the view matching the given matcher.

The right 'x' coordinate of the view displayed must equal the right 'x' coordinate of the view matching the given matcher.

Throws
junit.framework.AssertionFailedError junit.framework.AssertionFailedError

if the views are not aligned to the right.

androidx.test.espresso.AmbiguousViewMatcherException androidx.test.espresso.AmbiguousViewMatcherException

if more than one view matches the given matcher.

androidx.test.espresso.NoMatchingViewException androidx.test.espresso.NoMatchingViewException

if no views match the given matcher.

isRightOf

public static ViewAssertion isRightOf(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is completely right of the view matching the given matcher.

Throws
junit.framework.AssertionFailedError junit.framework.AssertionFailedError

if there is any horizontal overlap.

androidx.test.espresso.AmbiguousViewMatcherException androidx.test.espresso.AmbiguousViewMatcherException

if more than one view matches the given matcher.

androidx.test.espresso.NoMatchingViewException androidx.test.espresso.NoMatchingViewException

if no views match the given matcher.

isTopAlignedWith

public static ViewAssertion isTopAlignedWith(Matcher<View> matcher)

Returns a ViewAssertion that asserts that view displayed is top aligned with the view matching the given matcher.

The top 'y' coordinate of the view displayed must equal the top 'y' coordinate of the view matching the given matcher.

Throws
junit.framework.AssertionFailedError junit.framework.AssertionFailedError

if the views are not aligned top.

androidx.test.espresso.AmbiguousViewMatcherException androidx.test.espresso.AmbiguousViewMatcherException

if more than one view matches the given matcher.

androidx.test.espresso.NoMatchingViewException androidx.test.espresso.NoMatchingViewException

if no views match the given matcher.