Fix failing instrumentation test
This test was scrolling by the thumb height as opposed to the
track height.
Fixes: 165843688
Test: atest CarUILibUnitTests
Change-Id: Ie1784759f0c438b86998d21b17f7dfd0e2acf861
diff --git a/car-ui-lib/car-ui-lib/src/androidTest/java/com/android/car/ui/recyclerview/CarUiRecyclerViewTest.java b/car-ui-lib/car-ui-lib/src/androidTest/java/com/android/car/ui/recyclerview/CarUiRecyclerViewTest.java
index 168ab98..8d1bf9a 100644
--- a/car-ui-lib/car-ui-lib/src/androidTest/java/com/android/car/ui/recyclerview/CarUiRecyclerViewTest.java
+++ b/car-ui-lib/car-ui-lib/src/androidTest/java/com/android/car/ui/recyclerview/CarUiRecyclerViewTest.java
@@ -402,10 +402,13 @@
View trackView = mActivity.requireViewById(R.id.car_ui_scrollbar_track);
View thumbView = mActivity.requireViewById(R.id.car_ui_scrollbar_thumb);
+ // if you drag too far in a single step you'll stop selecting the thumb view
+ int numSteps = (int) Math.ceil(
+ trackView.getHeight() / (float) thumbView.getHeight() * 1.1f);
// drag and scroll to the middle
onView(withId(R.id.car_ui_scrollbar_track)).perform(
performDrag(0f, (thumbView.getHeight() / 2f), 0,
- (thumbView.getHeight() / 2f) - 1, 10, Float.MAX_VALUE,
+ (trackView.getHeight() / 2f) / numSteps, numSteps, Float.MAX_VALUE,
trackView.getHeight() / 2f));
onView(withText(adapter.getItemText(25))).check(matches(isDisplayed()));
}