androidx.test.espresso.contrib.RecyclerViewActions Java Examples

The following examples show how to use androidx.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 File: EditImageActivityTest.java    From PhotoEditor with MIT License 6 votes vote down vote up
@Test
public void checkIfUndoRedoIsWorkingCorrectWhenClickedOnUndoRedo() throws InterruptedException {
    EditImageActivity editImageActivity = mActivityRule.launchActivity(null);
    ArrayList<String> emojisUnicodes = PhotoEditor.getEmojis(editImageActivity);

    //Add Emoji
    onView(withText(R.string.label_emoji)).perform(click());
    onView(withId(R.id.rvEmoji)).perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
    onView(withText(emojisUnicodes.get(0))).check(matches(isDisplayed()));

    // Undo the Emoji
    onView(withId(R.id.imgUndo)).perform(click());
    onView(withText(emojisUnicodes.get(0))).check(doesNotExist());

    // Redo the Emoji
    onView(withId(R.id.imgRedo)).perform(click());
    onView(withText(emojisUnicodes.get(0))).check(matches(isDisplayed()));
}
 
Example #2
Source File: ScreenRunnerTest.java    From hash-checker with Apache License 2.0 5 votes vote down vote up
private void clickOnSettingsItem(int settingsTitleResId) {
    onView(withId(R.id.recycler_view)).perform(
                    RecyclerViewActions.actionOnItem(
                            hasDescendant(withText(settingsTitleResId)),
                            click()
                    )
    );
    delayAndBack();
}
 
Example #3
Source File: BaseUITest.java    From hash-checker with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("SameParameterValue")
protected void inRecyclerViewClickOnPosition(int recyclerId, int position) {
    onView(withId(recyclerId)).perform(
                    RecyclerViewActions.actionOnItemAtPosition(
                            position,
                            click()
                    )
    );
}
 
Example #4
Source File: EditImageActivityTest.java    From PhotoEditor with MIT License 5 votes vote down vote up
@Test
public void checkIfEmojiIsDisplayedWhenEmojiIsSelected() {
    Context context = mActivityRule.launchActivity(null);
    ArrayList<String> emojis = PhotoEditor.getEmojis(context);
    int emojiPosition = 1;
    String emojiUnicode = emojis.get(emojiPosition);
    onView(withText(R.string.label_emoji)).perform(click());
    onView(withId(R.id.rvEmoji))
            .perform(RecyclerViewActions.actionOnItemAtPosition(emojiPosition, click()));
    onView(withText(emojiUnicode)).check(matches(isDisplayed()));
}
 
Example #5
Source File: EditImageActivityTest.java    From PhotoEditor with MIT License 5 votes vote down vote up
@Test
public void checkIfDiscardDialogIsDisplayedWhenCacheIsNotEmpty() {
    EditImageActivity editImageActivity = mActivityRule.launchActivity(null);
    assertTrue(editImageActivity.mPhotoEditor.isCacheEmpty());
    onView(withText(R.string.label_emoji)).perform(click());
    onView(withId(R.id.rvEmoji))
            .perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
    onView(withId(R.id.imgClose)).perform(click());
    onView(withText(R.string.msg_save_image)).check(matches(isDisplayed()));
}
 
Example #6
Source File: BarricadeActivityTest.java    From Barricade with Apache License 2.0 5 votes vote down vote up
@Test public void verifyResponsesForEndpoints() {
  int endpointCount = 0;
  Map<String, BarricadeResponseSet> hashMap = barricade.getConfig();
  for (String endpoint : hashMap.keySet()) {
    int responseCount = 0;
    onView(withId(R.id.endpoint_rv)).perform(RecyclerViewActions.actionOnItemAtPosition(endpointCount, click()));
    for (BarricadeResponse response : hashMap.get(endpoint).responses) {
      onView(withRecyclerView(com.mutualmobile.barricade.R.id.endpoint_responses_rv).atPosition(responseCount)).check(
          matches(hasDescendant(withText(response.responseFileName))));
      responseCount++;
    }
    Espresso.pressBack();
  }
}
 
Example #7
Source File: LandscapeUITests.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Navigate to settings, press any checkbox there. switch to landscape. press checkbox again to
 * see if it has the different result
 */
@Test public void landscapeSettings() {
  boolean checked;
  Activity activity = mActivityRule.getActivity();
  goToSettings();
  onView(withId(R.id.list)).perform(RecyclerViewActions.scrollToPosition(11));
  onView(withId(R.id.list)).perform(RecyclerViewActions.actionOnItemAtPosition(11, click()));
  try {
    onView(withText(R.string.yes)).perform(click());
    checked =
        true; //if it doesn't fail it means that the checkbox was unchecked and is now checked
  } catch (Exception e) {
    checked = false;
  }
  activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  onView(withId(R.id.list)).perform(RecyclerViewActions.scrollToPosition(11));
  onView(withId(R.id.list)).perform(RecyclerViewActions.actionOnItemAtPosition(11, click()));
  if (!checked) { //it has the different behaviour than last time
    onView(withText(R.string.yes)).perform(click());
    checked = true;
  } else {
    checked = false;
  }
  activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  onView(withId(R.id.list)).perform(RecyclerViewActions.scrollToPosition(11));
  onView(withId(R.id.list)).perform(RecyclerViewActions.actionOnItemAtPosition(11, click()));
  if (!checked) {
    onView(withText(R.string.yes)).perform(click());
  }
}
 
Example #8
Source File: EspressoTestUtils.java    From Kore with Apache License 2.0 5 votes vote down vote up
public static void clickRecyclerViewItem(String text, int resourceId) {
    ViewInteraction viewInteraction = onView(allOf(withId(resourceId),
                                                   hasDescendant(withText(containsString(text))),
                                                   isDisplayed()));
    viewInteraction.perform(RecyclerViewActions.scrollTo(hasDescendant(withText(containsString(text)))));
    viewInteraction.perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(containsString(text))),
                                                             click()));
}
 
Example #9
Source File: RecyclerViewSampleTest.java    From testing-samples with Apache License 2.0 5 votes vote down vote up
@Test
public void scrollToItemBelowFold_checkItsText() {
    // First scroll to the position that needs to be matched and click on it.
    onView(ViewMatchers.withId(R.id.recyclerView))
            .perform(RecyclerViewActions.actionOnItemAtPosition(ITEM_BELOW_THE_FOLD, click()));

    // Match the text in an item below the fold and check that it's displayed.
    String itemElementText = getApplicationContext().getResources().getString(
            R.string.item_element_text) + String.valueOf(ITEM_BELOW_THE_FOLD);
    onView(withText(itemElementText)).check(matches(isDisplayed()));
}
 
Example #10
Source File: RecyclerViewSampleTest.java    From testing-samples with Apache License 2.0 5 votes vote down vote up
@Test
public void itemInMiddleOfList_hasSpecialText() {
    // First, scroll to the view holder using the isInTheMiddle matcher.
    onView(ViewMatchers.withId(R.id.recyclerView))
            .perform(RecyclerViewActions.scrollToHolder(isInTheMiddle()));

    // Check that the item has the special text.
    String middleElementText =
            getApplicationContext().getResources().getString(R.string.middle);
    onView(withText(middleElementText)).check(matches(isDisplayed()));
}
 
Example #11
Source File: StickyHeadersTestRobot.java    From StickyHeaders with Apache License 2.0 4 votes vote down vote up
StickyHeadersTestRobot scrollTo(int position) {
    onView(withId(R.id.recycler_view)).perform(RecyclerViewActions.scrollToPosition(position));
    return this;
}
 
Example #12
Source File: EspressoTestUtils.java    From Kore with Apache License 2.0 4 votes vote down vote up
public static void clickRecyclerViewItem(int position, int resourceId) {
    onView(withId(resourceId)).perform(RecyclerViewActions.actionOnItemAtPosition(position, click()));
}
 
Example #13
Source File: MoviesListingActivityTest.java    From MovieGuide with MIT License 4 votes vote down vote up
@Test
public void shouldBeAbleToScrollViewMovieDetails()
{
    onView(withId(R.id.movies_listing)).perform(RecyclerViewActions.actionOnItemAtPosition(10, click()));
    onView(withText("Summary")).check(matches(isDisplayed()));
}