mbmc
mbmc

Reputation: 5105

How to test that views are overlapping?

Using espresso, how to test that views are overlapping?

isDisplayed() will return true, even though it's not visible to the user.

isCompletelyVisible() is used for scrollable views.

noOverlaps only deals with TextView and ImageView.

Views are created on the fly, and don't have any id assigned. It also doesn't matter if they are completely or partially overlapping.

I'm thinking to compare the index of 2 views inside the parent container?

Upvotes: 2

Views: 1314

Answers (1)

Keith
Keith

Reputation: 811

Perhaps you could you use a combination of the PositionAssertions mentioned here:

https://developer.android.com/reference/android/support/test/espresso/assertion/PositionAssertions

maybe a combination of isCompletelyAbove() || isCompletelyBelow() || is CompletelyLeftOf() || isCompletelyRightOf() could get you what you want?

Or the opposite isPartiallyAbove() || isPartiallyBelow() || isPartiallyLeftOf() || isPartiallyRightOf()?

Or you could create your own ViewAssertion that checks the on screen position and width/height of each view and compare that way?

Upvotes: 1

Related Questions