Loading services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java +61 −4 Original line number Diff line number Diff line Loading @@ -33,11 +33,15 @@ import android.content.Context; import android.content.res.Configuration; import android.graphics.Insets; import android.os.RemoteException; import android.platform.test.annotations.RequiresFlagsDisabled; import android.platform.test.flag.junit.CheckFlagsRule; import android.platform.test.flag.junit.DeviceFlagsValueProvider; import android.provider.Settings; import android.util.Log; import android.view.WindowManagerGlobal; import android.view.WindowManagerPolicyConstants; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.Flags; import android.view.inputmethod.InputMethodManager; import androidx.annotation.NonNull; Loading @@ -56,6 +60,7 @@ import com.android.internal.inputmethod.InputMethodNavButtonFlags; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; Loading Loading @@ -89,6 +94,9 @@ public class InputMethodServiceTest { private String mInputMethodId; private boolean mShowImeWithHardKeyboardEnabled; @Rule public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule(); @Before public void setUp() throws Exception { mInstrumentation = InstrumentationRegistry.getInstrumentation(); Loading Loading @@ -155,8 +163,14 @@ public class InputMethodServiceTest { () -> assertThat(mUiDevice.pressHome()).isTrue(), true /* expected */, false /* inputViewStarted */); if (Flags.refactorInsetsController()) { // The IME visibility is only sent at the end of the animation. Therefore, we have to // wait until the visibility was sent to the server and the IME window hidden. eventually(() -> assertThat(mInputMethodService.isInputViewShown()).isFalse()); } else { assertThat(mInputMethodService.isInputViewShown()).isFalse(); } } /** * This checks that the IME can be shown and hidden using the WindowInsetsController APIs. Loading @@ -182,8 +196,13 @@ public class InputMethodServiceTest { /** * This checks the result of calling IMS#requestShowSelf and IMS#requestHideSelf. * * With the refactor in b/298172246, all calls to IMMS#{show,hide}MySoftInputLocked * will be just apply the requested visibility (by using the callback). Therefore, we will * lose flags like HIDE_IMPLICIT_ONLY. */ @Test @RequiresFlagsDisabled(Flags.FLAG_REFACTOR_INSETS_CONTROLLER) public void testShowHideSelf() throws Exception { setShowImeWithHardKeyboard(true /* enabled */); Loading Loading @@ -375,8 +394,13 @@ public class InputMethodServiceTest { /** * This checks that an implicit show request when the IME is not previously shown, * and it should be shown in fullscreen mode, results in the IME not being shown. * * With the refactor in b/298172246, all calls from InputMethodManager#{show,hide}SoftInput * will be redirected to InsetsController#{show,hide}. Therefore, we will lose flags like * SHOW_IMPLICIT. */ @Test @RequiresFlagsDisabled(Flags.FLAG_REFACTOR_INSETS_CONTROLLER) public void testShowSoftInputImplicitly_fullScreenMode() throws Exception { setShowImeWithHardKeyboard(true /* enabled */); Loading Loading @@ -425,8 +449,13 @@ public class InputMethodServiceTest { /** * This checks that an implicit show request when a hard keyboard is connected, * results in the IME not being shown. * * With the refactor in b/298172246, all calls from InputMethodManager#{show,hide}SoftInput * will be redirected to InsetsController#{show,hide}. Therefore, we will lose flags like * SHOW_IMPLICIT. */ @Test @RequiresFlagsDisabled(Flags.FLAG_REFACTOR_INSETS_CONTROLLER) public void testShowSoftInputImplicitly_withHardKeyboard() throws Exception { setShowImeWithHardKeyboard(false /* enabled */); Loading Loading @@ -484,8 +513,13 @@ public class InputMethodServiceTest { * This checks that an implicit show request followed by connecting a hard keyboard * and a configuration change, does not trigger IMS#onFinishInputView, * but results in the IME being hidden. * * With the refactor in b/298172246, all calls from InputMethodManager#{show,hide}SoftInput * will be redirected to InsetsController#{show,hide}. Therefore, we will lose flags like * SHOW_IMPLICIT. */ @Test @RequiresFlagsDisabled(Flags.FLAG_REFACTOR_INSETS_CONTROLLER) public void testShowSoftInputImplicitly_thenConfigurationChanged() throws Exception { setShowImeWithHardKeyboard(false /* enabled */); Loading Loading @@ -567,8 +601,13 @@ public class InputMethodServiceTest { * This checks that a forced show request directly followed by an explicit show request, * and then a hide not always request, still results in the IME being shown * (i.e. the explicit show request retains the forced state). * * With the refactor in b/298172246, all calls from InputMethodManager#{show,hide}SoftInput * will be redirected to InsetsController#{show,hide}. Therefore, we will lose flags like * HIDE_NOT_ALWAYS. */ @Test @RequiresFlagsDisabled(Flags.FLAG_REFACTOR_INSETS_CONTROLLER) public void testShowSoftInputForced_testShowSoftInputExplicitly_thenHideSoftInputNotAlways() throws Exception { setShowImeWithHardKeyboard(true /* enabled */); Loading Loading @@ -734,8 +773,14 @@ public class InputMethodServiceTest { backButtonUiObject.click(); mInstrumentation.waitForIdleSync(); if (Flags.refactorInsetsController()) { // The IME visibility is only sent at the end of the animation. Therefore, we have to // wait until the visibility was sent to the server and the IME window hidden. eventually(() -> assertThat(mInputMethodService.isInputViewShown()).isFalse()); } else { assertThat(mInputMethodService.isInputViewShown()).isFalse(); } } /** * Verifies that long clicking on the IME navigation bar back button hides the IME. Loading Loading @@ -766,8 +811,14 @@ public class InputMethodServiceTest { backButtonUiObject.longClick(); mInstrumentation.waitForIdleSync(); if (Flags.refactorInsetsController()) { // The IME visibility is only sent at the end of the animation. Therefore, we have to // wait until the visibility was sent to the server and the IME window hidden. eventually(() -> assertThat(mInputMethodService.isInputViewShown()).isFalse()); } else { assertThat(mInputMethodService.isInputViewShown()).isFalse(); } } /** * Verifies that clicking on the IME switch button either shows the Input Method Switcher Menu, Loading Loading @@ -848,7 +899,13 @@ public class InputMethodServiceTest { assertWithMessage("Input Method Switcher Menu is shown") .that(isInputMethodPickerShown(imm)) .isTrue(); if (Flags.refactorInsetsController()) { // The IME visibility is only sent at the end of the animation. Therefore, we have to // wait until the visibility was sent to the server and the IME window hidden. eventually(() -> assertThat(mInputMethodService.isInputViewShown()).isFalse()); } else { assertThat(mInputMethodService.isInputViewShown()).isTrue(); } // Hide the Picker menu before finishing. mUiDevice.pressBack(); Loading Loading
services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java +61 −4 Original line number Diff line number Diff line Loading @@ -33,11 +33,15 @@ import android.content.Context; import android.content.res.Configuration; import android.graphics.Insets; import android.os.RemoteException; import android.platform.test.annotations.RequiresFlagsDisabled; import android.platform.test.flag.junit.CheckFlagsRule; import android.platform.test.flag.junit.DeviceFlagsValueProvider; import android.provider.Settings; import android.util.Log; import android.view.WindowManagerGlobal; import android.view.WindowManagerPolicyConstants; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.Flags; import android.view.inputmethod.InputMethodManager; import androidx.annotation.NonNull; Loading @@ -56,6 +60,7 @@ import com.android.internal.inputmethod.InputMethodNavButtonFlags; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; Loading Loading @@ -89,6 +94,9 @@ public class InputMethodServiceTest { private String mInputMethodId; private boolean mShowImeWithHardKeyboardEnabled; @Rule public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule(); @Before public void setUp() throws Exception { mInstrumentation = InstrumentationRegistry.getInstrumentation(); Loading Loading @@ -155,8 +163,14 @@ public class InputMethodServiceTest { () -> assertThat(mUiDevice.pressHome()).isTrue(), true /* expected */, false /* inputViewStarted */); if (Flags.refactorInsetsController()) { // The IME visibility is only sent at the end of the animation. Therefore, we have to // wait until the visibility was sent to the server and the IME window hidden. eventually(() -> assertThat(mInputMethodService.isInputViewShown()).isFalse()); } else { assertThat(mInputMethodService.isInputViewShown()).isFalse(); } } /** * This checks that the IME can be shown and hidden using the WindowInsetsController APIs. Loading @@ -182,8 +196,13 @@ public class InputMethodServiceTest { /** * This checks the result of calling IMS#requestShowSelf and IMS#requestHideSelf. * * With the refactor in b/298172246, all calls to IMMS#{show,hide}MySoftInputLocked * will be just apply the requested visibility (by using the callback). Therefore, we will * lose flags like HIDE_IMPLICIT_ONLY. */ @Test @RequiresFlagsDisabled(Flags.FLAG_REFACTOR_INSETS_CONTROLLER) public void testShowHideSelf() throws Exception { setShowImeWithHardKeyboard(true /* enabled */); Loading Loading @@ -375,8 +394,13 @@ public class InputMethodServiceTest { /** * This checks that an implicit show request when the IME is not previously shown, * and it should be shown in fullscreen mode, results in the IME not being shown. * * With the refactor in b/298172246, all calls from InputMethodManager#{show,hide}SoftInput * will be redirected to InsetsController#{show,hide}. Therefore, we will lose flags like * SHOW_IMPLICIT. */ @Test @RequiresFlagsDisabled(Flags.FLAG_REFACTOR_INSETS_CONTROLLER) public void testShowSoftInputImplicitly_fullScreenMode() throws Exception { setShowImeWithHardKeyboard(true /* enabled */); Loading Loading @@ -425,8 +449,13 @@ public class InputMethodServiceTest { /** * This checks that an implicit show request when a hard keyboard is connected, * results in the IME not being shown. * * With the refactor in b/298172246, all calls from InputMethodManager#{show,hide}SoftInput * will be redirected to InsetsController#{show,hide}. Therefore, we will lose flags like * SHOW_IMPLICIT. */ @Test @RequiresFlagsDisabled(Flags.FLAG_REFACTOR_INSETS_CONTROLLER) public void testShowSoftInputImplicitly_withHardKeyboard() throws Exception { setShowImeWithHardKeyboard(false /* enabled */); Loading Loading @@ -484,8 +513,13 @@ public class InputMethodServiceTest { * This checks that an implicit show request followed by connecting a hard keyboard * and a configuration change, does not trigger IMS#onFinishInputView, * but results in the IME being hidden. * * With the refactor in b/298172246, all calls from InputMethodManager#{show,hide}SoftInput * will be redirected to InsetsController#{show,hide}. Therefore, we will lose flags like * SHOW_IMPLICIT. */ @Test @RequiresFlagsDisabled(Flags.FLAG_REFACTOR_INSETS_CONTROLLER) public void testShowSoftInputImplicitly_thenConfigurationChanged() throws Exception { setShowImeWithHardKeyboard(false /* enabled */); Loading Loading @@ -567,8 +601,13 @@ public class InputMethodServiceTest { * This checks that a forced show request directly followed by an explicit show request, * and then a hide not always request, still results in the IME being shown * (i.e. the explicit show request retains the forced state). * * With the refactor in b/298172246, all calls from InputMethodManager#{show,hide}SoftInput * will be redirected to InsetsController#{show,hide}. Therefore, we will lose flags like * HIDE_NOT_ALWAYS. */ @Test @RequiresFlagsDisabled(Flags.FLAG_REFACTOR_INSETS_CONTROLLER) public void testShowSoftInputForced_testShowSoftInputExplicitly_thenHideSoftInputNotAlways() throws Exception { setShowImeWithHardKeyboard(true /* enabled */); Loading Loading @@ -734,8 +773,14 @@ public class InputMethodServiceTest { backButtonUiObject.click(); mInstrumentation.waitForIdleSync(); if (Flags.refactorInsetsController()) { // The IME visibility is only sent at the end of the animation. Therefore, we have to // wait until the visibility was sent to the server and the IME window hidden. eventually(() -> assertThat(mInputMethodService.isInputViewShown()).isFalse()); } else { assertThat(mInputMethodService.isInputViewShown()).isFalse(); } } /** * Verifies that long clicking on the IME navigation bar back button hides the IME. Loading Loading @@ -766,8 +811,14 @@ public class InputMethodServiceTest { backButtonUiObject.longClick(); mInstrumentation.waitForIdleSync(); if (Flags.refactorInsetsController()) { // The IME visibility is only sent at the end of the animation. Therefore, we have to // wait until the visibility was sent to the server and the IME window hidden. eventually(() -> assertThat(mInputMethodService.isInputViewShown()).isFalse()); } else { assertThat(mInputMethodService.isInputViewShown()).isFalse(); } } /** * Verifies that clicking on the IME switch button either shows the Input Method Switcher Menu, Loading Loading @@ -848,7 +899,13 @@ public class InputMethodServiceTest { assertWithMessage("Input Method Switcher Menu is shown") .that(isInputMethodPickerShown(imm)) .isTrue(); if (Flags.refactorInsetsController()) { // The IME visibility is only sent at the end of the animation. Therefore, we have to // wait until the visibility was sent to the server and the IME window hidden. eventually(() -> assertThat(mInputMethodService.isInputViewShown()).isFalse()); } else { assertThat(mInputMethodService.isInputViewShown()).isTrue(); } // Hide the Picker menu before finishing. mUiDevice.pressBack(); Loading