Java Code Examples for android.support.test.espresso.ViewInteraction#perform()

The following examples show how to use android.support.test.espresso.ViewInteraction#perform() . 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: GroupSetTest.java    From Android with MIT License 6 votes vote down vote up
public void qrcodeTest(){
    ViewInteraction groupNameView = onView(withId(R.id.groupset_qrcode));
    groupNameView.check(matches(isEnabled()));
    groupNameView.perform(click());

    ViewInteraction rightView = onView(allOf(withId(R.id.right_lin), isDisplayed()));
    rightView.perform(click());

    DataInteraction listView = onData(anything()).inAdapterView(withId(R.id.list_view)).atPosition(0);
    listView.perform(click());

    ViewInteraction confirmView = onView(allOf(withId(R.id.okBtn), isDisplayed()));
    confirmView.perform(click());

    ViewInteraction leftView = onView(allOf(withId(R.id.left_rela), isDisplayed()));
    leftView.perform(click());
}
 
Example 2
Source File: GroupSetTest.java    From Android with MIT License 6 votes vote down vote up
public void managerTest(){
    ViewInteraction groupNameView = onView(allOf(withId(R.id.groupset_manage),isDisplayed()));
    groupNameView.perform(click());

    ViewInteraction openView = onView(allOf(withId(R.id.toggle),withParent(withId(R.id.groupset_sureinvite)), isDisplayed()));
    openView.perform(click());

    ViewInteraction introduceView = onView(allOf(withId(R.id.groupset_introdue), isDisplayed()));
    introduceView.perform(click());
    ViewInteraction introduceEditView = onView(allOf(withId(R.id.edit), isDisplayed()));
    introduceEditView.perform(replaceText("introduce:" + TimeUtil.getTime(TimeUtil.getCurrentTimeInLong(), TimeUtil.DATE_FORMAT_HOUR_MIN)));
    ViewInteraction rightView = onView(allOf(withId(R.id.right_lin), isDisplayed()));
    rightView.perform(click());

    ViewInteraction transferView = onView(allOf(withId(R.id.groupset_transferto), isDisplayed()));
    transferView.perform(click());
    onData(allOf(withId(R.id.recyclerview),isDisplayed())).perform(actionOnItemAtPosition(0,click()));
    ViewInteraction confirmView = onView(allOf(withId(R.id.okBtn), isDisplayed()));
    confirmView.perform(click());
}
 
Example 3
Source File: SplashActivityTest.java    From Expert-Android-Programming with MIT License 6 votes vote down vote up
@Test
public void verifyMessageSentToMessageActivity() {

    ViewInteraction appCompatTextView2 = onView(
            allOf(withId(R.id.subtitle), withText("NEARBY"), isDisplayed()));
    appCompatTextView2.perform(click());

    // Types a message into a EditText element.
    onView(withId(R.id.searchText))
            .perform(typeText(MESSAGE), closeSoftKeyboard());


    //onView(withId(R.id.submit)).perform(click());

    // Verifies that the DisplayMessageActivity received an intent
    // with the correct package name and message.
    // Check that the text was changed.
    onView(withId(R.id.subtitle))
            .check(matches(withText(MESSAGE)));

}
 
Example 4
Source File: InfoActivityTest.java    From open_flood with MIT License 6 votes vote down vote up
@Test
public void infoActivityTest() {
    // Launch the Info Activity
    ViewInteraction infoActivityButton = onView(
            allOf(withId(R.id.infoButton), isDisplayed()));
    infoActivityButton.perform(click());

    // Click the back button
    ViewInteraction appCompatButton = onView(
            allOf(withId(R.id.backButton), withText("Back")));
    appCompatButton.perform(scrollTo(), click());

    // Verify that we are now back in the GameActivity by checking that the FloodView is displayed
    ViewInteraction view = onView(
            allOf(withId(R.id.floodView)));
    view.check(matches(isDisplayed()));
}
 
Example 5
Source File: MainActivityTest.java    From Android-Developer-Fundamentals-Version-2 with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void mainActivityTest() {
    ViewInteraction floatingActionButton = onView(
            allOf(withId(R.id.fab),
                    childAtPosition(
                            childAtPosition(
                                    withId(android.R.id.content),
                                    0),
                            2),
                    isDisplayed()));
    floatingActionButton.perform(click());

    ViewInteraction recyclerView = onView(
            allOf(withId(R.id.recyclerView),
                    childAtPosition(
                            withClassName(is("android.support.constraint.ConstraintLayout")),
                            0)));
    recyclerView.perform(actionOnItemAtPosition(20, click()));

    ViewInteraction textView = onView(
            allOf(withId(R.id.word), withText("Clicked! + Word 20"),
                    childAtPosition(
                            childAtPosition(
                                    withId(R.id.recyclerView),
                                    19),
                            0),
                    isDisplayed()));
    textView.check(matches(withText("Clicked! + Word 20")));

    ViewInteraction textView2 = onView(
            allOf(withId(R.id.word), withText("Clicked! + Word 20"),
                    childAtPosition(
                            childAtPosition(
                                    withId(R.id.recyclerView),
                                    19),
                            0),
                    isDisplayed()));
    textView2.check(matches(isDisplayed()));
}
 
Example 6
Source File: FewChipsRowTest.java    From ChipsLayoutManager with Apache License 2.0 5 votes vote down vote up
@Test
public void deleteItemInTheFirstLine_ItemHasMaximumHeight_SameStartPadding() throws Exception {
    //arrange
    //just adapt input items list to required start values
    items.remove(1);
    activity.runOnUiThread(() -> activity.initialize());

    ViewInteraction recyclerView = onView(withId(R.id.rvTest)).check(matches(isDisplayed()));

    InstrumentalUtil.waitForIdle();

    View second = layoutManager.getChildAt(1);
    int startHeight = second.getHeight();
    double expectedY = second.getY();

    //act
    recyclerView.perform(
            actionDelegate(((uiController, view) -> items.remove(1))),
            notifyItemRemovedAction(1));

    InstrumentalUtil.waitForIdle();

    second = layoutManager.getChildAt(1);
    int endHeight = second.getHeight();
    double resultY = second.getY();

    //assert
    //check test behaviour
    assumeTrue(startHeight > endHeight);

    assertNotEquals(0, expectedY, 0.01);
    assertNotEquals(0, resultY, 0.01);
    assertEquals(resultY, expectedY, 0.01);
}
 
Example 7
Source File: MainActivityTest.java    From marvel with MIT License 5 votes vote down vote up
@Test
public void shouldBeAbleToCacheTestCharacter() {
    // Launch the activity
    mainActivity.launchActivity(new Intent());

    // search for Test Character
    ViewInteraction appCompatAutoCompleteTextView = onView(
            allOf(withId(R.id.character), isDisplayed()));
    appCompatAutoCompleteTextView.perform(replaceText(TEST_CHARACTER_NAME));

    ViewInteraction appCompatButton = onView(
            allOf(withId(R.id.show), isDisplayed()));
    appCompatButton.perform(click());

    pressBack();

    // Check view is loaded as we expect it to be
    ViewInteraction cachedName = onView(
            allOf(withId(R.id.name), withText(TEST_CHARACTER_NAME),
                    childAtPosition(
                            childAtPosition(
                                    IsInstanceOf.instanceOf(android.widget.FrameLayout.class),
                                    0),
                            1),
                    isDisplayed()));
    cachedName.check(matches(withText(TEST_CHARACTER_NAME)));
}
 
Example 8
Source File: MainActivityTest.java    From android-testing-guide with MIT License 5 votes vote down vote up
@Test
public void testEspresso() {
    ViewInteraction interaction =
            onView(allOf(withId(R.id.editText),
                    withText("this is a test"),
                    hasFocus()));
    interaction.perform(replaceText("how about some new text"));
    ViewInteraction interaction2 =
            onView(allOf(withId(R.id.editText),
                    withText("how about some new text")));
    interaction2.check(matches(hasFocus()));
}
 
Example 9
Source File: FewChipsColumnTest.java    From ChipsLayoutManager with Apache License 2.0 5 votes vote down vote up
@Test
public void wrapContent_HeightIsWrapContent_DeletedLastItemInLastRowCauseHeightToDecrease() throws Exception {
    //arrange
    activity.runOnUiThread(() -> activity.initialize());
    final RecyclerView[] rvTest = new RecyclerView[1];

    ViewInteraction recyclerView = onView(withId(R.id.rvTest)).check(matches(isDisplayed()));
    ViewAction viewAction = actionDelegate(((uiController, view) -> {
        rvTest[0] = view;
        view.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT;
        view.requestLayout();
    }));

    recyclerView.perform(viewAction);

    int startWidth = rvTest[0].getHeight();

    //act
    recyclerView.perform(
            actionDelegate(((uiController, view) -> items.remove(9))),
            notifyItemRemovedAction(9));
    InstrumentalUtil.waitForIdle();

    //assert
    int endWidth = rvTest[0].getWidth();
    System.out.println(String.format(Locale.getDefault(), "start height = %d, end height = %d", startWidth, endWidth));
    assertTrue(endWidth < startWidth);
}
 
Example 10
Source File: HomeEspressoTest.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
@Test
@AllowFlaky(attempts = 5)
public void A2_accept_license() {
    // accept the license agreement
    // TODO note espresso recorder uses hardcoded strings
    ViewInteraction appCompatCheckBox2 = onView(
            allOf(withId(R.id.agreeCheckBox), withText("I UNDERSTAND AND AGREE")));
    appCompatCheckBox2.perform(scrollTo(), click());

    ViewInteraction appCompatButton2 = onView(
            allOf(withId(R.id.saveButton), withText("Save")));
    appCompatButton2.perform(scrollTo(), click());

}
 
Example 11
Source File: SingleSetTest.java    From Android with MIT License 5 votes vote down vote up
@After
public void backTest() {
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    ViewInteraction leftView = onView(withId(R.id.left_rela));
    leftView.perform(click());
}
 
Example 12
Source File: AddRecordingTest.java    From go-bees with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void addRecordingTest() {
    ViewInteraction floatingActionButton = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton.perform(click());

    ViewInteraction appCompatEditText = onView(
            withId(R.id.add_apiary_name));
    appCompatEditText.perform(scrollTo(), replaceText("Apiary"), closeSoftKeyboard());

    ViewInteraction floatingActionButton2 = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton2.perform(click());

    ViewInteraction recyclerView = onView(
            allOf(withId(R.id.apiaries_list),
                    withParent(allOf(withId(R.id.apiariesLL),
                            withParent(withId(R.id.apiariesContainer)))),
                    isDisplayed()));
    recyclerView.perform(actionOnItemAtPosition(0, click()));

    ViewInteraction floatingActionButton3 = onView(
            allOf(withId(R.id.fab_add_hive),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton3.perform(click());

    ViewInteraction appCompatEditText2 = onView(
            withId(R.id.add_hive_name));
    appCompatEditText2.perform(scrollTo(), replaceText("Hive"), closeSoftKeyboard());

    ViewInteraction floatingActionButton4 = onView(
            allOf(withId(R.id.fab_add_hive),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton4.perform(click());

    ViewInteraction recyclerView2 = onView(
            allOf(withId(R.id.hives_list),
                    withParent(allOf(withId(R.id.hivesLL),
                            withParent(withId(R.id.hivesContainer)))),
                    isDisplayed()));
    recyclerView2.perform(actionOnItemAtPosition(0, click()));

    ViewInteraction floatingActionButton5 = onView(
            allOf(withId(R.id.fab_new_recording),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton5.perform(click());

    ViewInteraction appCompatImageView = onView(
            withId(R.id.record_icon));
    appCompatImageView.perform(click());

    SystemClock.sleep(20000);

    ViewInteraction appCompatImageView2 = onView(
            withId(R.id.record_icon));
    appCompatImageView2.perform(click());

    ViewInteraction frameLayout = onView(
            allOf(withId(R.id.card),
                    childAtPosition(
                            allOf(withId(R.id.recordings_list),
                                    childAtPosition(
                                            withId(R.id.recordingsLL),
                                            0)),
                            0),
                    isDisplayed()));
    frameLayout.check(matches(isDisplayed()));
}
 
Example 13
Source File: ListApiariesTest.java    From go-bees with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void listApiariesTest() {
    ViewInteraction floatingActionButton = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton.perform(click());

    ViewInteraction appCompatEditText = onView(
            withId(R.id.add_apiary_name));
    appCompatEditText.perform(scrollTo(), replaceText("A1"), closeSoftKeyboard());

    ViewInteraction floatingActionButton2 = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton2.perform(click());

    ViewInteraction floatingActionButton3 = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton3.perform(click());

    ViewInteraction appCompatEditText2 = onView(
            withId(R.id.add_apiary_name));
    appCompatEditText2.perform(scrollTo(), replaceText("A2"), closeSoftKeyboard());

    ViewInteraction floatingActionButton4 = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton4.perform(click());

    ViewInteraction floatingActionButton5 = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton5.perform(click());

    ViewInteraction appCompatEditText3 = onView(
            withId(R.id.add_apiary_name));
    appCompatEditText3.perform(scrollTo(), replaceText("A3"), closeSoftKeyboard());

    ViewInteraction floatingActionButton6 = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton6.perform(click());

    ViewInteraction textView = onView(
            withText("A1"));
    textView.check(matches(isDisplayed()));

    textView = onView(
            withText("A2"));
    textView.check(matches(isDisplayed()));

    textView = onView(
            withText("A3"));
    textView.check(matches(isDisplayed()));
}
 
Example 14
Source File: ViewApiaryTest.java    From go-bees with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void viewApiaryTest() {
    ViewInteraction floatingActionButton = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton.perform(click());

    ViewInteraction appCompatEditText = onView(
            withId(R.id.add_apiary_name));
    appCompatEditText.perform(scrollTo(), replaceText("Apiary"), closeSoftKeyboard());

    ViewInteraction appCompatEditText2 = onView(
            withId(R.id.add_apiary_notes));
    appCompatEditText2.perform(scrollTo(), replaceText("Notes"), closeSoftKeyboard());

    ViewInteraction floatingActionButton2 = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton2.perform(click());

    ViewInteraction recyclerView = onView(
            allOf(withId(R.id.apiaries_list),
                    withParent(allOf(withId(R.id.apiariesLL),
                            withParent(withId(R.id.apiariesContainer)))),
                    isDisplayed()));
    recyclerView.perform(actionOnItemAtPosition(0, click()));

    ViewInteraction textView = onView(
            withText("Apiary"));
    textView.check(matches(withText("Apiary")));

    ViewInteraction appCompatTextView = onView(
            allOf(withText("Info"), isDisplayed()));
    appCompatTextView.perform(click());

    ViewInteraction textView2 = onView(
            allOf(withId(R.id.notes_content), withText("Notes"),
                    childAtPosition(
                            childAtPosition(
                                    IsInstanceOf.<View>instanceOf(
                                            android.widget.LinearLayout.class), 1),
                            0),
                    isDisplayed()));
    textView2.check(matches(withText("Notes")));

}
 
Example 15
Source File: SingleSetTest.java    From Android with MIT License 4 votes vote down vote up
public void muteTest() {
    ViewInteraction muteView = onView(allOf(withId(R.id.toggle), withParent(withId(R.id.mute)), isDisplayed()));
    muteView.perform(click());
}
 
Example 16
Source File: SingleSetTest.java    From Android with MIT License 4 votes vote down vote up
public void topTest() {
    ViewInteraction topView = onView(allOf(withId(R.id.toggle), withParent(withId(R.id.top)), isDisplayed()));
    topView.perform(click());
}
 
Example 17
Source File: ChatActivityTest.java    From Android with MIT License 4 votes vote down vote up
@Test
public void runTest() {
    ElapsedTimeIdlingResource idlingResource = new ElapsedTimeIdlingResource(1000 * 1);
    Espresso.registerIdlingResources(idlingResource);

    ViewInteraction chatEditText = onView(
            allOf(withId(R.id.inputedit), isDisplayed()));
    chatEditText.perform(replaceText("nxns"), closeSoftKeyboard());

    ViewInteraction textView3 = onView(
            allOf(withId(R.id.inputtxt), withText("发送"),
                    withParent(allOf(withId(R.id.layout_inputbottom),
                            withParent(withId(R.id.layout_bottom)))),
                    isDisplayed()));
    textView3.perform(click());

    ViewInteraction imageView2 = onView(
            allOf(withId(R.id.inputmore), withContentDescription("Connect"),
                    withParent(allOf(withId(R.id.layout_inputbottom),
                            withParent(withId(R.id.layout_bottom)))),
                    isDisplayed()));
    imageView2.perform(click());

    ViewInteraction relativeLayout3 = onView(
            allOf(withClassName(is("android.widget.RelativeLayout")), isDisplayed()));
    relativeLayout3.perform(click());

    ViewInteraction relativeLayout4 = onView(
            allOf(withClassName(is("android.widget.RelativeLayout")), isDisplayed()));
    relativeLayout4.perform(click());

    ViewInteraction textView4 = onView(
            allOf(withId(R.id.photo_library), withText("发送1张图片"), isDisplayed()));
    textView4.perform(click());

    ViewInteraction imageView3 = onView(
            allOf(withId(R.id.inputmore), withContentDescription("Connect"),
                    withParent(allOf(withId(R.id.layout_inputbottom),
                            withParent(withId(R.id.layout_bottom)))),
                    isDisplayed()));
    imageView3.perform(click());

    ViewInteraction relativeLayout5 = onView(
            allOf(withClassName(is("android.widget.RelativeLayout")), isDisplayed()));
    relativeLayout5.perform(click());

    ViewInteraction videoBtnView = onView(
            allOf(withId(R.id.video_btn),
                    withParent(withId(R.id.bottom_rela)),
                    isDisplayed()));
    videoBtnView.perform(click());

    ViewInteraction relativeLayout6 = onView(
            allOf(withId(R.id.send_rela),
                    withParent(withId(R.id.bottom_rela)),
                    isDisplayed()));
    relativeLayout6.perform(click());

    ViewInteraction imageView4 = onView(
            allOf(withId(R.id.inputmore), withContentDescription("Connect"),
                    withParent(allOf(withId(R.id.layout_inputbottom),
                            withParent(withId(R.id.layout_bottom)))),
                    isDisplayed()));
    imageView4.perform(click());

    ViewInteraction relativeLayout7 = onView(
            allOf(withClassName(is("android.widget.RelativeLayout")), isDisplayed()));
    relativeLayout7.perform(click());

    ViewInteraction relativeLayout8 = onView(
            allOf(childAtPosition(
                    allOf(withId(R.id.listview),
                            withParent(withId(R.id.linearlayout))),
                    3),
                    isDisplayed()));
    relativeLayout8.perform(click());

    ViewInteraction relativeLayout9 = onView(
            allOf(withClassName(is("android.widget.RelativeLayout")), isDisplayed()));
    relativeLayout9.perform(click());

    ViewInteraction recyclerView = onView(
            allOf(withId(R.id.recyclerview), isDisplayed()));
    recyclerView.perform(actionOnItemAtPosition(0, click()));
}
 
Example 18
Source File: SettingsTest.java    From open_flood with MIT License 4 votes vote down vote up
@Test
public void changeNumColorsTest() {
    // Click each of the 6 color buttons that should be initially present
    clickColorButton(0);
    clickColorButton(1);
    clickColorButton(2);
    clickColorButton(3);
    clickColorButton(4);
    clickColorButton(5);

    // Click the settings button to launch the SettingsActivity
    ViewInteraction settingsButton = onView(
            allOf(withId(R.id.settingsButton), isDisplayed()));
    settingsButton.perform(click());

    // Click the 8 color button
    ViewInteraction changeNumColorsRadioButton = onView(
            allOf(withText("8"), withParent(withId(R.id.numColorsRadioGroup)), isDisplayed()));
    changeNumColorsRadioButton.perform(click());

    // Apply the settings changes
    ViewInteraction applyButton = onView(
            allOf(withId(R.id.applyButton), withText("Apply"), isDisplayed()));
    applyButton.perform(click());

    // We should now have 8 color buttons, click them all
    clickColorButton(0);
    clickColorButton(1);
    clickColorButton(2);
    clickColorButton(3);
    clickColorButton(4);
    clickColorButton(5);
    clickColorButton(6);
    clickColorButton(7);

    // Go back to the SettingsActivity
    settingsButton.perform(click());

    // Enable color blind mode
    ViewInteraction colorBlindModeCheckBox = onView(
            allOf(withId(R.id.colorBlindCheckBox), isDisplayed()));
    colorBlindModeCheckBox.perform(click());

    // Enable the old color scheme
    ViewInteraction oldColorSchemeCheckBox = onView(
            allOf(withId(R.id.oldColorsCheckBox), isDisplayed()));
    oldColorSchemeCheckBox.perform(click());

    // Set the board size to 24x24
    ViewInteraction changeBoardSizeRadioButton = onView(
            allOf(withText("24x24"), withParent(withId(R.id.boardSizeRadioGroup)), isDisplayed()));
    changeBoardSizeRadioButton.perform(click());

    // Apply the new settings
    applyButton.perform(click());

    // Click all 8 of the color buttons again
    clickColorButton(0);
    clickColorButton(1);
    clickColorButton(2);
    clickColorButton(3);
    clickColorButton(4);
    clickColorButton(5);
    clickColorButton(6);
    clickColorButton(7);
}
 
Example 19
Source File: ListRecordingsTest.java    From go-bees with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void listRecordingsTest() {

    ViewInteraction appCompatImageButton2 = onView(
            allOf(withContentDescription("Navigate up"),
                    withParent(withId(R.id.toolbar)),
                    isDisplayed()));
    appCompatImageButton2.perform(click());

    ViewInteraction appCompatCheckedTextView = onView(
            allOf(withId(R.id.design_menu_item_text), withText("Settings"), isDisplayed()));
    appCompatCheckedTextView.perform(click());

    ViewInteraction linearLayout = onView(
            allOf(childAtPosition(
                    withId(android.R.id.list),
                    3),
                    isDisplayed()));
    linearLayout.perform(click());

    ViewInteraction recyclerView = onView(
            allOf(withId(R.id.apiaries_list),
                    withParent(allOf(withId(R.id.apiariesLL),
                            withParent(withId(R.id.apiariesContainer)))),
                    isDisplayed()));
    recyclerView.perform(actionOnItemAtPosition(0, click()));

    ViewInteraction recyclerView2 = onView(
            allOf(withId(R.id.hives_list),
                    withParent(allOf(withId(R.id.hivesLL),
                            withParent(withId(R.id.hivesContainer)))),
                    isDisplayed()));
    recyclerView2.perform(actionOnItemAtPosition(0, click()));

    ViewInteraction frameLayout = onView(
            allOf(withId(R.id.card),
                    childAtPosition(
                            allOf(withId(R.id.recordings_list),
                                    childAtPosition(
                                            withId(R.id.recordingsLL),
                                            0)),
                            0),
                    isDisplayed()));
    frameLayout.check(matches(isDisplayed()));

    ViewInteraction frameLayout2 = onView(
            allOf(withId(R.id.card),
                    childAtPosition(
                            allOf(withId(R.id.recordings_list),
                                    childAtPosition(
                                            withId(R.id.recordingsLL),
                                            0)),
                            1),
                    isDisplayed()));
    frameLayout2.check(matches(isDisplayed()));

    ViewInteraction frameLayout3 = onView(
            allOf(withId(R.id.card),
                    childAtPosition(
                            allOf(withId(R.id.recordings_list),
                                    childAtPosition(
                                            withId(R.id.recordingsLL),
                                            0)),
                            2),
                    isDisplayed()));
    frameLayout3.check(matches(isDisplayed()));
}
 
Example 20
Source File: ViewHiveTest.java    From go-bees with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void viewHiveTest() {
    ViewInteraction floatingActionButton = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton.perform(click());

    ViewInteraction appCompatEditText = onView(
            withId(R.id.add_apiary_name));
    appCompatEditText.perform(scrollTo(), replaceText("Apiary"), closeSoftKeyboard());

    ViewInteraction floatingActionButton2 = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton2.perform(click());

    ViewInteraction recyclerView = onView(
            allOf(withId(R.id.apiaries_list),
                    withParent(allOf(withId(R.id.apiariesLL),
                            withParent(withId(R.id.apiariesContainer)))),
                    isDisplayed()));
    recyclerView.perform(actionOnItemAtPosition(0, click()));

    ViewInteraction floatingActionButton3 = onView(
            allOf(withId(R.id.fab_add_hive),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton3.perform(click());

    ViewInteraction appCompatEditText2 = onView(
            withId(R.id.add_hive_name));
    appCompatEditText2.perform(scrollTo(), replaceText("Hive"), closeSoftKeyboard());

    ViewInteraction appCompatEditText3 = onView(
            withId(R.id.add_hive_notes));
    appCompatEditText3.perform(scrollTo(), replaceText("Notes"), closeSoftKeyboard());

    ViewInteraction floatingActionButton4 = onView(
            allOf(withId(R.id.fab_add_hive),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton4.perform(click());

    ViewInteraction recyclerView2 = onView(
            allOf(withId(R.id.hives_list),
                    withParent(allOf(withId(R.id.hivesLL),
                            withParent(withId(R.id.hivesContainer)))),
                    isDisplayed()));
    recyclerView2.perform(actionOnItemAtPosition(0, click()));

    ViewInteraction textView = onView(
            withText("Hive"));
    textView.check(matches(isDisplayed()));

    ViewInteraction appCompatTextView = onView(
            allOf(withText("Info"), isDisplayed()));
    appCompatTextView.perform(click());

    ViewInteraction textView2 = onView(
            allOf(withId(R.id.notes_content), withText("Notes"),
                    childAtPosition(
                            childAtPosition(
                                    IsInstanceOf.<View>instanceOf(
                                            android.widget.LinearLayout.class),
                                    1),
                            0),
                    isDisplayed()));
    textView2.check(matches(withText("Notes")));

}