просмотр нажатия кнопки. Ожидание отклонения индикатора выполнения с помощью Thread.sleep (4000) иногда происходит правильно, но иногда все еще отображается как вопрос об ошибке «Не удалось запустить намеренное намерение». Я хотел бы знать, какие идеи лучше, чем мой ответ.
ProgressDialog Utils Class the method
public void showProgressDialog() {
if (mProgressDialog == null) {
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setCancelable(false);
mProgressDialog.setMessage("Loading...");
}
mProgressDialog.show();
}
public void hideProgressDialog() {
if (mProgressDialog != null && mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
}
}
Тестирование
@Test
public void test1() throws InterruptedException {
//onView(withText("Loading")).check(matches(isDisplayed()));
// onView(allOf(isAssignableFrom(ProgressBar.class),withText("Loading..."))).check(matches(isDisplayed()));
//onView(withId(R.id.btnWorkingDate)).perform(click());
// Intents.init();
// override progress bar infinite animation with a simple image
//onView(withText("Loading...")).check(matches(isDisplayed()));
// onView(withText("Loading...")).check(matches(not((isDisplayed()))));
//onView(withText("Loading...")).check(matches(isDisplayed()));
// onView(withText("Loading...")).check(matches(not(isDisplayed())));
// assertTrue(progressBar().exists());
try {
onView(allOf(withId(R.id.btnWorkingDate), withText("OPEN DAY"))).check(matches(isDisplayed())).perform(click(),closeSoftKeyboard());
}catch (NoMatchingViewException e) {
// View is not in hierarchy
}
Thread.sleep(4000);
/* onView(allOf(withId(R.id.btnWorkingTime),withText("START SHIFT"), isDisplayed())).perform(click(),closeSoftKeyboard());
onView(allOf(withId(R.id.btnWorkingTime),withText("END SHIFT"), isDisplayed())).perform(click(),closeSoftKeyboard());*/
// Intents.release();
// intended(hasComponent(DashboardActivity.class.getName()));
//assertNotNull(view);
//onView(withId(R.id.btnWorkingDate)).perform(click());
}
@Test
public void test2() throws InterruptedException {
// onView(allOf(withId(R.id.btnWorkingTime),withText("START SHIFT"), isDisplayed())).perform(click(),closeSoftKeyboard());
// assertTrue(progressBar().exists());
try {
onView(allOf(withId(R.id.btnWorkingTime), withText("START SHIFT"))).check(matches(isDisplayed())).perform(click(),closeSoftKeyboard());
}catch (NoMatchingViewException e) {
// View is not in hierarchy
}
Thread.sleep(4000);
}
@Test
public void test3() throws InterruptedException {
try {
onView(allOf(withId(R.id.btnWorkingTime), withText("END SHIFT"))).check(matches(isDisplayed())).perform(click(),closeSoftKeyboard());
}catch (NoMatchingViewException e) {
// View is not in hierarchy
}
Thread.sleep(5000);
}