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 File: RecyclerViewTests.java From zulip-android with Apache License 2.0 | 6 votes |
@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 #2
Source File: PlanListActivityTest.java From friendly-plans with GNU General Public License v3.0 | 6 votes |
@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 #3
Source File: PlanListActivityTest.java From friendly-plans with GNU General Public License v3.0 | 6 votes |
@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 #4
Source File: TaskListActivityTest.java From friendly-plans with GNU General Public License v3.0 | 6 votes |
@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 #5
Source File: ColumnTest.java From ChipsLayoutManager with Apache License 2.0 | 6 votes |
@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 #6
Source File: ColumnTest.java From ChipsLayoutManager with Apache License 2.0 | 6 votes |
@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 #7
Source File: RowTest.java From ChipsLayoutManager with Apache License 2.0 | 6 votes |
@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 #8
Source File: RecyclerViewTests.java From zulip-android with Apache License 2.0 | 6 votes |
@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 #9
Source File: UsersTest.java From base_app_android with Apache License 2.0 | 6 votes |
@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 #10
Source File: ChildListActivityTest.java From friendly-plans with GNU General Public License v3.0 | 6 votes |
@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 #11
Source File: ChildListActivityTest.java From friendly-plans with GNU General Public License v3.0 | 6 votes |
@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 #12
Source File: RowTest.java From ChipsLayoutManager with Apache License 2.0 | 6 votes |
@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 #13
Source File: MainActivityTest.java From ribot-app-android with Apache License 2.0 | 6 votes |
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 #14
Source File: CheckInActivityTest.java From ribot-app-android with Apache License 2.0 | 6 votes |
@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 #15
Source File: RecyclerViewSampleTest.java From testing-cin with MIT License | 5 votes |
@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 = mActivityRule.getActivity().getResources().getString( R.string.item_element_text) + String.valueOf(ITEM_BELOW_THE_FOLD); onView(withText(itemElementText)).check(matches(isDisplayed())); }
Example #16
Source File: DashboardTest.java From base_app_android with Apache License 2.0 | 5 votes |
@Test public void Open_And_Close_Search_User() { onView(withId(R.id.drawer_layout)).perform(actionOpenDrawer()); mediumWait(); onView(withId(R.id.rv_menu_items)).perform(RecyclerViewActions.actionOnItemAtPosition(2, click())); takeScreenShot("SearchUser"); onView(withId(R.id.drawer_layout)).perform(actionCloseDrawer()); }
Example #17
Source File: BenchmarkTest.java From incubator-weex-playground with Apache License 2.0 | 5 votes |
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 #18
Source File: AddTasksToPlanFragmentTest.java From friendly-plans with GNU General Public License v3.0 | 5 votes |
public void checkIsAddedToPlan (Integer typeId, String EXPECTED_NAME){ setView(typeId); final int testedTaskPosition = 3; onView(withId(R.id.rv_create_plan_add_tasks)).perform(scrollToPosition(testedTaskPosition)); onView(withId(R.id.rv_create_plan_add_tasks)) .perform(RecyclerViewActions.actionOnItemAtPosition(testedTaskPosition, click())); List<TaskTemplate> taskTemplates = planTemplateRepository.getTaskWithThisPlanByTypeId(planId, typeId); assertThat(taskTemplates.size(), is(1)); assertThat(taskTemplates.get(0).getName(), is(EXPECTED_NAME + testedTaskPosition)); }
Example #19
Source File: RepoInfoFragmentTests.java From android-step-by-step with Apache License 2.0 | 5 votes |
@Test public void testHideProgressBarOnErrorContributors() { apiConfig.setCustomAnswer(true, false); onView(withId(R.id.recycler_view)).perform( RecyclerViewActions.actionOnItemAtPosition(2, click())); onView(withId(R.id.toolbar_progress_bar)).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.INVISIBLE))); }
Example #20
Source File: RepoInfoFragmentTests.java From android-step-by-step with Apache License 2.0 | 5 votes |
@Test public void testHideProgressBarOnErrorBranches() { apiConfig.setCustomAnswer(false, true); onView(withId(R.id.recycler_view)).perform( RecyclerViewActions.actionOnItemAtPosition(2, click())); onView(withId(R.id.toolbar_progress_bar)).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.INVISIBLE))); }
Example #21
Source File: RepoInfoFragmentTests.java From android-step-by-step with Apache License 2.0 | 5 votes |
@Test public void testHideProgressBarOnError() { apiConfig.setErrorAnswer(); onView(withId(R.id.recycler_view)).perform( RecyclerViewActions.actionOnItemAtPosition(2, click())); onView(withId(R.id.toolbar_progress_bar)).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.INVISIBLE))); }
Example #22
Source File: RepoInfoFragmentTests.java From android-step-by-step with Apache License 2.0 | 5 votes |
@Test public void testHideProgressBar() { onView(withId(R.id.recycler_view)).perform( RecyclerViewActions.actionOnItemAtPosition(2, click())); onView(withId(R.id.toolbar_progress_bar)).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.INVISIBLE))); }
Example #23
Source File: BaseADFTest.java From aws-device-farm-sample-app-for-android with Apache License 2.0 | 5 votes |
/** * Gets the activity and navigates to the Class's category in the navigation drawer * * Uses espresso-contrib dor navigation drawer and recyclerView support * * @throws Exception instrumentation ActivityInstrumentationTestCase2 exception */ @Override protected void setUp() throws Exception { getActivity(); //IMPORTANT you must call this before your tests! super.setUp(); DrawerActions.openDrawer(R.id.drawer_layout); RecyclerViewActions.scrollTo(withText(getClassName())); onView(withId(R.id.drawerList)).perform(RecyclerViewActions.actionOnItem(hasDescendant(withText(getClassName())), click())); InstrumentationRegistry.getInstrumentation().waitForIdleSync(); }
Example #24
Source File: PlanListActivityTest.java From friendly-plans with GNU General Public License v3.0 | 5 votes |
@Test public void whenPlanRemoveIconIsClickedButNoConfirmationGivenExpectPlanIsOnTheList() { final int testedTaskPosition = 3; onView(withId(R.id.rv_plan_list)) .perform(RecyclerViewActions .actionOnItemAtPosition(testedTaskPosition, new ViewClicker(R.id.id_remove_plan))); onView(withText(R.string.plan_removal_confirmation_negative_button)).perform(click()); onView(withId(R.id.rv_plan_list)).perform(scrollToPosition(testedTaskPosition)); onView(withRecyclerView(R.id.rv_plan_list) .atPosition(testedTaskPosition)) .check(matches(hasDescendant(withText(expectedName + testedTaskPosition)))); }
Example #25
Source File: PlanListActivityTest.java From friendly-plans with GNU General Public License v3.0 | 5 votes |
@Test public void whenPlanIsRemovedExpectPlanIsNotOnTheList() { final int testedTaskPosition = 3; onView(withId(R.id.rv_plan_list)) .perform(RecyclerViewActions .actionOnItemAtPosition(testedTaskPosition, 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(testedTaskPosition)); onView(withRecyclerView(R.id.rv_plan_list) .atPosition(testedTaskPosition)) .check(matches(not(hasDescendant(withText(expectedName + testedTaskPosition))))); }
Example #26
Source File: TaskListActivityTest.java From friendly-plans with GNU General Public License v3.0 | 5 votes |
@Test public void whenTaskWhichIsInAPlanIsRemovedExpectTaskNotRemoved() { final int testedTaskPosition = 6; onView(withId(R.id.rv_task_list)).perform(scrollToPosition(testedTaskPosition)); onView(withId(R.id.rv_task_list)) .perform(RecyclerViewActions .actionOnItemAtPosition(testedTaskPosition, new ViewClicker(R.id.id_remove_task))); onView(withText(R.string.task_cannot_be_removed_dialog_close_button)).perform(click()); onView(withRecyclerView(R.id.rv_task_list) .atPosition(testedTaskPosition)) .check(matches(hasDescendant(withText(TASK_THAT_IS_ADDED_TO_PLAN_NAME)))); }
Example #27
Source File: TaskListActivityTest.java From friendly-plans with GNU General Public License v3.0 | 5 votes |
@Test public void whenTaskIsRemovedExpectTaskIsNotOnTheList() { final int testedTaskPosition = 3; onView(withId(R.id.rv_task_list)) .perform(RecyclerViewActions .actionOnItemAtPosition(testedTaskPosition, new ViewClicker(R.id.id_remove_task))); onView(withText(R.string.task_removal_confirmation_positive_button)).perform(click()); onView(withId(R.id.rv_task_list)).perform(scrollToPosition(testedTaskPosition)); onView(withRecyclerView(R.id.rv_task_list) .atPosition(testedTaskPosition)) .check(matches(not(hasDescendant(withText(expectedNameTask + testedTaskPosition))))); }
Example #28
Source File: ChildListActivityTest.java From friendly-plans with GNU General Public License v3.0 | 5 votes |
@Test public void whenChildIsSelectedExpectButtonIsEnabled() { final int testedChildPosition = 5; closeSoftKeyboard(); onView(withId(R.id.id_set_active_child)).check(matches(not(isEnabled()))); onView(withId(R.id.rv_child_list)) .perform(RecyclerViewActions.actionOnItemAtPosition(testedChildPosition, click())); onView(withId(R.id.id_set_active_child)).check(matches(isEnabled())); }
Example #29
Source File: ChildListActivityTest.java From friendly-plans with GNU General Public License v3.0 | 5 votes |
@Test public void whenChildRemoveIconIsClickedButNoConfirmationGivenExpectChildIsOnTheList() { 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_negative_button)).perform(click()); onView(withId(R.id.rv_child_list)).perform(scrollToPosition(testedChildPosition)); onView(withRecyclerView(R.id.rv_child_list) .atPosition(testedChildPosition)) .check(matches(hasDescendant(withText(EXPECTED_FIRST_NAME + " " + EXPECTED_LAST_NAME + testedChildPosition)))); }
Example #30
Source File: NotificationsTest.java From RxGcm with Apache License 2.0 | 5 votes |
@Test public void _2_Send_And_Receive_Notification_On_Foreground_Nested_Fragment() { onView(withId(R.id.bt_nested_fragment)).perform(click()); //Send nested supply onView(withId(R.id.et_title)).perform(click(), replaceText(TITLE), closeSoftKeyboard()); onView(withId(R.id.et_body)).perform(click(), replaceText(BODY), closeSoftKeyboard()); onView(withId(R.id.bt_send_supply)).perform(click()); waitTime(3000); onView(withId(R.id.rv_notifications)).perform(RecyclerViewActions.actionOnItemAtPosition(0, click())); }