當前位置: 首頁>>代碼示例>>Java>>正文


Java RecyclerViewActions類代碼示例

本文整理匯總了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++;
    }
}
 
開發者ID:OHoussein,項目名稱:Android-Show-Reader,代碼行數:18,代碼來源:ShowListActivityTest.java

示例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()));
}
 
開發者ID:Frank1234,項目名稱:FireBaseTest,代碼行數:25,代碼來源:HomeScreenTest.java

示例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()));
    }

}
 
開發者ID:jaysondc,項目名稱:TripleTap,代碼行數:26,代碼來源:SetGameFragmentAndroidTests.java

示例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(""))));

}
 
開發者ID:googlesamples,項目名稱:android-architecture-components,代碼行數:17,代碼來源:MainActivityTest.java

示例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();
}
 
開發者ID:sathishmscict,項目名稱:ChipsLayoutManager,代碼行數:19,代碼來源:ColumnTest.java

示例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())));
}
 
開發者ID:sathishmscict,項目名稱:ChipsLayoutManager,代碼行數:18,代碼來源:ColumnTest.java

示例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())));
}
 
開發者ID:sathishmscict,項目名稱:ChipsLayoutManager,代碼行數:20,代碼來源:RowTest.java

示例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);
}
 
開發者ID:sathishmscict,項目名稱:ChipsLayoutManager,代碼行數:19,代碼來源:RowTest.java

示例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++;
    }
}
 
開發者ID:ebridfighter,項目名稱:GongXianSheng,代碼行數:22,代碼來源:MainActivityTest.java

示例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());
}
 
開發者ID:jgevans,項目名稱:TherapyGuide,代碼行數:26,代碼來源:DiaryScreenTest.java

示例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++;
    }
}
 
開發者ID:w4mxl,項目名稱:read-expand,代碼行數:22,代碼來源:MainActivityTest.java

示例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()));

    }
 
開發者ID:fga-gpp-mds,項目名稱:2016.2-WikiLegis,代碼行數:25,代碼來源:CreateCommentTest.java

示例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))));
    }
 
開發者ID:fga-gpp-mds,項目名稱:2016.2-WikiLegis,代碼行數:27,代碼來源:CreateCommentTest.java

示例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()));
}
 
開發者ID:fga-gpp-mds,項目名稱:2016.2-WikiLegis,代碼行數:25,代碼來源:SearchBillFragmentTest.java

示例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()));
}
 
開發者ID:fga-gpp-mds,項目名稱:2016.2-WikiLegis,代碼行數:27,代碼來源:SearchBillFragmentTest.java


注:本文中的android.support.test.espresso.contrib.RecyclerViewActions類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。