I'm using a numberPicker on my Android app, and I want to make some E2E tests to check it. I made a customView that holds the NumberPicker that looks like this:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/numberPicker_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
style="@style/DatePickerLabel"
android:paddingBottom="11dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<FrameLayout
android:id="@+id/numberPicker_layout"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@drawable/number_picker_background"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/numberPicker_label">
<NumberPicker
android:id="@+id/numberPicker"
style="@style/NumberPickerText"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginBottom="1dp"
android:layout_gravity="center"
android:theme="@style/NumberPickerText"/>
</FrameLayout>
<ImageView
android:id="@+id/numberPicker_button"
android:src="@drawable/ic_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="@+id/numberPicker_layout"
app:layout_constraintEnd_toEndOf="@+id/numberPicker_layout"
app:layout_constraintBottom_toBottomOf="@id/numberPicker_layout"
android:layout_marginEnd="7dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
And to test it, I tried this:
protected fun numberPickerSelect(pickerId: Int, swipes: Int = 1) {
val pickerView = onView(
allOf(
withId(R.id.numberPicker),
isDescendantOfA(withId(pickerId))
)
)
pickerView.perform(click())
for (i in 0 until swipes) {
pickerView.perform(swipeUp())
}
}
but it throws me this error:
Error performing 'single click' on view 'Animations or transitions are enabled on the target device.
And if I remove the click() action and keep only the swipe, it throw the same error for swipeUp() too. I need to say that animations are disabled on the device, and I'm pretty sure of that. Do you have any tips to test a numberPicker please ?
Thanks.