android / android/android-test
isDisplayingAtLeast does not check whether a parent obscures the view
- Dominant language
- Java
- Stars
- 1.2k
- Forks
- 342
- Avg merge
- 11h 29m
- Merged PRs (30d)
- 2
Description
### Description
According to the [documentation](https://developer.android.com/reference/android/support/test/espresso/matcher/ViewMatchers.html#isdisplayingatleast) isDisplayingAtLeast:
> Returns a matcher which accepts a view so long as a given percentage of that view's area **is not obscured by any parent view** and is thus visible to the user.
That's not what happens. It actuality the matcher only checks whether a sufficient portion of the view area is within the boundaries of the screen. It's evident from examining the code of `IsDisplayingAtLeastMatcher#matchesSafely`.
### Steps to Reproduce
Make the parent view clip a portion of the child view, e.g.:
```jsx
```
only 74% of the child view will be visible to the user, the bottom 26% will be clipped by the parent. Both views will render within the boundaries of the screen.
### Expected Results
`isDisplayingAtLeast(75)` should fail.
### Actual Results
`isDisplayingAtLeast(75)` passes even though only 74% is displayed.
### AndroidX Test and Android OS Versions
Android 9, espresso-core 3.1.1
Contributor guide
Research direction
Start at IsDisplayingAtLeastMatcher#matchesSafely and reproduce the supplied parent/child clipping case. Trace how the displayed area is calculated, then verify that isDisplayingAtLeast(75) fails when the parent clips 26% of the child while an unobscured case still passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- mobile-dev, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100