Java Code Examples for android.support.test.espresso.action.CloseKeyboardAction

The following are top voted examples for showing how to use android.support.test.espresso.action.CloseKeyboardAction. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: GitHub   File: StartupTest.java   View source code 6 votes vote down vote up
public static ViewAction closeSoftKeyboard() {
	return new ViewAction() {
		/**
		 * 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);
		}
	};
}
 
Example 2
Project: orgzly-android   File: EspressoUtils.java   View source code 5 votes vote down vote up
/**
 * 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);
        }
    };
}