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

Slider instrumentation testing is not supported (espresso)

Open
#3,275 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

**Description:**
There is a Slider view included in the Material Design website: https://m3.material.io/components/sliders/overview
![image](https://user-images.githubusercontent.com/17856537/222101905-f16f9fdd-00bc-470b-b433-ecd16313f1c1.png)

I would like to test some functionality regarding Slider via instrumentation tests.
However, there are no ViewAssertions or ViewInteractions that specifically support slider values.

For assertions that's manageable since some custom assertions can be made.

For interactions though, to my understanding there is no way to change the slider values. I can obtain the slider instance and change value parameter to a new value. But this does not simulate the user's "click" on that value and therefore no actions (e.g. screen transitions) based on that click are triggered.

**Expected behavior:**
I would expect to be able to perform a click on a slider value via a provided api, something like this:
```
onView(withId(R.id.slider)).perform(clickSliderValue(10.0f))
```
**Source code:**
- Not applicable

**Minimal sample app repro:**
- Not applicable

**Android API version:**
- Not applicable

**Material Library version:**
com.google.android.material:material:1.8.0

**Device:** Device on which the bug was encountered here
- Not applicable

To help us triage faster, please check to make sure you are using the [latest version](https://github.com/material-components/material-components-android/releases) of the library.

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 reviewing Espresso ViewInteractions and ViewActions, then examine the Material Slider behavior described in the issue. Determine how an instrumentation action can target a slider value and trigger the same behavior as a user interaction. Done means a provided slider-value interaction exists and supports the expected screen-transition use case, with instrumentation coverage.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.