summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/AndroidManifest.xml4
-rw-r--r--services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java27
-rw-r--r--services/tests/InputMethodSystemServerTests/test-apps/SimpleTestIme/res/xml/method.xml11
-rw-r--r--services/tests/InputMethodSystemServerTests/test-apps/SimpleTestIme/src/com/android/apps/inputmethod/simpleime/SimpleKeyboardView.java10
4 files changed, 38 insertions, 14 deletions
diff --git a/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/AndroidManifest.xml b/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/AndroidManifest.xml
index b7de74987eb8..45523268c966 100644
--- a/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/AndroidManifest.xml
+++ b/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/AndroidManifest.xml
@@ -32,8 +32,8 @@
<uses-library android:name="android.test.runner" />
</application>
- <!-- The "targetPackage" reference the instruments APK package, which is the FakeImeApk, while
- the test package is "com.android.inputmethod.imetests" (FrameworksImeTests.apk).-->
+ <!-- The "targetPackage" reference the instruments APK package, which is the SimpleTestIme.apk,
+ while the test package is "com.android.inputmethod.imetests" (FrameworksImeTests.apk).-->
<instrumentation
android:name="androidx.test.runner.AndroidJUnitRunner"
android:targetPackage="com.android.apps.inputmethod.simpleime"
diff --git a/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java b/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java
index b501dd246363..5d64cb638702 100644
--- a/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java
+++ b/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java
@@ -92,6 +92,9 @@ public class InputMethodServiceTest {
private static final String DISABLE_SHOW_IME_WITH_HARD_KEYBOARD_CMD =
"settings put secure " + Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD + " 0";
+ /** The ids of the subtypes of SimpleIme. */
+ private static final int[] SUBTYPE_IDS = new int[]{1, 2};
+
private final WindowManagerStateHelper mWmState = new WindowManagerStateHelper();
private final GestureNavSwitchHelper mGestureNavSwitchHelper = new GestureNavSwitchHelper();
@@ -833,8 +836,7 @@ public class InputMethodServiceTest {
}
/**
- * Verifies that clicking on the IME switch button either shows the Input Method Switcher Menu,
- * or switches the input method.
+ * Verifies that clicking on the IME switch button switches the input method subtype.
*/
@Test
public void testImeSwitchButtonClick() throws Exception {
@@ -844,6 +846,12 @@ public class InputMethodServiceTest {
setShowImeWithHardKeyboard(true /* enabled */);
+ final var info = mImm.getCurrentInputMethodInfo();
+ assertWithMessage("InputMethodInfo is not null").that(info).isNotNull();
+ mImm.setExplicitlyEnabledInputMethodSubtypes(info.getId(), SUBTYPE_IDS);
+
+ final var initialSubtype = mImm.getCurrentInputMethodSubtype();
+
try (var ignored = mGestureNavSwitchHelper.withGestureNavigationMode()) {
verifyInputViewStatusOnMainSync(
() -> {
@@ -852,23 +860,18 @@ public class InputMethodServiceTest {
},
EVENT_SHOW, true /* eventExpected */, true /* shown */, "IME is shown");
- final var initialInfo = mImm.getCurrentInputMethodInfo();
-
final var imeSwitcherButton = getUiObject(By.res(INPUT_METHOD_NAV_IME_SWITCHER_ID));
imeSwitcherButton.click();
mInstrumentation.waitForIdleSync();
- final var newInfo = mImm.getCurrentInputMethodInfo();
+ final var newSubtype = mImm.getCurrentInputMethodSubtype();
- assertWithMessage("Input Method Switcher Menu is shown or input method was switched")
- .that(isInputMethodPickerShown(mImm) || !Objects.equals(initialInfo, newInfo))
+ assertWithMessage("Input method subtype was switched")
+ .that(!Objects.equals(initialSubtype, newSubtype))
.isTrue();
assertWithMessage("IME is still shown after IME Switcher button was clicked")
.that(mInputMethodService.isInputViewShown()).isTrue();
-
- // Hide the IME Switcher Menu before finishing.
- mUiDevice.pressBack();
}
}
@@ -883,6 +886,10 @@ public class InputMethodServiceTest {
setShowImeWithHardKeyboard(true /* enabled */);
+ final var info = mImm.getCurrentInputMethodInfo();
+ assertWithMessage("InputMethodInfo is not null").that(info).isNotNull();
+ mImm.setExplicitlyEnabledInputMethodSubtypes(info.getId(), SUBTYPE_IDS);
+
try (var ignored = mGestureNavSwitchHelper.withGestureNavigationMode()) {
verifyInputViewStatusOnMainSync(
() -> {
diff --git a/services/tests/InputMethodSystemServerTests/test-apps/SimpleTestIme/res/xml/method.xml b/services/tests/InputMethodSystemServerTests/test-apps/SimpleTestIme/res/xml/method.xml
index 872b0688814a..3dd4a97f464f 100644
--- a/services/tests/InputMethodSystemServerTests/test-apps/SimpleTestIme/res/xml/method.xml
+++ b/services/tests/InputMethodSystemServerTests/test-apps/SimpleTestIme/res/xml/method.xml
@@ -17,7 +17,14 @@
<input-method xmlns:android="http://schemas.android.com/apk/res/android">
<subtype
- android:label="FakeIme"
+ android:label="SimpleIme"
android:imeSubtypeLocale="en_US"
- android:imeSubtypeMode="keyboard"/>
+ android:imeSubtypeMode="keyboard"
+ android:subtypeId="1" />
+
+ <subtype
+ android:label="SimpleIme French"
+ android:imeSubtypeLocale="fr_FR"
+ android:imeSubtypeMode="keyboard"
+ android:subtypeId="2" />
</input-method> \ No newline at end of file
diff --git a/services/tests/InputMethodSystemServerTests/test-apps/SimpleTestIme/src/com/android/apps/inputmethod/simpleime/SimpleKeyboardView.java b/services/tests/InputMethodSystemServerTests/test-apps/SimpleTestIme/src/com/android/apps/inputmethod/simpleime/SimpleKeyboardView.java
index 55d1b451c6b0..1840cdea4c20 100644
--- a/services/tests/InputMethodSystemServerTests/test-apps/SimpleTestIme/src/com/android/apps/inputmethod/simpleime/SimpleKeyboardView.java
+++ b/services/tests/InputMethodSystemServerTests/test-apps/SimpleTestIme/src/com/android/apps/inputmethod/simpleime/SimpleKeyboardView.java
@@ -23,6 +23,7 @@ import android.util.Log;
import android.util.SparseArray;
import android.view.KeyEvent;
import android.view.LayoutInflater;
+import android.view.WindowInsets;
import android.widget.FrameLayout;
import android.widget.TextView;
@@ -107,6 +108,15 @@ final class SimpleKeyboardView extends FrameLayout {
mapSoftKeys();
}
+ @Override
+ public WindowInsets onApplyWindowInsets(WindowInsets insets) {
+ // Handle edge to edge for navigationBars insets (system nav bar)
+ // and captionBars insets (IME navigation bar).
+ final int insetBottom = insets.getInsets(WindowInsets.Type.systemBars()).bottom;
+ setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight(), insetBottom);
+ return insets.inset(0, 0, 0, insetBottom);
+ }
+
/**
* Sets the key press listener.
*