/** * Check that the soft keyboard is closed. * * > Warning: Espresso don't wait for keyboard open/close actions so this method have a fixed delay to avoid flaky tests. * You can adjust the delay by changing EspDevice.DELAY_TO_CHANGE_KEYBOARD_STATE * * @since Espresso Macchiato 0.2 */ public void assertSoftKeyboardIsClosed() { assertSoftKeyboardIsOpen(false); }
/** * Check that the soft keyboard is open. * * For emulator disable the hardware keyboard support (hw.keyboard=no) or soft keyboard will never be shown. * * > Warning: Espresso don't wait for keyboard open/close actions so this method have a fixed delay to avoid flaky tests. * You can adjust the delay by changing EspDevice.DELAY_TO_CHANGE_KEYBOARD_STATE * * @since Espresso Macchiato 0.2 */ public void assertSoftKeyboardIsOpen() { assertSoftKeyboardIsOpen(true); }
@Test public void testAssertSoftKeyboardIsOpenFailure() { exception.expect(AssertionFailedError.class); exception.expectMessage(containsString("Keyboard should be open.")); exception.expectMessage(containsString("Expected: is <true>")); exception.expectMessage(containsString("Got: <false>")); espDevice.assertSoftKeyboardIsOpen(); }
@Test public void testCloseSoftKeyboard() { givenEditTextToOpenSoftKeyboard(); espDevice.assertSoftKeyboardIsClosed(); espEditText.click(); espDevice.assertSoftKeyboardIsOpen(); espDevice.closeSoftKeyboard(); espDevice.assertSoftKeyboardIsClosed(); }