material-components / material-components/material-components-android

[BadgeUtils] Expose Espresso matchers to match attached drawable

Open
#2,770 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request Issue: Test Widget: Badge
Dominant language
Java
Stars
17.4k
Forks
3.2k
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is.
Currently, when adding espresso tests, aiming to cover `BadgeUtils.attachBadgeDrawable` there is no way to write fluent assertions on the badge produced by `BadgeUtils`

**Describe the solution you'd like**
A clear and concise description of what you want to happen.
I'd expect to have class similar to i.e. ` androidx.test.espresso.contrib.RecyclerViewActions` which would expose convenient utilities to assert i.e.
`onView(fixtureView).check(matches(hasBadgeDrawable(contentDesritpion = "View updates")))`

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
I tried to set `setContentDescriptionNumberless` or `setContentDescriptionQuantityStringsResource` but there is no way to assert them using Espresso :/
I tried to write custom matcher accessing `view#getOverlay` but ViewOverlay's api seems to be too restricted
I tried to use reflection to read `ViewOverlay`'s drawables but this obviously doesn't work on recent android versions

**Additional context**
Add any other context or screenshots about the feature request here.

We also happily accept [pull requests](https://github.com/material-components/material-components-android/pulls).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating BadgeUtils.attachBadgeDrawable and the existing Espresso matcher utilities or tests in the repository. Determine how an assertion can observe the attached badge drawable and define completion as a matcher that verifies the badge content description through Espresso.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile-dev, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.