I use Espresso library in my project. In tutorial and samples have examples how to test adapter and view. But I have custom adapter and custom specific view. My view:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/tvCity"
style="@style/Widget.TextView.OnlyOneLine"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/ab_city_spinner_inner_padding"
android:text="Test"
android:textColor="@color/ab_city_spinner_city_text"
android:textSize="@dimen/ab_city_spinner_city_text_size" />
<TextView
android:id="@+id/tvRegion"
style="@style/Widget.TextView.OnlyOneLine"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/ab_city_spinner_inner_padding"
android:text="Test"
android:textColor="@color/ab_city_spinner_region_text"
android:textSize="@dimen/ab_city_spinner_region_text_size" /></LinearLayout>
My test:
@SmallTest
public void testChangeCity()
{
onView(withId(R.id.spAB)).perform(ViewActions.click());
onView(allOf(withText("City1"), hasSibling(withText("Test")))).perform(ViewActions.click());
}
It's work. But I don't now what data have view. Haw can I open Spinner and click for item?