@Implementation protected void toggleSoftInput(int showFlags, int hideFlags) { setSoftInputVisibility(!isSoftInputVisible()); }
@Test public void shouldRecordSoftInputVisibility() { assertThat(shadow.isSoftInputVisible()).isFalse(); manager.showSoftInput(null, 0); assertThat(shadow.isSoftInputVisible()).isTrue(); manager.hideSoftInputFromWindow(null, 0); assertThat(shadow.isSoftInputVisible()).isFalse(); }
@Implementation protected boolean hideSoftInputFromWindow( IBinder windowToken, int flags, ResultReceiver resultReceiver) { int resultCode; if (isSoftInputVisible()) { setSoftInputVisibility(false); resultCode = InputMethodManager.RESULT_HIDDEN; } else { resultCode = InputMethodManager.RESULT_UNCHANGED_HIDDEN; } if (resultReceiver != null) { resultReceiver.send(resultCode, null); } return true; }
@Test public void shouldToggleSoftInputVisibility() { assertThat(shadow.isSoftInputVisible()).isFalse(); manager.toggleSoftInput(0, 0); assertThat(shadow.isSoftInputVisible()).isTrue(); manager.toggleSoftInput(0, 0); assertThat(shadow.isSoftInputVisible()).isFalse(); }
@Test public void shouldNotifyHandlerWhenVisibilityChanged() { ShadowInputMethodManager.SoftInputVisibilityChangeHandler mockHandler = mock(ShadowInputMethodManager.SoftInputVisibilityChangeHandler.class); shadow.setSoftInputVisibilityHandler(mockHandler); assertThat(shadow.isSoftInputVisible()).isFalse(); manager.toggleSoftInput(0, 0); verify(mockHandler).handleSoftInputVisibilityChange(true); }
@Implementation protected void toggleSoftInput(int showFlags, int hideFlags) { setSoftInputVisibility(!isSoftInputVisible()); }
@Implementation public void toggleSoftInput(int showFlags, int hideFlags) { setSoftInputVisibility(!isSoftInputVisible()); }