Search in sources :

Example 1 with CloseKeyboardAction

use of androidx.test.espresso.action.CloseKeyboardAction in project orgzly-android by orgzly.

the class EspressoUtils method closeSoftKeyboardWithDelay.

/**
 * Give keyboard time to close, to avoid java.lang.SecurityException
 * if hidden button is clicked next.
 */
static ViewAction closeSoftKeyboardWithDelay() {
    return new ViewAction() {

        /**
         * The delay time to allow the soft keyboard to dismiss.
         */
        private static final long KEYBOARD_DISMISSAL_DELAY_MILLIS = 1000L;

        /**
         * The real {@link CloseKeyboardAction} instance.
         */
        private final ViewAction mCloseSoftKeyboard = new CloseKeyboardAction();

        @Override
        public Matcher<View> getConstraints() {
            return mCloseSoftKeyboard.getConstraints();
        }

        @Override
        public String getDescription() {
            return mCloseSoftKeyboard.getDescription();
        }

        @Override
        public void perform(final UiController uiController, final View view) {
            mCloseSoftKeyboard.perform(uiController, view);
            uiController.loopMainThreadForAtLeast(KEYBOARD_DISMISSAL_DELAY_MILLIS);
        }
    };
}
Also used : ViewAction(androidx.test.espresso.ViewAction) CloseKeyboardAction(androidx.test.espresso.action.CloseKeyboardAction) UiController(androidx.test.espresso.UiController) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Espresso.onView(androidx.test.espresso.Espresso.onView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Aggregations

View (android.view.View)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 Espresso.onView (androidx.test.espresso.Espresso.onView)1 UiController (androidx.test.espresso.UiController)1 ViewAction (androidx.test.espresso.ViewAction)1 CloseKeyboardAction (androidx.test.espresso.action.CloseKeyboardAction)1