@Test public void scrollToBottom() { onData(anything()) .inAdapterView(withId(android.R.id.list)) .atPosition(24) .check(matches(withText("purus"))); }
private void selectSpinnerValue(int spinnerId, String text) { onView(withId(spinnerId)).perform(click()); onData(allOf(is(instanceOf(String.class)), is(text))).perform(click()); }
protected <T> ActionableObject onViewWithObject(T object) { return new ActionableData(onData(new ObjectMatcher<>(object))); }
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); } }
public DataInteraction onLayerAt(int listPosition) { return onData(instanceOf(Layer.class)) .inAdapterView(withId(R.id.pocketpaint_layer_side_nav_list)) .atPosition(listPosition); }
/** * Perform the search view clicked UI test */ @Test public void testSearchMenuItemClick() { openContextualActionModeOverflowMenu(); final String searchViewTitle = mActivityRule.getActivity().getString( R.string.title_dialog_search); onData(allOf(instanceOf(MenuItem.class), withTitle(searchViewTitle))).perform(click()); } }
public void testListViewPeople() { List<Person> listPeople = DataProvider.getMockPeopleSet1(); for (int position = 0; position < listPeople.size(); position++) { onData(is(instanceOf(Person.class))) .inAdapterView(withId(R.id.list_view)) .atPosition(position) .onChildView(withText(listPeople.get(position).getName())) .check(matches(isDisplayed())); } }
@Test public void clickSpinner() { CodeLabelExampleActivity activity = mActivityTestRule.launchActivity(null); activity.mSnackbarLogic = spy(new MockSnackbarLogic()); for (OrdinalLabel item : OrdinalLabel.values()) { onView(withId(R.id.spinner)).perform(click()); onData(is(item)).perform(click()); Resources res = activity.getResources(); verify(activity.mSnackbarLogic).make(any(View.class), contains(item.getLabel(res)), anyInt()); } } }
/** * Performs a click on an item in an adapter view, such as GridView or ListView * @param position * @param resourceId of adapter view holding the item that should be clicked */ public static void clickAdapterViewItem(int position, int resourceId) { onData(anything()).inAdapterView(allOf(withId(resourceId), isDisplayed())) .atPosition(position).perform(click()); }
@Test public void run() { Entry<String> entry = find(mAdapter.getOrig().getItems(), String.class, 4); onView(withId(R.id.spinner)).perform(click()); onData(is(entry.object)).perform(click()); onView(withId(R.id.spinner)).check(hasSelectedItem(is(entry.object))); verify(mActivity.mSnackbarLogic).make(any(View.class), contains(entry.object), anyInt()); } }
@Test public void clickSome() { Entry<WrappedItem> entry = find(mAdapter.getItems(), WrappedItem.class, 4); onView(withId(R.id.spinner)).perform(click()); onData(is(entry.object)).perform(click()); onView(withId(R.id.spinner)).check(hasSelectedItem(is(entry.object))); verify(mActivity.mSnackbarLogic).make(any(View.class), contains(entry.object.getItem().getText()), anyInt()); } }
public void clickPrevAnswer(int position) { updateNumberofResults(); onData(anything()) .inAdapterView(withId(android.R.id.list)) .atPosition(numberOfAdapterItems - 1 - position) .onChildView(withId(R.id.list_item_result_textPrevAnswer)) .perform(click()); }
public void clickPrevQuery(int position) { updateNumberofResults(); onData(anything()) .inAdapterView(withId(android.R.id.list)) .atPosition(numberOfAdapterItems - 1 - position) .onChildView(withId(R.id.list_item_result_textPrevQuery)) .perform(click()); }
public void testListViewClickOnImages() { List<Person> listPeople = DataProvider.getMockPeopleSet1(); for (int position = 0; position < listPeople.size(); position++) { onData(is(instanceOf(Person.class))) .inAdapterView(withId(R.id.list_view)) .atPosition(position) .onChildView(withId(R.id.image_view_person)) .perform(click()); //Check Dialog shows and close it onView(withText(getActivity().getString(R.string.my_name_string, listPeople.get(position).getName()))) .check(matches(isDisplayed())); onView(withText(R.string.ok)) .perform(click()); } }
private void excluir(){ onData(withRowString(HotelSQLHelper.COLUNA_NOME, "Hotel Modificado")) .perform(longClick()); onView(withId(R.id.acao_delete)).perform(click()); onView(withId(android.R.id.list)).perform(swipeDown()); } }
public void test006Rename(){ onData(anything()).inAdapterView(withId(R.id.listView)) .atPosition(1) .perform(longClick()); onView(withId(R.id.action_edit)).check(matches(isDisplayed())); onView(withId(R.id.action_edit)).perform(click()); onView(withText(codes[1][0])).perform(click()).perform(typeText(" VERY TEST")); onView(withText("Save")).perform(click()); onData(anything()).inAdapterView(withId(R.id.listView)) .atPosition(1) .onChildView(withId(R.id.textViewLabel)) .check(matches(withText(codes[1][0] + " VERY TEST"))); }
public void test005RenameCancel(){ onData(anything()).inAdapterView(withId(R.id.listView)) .atPosition(1) .perform(longClick()); onView(withId(R.id.action_edit)).check(matches(isDisplayed())); onView(withId(R.id.action_edit)).perform(click()); onView(withText(codes[1][0])).perform(click()).perform(typeText(" VERY TEST")); onView(withText("Cancel")).perform(click()); onData(anything()).inAdapterView(withId(R.id.listView)) .atPosition(1) .onChildView(withId(R.id.textViewLabel)) .check(matches(withText(codes[1][0]))); }
private void editar() { onData(withRowString(HotelSQLHelper.COLUNA_NOME, "Hotel de Teste")) .perform(click()); onView(withId(R.id.acao_editar)).perform(click()); onView(withId(R.id.txtNome)).perform(replaceText("Hotel Modificado")); onView(withId(R.id.txtEndereco)).perform(replaceText("Rua modificada")); onView(withId(R.id.txtEndereco)).perform(pressImeActionButton()); pressBack(); } private void excluir(){
public void editQuestions() { String question = "This is just a silly question whose answer changed to (a)."; onData(anything()).inAdapterView(withId(R.id.template_editor_listview)).atPosition(1).perform(longClick()); onView(withId(R.id.action_edit)).perform(click()); onView(withId(R.id.quiz_question)).perform(replaceText(question)); closeSoftKeyboard(); onView(withId(R.id.quiz_radio_1)).perform(scrollTo()).perform(click()); closeSoftKeyboard(); onView(withResourceName("buttonDefaultPositive")).perform(click()); }
public void test007DeleteCancel() throws InterruptedException, EncoderException { onData(anything()).inAdapterView(withId(R.id.listView)) .atPosition(0) .perform(longClick()); onView(withId(R.id.action_delete)).check(matches(isDisplayed())); onView(withId(R.id.action_delete)).perform(click()); onView(withText("Remove")).check(matches(isDisplayed())); onView(withText("Cancel")).check(matches(isDisplayed())); onView(withText("Cancel")).perform(click()); onView(withText("Remove")).check(doesNotExist()); onView(withId(R.id.listView)).check(matches(withListSize(codes.length))); }