Loading services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/AndroidManifest.xml +2 −2 Original line number Diff line number Diff line Loading @@ -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" Loading services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java +17 −10 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading @@ -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 { Loading @@ -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( () -> { Loading @@ -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(); } } Loading @@ -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( () -> { Loading services/tests/InputMethodSystemServerTests/test-apps/SimpleTestIme/res/xml/method.xml +9 −2 Original line number Diff line number Diff line Loading @@ -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 services/tests/InputMethodSystemServerTests/test-apps/SimpleTestIme/src/com/android/apps/inputmethod/simpleime/SimpleKeyboardView.java +10 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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. * Loading Loading
services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/AndroidManifest.xml +2 −2 Original line number Diff line number Diff line Loading @@ -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" Loading
services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java +17 −10 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading @@ -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 { Loading @@ -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( () -> { Loading @@ -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(); } } Loading @@ -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( () -> { Loading
services/tests/InputMethodSystemServerTests/test-apps/SimpleTestIme/res/xml/method.xml +9 −2 Original line number Diff line number Diff line Loading @@ -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
services/tests/InputMethodSystemServerTests/test-apps/SimpleTestIme/src/com/android/apps/inputmethod/simpleime/SimpleKeyboardView.java +10 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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. * Loading