Add test for showSoftInput with no registered IME
Bug: 220125769
Test: atest InputMethodServiceTest#testShowSoftInput_whenAllImesDisabled
Change-Id: I77e889f5f636c295e6bbc26cfddc440735cf313e
(cherry picked from commit c3b36b897a8f5a5ba117fbd94aea9bf0c44da11e)
Merged-In:I77e889f5f636c295e6bbc26cfddc440735cf313e
diff --git a/tests/inputmethod/src/android/view/inputmethod/cts/InputMethodServiceTest.java b/tests/inputmethod/src/android/view/inputmethod/cts/InputMethodServiceTest.java
index ec39a05..31b7a92 100644
--- a/tests/inputmethod/src/android/view/inputmethod/cts/InputMethodServiceTest.java
+++ b/tests/inputmethod/src/android/view/inputmethod/cts/InputMethodServiceTest.java
@@ -60,6 +60,7 @@
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputConnectionWrapper;
+import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.cts.util.EndToEndImeTestBase;
import android.view.inputmethod.cts.util.SimulatedVirtualDisplaySession;
@@ -90,6 +91,7 @@
import java.io.IOException;
import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
@@ -793,6 +795,27 @@
}
}
+ @Test
+ public void testShowSoftInput_whenAllImesDisabled() {
+ final InputMethodManager inputManager =
+ mInstrumentation.getTargetContext().getSystemService(InputMethodManager.class);
+ assertNotNull(inputManager);
+ final List<InputMethodInfo> enabledImes = inputManager.getEnabledInputMethodList();
+
+ try {
+ // disable all IMEs
+ for (InputMethodInfo ime : enabledImes) {
+ SystemUtil.runShellCommand("ime disable " + ime.getId());
+ }
+
+ // start a test activity and expect it not to crash
+ createTestActivity(SOFT_INPUT_STATE_ALWAYS_VISIBLE);
+ } finally {
+ // restore all previous IMEs
+ SystemUtil.runShellCommand("ime reset");
+ }
+ }
+
/** Explicitly start-up the IME process if it would have been prevented. */
protected void ensureImeRunning() {
if (isPreventImeStartup()) {