Java Code Examples for android.support.test.espresso.contrib.RecyclerViewActions

The following are top voted examples for showing how to use android.support.test.espresso.contrib.RecyclerViewActions. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Android-Show-Reader   File: ShowListActivityTest.java   View source code 6 votes vote down vote up
@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++;
    }
}
 
Example 2
Project: FireBaseTest   File: HomeScreenTest.java   View source code 6 votes vote down vote up
@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()));
}
 
Example 3
Project: TripleTap   File: SetGameFragmentAndroidTests.java   View source code 6 votes vote down vote up
/**
 * 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()));
    }

}
 
Example 4
Project: android-architecture-components   File: MainActivityTest.java   View source code 6 votes vote down vote up
@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(""))));

}
 
Example 5
Project: ChipsLayoutManager   File: ColumnTest.java   View source code 6 votes vote down vote up
@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
Project: ChipsLayoutManager   File: ColumnTest.java   View source code 6 votes vote down vote up
@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
Project: ChipsLayoutManager   File: RowTest.java   View source code 6 votes vote down vote up
@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
Project: ChipsLayoutManager   File: RowTest.java   View source code 6 votes vote down vote up
@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 9
Project: GongXianSheng   File: MainActivityTest.java   View source code 6 votes vote down vote up
@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++;
    }
}
 
Example 10
Project: TherapyGuide   File: DiaryScreenTest.java   View source code 6 votes vote down vote up
@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());
}
 
Example 11
Project: read-expand   File: MainActivityTest.java   View source code 6 votes vote down vote up
@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++;
    }
}
 
Example 12
Project: generator-android-boilerplate   File: MainActivityTest.java   View source code 6 votes vote down vote up
@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++;
    }
}
 
Example 13
Project: 2016.2-WikiLegis   File: CreateCommentTest.java   View source code 6 votes vote down vote up
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()));

    }
 
Example 14
Project: 2016.2-WikiLegis   File: CreateCommentTest.java   View source code 6 votes vote down vote up
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))));
    }
 
Example 15
Project: 2016.2-WikiLegis   File: SearchBillFragmentTest.java   View source code 6 votes vote down vote up
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()));
}
 
Example 16
Project: 2016.2-WikiLegis   File: SearchBillFragmentTest.java   View source code 6 votes vote down vote up
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()));
}
 
Example 17
Project: 2016.2-WikiLegis   File: CreateSuggestProposalTest.java   View source code 6 votes vote down vote up
public void testSuggestProposalLoggedOut(){

        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(scrollTo()).perform(click());
        onView(withId(R.id.recycler_view_open))
                .perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
        onView(withId(R.id.recycler_viewBill))
                .perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
        onView(withId(R.id.recycler_viewSegment))
                .perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
        onView(withId(R.id.floatingButton))
                .perform((click()));
        onView(withId(R.id.emailLoginField)).check(matches(isDisplayed()));

    }
 
Example 18
Project: MVP-Boilerplate   File: MainActivityTest.java   View source code 6 votes vote down vote up
@Test
public void shouldShowsListOfPhotos() {
    // Initialize: prepare test photos
    List<Photo> testPhotos = TestDataFactory.getRandomPhotos();
    Context testContext = InstrumentationRegistry.getTargetContext();
    DataManager mockedDataManager = FunctionalTestApp.get(testContext)
            .getComponent()
            .dataManager();
    when(mockedDataManager.getPhotos())
            .thenReturn(Observable.just(testPhotos));

    // Run: launch MainActivity
    mainActivityTestRule.launchActivity(null);

    // Check: should show all photos
    int position = 0;
    for (Photo photo : testPhotos) {
        onView(withId(R.id.recycler_view))
                .perform(RecyclerViewActions.scrollToPosition(position));
        onView(withText(photo.getText()))
                .check(matches(isDisplayed()));
        position++;
    }
}
 
Example 19
Project: Expander   File: MacroActivityTest.java   View source code 6 votes vote down vote up
@Test
public void whenUserHitsDeviceBackButtonAndTheyDidNotMakeChangesToTheMacroMacroTheMacroChangesFoundDialogShouldNotBeCalled() {

    //launch the main activity
    Intent intent = new Intent();
    mMainActivityActivityTestRule.launchActivity(intent);

    //Click the macro
    onView(withId(R.id.noteListRecyclerView)).perform(
            RecyclerViewActions.actionOnItemAtPosition(0, click()));

    //press the back button to get rid of keyboard
    pressBack();

    //Press back again to go back
    pressBack();

    //Validate that the the pop up that detects changes is not called
    onView(withText("Changes Found")).check(doesNotExist());
}
 
Example 20
Project: Expander   File: MacroActivityTest.java   View source code 6 votes vote down vote up
@Test
public void whenUserHitsToolbarBackButtonAndTheyDidNotMakeChangesToTheMacroTheMacroChangesFoundDialogShouldNotBeCalled() {

    //launch the main activity
    Intent intent = new Intent();
    mMainActivityActivityTestRule.launchActivity(intent);

    //Click the macro
    onView(withId(R.id.noteListRecyclerView)).perform(
            RecyclerViewActions.actionOnItemAtPosition(0, click()));

    //press the back button to get rid of keyboard
    onView(withContentDescription("Navigate up")).perform(click());

    //Validate that the the pop up that detects changes is not called
    onView(withText("Changes Found")).check(doesNotExist());
}
 
Example 21
Project: Expander   File: MacroActivityTest.java   View source code 6 votes vote down vote up
@Test
public void whenUserAddsDynamicValueToPhraseThePhraseShouldContainTheDynamicValueTheySelected(){

    //Clear shared Prefs
    clearSharedPrefs(InstrumentationRegistry.getTargetContext());

    //Set pref
    setBooleanPref(InstrumentationRegistry.getTargetContext(), "isDynamicValuesEnabled", true);

    //launch the main activity
    Intent intent = new Intent();
    mActivityTestRule.launchActivity(intent);

    //Input text into the phrase field
    onView(withId(R.id.input_phrase)).perform(clearText(), typeText("Test Phrase"));

    //Click the dynamic value button
    onView(withId(R.id.dynamic_value_button)).perform(click());

    //Click the first item in the recycler view
    onView(withId(R.id.dynamicValueRecyclerView)).perform(
            RecyclerViewActions.actionOnItemAtPosition(1, click()));

    //Validate the phrase now contains the dynamic value phrase for day of week
    onView(withId(R.id.input_phrase)).check(matches(withText("Test Phrase !date")));
}
 
Example 22
Project: RecipeFinderJavaVersion   File: SearchRecipesFragmentTest.java   View source code 6 votes vote down vote up
@Test
public void testStartSearching() {
    when(repository.searchRecipes(Mockito.<String, String>anyMap()))
            .thenReturn(Single.just(AssetUtils.getRecipeList(context)));
    when(repository.loadMore(Mockito.<String, String>anyMap()))
            .thenReturn(Single.just(AssetUtils.getMoreRecipeList(context)));
    when(repository.isInFavorites(Mockito.<Recipe>any()))
            .thenReturn(Single.just(true));
    rule.launchActivity(new Intent());
    performSearch();

    onView(withText(firstRecipeTitle)).check(matches(isDisplayed()));
    onView(ViewMatchers.withId(R.id.rv_recipe_list)).perform(RecyclerViewActions.scrollToPosition(9));
    onView(withText(lastRecipeTitle)).check(matches(isDisplayed()));

    // Scroll to top and click upon the first item
    Recipe recipe = AssetUtils.getRecipeEntity(InstrumentationRegistry.getContext());
    onView(withId(R.id.rv_recipe_list)).perform(RecyclerViewActions.scrollToPosition(0));

    onView(withText(recipe.getLabel())).perform(ViewActions.click());

    onView(withId(R.id.tv_health_labels)).check(matches(isDisplayed()));
    onView(withId(R.id.iv_recipe_image)).check(matches(isDisplayed()));
    onView(withId(R.id.toolbar)).check(matches(isDisplayed()));
}
 
Example 23
Project: zulip-android   File: RecyclerViewTests.java   View source code 6 votes vote down vote up
@Test
public void sendStreamMessage() {
    //Wait to make sure the messages are loaded
    sleep(2000);

    onView(withId(R.id.recyclerView)).perform(RecyclerViewActions.scrollToHolder(withMessageHolderAndClick(MessageType.STREAM_MESSAGE, R.id.contentView)));
    sleep(1000);

    //Fill message EditText
    ViewInteraction messageInteraction = onView(allOf(withId(R.id.message_et), isDisplayed()));
    messageInteraction.perform(replaceText(testMessageStream));

    //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(testMessageStream, R.id.contentView)));

    onView(AllOf.allOf(withId(R.id.contentView), withText(testMessageStream))).check(matches(isDisplayed()));

    checkIfMessagesMatchTheHeaderParent();
    checkOrderOfMessagesCurrentList();
}
 
Example 24
Project: zulip-android   File: RecyclerViewTests.java   View source code 6 votes vote down vote up
@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 25
Project: zulip-android   File: RecyclerViewTests.java   View source code 6 votes vote down vote up
@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 26
Project: todos   File: MainActivityTest.java   View source code 6 votes vote down vote up
public void testTapItem() {
    Intents.init();
    addInitialData();

    pause();

    // DO UI INTERACTION
    onView(withId(R.id.recycler)).perform(RecyclerViewActions.actionOnItemAtPosition(1, click
            ()));

    pause();

    // Confirm that the TodoListActivity was started!
    intended(hasComponent(TodoListActivity.class.getName()));
    Intents.release();
}
 
Example 27
Project: Vineyard   File: MainActivityTest.java   View source code 6 votes vote down vote up
@Test
public void allCategoriesAreDisplayed() {
    stubVideoFeedData();

    main.launchActivity(null);

    List<String> categoryList = getCategoriesArray();
    for (int i = 0; i < categoryList.size(); i++) {
        // We don't need to click on the first item as it's already in focus
        if (i > 0) {
            onView(withId(R.id.browse_headers))
                    .perform(RecyclerViewActions.actionOnItemAtPosition(i, click()));
        }
        onView(withItemText(categoryList.get(i), R.id.browse_headers))
                .check(matches(isDisplayed()));
    }
}
 
Example 28
Project: Vineyard   File: MainActivityTest.java   View source code 6 votes vote down vote up
@Test
public void testOptionsDisplayAndAreBrowsable() {
    stubVideoFeedData();
    main.launchActivity(null);

    List<String> categoryList = getCategoriesArray();
    for (int i = 0; i < categoryList.size(); i++) {
        // We don't need to click on the first item as it's already in focus
        if (i > 0) {
            onView(withId(R.id.browse_headers))
                    .perform(RecyclerViewActions.actionOnItemAtPosition(i, click()));
        }
    }
    onView(withId(R.id.browse_headers))
            .perform(RecyclerViewActions.actionOnItemAtPosition(categoryList.size() - 1, click()));
    onView(withItemText("Options", R.id.browse_container_dock))
            .check(matches(isDisplayed()));
    onView(withItemText("Auto-loop", R.id.browse_container_dock))
            .check(matches(isDisplayed()));
}
 
Example 29
Project: Vineyard   File: MainActivityTest.java   View source code 6 votes vote down vote up
@Test
public void autoLoopGuidedStepOpens() {
    stubVideoFeedData();
    main.launchActivity(null);

    List<String> categoryList = getCategoriesArray();
    for (int i = 0; i < categoryList.size(); i++) {
        // We don't need to click on the first item as it's already in focus
        if (i > 0) {
            onView(withId(R.id.browse_headers))
                    .perform(RecyclerViewActions.actionOnItemAtPosition(i, click()));
        }
    }
    onView(withId(R.id.browse_headers))
            .perform(RecyclerViewActions.actionOnItemAtPosition(categoryList.size() - 1, click()));
    onView(withItemText("Auto-loop", R.id.browse_container_dock))
            .check(matches(isDisplayed()))
            .perform(click());
    onView(withText(R.string.guided_step_auto_loop_title))
            .check(matches(isDisplayed()));
}
 
Example 30
Project: ribot-app-android   File: CheckInActivityTest.java   View source code 6 votes vote down vote up
@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 31
Project: ribot-app-android   File: MainActivityTest.java   View source code 6 votes vote down vote up
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 32
Project: GameCheck   File: GameActivityTest.java   View source code 6 votes vote down vote up
@Test
public void checkingFields_WithPlatform() {

    Game game = GameBuilder.aGame()
            .withPlatform(PlatformBuilder.aPlatform().withImage(ImageBuilder.aImage().build()).build())
            .withImage(ImageBuilder.aImage().build())
            .build();

    activityRule.launchActivity(GameActivity.newInstance(game));

    onView(allOf(withId(R.id.textview_name), withParent(withId(R.id.linearlayout_header)))).check(matches(withText(game.getName())));
    onView(allOf(withId(R.id.imageview_cover), hasSibling(withId(R.id.imageview_photo)))).check(matches(isDisplayed()));
    onView(allOf(withId(R.id.imageview_photo), hasSibling(withId(R.id.imageview_cover)))).check(matches(isDisplayed()));
    onView(withId(R.id.textview_noplatform)).check(matches(not(isDisplayed())));
    onView(withId(R.id.recyclerview_platforms)).check(matches(isDisplayed()));

    onView(withId(R.id.recyclerview_platforms)).perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
}
 
Example 33
Project: GameCheck   File: GameActivityTest.java   View source code 6 votes vote down vote up
@Test
public void checkingFields_ScreenRotation() {
    String description = "A Game";
    Game game = GameBuilder.aGame()
            .withDeck(description)
            .withPlatform(PlatformBuilder.aPlatform().withImage(ImageBuilder.aImage().build()).build())
            .withImage(ImageBuilder.aImage().build())
            .build();

    activityRule.launchActivity(GameActivity.newInstance(game));
    activityRule.getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    onView(allOf(withId(R.id.textview_name), withParent(withId(R.id.linearlayout_header)))).check(matches(withText(game.getName())));
    onView(allOf(withId(R.id.imageview_cover), hasSibling(withId(R.id.imageview_photo)))).check(matches(isDisplayed()));
    onView(allOf(withId(R.id.imageview_photo), hasSibling(withId(R.id.imageview_cover)))).check(matches(isDisplayed()));
    onView(withId(R.id.textview_description)).check(matches(isDisplayed()));
    onView(withId(R.id.textview_description)).check(matches(withText(description)));
    onView(withId(R.id.textview_noplatform)).check(matches(not(isDisplayed())));
    onView(withId(R.id.recyclerview_platforms)).check(matches(isDisplayed()));
    onView(withId(R.id.recyclerview_platforms)).perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
}
 
Example 34
Project: GameCheck   File: PlatformActivityTest.java   View source code 6 votes vote down vote up
@Test
public void selectAGame() {
    String description = "A Platform";
    Platform platform = PlatformBuilder.aPlatform()
            .withDeck(description)
            .withImage(ImageBuilder.aImage().build())
            .build();

    activityRule.launchActivity(PlatformActivity.newInstance(platform));

    try {
        Thread.sleep(10000);
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    onView(withId(R.id.recyclerview_games)).perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
    onView(withId(R.id.ratingBar)).check(matches(isDisplayed()));
    onView(withContentDescription(R.string.abc_action_bar_up_description)).perform(click());
}
 
Example 35
Project: GameCheck   File: SearchGameActivityTest.java   View source code 6 votes vote down vote up
@Test
public void selectingAGame() {

    onView(isAssignableFrom(EditText.class))
            .perform(typeText(GameBuilder.DEFAULT_NAME), pressImeActionButton());

    try {
        Thread.sleep(10000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    onView(withId(R.id.recyclerview_games)).perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
    onView(withId(R.id.ratingBar)).check(matches(isDisplayed()));
    onView(withContentDescription(R.string.abc_action_bar_up_description)).perform(click());
}
 
Example 36
Project: GameCheck   File: SearchPlatformActivityTest.java   View source code 6 votes vote down vote up
@Test
public void selectingAPlatform() {

    onView(isAssignableFrom(EditText.class))
            .perform(typeText(PlatformBuilder.DEFAULT_NAME), pressImeActionButton());

    try {
        Thread.sleep(10000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    onView(withId(R.id.recyclerview_platforms)).perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
    onView(withId(R.id.ratingBar)).check(matches(isDisplayed()));
    onView(withContentDescription(R.string.abc_action_bar_up_description)).perform(click());
}
 
Example 37
Project: calendula   File: MedicinesAlertTest.java   View source code 6 votes vote down vote up
@Test
public void testViewAlert() {
    final HomePagerActivity activity = rule.getActivity();
    activity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            activity.showPagerItem(HomePages.MEDICINES.ordinal());
        }
    });


    onView(withId(R.id.medicines_list)).perform(
            RecyclerViewActions.actionOnItemAtPosition(0, CustomViewActions.clickChildViewWithId(R.id.imageView)));

    TestUtils.sleep(400);

    onView(withId(R.id.rv)).check(matches(CustomViewMatchers.withRecyclerViewSize(1)));
    onView(withId(R.id.rv)).check(matches(drivingAlertRecyclerMatcher()));
}
 
Example 38
Project: GitHub   File: MainActivityTest.java   View source code 5 votes vote down vote up
private void checkPostsDisplayOnRecyclerView(List<Post> postsToCheck) {
    for (int i = 0; i < postsToCheck.size(); i++) {
        onView(withId(R.id.recycler_stories))
                .perform(RecyclerViewActions.scrollToPosition(i));
        checkPostDisplays(postsToCheck.get(i));
    }
}
 
Example 39
Project: Pickr   File: MainActivityTest.java   View source code 5 votes vote down vote up
private void checkLocationsDisplayOnRecyclerView(List<PointOfInterest> charactersToCheck) {
    for (int i = 0; i < charactersToCheck.size(); i++) {
        onView(withId(R.id.recycler_places))
                .perform(RecyclerViewActions.scrollToPosition(i));
        checkLocationDisplays(charactersToCheck.get(i));
    }
}
 
Example 40
Project: UdacityBakingAndroid   File: MainRecyclerViewTest.java   View source code 5 votes vote down vote up
@Test
public void clickRecyclerViewItem_OpensDetailActivity() {

    try {
        Thread.sleep(3000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    onView(withId(R.id.recipe_recycler_view))
            .perform(RecyclerViewActions.actionOnItem(
                    hasDescendant(withText(RECIPE_NAME)), click()));

    matchToolbarTitle(RECIPE_NAME);
}