本文整理汇总了Java中android.support.test.espresso.contrib.RecyclerViewActions类的典型用法代码示例。如果您正苦于以下问题:Java RecyclerViewActions类的具体用法?Java RecyclerViewActions怎么用?Java RecyclerViewActions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RecyclerViewActions类属于android.support.test.espresso.contrib包,在下文中一共展示了RecyclerViewActions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listOfCitiesShows
import android.support.test.espresso.contrib.RecyclerViewActions; //导入依赖的package包/类
@Test
public void listOfCitiesShows() {
List<Show> testDataShows = TestDataFactory.makeCities(20);
when(mComponent.getMockDataManager().getShows())
.thenReturn(Observable.just(testDataShows));
mCityListTestRule.launchActivity(null);
int position = 0;
for (Show show : testDataShows) {
onView(withId(R.id.recycler_view))
.perform(RecyclerViewActions.scrollToPosition(position));
onView(withText(show.getName()))
.check(matches(isDisplayed()));
position++;
}
}
示例2: onItemClicked_OpenContentScreen
import android.support.test.espresso.contrib.RecyclerViewActions; //导入依赖的package包/类
@Test
public void onItemClicked_OpenContentScreen() throws Exception {
FakeContentRepository.setFakeData(new ArrayList<>(Arrays.asList(
createFakeContentItem(1),
createFakeContentItem(2),
createFakeContentItem(3),
createFakeContentItem(4))));
createActivity();
onView(withId(R.id.recyclerContent)).check(matches(isDisplayed()));
onView(withId(R.id.recyclerContent)).check(withItemCount(4));
onView(withId(R.id.progressBar)).check(matches(not(isDisplayed())));
onView(withId(R.id.textLoadingError)).check(matches(not(isDisplayed())));
// click on the first item in the list:
onView(withId(R.id.recyclerContent))
.perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
// content screen should be opened:
onView(withId(R.id.textDescription)).check(matches(isDisplayed()));
}
示例3: clickRandomSet
import android.support.test.espresso.contrib.RecyclerViewActions; //导入依赖的package包/类
/**
* Click a random set on the board
*/
@Test
public void clickRandomSet() {
// Pick a random valid SET
SetGame.Triplet location = mSetGame.getRandomSet();
if (location != null) {
int first = (int) location.getFirst();
int second = (int) location.getSecond();
int third = (int) location.getThird();
onView(withId(R.id.game_recycler_grid))
.perform(RecyclerViewActions
.actionOnItemAtPosition(first, click()));
onView(withId(R.id.game_recycler_grid))
.perform(RecyclerViewActions
.actionOnItemAtPosition(second, click()));
onView(withId(R.id.game_recycler_grid))
.perform(RecyclerViewActions
.actionOnItemAtPosition(third, click()));
}
}
示例4: clickOnFirstItem_opensComments
import android.support.test.espresso.contrib.RecyclerViewActions; //导入依赖的package包/类
@Test
public void clickOnFirstItem_opensComments() throws Throwable {
drain();
// When clicking on the first product
onView(ViewMatchers.withContentDescription(R.string.cd_products_list))
.perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
drain();
// Then the second screen with the comments should appear.
onView(withContentDescription(R.string.cd_comments_list))
.check(matches(isDisplayed()));
drain();
// Then the second screen with the comments should appear.
onView(withContentDescription(R.string.cd_product_name))
.check(matches(not(withText(""))));
}
示例5: rotate_LMHasItems_firstItemNotChanged
import android.support.test.espresso.contrib.RecyclerViewActions; //导入依赖的package包/类
@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();
}
示例6: gapsNormalization_OnLastRowDeleted_PaddingStaySame
import android.support.test.espresso.contrib.RecyclerViewActions; //导入依赖的package包/类
@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())));
}
示例7: scrollBy_LastItemInLastRowHasSmallSize_scrolledCompletelyToBiggestItemSize
import android.support.test.espresso.contrib.RecyclerViewActions; //导入依赖的package包/类
@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())));
}
示例8: rotate_LMHasItems_firstItemNotChanged
import android.support.test.espresso.contrib.RecyclerViewActions; //导入依赖的package包/类
@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);
}
示例9: listOfRibotsShows
import android.support.test.espresso.contrib.RecyclerViewActions; //导入依赖的package包/类
@Test
public void listOfRibotsShows() {
List<Ribot> testDataRibots = TestDataFactory.makeListRibots(20);
when(component.getMockDataManager().getRibots())
.thenReturn(Observable.just(testDataRibots));
main.launchActivity(null);
int position = 0;
for (Ribot ribot : testDataRibots) {
onView(withId(R.id.recycler_view))
.perform(RecyclerViewActions.scrollToPosition(position));
String name = String.format("%s %s", ribot.profile().name().first(),
ribot.profile().name().last());
onView(withText(name))
.check(matches(isDisplayed()));
onView(withText(ribot.profile().email()))
.check(matches(isDisplayed()));
position++;
}
}
示例10: swipeOnEntry_ShowsDeletionDialog
import android.support.test.espresso.contrib.RecyclerViewActions; //导入依赖的package包/类
@Test
public void swipeOnEntry_ShowsDeletionDialog() {
String newDiaryText1 = "I'm going to delete this entry";
String newDiaryText2 = newDiaryText1 + " - pt2";
String newDiaryText3 = newDiaryText1 + " - pt3";
String newDiaryText4 = newDiaryText1 + " - pt4";
String newDiaryText5 = newDiaryText1 + " - pt5";
// Click on the diary tab
onView(withText(R.string.diary_tab_name)).perform(click());
// Add an entry
addNewDiaryEntry(newDiaryText1, newDiaryText2, newDiaryText3, newDiaryText4, newDiaryText5);
// Swipe the entry
onView(withId(R.id.diary_view))
.perform(scrollTo(hasDescendant(withText(newDiaryText1))))
.perform(RecyclerViewActions.actionOnItemAtPosition(0, swipeLeft()));
// Verify deletion dialog message is shown
onView(withText(R.string.dialog_delete_diary_entry)).check(matches(isDisplayed()));
// Delete it to clean up
onView(withText(R.string.ok_delete_diary_entry)).perform(click());
}
示例11: listOfRibotsShows
import android.support.test.espresso.contrib.RecyclerViewActions; //导入依赖的package包/类
@Test
public void listOfRibotsShows() {
List<Ribot> testDataRibots = TestDataFactory.makeListRibots(20);
when(component.getMockDataManager().getRibots())
.thenReturn(Observable.just(testDataRibots));
main.launchActivity(null);
int position = 0;
for (Ribot ribot : testDataRibots) {
onView(withId(R.id.recycler_view))
.perform(RecyclerViewActions.scrollToPosition(position));
String name = String.format("%s %s", ribot.profile.name.first,
ribot.profile.name.last);
onView(withText(name))
.check(matches(isDisplayed()));
onView(withText(ribot.profile.email))
.check(matches(isDisplayed()));
position++;
}
}
示例12: testCommentSegmentLoggedOut
import android.support.test.espresso.contrib.RecyclerViewActions; //导入依赖的package包/类
public void testCommentSegmentLoggedOut () {
Boolean isLoggedIn = PreferenceManager.getDefaultSharedPreferences
(activityOnTest.getBaseContext()).getBoolean("IsLoggedIn", false);
if(isLoggedIn){
onView(withId(R.id.action_profile_logged)).perform(click());
onView(withText("Sair")).perform(click());
}
closeSoftKeyboard();
onView(withText("Visitante")).perform(ViewActions.scrollTo()).perform(click());
onView(withId(R.id.recycler_view_open))
.perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
onView(withId(R.id.recycler_viewBill))
.perform(RecyclerViewActions.actionOnItemAtPosition(2, click()));
onView(withId(R.id.recycler_viewSegment))
.perform(RecyclerViewActions.actionOnItemAtPosition(1, click()));
onView(withId(R.id.floatingButton))
.perform((click()));
onView(withId(R.id.emailLoginField)).check(matches(isDisplayed()));
}
示例13: testEmptyComment
import android.support.test.espresso.contrib.RecyclerViewActions; //导入依赖的package包/类
public void testEmptyComment(){
closeSoftKeyboard();
Boolean isLoggedIn = PreferenceManager.getDefaultSharedPreferences
(activityOnTest.getBaseContext()).getBoolean("IsLoggedIn", false);
if(!isLoggedIn){
onView(withId(R.id.emailLoginField)).perform(typeText("[email protected]"));
closeSoftKeyboard();
onView(withId(R.id.passwordLoginField)).perform(typeText("iza3bel"));
closeSoftKeyboard();
onView(withId(R.id.loginButton)).perform(click());
}
onView(withId(R.id.recycler_view_open))
.perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
onView(withId(R.id.recycler_viewBill))
.perform(RecyclerViewActions.actionOnItemAtPosition(2, click()));
onView(withId(R.id.recycler_viewSegment))
.perform(RecyclerViewActions.actionOnItemAtPosition(1, MyViewAction
.clickChildViewWithId(R.id.imageViewProposalCard)));
onView(withId(R.id.saveComment)).perform(click());
onView(withId(R.id.commentEditText)).check(matches(hasErrorText(getActivity()
.getApplicationContext().getResources().getString(R.string.empty_comment))));
}
示例14: testResultSearchExistWithInternet
import android.support.test.espresso.contrib.RecyclerViewActions; //导入依赖的package包/类
public void testResultSearchExistWithInternet() {
Boolean isLoggedIn = PreferenceManager.getDefaultSharedPreferences
(activityOnTest.getBaseContext()).getBoolean("IsLoggedIn", false);
if(isLoggedIn){
onView(withId(R.id.action_profile_logged)).perform(click());
onView(withText("Sair")).perform(click());
}
closeSoftKeyboard();
onView(withText("Visitante")).perform(ViewActions.scrollTo()).perform(click());
onView(withId(R.id.action_search)).perform(click());
onView(isAssignableFrom(EditText.class)).perform(typeText("Gr"),
pressKey(KeyEvent.KEYCODE_ENTER));
closeSoftKeyboard();
onView(withId(R.id.recycler_view_search))
.perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
onView(withId(R.id.textViewTitleBill)).check(matches(isDisplayed()));
}
示例15: testResultSearchExistWithoutInternet
import android.support.test.espresso.contrib.RecyclerViewActions; //导入依赖的package包/类
public void testResultSearchExistWithoutInternet() {
disabledInternet();
Boolean isLoggedIn = PreferenceManager.getDefaultSharedPreferences
(activityOnTest.getBaseContext()).getBoolean("IsLoggedIn", false);
if(isLoggedIn){
onView(withId(R.id.action_profile_logged)).perform(click());
onView(withText("Sair")).perform(click());
}
closeSoftKeyboard();
onView(withText("Visitante")).perform(ViewActions.scrollTo()).perform(click());
onView(withId(R.id.action_search)).perform(click());
onView(isAssignableFrom(EditText.class)).perform(typeText("Gr"),
pressKey(KeyEvent.KEYCODE_ENTER));
closeSoftKeyboard();
onView(withId(R.id.recycler_view_search))
.perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
onView(withId(R.id.textViewTitleBill)).check(matches(isDisplayed()));
}