protected void openPcrForm() {
    EventBusIdlingResource<FetchXformSucceededEvent> xformIdlingResource =
        new EventBusIdlingResource<FetchXformSucceededEvent>(
            UUID.randomUUID().toString(), mEventBus);
    onView(withId(R.id.action_add_test_result)).perform(click());
    Espresso.registerIdlingResources(xformIdlingResource);

    // Give the form time to be parsed on the client (this does not result in an event firing).
    checkViewDisplayedSoon(withText("Encounter"));
  }
 private void answerVisibleToggleQuestion(String questionText, String answerText) {
   // Close the soft keyboard before answering any toggle questions -- on rare occasions,
   // if Espresso answers one of these questions and is then instructed to type into another
   // field, the input event will actually be generated as the keyboard is hiding and will be
   // lost, but Espresso won't detect this case.
   Espresso.closeSoftKeyboard();
   onView(
           allOf(
               anyOf(isAssignableFrom(CheckBox.class), isAssignableFrom(RadioButton.class)),
               isDescendantOfA(
                   allOf(
                       anyOf(
                           isAssignableFrom(ButtonsSelectOneWidget.class),
                           isAssignableFrom(TableWidgetGroup.class),
                           isAssignableFrom(ODKView.class)),
                       hasDescendant(withText(containsString(questionText))))),
               withText(containsString(answerText))))
       .perform(scrollTo(), click());
 }
  /** Tests that the general condition dialog successfully changes general condition. */
  public void testGeneralConditionDialog_AppliesGeneralConditionChange() {
    inUserLoginGoToDemoPatientChart();
    onView(withId(R.id.patient_chart_vital_general_parent)).perform(click());
    screenshot("General Condition Dialog");
    onView(withText(R.string.status_well)).perform(click());

    // Wait for a sync operation to update the chart.
    EventBusIdlingResource<SyncFinishedEvent> syncFinishedIdlingResource =
        new EventBusIdlingResource<>(UUID.randomUUID().toString(), mEventBus);
    Espresso.registerIdlingResources(syncFinishedIdlingResource);

    // Check for updated vital view.
    checkViewDisplayedSoon(withText(R.string.status_well));

    // Check for updated chart view.
    onView(
            allOf(
                withText(R.string.status_short_desc_well),
                not(withId(R.id.patient_chart_vital_general_condition_number))))
        .check(matches(isDisplayed()));
  }
 private void saveForm() {
   IdlingResource xformWaiter = getXformSubmissionIdlingResource();
   onView(withText("Save")).perform(click());
   Espresso.registerIdlingResources(xformWaiter);
 }