android.support.test.espresso.contrib.RecyclerViewActions Java Examples

The following examples show how to use android.support.test.espresso.contrib.RecyclerViewActions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: ChipsLayoutManager   Author: BelooS   File: ColumnTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void rotate_LMHasItems_firstItemNotChanged() throws Exception {
    //arrange
    recyclerView.perform(RecyclerViewActions.scrollToPosition(18));
    InstrumentalUtil.waitForIdle();

    int expected = layoutManager.findFirstVisibleItemPosition();
    //act
    rotateAndWaitIdle();
    int actual = layoutManager.findFirstVisibleItemPosition();
    //assert
    assertNotEquals(-1, expected);
    assertNotEquals(-1, actual);
    assertEquals("first visible positions before and after rotation doesn't match", expected, actual);
    System.out.println("first visible position = " + actual);

    resetToInitialAfterRotate();
}
 
Example #2
Source Project: ChipsLayoutManager   Author: BelooS   File: ColumnTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void gapsNormalization_OnLastRowDeleted_PaddingStaySame() throws Exception {
    //arrange
    {
        items.remove(39);
        items.remove(38);
        items.remove(37);
        activity.runOnUiThread(() -> activity.initialize());
        InstrumentalUtil.waitForIdle();
    }
    recyclerView.perform(RecyclerViewActions.scrollToPosition(36));
    //act
    recyclerView.perform(actionDelegate((uiController, recyclerView) -> items.remove(36)),
            notifyItemRemovedAction(36));
    //assert
    recyclerView.check(matches(atPosition(29, rvPaddingMatcher())));
}
 
Example #3
Source Project: ChipsLayoutManager   Author: BelooS   File: RowTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void scrollBy_LastItemInLastRowHasSmallSize_scrolledCompletelyToBiggestItemSize() throws Exception {
    //arrange
    {
        items.remove(39);
        items.remove(37);
    }
    activity.runOnUiThread(() -> activity.initialize());
    InstrumentalUtil.waitForIdle();

    //act
    recyclerView.perform(RecyclerViewActions.scrollToPosition(37),
            scrollBy(0, -200),
            scrollBy(0, 200));


    //assert
    recyclerView.check(matches(atPosition(36, rvPaddingMatcher())));
}
 
Example #4
Source Project: ChipsLayoutManager   Author: BelooS   File: RowTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void rotate_LMHasItems_firstItemNotChanged() throws Exception {
    //arrange
    recyclerView.perform(RecyclerViewActions.scrollToPosition(7));
    InstrumentalUtil.waitForIdle();

    int expected = layoutManager.findFirstVisibleItemPosition();
    //act
    rotateAndWaitIdle();
    int actual = layoutManager.findFirstVisibleItemPosition();
    resetToInitialAfterRotate();

    //assert
    assertNotEquals(-1, expected);
    assertNotEquals(-1, actual);
    assertEquals("first visible positions before and after rotation doesn't match", expected, actual);
    System.out.println("first visible position = " + actual);
}
 
Example #5
Source Project: ribot-app-android   Author: ribot   File: CheckInActivityTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void checkInAtVenueSuccessful() {
    main.launchActivity(null);
    int venuePosition = 3;
    Venue venue = mVenues.get(venuePosition);
    CheckIn checkIn = MockModelFabric.newCheckInWithVenue();
    checkIn.venue = venue;
    doReturn(Observable.just(checkIn))
            .when(component.getMockDataManager())
            .checkIn(CheckInRequest.fromVenue(venue.id));

    onView(withId(R.id.recycler_view_venues))
            .perform(RecyclerViewActions.actionOnItemAtPosition(venuePosition, click()));
    onView(allOf(withId(R.id.image_venue_tick), isDisplayed()))
            .check(matches(isDisplayed()));
}
 
Example #6
Source Project: ribot-app-android   Author: ribot   File: MainActivityTest.java    License: Apache License 2.0 6 votes vote down vote up
private void checkRibotDisplayOnRecyclerView(List<Ribot> ribotsToCheck) {
    for (int i = 0; i < ribotsToCheck.size(); i++) {
        onView(withId(R.id.recycler_view_team))
                .perform(RecyclerViewActions.scrollToPosition(i));
        Ribot ribot = ribotsToCheck.get(i);
        CheckIn checkIn = ribot.latestCheckIn;
        if (checkIn != null) {
            Encounter encounter = checkIn.latestBeaconEncounter;
            String expectedLocationName = encounter == null ? checkIn.getLocationName() :
                    encounter.beacon.zone.label;
            onView(withText(expectedLocationName))
                    .check(matches(isDisplayed()));
            onView(withText(ribot.profile.name.first))
                    .check(matches(isDisplayed()));
        }
    }
}
 
Example #7
Source Project: friendly-plans   Author: autyzm-pg   File: ChildListActivityTest.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Test
public void whenChildIsRemovedExpectChildIsNotOnTheList() {

    final int testedChildPosition = 5;
    onView(withId(R.id.rv_child_list))
            .perform(RecyclerViewActions
                    .actionOnItemAtPosition(testedChildPosition,
                            new ViewClicker(R.id.id_remove_child)));
    onView(withText(R.string.child_removal_confirmation_positive_button)).perform(click());
    onView(withId(R.id.rv_child_list)).perform(scrollToPosition(testedChildPosition));
    onView(withRecyclerView(R.id.rv_child_list)
            .atPosition(testedChildPosition))
            .check(matches(
                    not(hasDescendant(withText(EXPECTED_FIRST_NAME + " " + EXPECTED_LAST_NAME
                            + testedChildPosition)))));
}
 
Example #8
Source Project: friendly-plans   Author: autyzm-pg   File: ChildListActivityTest.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Test
public void whenOtherChildIsSelectedActiveExpectPreviousActiveChildNoLongerActiveInDB() {
    final int firstTestedChildPosition = 5;
    final int secondTestedChildPosition = 6;
    closeSoftKeyboard();
    onView(withId(R.id.rv_child_list))
            .perform(RecyclerViewActions
                    .actionOnItemAtPosition(firstTestedChildPosition, click()));
    onView(withId(R.id.id_set_active_child)).perform(click());
    assertThat(childRepository.getByIsActive().size(), is(1));
    assertThat(childRepository.getByIsActive().get(0).getSurname(),
            is(EXPECTED_LAST_NAME + firstTestedChildPosition));

    onView(withId(R.id.button_addRemoveChild)).perform(scrollTo()).perform(click());
    closeSoftKeyboard();
    onView(withId(R.id.rv_child_list))
            .perform(RecyclerViewActions
                    .actionOnItemAtPosition(secondTestedChildPosition, click()));
    onView(withId(R.id.id_set_active_child)).perform(click());
    assertThat(childRepository.getByIsActive().size(), is(1));
    assertThat(childRepository.getByIsActive().get(0).getSurname(),
            is(EXPECTED_LAST_NAME + secondTestedChildPosition));
}
 
Example #9
Source Project: friendly-plans   Author: autyzm-pg   File: TaskListActivityTest.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Test
public void whenSearchTaskIsRemovedExpectItToBeRemoved(){
    final int testedTaskPosition = 3;

    onView(withId(R.id.menu_search)).perform(typeText(expectedNameTask + testedTaskPosition));
    closeSoftKeyboard();

    onView(withId(R.id.rv_task_list))
            .perform(RecyclerViewActions
                    .actionOnItemAtPosition(0,
                            new ViewClicker(R.id.id_remove_task)));
    onView(withText(R.string.task_removal_confirmation_positive_button)).perform(click());

    onView(withRecyclerView(R.id.rv_task_list)
            .atPosition(0))
            .check(doesNotExist());
    onView(isAssignableFrom(EditText.class)).perform(clearText());
    closeSoftKeyboard();

    onView(withId(R.id.rv_task_list)).perform(scrollToPosition(testedTaskPosition));
    onView(withRecyclerView(R.id.rv_task_list)
            .atPosition(testedTaskPosition))
            .check(matches(hasDescendant(withText(expectedNameTask
                    + (testedTaskPosition + 1)))));
}
 
Example #10
Source Project: friendly-plans   Author: autyzm-pg   File: PlanListActivityTest.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Test
public void whenMultiplePlansAreRemovedExpectListRefreshedAfterEachOneOfThem() {
    final int testedFirstTaskPosition = 3;
    final int testedSecondTaskPosition = 4;
    onView(withId(R.id.rv_plan_list))
            .perform(RecyclerViewActions
                    .actionOnItemAtPosition(testedFirstTaskPosition,
                            new ViewClicker(R.id.id_remove_plan)));
    onView(withText(R.string.plan_removal_confirmation_positive_button)).perform(click());
    onView(withId(R.id.rv_plan_list)).perform(scrollToPosition(testedFirstTaskPosition));
    onView(withRecyclerView(R.id.rv_plan_list)
            .atPosition(testedFirstTaskPosition))
            .check(matches(not(hasDescendant(withText(expectedName
                    + testedFirstTaskPosition)))));

    onView(withId(R.id.rv_plan_list))
            .perform(RecyclerViewActions
                    .actionOnItemAtPosition(testedSecondTaskPosition - 1,
                            new ViewClicker(R.id.id_remove_plan)));
    onView(withText(R.string.plan_removal_confirmation_positive_button)).perform(click());
    onView(withId(R.id.rv_plan_list)).perform(scrollToPosition(testedSecondTaskPosition));
    onView(withRecyclerView(R.id.rv_plan_list)
            .atPosition(testedSecondTaskPosition))
            .check(matches(not(hasDescendant(withText(expectedName
                    + testedSecondTaskPosition)))));
}
 
Example #11
Source Project: friendly-plans   Author: autyzm-pg   File: PlanListActivityTest.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Test
public void whenSearchPlanIsRemovedExpectItToBeRemoved() {
    final int testedPlanPosition = 5;

    onView(withId(R.id.menu_search))
            .perform(click());
    onView(withId(R.id.menu_search)).perform(typeText(expectedName + testedPlanPosition));
    closeSoftKeyboard();

    onView(withId(R.id.rv_plan_list))
            .perform(RecyclerViewActions
                    .actionOnItemAtPosition(0,
                            new ViewClicker(R.id.id_remove_plan)));
    onView(withText(R.string.plan_removal_confirmation_positive_button)).perform(click());

    onView(withRecyclerView(R.id.rv_plan_list)
            .atPosition(0))
            .check(doesNotExist());
    onView(isAssignableFrom(EditText.class)).perform(clearText());

    onView(withId(R.id.rv_plan_list)).perform(scrollToPosition(testedPlanPosition));
    onView(withRecyclerView(R.id.rv_plan_list)
            .atPosition(testedPlanPosition))
            .check(matches(hasDescendant(withText(expectedName
                    + (testedPlanPosition + 1)))));
}
 
Example #12
Source Project: zulip-android   Author: zulip   File: RecyclerViewTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void checkAfterNarrowToStream() {
    sleep(2000);

    hideToolBar();

    sleep(2000);

    //Scroll to Stream MessageHeaderParent
    onView(withId(R.id.recyclerView)).perform(RecyclerViewActions.scrollToHolder(withMessageHeaderHolder(MessageType.STREAM_MESSAGE)));

    //Perform a click on the subject textView to narrow to the topic
    onView(withFirstId(R.id.instance)).perform(click());

    sleep(4000);
    //Check if all messages belong to this subject
    onView(withId(R.id.recyclerView)).check(ViewAssertions.checkIfBelongToSameNarrow(mActivityTestRule.getActivity()));
}
 
Example #13
Source Project: zulip-android   Author: zulip   File: RecyclerViewTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void sendPrivateMessage() {
    //Wait to make sure the messages are loaded
    sleep(2000);

    onView(withId(R.id.recyclerView)).perform(RecyclerViewActions.scrollToHolder(withMessageHolderAndClick(MessageType.PRIVATE_MESSAGE, R.id.contentView)));
    sleep(1000);

    //Fill message EditText
    ViewInteraction messageInteraction = onView(allOf(withId(R.id.message_et), isDisplayed()));
    messageInteraction.perform(replaceText(testMessagePrivate));

    //Click Send Button
    ViewInteraction imageView = onView(allOf(withId(R.id.send_btn), isDisplayed()));
    imageView.perform(click());

    sleep(2000);

    //Scroll And check the new sent message
    onView(withId(R.id.recyclerView)).perform(RecyclerViewActions.scrollToHolder(withMessageHolder(testMessagePrivate, R.id.contentView)));

    onView(AllOf.allOf(withId(R.id.contentView), withText(testMessagePrivate))).check(matches(isDisplayed()));

    checkIfMessagesMatchTheHeaderParent();
    checkOrderOfMessagesCurrentList();
}
 
Example #14
Source Project: base_app_android   Author: RefineriaWeb   File: UsersTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test public void _3_Search_User() {
    mediumWait();
    onView(withId(R.id.rv_users)).perform(RecyclerViewActions.scrollToPosition(INDEX_LIST));

    mediumWait();
    onView(withId(R.id.rv_users)).perform(RecyclerViewActions.actionOnItemAtPosition(INDEX_LIST, click()));

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

    onView(withId(R.id.et_name)).perform(click(), replaceText(USERNAME_REFINERIA), closeSoftKeyboard());
    onView(withId(R.id.bt_find_user)).perform(click());
    mediumWait();

    onView(withId(R.id.tv_name)).check(matches(withText(ID_USER_REFINERIA + ":" + USERNAME_REFINERIA)));
    takeScreenShot(USERNAME_REFINERIA);
}
 
Example #15
Source Project: incubator-weex-playground   Author: apache   File: BenchmarkTest.java    License: Apache License 2.0 5 votes vote down vote up
private long calcTime() {
  BenchmarkActivity benchmarkActivity = mActivityRule.getActivity();
  benchmarkActivity.loadWeexPage("http://30.8.53.163:8080/complicated.js");
  onView(withClassName(Matchers.is(WXRecyclerView.class.getName()))).perform
      (RecyclerViewActions.scrollToPosition(0));
  return benchmarkActivity.getWXInstance().getWXPerformance().screenRenderTime;
}
 
Example #16
Source Project: android-showcase-template   Author: aerogear   File: StorageFeatureTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testNotesOperations() {
    //go to the notes list view
    onView(withId(R.id.drawer_layout)).perform(open());
    onView(withText(R.string.nav_security_storage)).perform(click());
    //the list view should be appear
    onView(withId(R.id.notes_list_view)).check(matches(isDisplayed()));
    //click on the add button
    onView(withId(R.id.add_note_btn)).perform(click());
    //details view should be appear
    onView(withId(R.id.note_details_view)).check(matches(isDisplayed()));
    //enter the title & content
    onView(withId(R.id.note_title_field)).perform(typeText(TEST_TITLE), closeSoftKeyboard());
    onView(withId(R.id.note_content_field)).perform(typeText(TEST_CONTENT), closeSoftKeyboard());
    //save
    onView(withId(R.id.save_note_btn)).perform(scrollTo(), click());
    //the list view should show again, and it should have the new note
    onView(withId(R.id.notes_list_view)).check(matches(isDisplayed()));
    onView(withId(R.id.notes_list_view)).check(matches(hasDescendant(withText(TEST_TITLE))));
    //should be able to click on it
    onView(withId(R.id.notes_list_view)).perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
    //details view should be loaded
    onView(withId(R.id.note_details_view)).check(matches(isDisplayed()));
    onView(withId(R.id.note_title_field)).check(matches(withText(TEST_TITLE)));
    onView(withId(R.id.note_content_field)).check(matches(withText(TEST_CONTENT)));
    //update the title and save
    onView(withId(R.id.note_title_field)).perform(clearText(), typeText(TEST_TITLE_UPDATED), closeSoftKeyboard());
    onView(withId(R.id.save_note_btn)).perform(scrollTo(), click());
    //title should be updated on the list view
    onView(withId(R.id.notes_list_view)).check(matches(hasDescendant(withText(TEST_TITLE_UPDATED))));
}
 
Example #17
Source Project: ncalc   Author: tranleduy2000   File: MarkdownDocumentActivityTest.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testSearch() {
    onView(withContentDescription(R.string.navigation_drawer_open)).perform(click());

    onView(withText("All functions")).perform(click());
    onView(withId(R.id.edit_search_view)).perform(typeText("ArcSin"));

    onView(withId(R.id.recycler_view)).perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
    onView(withText("ArcSin")).check(matches(isDisplayed()));

    pressBack();

    onView(withText("Documentation")).check(matches(isDisplayed()));
}
 
Example #18
Source Project: DebugRank   Author: GrapeCity   File: LanguagesViewBehaviorTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void listProgrammingLanguages()
{
    launchActivityWithIntent();

    onView(withId(R.id.loadingProgressBar)).check(matches(not(isDisplayed())));
    onView(withId(R.id.noDataLayout)).check(matches(not(isDisplayed())));

    //load the languages from the test memory repo that's injected by dagger
    final List<ProgrammingLanguage> programmingLanguageList = dataRepo.getTestProgrammingLanguages();

    int position = 0;

    for (final ProgrammingLanguage language : programmingLanguageList)
    {
        onView(withId(R.id.recyclerView))
                .perform(RecyclerViewActions.scrollToPosition(position));

        //make sure the language name is set foreach language in the recyclerview
        onView(withRecyclerView(R.id.recyclerView)
                .atPositionOnView(position, R.id.languageName))
                .check(matches(withText(language.name)));

        //make sure the image loading service was correctly called
        onView(withRecyclerView(R.id.recyclerView)
                .atPositionOnView(position, R.id.languageIcon))
                .check(mockDrawable(language.key));

        position++;
    }
}
 
Example #19
Source Project: DebugRank   Author: GrapeCity   File: LanguagesViewBehaviorTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void viewPuzzlesForLanguage()
{
    launchActivityWithIntent();

    onView(withId(R.id.recyclerView)).perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));

    //make sure clicking on an language navigates to puzzle activity
    intended(hasComponent(new ComponentName(getTargetContext(), PuzzlesActivity.class)));
}
 
Example #20
Source Project: DebugRank   Author: GrapeCity   File: PuzzlesViewBehaviorTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void listPuzzles()
{
    launchActivityWithIntent();

    onView(withId(R.id.loadingProgressBar)).check(matches(not(isDisplayed())));
    onView(withId(R.id.noDataLayout)).check(matches(not(isDisplayed())));

    //load the puzzles from the test memory repo that's injected by dagger
    final List<Puzzle> puzzzleList = dataRepo.getTestPuzzles();

    //start at position 1 for puzzles,  as the language header is at position 0
    int position = 1;

    for (final Puzzle puzzle : puzzzleList)
    {
        onView(withId(R.id.recyclerView))
                .perform(RecyclerViewActions.scrollToPosition(position));

        onView(withRecyclerView(R.id.recyclerView)
                .atPositionOnView(position, R.id.puzzleName))
                .check(matches(withText(puzzle.name)));

        onView(withRecyclerView(R.id.recyclerView)
                .atPositionOnView(position, R.id.points))
                .check(matches(withText(String.format("%d\npoints", puzzle.points))));

        onView(withRecyclerView(R.id.recyclerView)
                .atPositionOnView(position, R.id.minutes))
                .check(matches(withText(String.format("%d:00\nminutes", (int) Math.round(puzzle.time / 60)))));

        onView(withRecyclerView(R.id.recyclerView)
                .atPositionOnView(position, R.id.bugs))
                .check(matches(withText(String.format("%d\nbugs", puzzle.bugs))));

        position++;
    }
}
 
Example #21
Source Project: DebugRank   Author: GrapeCity   File: PuzzlesViewBehaviorTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void viewSolvePuzzle()
{
    launchActivityWithIntent();

    //click second puzzle as first puzzle is already completed
    onView(withId(R.id.recyclerView)).perform(RecyclerViewActions.actionOnItemAtPosition(2, click()));

    //make sure clicking on an language navigates to puzzle activity
    intended(hasComponent(new ComponentName(getTargetContext(), SolveActivity.class)));
}
 
Example #22
Source Project: DebugRank   Author: GrapeCity   File: SolveViewBehaviorTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void checkTestCasesWhenCodeDoesNotCompile()
{
    launchActivityWithIntent();

    staticProps().setCodeCompilesSuccessfully(false);

    //click the fab to start the "upload"
    onView(withId(R.id.fab)).perform(click());

    //click tab to see test case results RecyclerView
    onView(allOf(withText("Compile Error(s)"), isCompletelyDisplayed()))
            .perform(click());

    onView(withId(R.id.recyclerView))
            .perform(RecyclerViewActions.scrollToPosition(0));

    onView(withRecyclerView(R.id.recyclerView)
            .atPositionOnView(0, R.id.testcase))
            .check(matches(withText("Compile Error(s)")));

    onView(withRecyclerView(R.id.recyclerView)
            .atPositionOnView(0, R.id.message))
            .check(matches(withText("compile error")));

    reset();
}
 
Example #23
Source Project: DebugRank   Author: GrapeCity   File: SolveViewBehaviorTests.java    License: Apache License 2.0 5 votes vote down vote up
private void testCaseAt(int position, String testcase, @DrawableRes int resourceId, String input, String output, String expectedOutput, String message)
{
    onView(withId(R.id.recyclerView))
            .perform(RecyclerViewActions.scrollToPosition(position));

    onView(withRecyclerView(R.id.recyclerView)
            .atPositionOnView(position, R.id.testcase))
            .check(matches(withText(testcase)));

    onView(withRecyclerView(R.id.recyclerView)
            .atPositionOnView(position, R.id.passed))
            .check(withDrawable(resourceId));

    onView(withRecyclerView(R.id.recyclerView)
            .atPositionOnView(position, R.id.input))
            .check(matches(withText(input)));

    onView(withRecyclerView(R.id.recyclerView)
            .atPositionOnView(position, R.id.output))
            .check(matches(withText(output)));

    onView(withRecyclerView(R.id.recyclerView)
            .atPositionOnView(position, R.id.expectedOutput))
            .check(matches(withText(expectedOutput)));

    onView(withRecyclerView(R.id.recyclerView)
            .atPositionOnView(position, R.id.message))
            .check(matches(withText(message)));
}
 
Example #24
Source Project: BrainPhaser   Author: Kamshak   File: CategorySelectionTest.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Tests that all categories are displayed in the list.
 */
@Test
public void checkAllCategoriesShown() {
    for (Category c : mFakeCategories) {
        Matcher<View> hasDescendantTitle = hasDescendant(withText(c.getTitle()));
        onView(allOf(withId(R.id.select_category_fragment), withEffectiveVisibility(Visibility.VISIBLE)))
            .perform(RecyclerViewActions.scrollToHolder(categoryVH(c.getTitle())))
            .check(matches(hasDescendantTitle));
    }
}
 
Example #25
Source Project: BrainPhaser   Author: Kamshak   File: CategorySelectionTest.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Tests that the list ordering is correct (cards with more due challenges are further up in the list)
 */
@Test
public void checkListOrdering() {
    for (int i = 0; i < mPositions.size(); i++) {
        int position = mPositions.keyAt(i);

        String categoryName = mPositions.get(position).getTitle();
        Matcher<View> hasDescendantTitle = hasDescendant(withText(categoryName));

        onView(allOf(withId(R.id.select_category_fragment), withEffectiveVisibility(Visibility.VISIBLE)))
            .perform(RecyclerViewActions.scrollToHolder(categoryVH(categoryName)))
            .check(matches(TestUtils.atPosition(position, hasDescendantTitle)));
    }
}
 
Example #26
Source Project: Villains-and-Heroes   Author: andremion   File: MainActivityTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testListItemClick() {
    // Check if the list is displayed
    onView(withId(R.id.recycler)).check(matches(isDisplayed()));
    // Perform click on first item
    onView(withId(R.id.recycler)).perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
}
 
Example #27
Source Project: ribot-app-android   Author: ribot   File: CheckInActivityTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void venuesShow() {
    main.launchActivity(null);

    for (int position = 0; position < mVenues.size(); position++) {
        Venue venue = mVenues.get(position);
        onView(withId(R.id.recycler_view_venues))
                .perform(RecyclerViewActions.scrollToPosition(position));
        onView(withText(venue.label))
                .check(matches(isDisplayed()));
    }
}
 
Example #28
Source Project: KataSuperHeroesAndroid   Author: Karumi   File: MainActivityTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test public void opensSuperHeroDetailActivityOnRecyclerViewItemTapped() {
  List<SuperHero> superHeroes = givenThereAreSomeSuperHeroes();
  int superHeroIndex = 0;
  startActivity();

  onView(withId(R.id.recycler_view)).
      perform(RecyclerViewActions.actionOnItemAtPosition(superHeroIndex, click()));

  SuperHero superHeroSelected = superHeroes.get(superHeroIndex);
  intended(hasComponent(SuperHeroDetailActivity.class.getCanonicalName()));
  intended(hasExtra("super_hero_name_key", superHeroSelected.getName()));
}
 
Example #29
Source Project: base_app_android   Author: RefineriaWeb   File: DashboardTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test public void Open_And_Close_User() {
    onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer());
    mediumWait();

    onView(withId(R.id.rv_menu_items)).perform(RecyclerViewActions.actionOnItemAtPosition(1, click()));

    takeScreenShot("User");
    onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer());
}
 
Example #30
Source Project: ChipsLayoutManager   Author: BelooS   File: ColumnTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void scrollBy_LastItemInLastRowHasSmallSize_scrolledCompletelyToBiggestItemSize() throws Exception {
    //arrange

    //act
    recyclerView.perform(RecyclerViewActions.scrollToPosition(36),
            scrollBy(0, -200),
            scrollBy(0, 200));


    //assert
    recyclerView.check(matches(atPosition(39, rvPaddingMatcher())));
}