Java Code Examples for android.support.test.espresso.DataInteraction

The following are top voted examples for showing how to use android.support.test.espresso.DataInteraction. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: TitanCompanion   File: TCBaseTest.java   View source code 6 votes vote down vote up
protected void performStartAdventure() {
    ViewInteraction button = onView(allOf(withText(getString(R.string.create_new_adventure)), isDisplayed()));
    button.perform(click());


    //Clicks over the proper book using the property order of the GamebookEnum
    DataInteraction textView = onData(anything())
            .inAdapterView(allOf(withId(R.id.gamebookListView),
                    childAtPosition(
                            withClassName(is("android.widget.RelativeLayout")),
                            0)))
            .atPosition(getGamebook().getOrder() - 1);
    textView.perform(click());

    button = onView(allOf(withText(getString(R.string.create_new_adventure)), isDisplayed()));
    button.perform(click());

    Espresso.closeSoftKeyboard();
}
 
Example 2
Project: orgzly-android   File: EspressoUtils.java   View source code 5 votes vote down vote up
/**
 */
@SuppressWarnings("unchecked")
public static DataInteraction onListItem(int pos) {
    return onData(anything())
            .inAdapterView(allOf(withId(android.R.id.list), isDisplayed()))
            .atPosition(pos);
}
 
Example 3
Project: TitanCompanion   File: TestSOTS.java   View source code 5 votes vote down vote up
public void performChoosemartialArt() {

        DataInteraction linearLayout = onData(anything())
                .inAdapterView(allOf(withId(R.id.skillList),
                        childAtPosition(
                                withClassName(is("android.widget.RelativeLayout")),
                                1)))
                .atPosition(0);
        linearLayout.perform(click());
    }
 
Example 4
Project: TitanCompanion   File: TestTCOC.java   View source code 5 votes vote down vote up
public void performChooseSpells() {
    DataInteraction textView2 = onData(anything())
            .inAdapterView(allOf(withId(R.id.spellListView),
                    childAtPosition(
                            withClassName(is("android.widget.LinearLayout")),
                            1)))
            .atPosition(0);
    textView2.perform(click());

    DataInteraction textView3 = onData(anything())
            .inAdapterView(allOf(withId(R.id.spellListView),
                    childAtPosition(
                            withClassName(is("android.widget.LinearLayout")),
                            1)))
            .atPosition(0);
    textView3.perform(click());

    DataInteraction textView4 = onData(anything())
            .inAdapterView(allOf(withId(R.id.spellListView),
                    childAtPosition(
                            withClassName(is("android.widget.LinearLayout")),
                            1)))
            .atPosition(1);
    textView4.perform(click());

    DataInteraction textView5 = onData(anything())
            .inAdapterView(allOf(withId(R.id.spellListView),
                    childAtPosition(
                            withClassName(is("android.widget.LinearLayout")),
                            1)))
            .atPosition(1);
    textView5.perform(click());
}
 
Example 5
Project: TitanCompanion   File: TestAWF.java   View source code 5 votes vote down vote up
public void performChooseSuperpower() {

        DataInteraction linearLayout = onData(anything())
                .inAdapterView(allOf(withId(R.id.superpowerList),
                        childAtPosition(
                                withClassName(is("android.widget.RelativeLayout")),
                                1)))
                .atPosition(0);
        linearLayout.perform(click());
    }
 
Example 6
Project: TitanCompanion   File: TCBaseTest.java   View source code 5 votes vote down vote up
protected void performChoosePotion() {
    DataInteraction linearLayout = onData(anything())
            .inAdapterView(allOf(withId(R.id.potionList),
                    childAtPosition(
                            withClassName(is("android.widget.LinearLayout")),
                            0)))
            .atPosition(0);
    linearLayout.perform(click());
}
 
Example 7
Project: GroupScheduleCoordinator   File: MainActivityTest.java   View source code 5 votes vote down vote up
@Test
public void testExistingGroup() throws InterruptedException {
    //Given a preexisting group newGroup, when we search for new group in the list view,
    //then the new group is still there (and clickable)
    Thread.sleep(1000);
    DataInteraction v2 = onData(hasToString(startsWith("newGroup")))
            .inAdapterView(withId(R.id.groupList)).atPosition(0);
    v2.check(matches(withText("newGroup")));
}
 
Example 8
Project: Cook-E   File: HomeActivityTest.java   View source code 5 votes vote down vote up
/**
     * Tests clicking on a meal in the meal list to open it
     */
    public void testOpenMeal() throws SQLException {
        final Matcher<View> mealList = withTagKey(R.id.test_tag_meal_list,
                Is.<Object>is("Meal List"));
        final DataInteraction mealItem = onData(anything()).inAdapterView(mealList);
        mealItem.perform(click());
        // Check that the MealViewActivity activity has started
        // The below statement produces an error in the instrumentation code.
        // TODO: Fix
//        intended(hasComponent(new ComponentName(getInstrumentation().getTargetContext(),
//                MealViewActivity.class)));
    }
 
Example 9
Project: green-coffee   File: DataMatcher.java   View source code 5 votes vote down vote up
public ActionableData with(C content)
{
    DataInteraction dataInteraction = onData(dataMatcher(content));

    if (resourceId != 0)
    {
        return new ActionableData(dataInteraction.inAdapterView(withId(resourceId)));
    }
    else
    {
        return new ActionableData(dataInteraction);
    }
}
 
Example 10
Project: rCaltrain   File: ApplicationTest.java   View source code 5 votes vote down vote up
@Test
public void test_schedule_saturday() {
    String fromName = "San Francisco";
    String toName = "22nd St";

    onView(withId(R.id.btn_sat)).perform(click());

    onView(withId(R.id.input_departure)).perform(click());
    onData(is(fromName)).perform(click());

    onView(withId(R.id.input_arrival)).perform(click());
    onData(is(toName)).perform(click());

    List<String> expects = Arrays.asList("08:07 => 08:11",
                                         "09:37 => 09:41",
                                         "11:07 => 11:11",
                                         "12:37 => 12:41",
                                         "14:07 => 14:11",
                                         "15:37 => 15:41",
                                         "17:07 => 17:11",
                                         "18:37 => 18:41",
                                         "20:07 => 20:11",
                                         "21:37 => 21:41",
                                         "22:51 => 22:55",
                                         "00:05 => 00:10");

    onView(withId(R.id.results)).check(matches(new ResultListMatcher(fromName,
                                                                     toName,
                                                                     expects.size())));

    DataInteraction interaction = onData(anything()).inAdapterView(withId(R.id.results));
    for (int l = expects.size() - 1; l >= 0; l--) {
        String expect = expects.get(l);
        interaction
                .atPosition(l)
                .check(matches(new ResultViewMatcher(fromName, toName, l, expect)));
    }
}
 
Example 11
Project: rCaltrain   File: ApplicationTest.java   View source code 5 votes vote down vote up
@Test
public void test_schedule_sunday() {
    String fromName = "San Francisco";
    String toName = "22nd St";

    onView(withId(R.id.btn_sun)).perform(click());

    onView(withId(R.id.input_departure)).perform(click());
    onData(is(fromName)).perform(click());

    onView(withId(R.id.input_arrival)).perform(click());
    onData(is(toName)).perform(click());

    List<String> expects = Arrays.asList("08:07 => 08:11",
                                         "09:37 => 09:41",
                                         "11:07 => 11:11",
                                         "12:37 => 12:41",
                                         "14:07 => 14:11",
                                         "15:37 => 15:41",
                                         "17:07 => 17:11",
                                         "18:37 => 18:41",
                                         "20:07 => 20:11",
                                         "21:37 => 21:41");

    onView(withId(R.id.results)).check(matches(new ResultListMatcher(fromName,
                                                                     toName,
                                                                     expects.size())));

    DataInteraction interaction = onData(anything()).inAdapterView(withId(R.id.results));
    for (int l = expects.size() - 1; l >= 0; l--) {
        String expect = expects.get(l);
        interaction
                .atPosition(l)
                .check(matches(new ResultViewMatcher(fromName, toName, l, expect)));
    }
}
 
Example 12
Project: apps-android-wikipedia   File: PageActivityTest.java   View source code 5 votes vote down vote up
public static void testArticleLoad(Activity activity) {

        while (!viewIsDisplayed(R.id.search_results_list)) {
            waitFor(WAIT_FOR_1000);
        }

        DataInteraction view = onData(anything())
                .inAdapterView(allOf(withId(R.id.search_results_list),
                        childAtPosition(
                                withId(R.id.search_results_container),
                                1)))
                .atPosition(0);
        view.perform(click());
        while (!viewIsDisplayed(R.id.view_page_header_image)) {
            waitFor(WAIT_FOR_2000);
        }
        ScreenshotTools.snap("Barack");

        onView(withId(R.id.view_page_header_image))
                .perform(swipeUp());

        onView(withId(R.id.page_fragment))
                .perform(swipeUp());
        ScreenshotTools.snap("ArticleSwipeUpNoActionBar");

        onView(withId(R.id.page_fragment))
                .perform(swipeUp());
        onView(withId(R.id.page_fragment))
                .perform(swipeDown());
        ScreenshotTools.snap("ArticleSwipeDownActionBarAndTabSeen");

    }
 
Example 13
Project: orgzly-android   File: EspressoUtils.java   View source code 4 votes vote down vote up
static DataInteraction onSpinnerString(String value) {
    return onData(allOf(instanceOf(String.class), is(value))).inRoot(not(isDialog()));
}
 
Example 14
Project: GroupScheduleCoordinator   File: AddMemberTest.java   View source code 4 votes vote down vote up
@Test
public void testAddMember(){
    //Given that we have a new group, when we click on it
    onData(hasToString(startsWith("Group E")))
            .inAdapterView(withId(R.id.groupList)).atPosition(0)
            .perform(click());

    //and when we click on members in the content page
    ViewInteraction appCompatTextView7 = onView(
            allOf(withId(android.R.id.title), withText("Members"), isDisplayed()));
    appCompatTextView7.perform(click());

    //and when we click on add members
    onView(withId(R.id.addmembers))
            .perform(click());

    //and when we type in the name of and email of the new member
    ViewInteraction appCompatEditText = onView(
            allOf(withId(R.id.tbMemberName), isDisplayed()));
    appCompatEditText.perform(click());

    appCompatEditText.perform(replaceText("Harry"), closeSoftKeyboard());

    ViewInteraction appCompatEditText4 = onView(
            allOf(withId(R.id.tbMemberEmail), isDisplayed()));
    appCompatEditText4.perform(replaceText("[email protected]"), closeSoftKeyboard());

    ViewInteraction appCompatEditText5 = onView(
            allOf(withId(R.id.tbMemberEmail), withText("[email protected]"), isDisplayed()));
    appCompatEditText5.perform(pressImeActionButton());

    //and click on the button add member
    ViewInteraction appCompatButton2 = onView(
            allOf(withId(R.id.btnCreateGroup), withText("Add Member"), isDisplayed()));
    appCompatButton2.perform(click());

    ViewInteraction appCompatTextView5 = onView(
            allOf(withId(android.R.id.title), withText("Members"), isDisplayed()));
    appCompatTextView5.perform(click());

    //then a new member with the info we just inputted appears in the list view
    DataInteraction v2 = onData(hasToString(startsWith("[email protected]")))
            .inAdapterView(withId(R.id.lvMembers)).atPosition(0);
    v2.check(matches(withText("[email protected]")));

}
 
Example 15
Project: GroupScheduleCoordinator   File: MainActivityTest.java   View source code 4 votes vote down vote up
@Test
public void testAddMember() throws InterruptedException {
    Thread.sleep(1000);
    ViewInteraction floatingActionButton = onView(
            allOf(withId(R.id.myFab),
                    withParent(allOf(withId(R.id.activity_main),
                            withParent(withId(android.R.id.content)))),
                    isDisplayed()));
    floatingActionButton.perform(click());

    Thread.sleep(1000);
    //and when we create a new group
    onView(withId(R.id.userInputDialog))
            .perform(typeText("Group C"));

    Thread.sleep(1000);
    ViewInteraction appCompatButton = onView(
            allOf(withId(android.R.id.button1), withText("Create"),
                    withParent(allOf(withId(R.id.buttonPanel),
                            withParent(withId(R.id.parentPanel)))),
                    isDisplayed()));
    appCompatButton.perform(click());

    //when we enter the new group
    onData(hasToString(startsWith("Group C")))
            .inAdapterView(withId(R.id.groupList)).atPosition(0)
            .perform(click());

    //When we click on members...
    ViewInteraction appCompatTextView7 = onView(
            allOf(withId(android.R.id.title), withText("Members"), isDisplayed()));
    appCompatTextView7.perform(click());

    //then members content page appears. When we click on it...
    onView(withId(R.id.addmembers))
            .check(matches(isDisplayed()))
            .perform(click());

    //Then Dialog appears to enter member
    ViewInteraction appCompatEditText = onView(
            allOf(withId(R.id.tbMemberName), isDisplayed()));
    appCompatEditText.perform(click());

    //When we enter "Students" for the name of the new member
    appCompatEditText.perform(replaceText("Students"), closeSoftKeyboard());

    //and when we enter an email
    ViewInteraction appCompatEditText4 = onView(
            allOf(withId(R.id.tbMemberEmail), isDisplayed()));
    appCompatEditText4.perform(typeText("[email protected]"), closeSoftKeyboard());

    //and when we click addmember
    ViewInteraction appCompatButton2 = onView(
            allOf(withId(R.id.btnCreateGroup), withText("Add Member"), isDisplayed()));
    appCompatButton2.perform(click());

    //and when we cut away from member content page
    ViewInteraction appCompatTextView5 = onView(
            allOf(withId(android.R.id.title), withText("Info"), isDisplayed()));
    appCompatTextView5.perform(click());

    //when we come back to the member content page
    ViewInteraction appCompatTextView9 = onView(
            allOf(withId(android.R.id.title), withText("Members"), isDisplayed()));
    appCompatTextView9.perform(click());

    //the new member's email is still there!
    DataInteraction v2 = onData(hasToString(startsWith("[email protected]")))
            .inAdapterView(withId(R.id.lvMembers)).atPosition(0);
    v2.check(matches(withText("[email protected]")));
}
 
Example 16
Project: GroupScheduleCoordinator   File: MainActivityTest.java   View source code 4 votes vote down vote up
@Test
public void testAddMembertoExisting() throws InterruptedException {
    //when we enter the new group
    Thread.sleep(1000);
    onData(hasToString(startsWith("newGroup")))
            .inAdapterView(withId(R.id.groupList)).atPosition(0)
            .perform(click());

    //When we click on members...
    ViewInteraction appCompatTextView7 = onView(
            allOf(withId(android.R.id.title), withText("Members"), isDisplayed()));
    appCompatTextView7.perform(click());

    //then members content page appears. When we click on it...
    onView(withId(R.id.addmembers))
            .check(matches(isDisplayed()))
            .perform(click());

    //Then Dialog appears to enter member
    ViewInteraction appCompatEditText = onView(
            allOf(withId(R.id.tbMemberName), isDisplayed()));
    appCompatEditText.perform(click());

    //When we enter "Students" for the name of the new member
    appCompatEditText.perform(replaceText("Dogs"), closeSoftKeyboard());

    //and when we enter an email
    ViewInteraction appCompatEditText4 = onView(
            allOf(withId(R.id.tbMemberEmail), isDisplayed()));
    appCompatEditText4.perform(typeText("[email protected]"), closeSoftKeyboard());

    //and when we click addmember
    ViewInteraction appCompatButton2 = onView(
            allOf(withId(R.id.btnCreateGroup), withText("Add Member"), isDisplayed()));
    appCompatButton2.perform(click());

    //and when we cut away from member content page
    ViewInteraction appCompatTextView5 = onView(
            allOf(withId(android.R.id.title), withText("Info"), isDisplayed()));
    appCompatTextView5.perform(click());

    //when we come back to the member content page
    ViewInteraction appCompatTextView9 = onView(
            allOf(withId(android.R.id.title), withText("Members"), isDisplayed()));
    appCompatTextView9.perform(click());

    //the new member's email is still there!
    DataInteraction v2 = onData(hasToString(startsWith("[email protected]")))
            .inAdapterView(withId(R.id.lvMembers)).atPosition(0);
    v2.check(matches(withText("[email protected]")));

    if (m2)
    {
        DataInteraction v3 = onData(hasToString(startsWith("[email protected]")))
                .inAdapterView(withId(R.id.lvMembers)).atPosition(0);
        v3.check(matches(withText("[email protected]")));
    }

    m1 = true;
}
 
Example 17
Project: GroupScheduleCoordinator   File: MainActivityTest.java   View source code 4 votes vote down vote up
@Test
public void addMember2Existing() throws InterruptedException {
    Thread.sleep(1000);
    onData(hasToString(startsWith("newGroup")))
            .inAdapterView(withId(R.id.groupList)).atPosition(0)
            .perform(click());

    //When we click on members...
    ViewInteraction appCompatTextView7 = onView(
            allOf(withId(android.R.id.title), withText("Members"), isDisplayed()));
    appCompatTextView7.perform(click());

    //then members content page appears. When we click on it...
    onView(withId(R.id.addmembers))
            .check(matches(isDisplayed()))
            .perform(click());

    //Then Dialog appears to enter member
    ViewInteraction appCompatEditText = onView(
            allOf(withId(R.id.tbMemberName), isDisplayed()));
    appCompatEditText.perform(click());

    //When we enter "Students" for the name of the new member
    appCompatEditText.perform(replaceText("Cats"), closeSoftKeyboard());

    //and when we enter an email
    ViewInteraction appCompatEditText4 = onView(
            allOf(withId(R.id.tbMemberEmail), isDisplayed()));
    appCompatEditText4.perform(typeText("[email protected]"), closeSoftKeyboard());

    //and when we click addmember
    ViewInteraction appCompatButton2 = onView(
            allOf(withId(R.id.btnCreateGroup), withText("Add Member"), isDisplayed()));
    appCompatButton2.perform(click());

    //and when we click on the members tab
    ViewInteraction ac = onView(
            allOf(withId(android.R.id.title), withText("Members"), isDisplayed()));
    ac.perform(click());

    Thread.sleep(1000);
    //the new member's email is still there!
    DataInteraction v2 = onData(hasToString(startsWith("[email protected]")))
            .inAdapterView(withId(R.id.lvMembers)).atPosition(0);
    v2.check(matches(withText("[email protected]")));

    if (m1)
    {
        //tests that given a previously existing member, when we add a new member and return
        //to the member list view, the previously created member is still there.
        Thread.sleep(1000);
        DataInteraction v3 = onData(hasToString(startsWith("[email protected]")))
                .inAdapterView(withId(R.id.lvMembers)).atPosition(0);
        v3.check(matches(withText("[email protected]")));
    }
    m2 = true;
}
 
Example 18
Project: green-coffee   File: ActionableData.java   View source code 4 votes vote down vote up
public ActionableData(DataInteraction dataInteraction)
{
    this.dataInteraction = dataInteraction;
}
 
Example 19
Project: rxpresso   File: Then.java   View source code 4 votes vote down vote up
public DataInteraction thenOnData(Matcher<Object> dataMatcher) {
    return onData(dataMatcher);
}
 
Example 20
Project: Bill-Calculator   File: ProviderSettingsTester.java   View source code 4 votes vote down vote up
public Preference getPreferenceAtLine(int index) {
    DataInteraction dataInteraction = onData(anything())
            .inAdapterView(withId(android.R.id.list))
            .atPosition(index);
    return new Preference(dataInteraction);
}
 
Example 21
Project: Bill-Calculator   File: ProviderSettingsTester.java   View source code 4 votes vote down vote up
public Preference getPreferenceWithTitle(@StringRes int id) {
    DataInteraction dataInteraction = onData(allOf(instanceOf(EditTextPreference.class), withTitle(id)));
    return new Preference(dataInteraction);
}
 
Example 22
Project: Bill-Calculator   File: ProviderSettingsTester.java   View source code 4 votes vote down vote up
private Preference(DataInteraction dataInteraction) {
    this.dataInteraction = dataInteraction;
}
 
Example 23
Project: openhab-android   File: BasicWidgetTest.java   View source code 4 votes vote down vote up
@Test
public void openHABMainActivityTest() throws InterruptedException {
    ViewInteraction firstRecyclerView = onView(withId(R.id.recyclerview));
    firstRecyclerView
            .perform(RecyclerViewActions.scrollToPosition(0))
            .check(matches(atPositionOnView(0, isDisplayed(), R.id.widgetlabel)))
            .check(matches(atPositionOnView(0, withText("First Floor"), R.id.widgetlabel)));

    firstRecyclerView
            .perform(RecyclerViewActions.scrollToPosition(6))
            .check(matches(atPositionOnView(6, isDisplayed(), R.id.widgetlabel)))
            .check(matches(atPositionOnView(6, withText("Astronomical Data"), R.id.widgetlabel)));

    // does it show "garden"?
    firstRecyclerView
            .perform(RecyclerViewActions.scrollToPosition(3))
            .check(matches(atPositionOnView(3, isDisplayed(), R.id.widgetlabel)))
            .check(matches(atPositionOnView(3, withText("Garden"), R.id.widgetlabel)));

    // open widget overview
    firstRecyclerView
            .perform(RecyclerViewActions.actionOnItemAtPosition(10, click()));

    // FIXME: is there a more elegant way to wait for the new fragment?
    Thread.sleep(1000);

    // check whether selection widget appears and click on it
    ViewInteraction secondRecyclerView = onView(withIndex(withId(R.id.recyclerview), 1));

    secondRecyclerView
            .perform(RecyclerViewActions.scrollToPosition(4))
            .check(matches(atPositionOnView(4, withText("Scene Selection"), R.id.widgetlabel)))
            .check(matches(atPositionOnView(4, isDisplayed(), R.id.selectionspinner)))
            .perform(RecyclerViewActions.actionOnItemAtPosition(4, onChildView(click(), R.id.selectionspinner)));

    DataInteraction appCompatCheckedTextView = onData(anything())
            .inAdapterView(withClassName(
                    is("com.android.internal.app.AlertController$RecycleListView")))
            .atPosition(0);
    appCompatCheckedTextView.check(matches(withText("off")));
    appCompatCheckedTextView.perform(click());

    // check whether scene radio button group is present
    secondRecyclerView
            .perform(RecyclerViewActions.scrollToPosition(5))
            .check(matches(atPositionOnView(5, isDisplayed(), R.id.sectionswitchradiogroup)));

    // check whether switch is displayed
    secondRecyclerView
            .perform(RecyclerViewActions.scrollToPosition(1))
            .check(matches(atPositionOnView(1, isDisplayed(), R.id.switchswitch)));

    // check whether slider is displayed
    secondRecyclerView
            .perform(RecyclerViewActions.scrollToPosition(8))
            .check(matches(atPositionOnView(8, isDisplayed(), R.id.sliderseekbar)));

    // check whether color control button is displayed
    secondRecyclerView
            .perform(RecyclerViewActions.scrollToPosition(9))
            .check(matches(atPositionOnView(9, isDisplayed(), R.id.colorbutton_color)));

    // check whether roller shutter button is displayed
    secondRecyclerView
            .perform(RecyclerViewActions.scrollToPosition(10))
            .check(matches(atPositionOnView(10, isDisplayed(), R.id.rollershutterbutton_stop)));
}
 
Example 24
Project: rCaltrain   File: ApplicationTest.java   View source code 4 votes vote down vote up
@Test
public void test_schedule_weekday() {
    String fromName = "San Francisco";
    String toName = "22nd St";

    onView(withId(R.id.btn_week)).perform(click());

    onView(withId(R.id.input_departure)).perform(click());
    onData(is(fromName)).perform(click());

    onView(withId(R.id.input_arrival)).perform(click());
    onData(is(toName)).perform(click());

    List<String> expects = Arrays.asList("04:55 => 04:59",
                                         "05:25 => 05:29",
                                         "06:05 => 06:09",
                                         "06:15 => 06:19",
                                         "06:35 => 06:39",
                                         "06:45 => 06:51",
                                         "06:59 => 07:03",
                                         "07:05 => 07:10",
                                         "07:15 => 07:19",
                                         "07:35 => 07:39",
                                         "07:45 => 07:51",
                                         "07:59 => 08:03",
                                         "08:05 => 08:10",
                                         "08:15 => 08:19",
                                         "08:35 => 08:39",
                                         "08:45 => 08:49",
                                         "09:00 => 09:05",
                                         "10:00 => 10:04",
                                         "11:00 => 11:04",
                                         "12:00 => 12:04",
                                         "13:00 => 13:04",
                                         "14:00 => 14:04",
                                         "15:00 => 15:04",
                                         "16:32 => 16:36",
                                         "17:32 => 17:36",
                                         "18:32 => 18:36",
                                         "19:30 => 19:34",
                                         "20:30 => 20:34",
                                         "21:30 => 21:34",
                                         "22:40 => 22:44",
                                         "00:05 => 00:10");

    onView(withId(R.id.results)).check(matches(new ResultListMatcher(fromName,
                                                                     toName,
                                                                     expects.size())));

    DataInteraction interaction = onData(anything()).inAdapterView(withId(R.id.results));
    for (int l = expects.size() - 1; l >= 0; l--) {
        String expect = expects.get(l);
        interaction
                .atPosition(l)
                .check(matches(new ResultViewMatcher(fromName, toName, l, expect)));
    }
}
 
Example 25
Project: Ironhide   File: ListItem.java   View source code 4 votes vote down vote up
/**
 * @see BaseView#BaseView(Class, org.hamcrest.Matcher)
 * Instead instantiates a {@link DataInteraction}
 */
@SuppressWarnings("unchecked")
public ListItem(Class<T> type, DataInteraction adapter) {
    super(type, (Matcher) anything());
    this.adapter = adapter;
}
 
Example 26
Project: Ironhide   File: ListAdapter.java   View source code 4 votes vote down vote up
/**
 * Retains type and adapter for use later on.
 * @param type  the class of the generic type
 * @param adapter   the {@link android.support.test.espresso.DataInteraction} for the {@link android.widget.AdapterView} this represents
 */
@SuppressWarnings("unchecked")
private ListAdapter(Class<T> type, DataInteraction adapter) {
    super(type, (Matcher) anything());
    this.adapter = adapter;
}
 
Example 27
Project: apps-android-wikipedia   File: SearchTest.java   View source code 4 votes vote down vote up
public static void searchKeywordAndGo(@NonNull String keyword) {

        while (!viewIsDisplayed(R.id.search_container)) {
            waitFor(WAIT_FOR_1000);
        }

        ViewInteraction linearLayout = onView(
                allOf(withId(R.id.search_container),
                        childAtPosition(
                                childAtPosition(
                                        withId(R.id.fragment_feed_feed),
                                        0),
                                0),
                        isDisplayed()));
        linearLayout.perform(click());

        ViewInteraction frameLayout = onView(
                allOf(withId(R.id.search_lang_button_container), withContentDescription("Wikipedia language"),
                        childAtPosition(
                                childAtPosition(
                                        withId(R.id.search_toolbar),
                                        1),
                                1),
                        isDisplayed()));
        frameLayout.perform(click());

        ViewInteraction plainPasteEditText = onView(
                allOf(withId(R.id.preference_languages_filter),
                        childAtPosition(
                                childAtPosition(
                                        withClassName(is("android.support.design.widget.TextInputLayout")),
                                        0),
                                0),
                        isDisplayed()));
        plainPasteEditText.perform(replaceText("test"), closeSoftKeyboard());

        // take screenshot
        ScreenshotTools.snap("SearchPage");

        DataInteraction linearLayout2 = onData(anything())
                .inAdapterView(allOf(withId(R.id.preference_languages_list),
                        childAtPosition(
                                withClassName(is("android.widget.LinearLayout")),
                                1)))
                .atPosition(0);
        linearLayout2.perform(click());

        ViewInteraction searchAutoComplete = onView(
                allOf(withId(R.id.search_src_text),
                        childAtPosition(
                                allOf(withId(R.id.search_plate),
                                        childAtPosition(
                                                withId(R.id.search_edit_frame),
                                                1)),
                                0),
                        isDisplayed()));
        searchAutoComplete.perform(replaceText(keyword), closeSoftKeyboard());

        // hold until the result fetch
        while (!viewIsDisplayed(R.id.search_results_list)) {
            waitFor(WAIT_FOR_1000);
        }

        // take screenshot
        ScreenshotTools.snap("SearchSuggestionPage");

    }
 
Example 28
Project: igrow-android   File: EnvironmentalSensorsActivityTest.java   View source code 2 votes vote down vote up
/**
 * Uses {@link Espresso#onData(org.hamcrest.Matcher)} to get a reference to a specific row.
 * <p>
 * Note: A custom matcher can be used to match the content and have more readable code.
 * See the Custom Matcher Sample.
 * </p>
 *
 * @param str the content of the field
 * @return a {@link DataInteraction} referencing the row
 */
private static DataInteraction onRow(String str) {
    //return onData(hasEntry(equalTo(LongListActivity.ROW_TEXT), is(str)));
    return null;
}
 
Example 29
Project: AndroidProjects   File: LongListActivityTest.java   View source code 2 votes vote down vote up
/**
 * Uses {@link Espresso#onData(org.hamcrest.Matcher)} to get a reference to a specific row.
 * <p>
 * Note: A custom matcher can be used to match the content and have more readable code.
 * See the Custom Matcher Sample.
 * </p>
 *
 * @param str the content of the field
 * @return a {@link DataInteraction} referencing the row
 */
private static DataInteraction onRow(String str) {
    return onData(hasEntry(equalTo(LongListActivity.ROW_TEXT), is(str)));
}