下面列出了怎么用android.support.test.espresso.ViewInteraction的API类实例代码及写法,或者点击链接到github查看源代码。
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());
}
@Test
public void runTest()throws Exception{
ViewInteraction relativeLayout = onView(
allOf(withId(R.id.bottom_notify),
withParent(withId(R.id.bottom_layout)),
isDisplayed()));
relativeLayout.perform(click());
ViewInteraction relativeLayout2 = onView(
allOf(withId(R.id.bottom_notify),
withParent(withId(R.id.bottom_layout)),
isDisplayed()));
relativeLayout2.perform(click());
ViewInteraction relativeLayout3 = onView(
allOf(withId(R.id.bottom_trash),
withParent(withId(R.id.bottom_layout)),
isDisplayed()));
relativeLayout3.perform(click());
}
private static ViewInteraction[] getButtonInteractions() {
ViewInteraction[] buttonsInteractions = new ViewInteraction[10];
// We cannot rely on the withDigit() matcher to retrieve these because,
// after performing a click on a button, the time display will update to
// take on that button's digit text, and so withDigit() will return a matcher
// that matches multiple views with that digit text: the button
// itself and the time display. This will prevent us from performing
// validation on the same ViewInteractions later.
buttonsInteractions[0] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text10));
buttonsInteractions[1] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text0));
buttonsInteractions[2] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text1));
buttonsInteractions[3] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text2));
buttonsInteractions[4] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text3));
buttonsInteractions[5] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text4));
buttonsInteractions[6] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text5));
buttonsInteractions[7] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text6));
buttonsInteractions[8] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text7));
buttonsInteractions[9] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text8));
return buttonsInteractions;
}
private static void verifyViewEnabledStates(TestCase test) {
ViewInteraction[] buttonsInteractions = getButtonInteractions();
ViewInteraction[] altButtonsInteractions = getAltButtonInteractions();
for (int digit : test.sequence) {
buttonsInteractions[digit]
.check(ViewAssertions.matches(ViewMatchers.isEnabled()))
.perform(ViewActions.click());
}
for (int i = 0; i < 10; i++) {
buttonsInteractions[i].check(matchesIsEnabled(
i >= test.numberKeysEnabledStart && i < test.numberKeysEnabledEnd));
altButtonsInteractions[0].check(matchesIsEnabled(test.leftAltKeyEnabled));
altButtonsInteractions[1].check(matchesIsEnabled(test.rightAltKeyEnabled));
}
Espresso.onView(ViewMatchers.withText(android.R.string.ok))
.check(matchesIsEnabled(test.okButtonEnabled));
ViewInteraction backspaceInteraction = Espresso.onView(
ViewMatchers.withId(R.id.nptp_backspace));
// Reset after each iteration by backspacing on the button just clicked.
backspaceInteraction.check(matchesIsEnabled(true))
.perform(ViewActions.longClick())
.check(matchesIsEnabled(false));
}
@Test
public void mainActivityTest() throws Throwable {
ViewInteraction webView = onView(
allOf(childAtPosition(
allOf(withId(R.id.activity_main),
childAtPosition(
withId(android.R.id.content),
0)),
0),
isDisplayed()));
webView.check(matches(isDisplayed()));
ViewInteraction editText = onView(
allOf(withId(R.id.input_view),
childAtPosition(
allOf(withId(R.id.activity_main),
childAtPosition(
withId(android.R.id.content),
0)),
1),
isDisplayed()));
editText.check(matches(isDisplayed()));
}
@Test
public void mainActivityTest() {
// Test send a request to myApi/sayHi with a human's name
// and expect the response "Hi, Human's Name!"
ViewInteraction nameInput = onView(allOf(withId(R.id.person_name_input), isDisplayed()));
nameInput.perform(replaceText("Human 1"));
ViewInteraction sendButton = onView(
allOf(withId(R.id.send_bn), withText("Send"), isDisplayed()));
sendButton.perform(click());
// Sleep for a 1 second to receive a response and update R.id.response_view
SystemClock.sleep(1000);
onView(withId(R.id.response_view)).check(matches(withText("Hi, Human 1!")));
}
@Test
public void helpTest() {
ViewInteraction appCompatImageButton = onView(
allOf(withContentDescription("Navigate up"),
withParent(withId(R.id.toolbar)),
isDisplayed()));
appCompatImageButton.perform(click());
ViewInteraction appCompatCheckedTextView = onView(
allOf(withId(R.id.design_menu_item_text), withText("Help"), isDisplayed()));
appCompatCheckedTextView.perform(click());
ViewInteraction webView = onView(
allOf(childAtPosition(
allOf(withId(R.id.linear_layout),
childAtPosition(
withId(R.id.contentFrame),
0)),
0),
isDisplayed()));
webView.check(matches(isDisplayed()));
}
@Test
public void mainActivityTest() {
// Test send a request to myApi/sayHi with a human's name
// and expect the response "Hi, Human's Name!"
ViewInteraction nameInput = onView(allOf(withId(R.id.person_name_input), isDisplayed()));
nameInput.perform(replaceText("Human 1"));
ViewInteraction sendButton = onView(
allOf(withId(R.id.send_bn), withText("Send"), isDisplayed()));
sendButton.perform(click());
// Sleep for a 1 second to receive a response and update R.id.response_view
SystemClock.sleep(1000);
onView(withId(R.id.response_view)).check(matches(withText("Hi, Human 1!")));
}
@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)));
}
@Test
public void shouldBeAbleToSearchForTestCharacter() {
// Launch the activity
mainActivity.launchActivity(new Intent());
// fix Travis locked device issue
unlockScreen();
// 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());
// Check view is loaded as we expect it to be
onView(withText(TEST_CHARACTER_NAME)).check(matches(withText(TEST_CHARACTER_NAME)));
onView(withId(R.id.description)).check(matches(withText(TEST_CHARACTER_DESCRIPTION)));
}
@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());
}
private static void clickColorButton(int index) {
ViewInteraction colorButton = onView(
allOf(withClassName(is("com.gunshippenguin.openflood.ColorButton")),
withParent(withId(R.id.buttonLayout)),
isDisplayed(),
nthChildOf(withId(R.id.buttonLayout), index)));
colorButton.perform(click());
}
public void otherTest() {
ViewInteraction clearView = onView(withId(R.id.clear));
clearView.perform(click());
ViewInteraction cancelView = onView(withId(R.id.tv_popup_cancel)).check(matches(isDisplayed()));
cancelView.perform(click());
clearView.perform(click());
DataInteraction confirmView = onData(anything()).inAdapterView(withId(R.id.list_view)).atPosition(0);
confirmView.perform(click());
ViewInteraction exitView = onView(withId(R.id.delete));
exitView.perform(click());
ViewInteraction okView = onView(allOf(withId(R.id.okBtn), isDisplayed()));
okView.perform(click());
}
public void clearTest() {
ViewInteraction clearView = onView(withId(R.id.clear));
clearView.perform(click());
ViewInteraction cancelView = onView(withId(R.id.tv_popup_cancel)).check(matches(isDisplayed()));
cancelView.perform(click());
clearView.perform(click());
DataInteraction confirmView = onData(anything()).inAdapterView(withId(R.id.list_view)).atPosition(0);
confirmView.perform(click());
}
@After
public void backTest() {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
ViewInteraction leftView = onView(withId(R.id.left_rela));
leftView.perform(click());
}
@Test
public void dayNightModeTest() {
openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
ViewInteraction appCompatTextView = onView(
allOf(withId(R.id.title), withText("Night Mode"),
childAtPosition(
childAtPosition(
withId(R.id.content),
0),
0),
isDisplayed()));
appCompatTextView.perform(click());
openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
ViewInteraction textView = onView(
allOf(withId(R.id.title), withText("Day Mode"),
childAtPosition(
childAtPosition(
withId(R.id.content),
0),
0),
isDisplayed()));
textView.check(matches(withText("Day Mode")));
ViewInteraction appCompatTextView2 = onView(
allOf(withId(R.id.title), withText("Day Mode"),
childAtPosition(
childAtPosition(
withId(R.id.content),
0),
0),
isDisplayed()));
appCompatTextView2.perform(click());
openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
ViewInteraction textView2 = onView(
allOf(withId(R.id.title), withText("Night Mode"),
childAtPosition(
childAtPosition(
withId(R.id.content),
0),
0),
isDisplayed()));
textView2.check(matches(withText("Night Mode")));
}
public ViewInteraction toolbar() {
return Espresso.onView(ViewMatchers.withId(R.id.toolbar));
}
@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()));
}
@Test
public void editHiveTest() {
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 appCompatImageView = onView(
allOf(withId(R.id.more_icon), withContentDescription("More…"), isDisplayed()));
appCompatImageView.perform(click());
ViewInteraction appCompatTextView = onView(
allOf(withId(android.R.id.title), withText("Edit"), isDisplayed()));
appCompatTextView.perform(click());
ViewInteraction appCompatEditText3 = onView(
allOf(withId(R.id.add_hive_name), withText("Hive")));
appCompatEditText3.perform(scrollTo(), click());
ViewInteraction appCompatEditText4 = onView(
withId(R.id.add_hive_name));
appCompatEditText4.perform(scrollTo(), replaceText("Hive Edited"), closeSoftKeyboard());
ViewInteraction floatingActionButton5 = onView(
allOf(withId(R.id.fab_add_hive),
withParent(withId(R.id.coordinatorLayout)),
isDisplayed()));
floatingActionButton5.perform(click());
ViewInteraction textView = onView(
allOf(withId(R.id.hive_name), withText("Hive Edited"),
childAtPosition(
childAtPosition(
withId(R.id.card),
0),
1),
isDisplayed()));
textView.check(matches(withText("Hive Edited")));
}
public ViewInteraction root() {
return Espresso.onView(ViewMatchers.withId(R.id.root));
}
@Test
public void viewRecordingTest() {
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 recyclerView3 = onView(
allOf(withId(R.id.recordings_list),
withParent(allOf(withId(R.id.recordingsLL),
withParent(withId(R.id.recordingsContainer)))),
isDisplayed()));
recyclerView3.perform(actionOnItemAtPosition(0, click()));
ViewInteraction viewGroup = onView(
allOf(withId(R.id.recording_chart),
childAtPosition(
childAtPosition(
withId(R.id.card),
0),
0),
isDisplayed()));
viewGroup.check(matches(isDisplayed()));
}
@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()));
}
public ViewInteraction loginButton() {
return Espresso.onView(ViewMatchers.withId(R.id.login_login));
}
@Test
public void aboutTest() {
ViewInteraction appCompatImageButton = onView(
allOf(withContentDescription("Navigate up"),
withParent(withId(R.id.toolbar)),
isDisplayed()));
appCompatImageButton.perform(click());
ViewInteraction appCompatCheckedTextView = onView(
allOf(withId(R.id.design_menu_item_text), withText("About GoBees"), isDisplayed()));
appCompatCheckedTextView.perform(click());
ViewInteraction textView = onView(
allOf(withId(R.id.app_name), withText("GoBees App"),
childAtPosition(
allOf(withId(R.id.linear_layout),
childAtPosition(
withId(R.id.contentFrame),
0)),
1),
isDisplayed()));
textView.check(matches(withText("GoBees App")));
ViewInteraction button = onView(
allOf(withId(R.id.website_btn),
childAtPosition(
childAtPosition(
withId(R.id.linear_layout),
3),
0),
isDisplayed()));
button.check(matches(isDisplayed()));
ViewInteraction button2 = onView(
allOf(withId(R.id.license_btn),
childAtPosition(
childAtPosition(
withId(R.id.linear_layout),
3),
1),
isDisplayed()));
button2.check(matches(isDisplayed()));
ViewInteraction button3 = onView(
allOf(withId(R.id.changelog_btn),
childAtPosition(
childAtPosition(
withId(R.id.linear_layout),
3),
2),
isDisplayed()));
button3.check(matches(isDisplayed()));
}
private static ViewInteraction[] getAltButtonInteractions() {
ViewInteraction[] buttonsInteractions = new ViewInteraction[2];
buttonsInteractions[0] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text9));
buttonsInteractions[1] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text11));
return buttonsInteractions;
}
public static cortado.Start.ViewInteraction onView() {
return onView(null);
}
public static cortado.Start.ViewInteraction onTextView() {
return onView(TextView.class);
}
@Test
public void mainActivityTest() throws Exception {
ConditionWatcher.waitForCondition(new FragmentResumedInstruction());
ViewInteraction textView = onView(
allOf(withId(R.id.mVerifyResult), withText("invalid phone number"),
childAtPosition(
childAtPosition(
withId(android.R.id.content),
0),
1),
isDisplayed()));
textView.check(matches(withText("invalid phone number")));
ViewInteraction appCompatEditText = onView(
allOf(withId(R.id.mEtPhone), isDisplayed()));
appCompatEditText.perform(click());
ViewInteraction appCompatEditText2 = onView(
allOf(withId(R.id.mEtPhone), isDisplayed()));
appCompatEditText2.perform(replaceText("+86"), closeSoftKeyboard());
Thread.sleep(BuildConfig.TEST_WAIT_BEFORE_VERIFY);
ViewInteraction textView2 = onView(
allOf(withId(R.id.mVerifyResult), withText("invalid phone number"),
childAtPosition(
childAtPosition(
withId(android.R.id.content),
0),
1),
isDisplayed()));
textView2.check(matches(withText("invalid phone number")));
ViewInteraction appCompatEditText3 = onView(
allOf(withId(R.id.mEtPhone), isDisplayed()));
appCompatEditText3.perform(replaceText("+8613312345678"), closeSoftKeyboard());
Thread.sleep(BuildConfig.TEST_WAIT_BEFORE_VERIFY);
ViewInteraction textView3 = onView(
allOf(withId(R.id.mVerifyResult), withText("valid phone number"),
childAtPosition(
childAtPosition(
withId(android.R.id.content),
0),
1),
isDisplayed()));
textView3.check(matches(withText("valid phone number")));
}
public static cortado.Start.ViewInteraction onImageView() {
return onView(ImageView.class);
}
@Test
public void deleteRecordingTest() {
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 appCompatImageView3 = onView(
allOf(withId(R.id.more_icon), withContentDescription("More…"), isDisplayed()));
appCompatImageView3.perform(click());
ViewInteraction appCompatTextView = onView(
allOf(withId(android.R.id.title), withText("Delete"), isDisplayed()));
appCompatTextView.perform(click());
ViewInteraction textView = onView(
withId(R.id.no_recordings_text));
textView.check(matches(isDisplayed()));
}