Skip to content

Instantly share code, notes, and snippets.

@cdmunoz
Created October 13, 2018 23:17
Show Gist options
  • Save cdmunoz/09db417cca1015dda4f825adefc361ed to your computer and use it in GitHub Desktop.
Save cdmunoz/09db417cca1015dda4f825adefc361ed to your computer and use it in GitHub Desktop.
WithSeekBarProgress: Matcher to check the value/progress of a SeekBar
public static Matcher<View> withSeekbarProgress(final int expectedProgress) {
return new BoundedMatcher<View, AppCompatSeekBar>(AppCompatSeekBar.class) {
@Override
public void describeTo(Description description) {
description.appendText("expected: ");
description.appendText("" + expectedProgress);
}
@Override
public boolean matchesSafely(AppCompatSeekBar seekBar) {
return seekBar.getProgress() == expectedProgress;
}
};
}
//how to use it
onView(withId(R.id.my_seekbar)).check(matches(withSeekbarProgress(100)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment