Loading services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java +14 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import android.os.ServiceManager; import android.util.ArraySet; import android.view.InputChannel; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.ImeTracker; import android.window.ImeOnBackInvokedDispatcher; import androidx.test.platform.app.InstrumentationRegistry; Loading Loading @@ -260,6 +261,11 @@ public class InputMethodManagerServiceTestBase { unusedUserId -> mMockInputMethodBindingController); spyOn(mInputMethodManagerService); synchronized (ImfLock.class) { doReturn(true).when(mInputMethodManagerService).setImeVisibilityOnFocusedWindowClient( anyBoolean(), any(UserData.class), any(ImeTracker.Token.class)); } // Start a InputMethodManagerService.Lifecycle to publish and manage the lifecycle of // InputMethodManagerService, which is closer to the real situation. InputMethodManagerService.Lifecycle lifecycle = Loading Loading @@ -347,6 +353,14 @@ public class InputMethodManagerServiceTestBase { anyInt() /* flags */, any() /* resultReceiver */); } protected void verifySetImeVisibility(boolean setVisible, boolean invoked) { synchronized (ImfLock.class) { verify(mInputMethodManagerService, times(invoked ? 1 : 0)).setImeVisibilityOnFocusedWindowClient(eq(setVisible), any(UserData.class), any(ImeTracker.Token.class)); } } protected void createSessionForClient(IInputMethodClient client) { synchronized (ImfLock.class) { ClientState cs = mInputMethodManagerService.getClientStateLocked(client); Loading services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceWindowGainedFocusTest.java +77 −26 Original line number Diff line number Diff line Loading @@ -125,27 +125,52 @@ public class InputMethodManagerServiceWindowGainedFocusTest case SOFT_INPUT_STATE_UNSPECIFIED: boolean showSoftInput = (mSoftInputAdjustment == SOFT_INPUT_ADJUST_RESIZE) || mIsLargeScreen; verifyShowSoftInput( showSoftInput /* setVisible */, showSoftInput /* showSoftInput */); if (android.view.inputmethod.Flags.refactorInsetsController()) { verifySetImeVisibility(true /* setVisible */, showSoftInput /* invoked */); // A hide can only be triggered if there is no editorFocused, which this test // always sets. verifySetImeVisibility(false /* setVisible */, false /* invoked */); } else { verifyShowSoftInput(showSoftInput /* setVisible */, showSoftInput /* showSoftInput */); // Soft input was hidden by default, so it doesn't need to call // {@code IMS#hideSoftInput()}. verifyHideSoftInput(!showSoftInput /* setNotVisible */, false /* hideSoftInput */); verifyHideSoftInput(!showSoftInput /* setNotVisible */, false /* hideSoftInput */); } break; case SOFT_INPUT_STATE_VISIBLE: case SOFT_INPUT_STATE_ALWAYS_VISIBLE: if (android.view.inputmethod.Flags.refactorInsetsController()) { verifySetImeVisibility(true /* setVisible */, true /* invoked */); verifySetImeVisibility(false /* setVisible */, false /* invoked */); } else { verifyShowSoftInput(true /* setVisible */, true /* showSoftInput */); verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */); } break; case SOFT_INPUT_STATE_UNCHANGED: // Do nothing case SOFT_INPUT_STATE_UNCHANGED: if (android.view.inputmethod.Flags.refactorInsetsController()) { verifySetImeVisibility(true /* setVisible */, false /* invoked */); verifySetImeVisibility(false /* setVisible */, false /* invoked */); } else { verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */); verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */); } break; case SOFT_INPUT_STATE_HIDDEN: case SOFT_INPUT_STATE_ALWAYS_HIDDEN: if (android.view.inputmethod.Flags.refactorInsetsController()) { verifySetImeVisibility(true /* setVisible */, false /* invoked */); // In this case, we don't have to manipulate the requested visible types of // the WindowState, as they're already in the correct state verifySetImeVisibility(false /* setVisible */, false /* invoked */); } else { verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */); // Soft input was hidden by default, so it doesn't need to call // {@code IMS#hideSoftInput()}. verifyHideSoftInput(true /* setNotVisible */, false /* hideSoftInput */); } break; default: throw new IllegalStateException( Loading @@ -167,26 +192,52 @@ public class InputMethodManagerServiceWindowGainedFocusTest case SOFT_INPUT_STATE_UNSPECIFIED: boolean hideSoftInput = (mSoftInputAdjustment != SOFT_INPUT_ADJUST_RESIZE) && !mIsLargeScreen; if (android.view.inputmethod.Flags.refactorInsetsController()) { // A show can only be triggered in forward navigation verifySetImeVisibility(false /* setVisible */, false /* invoked */); // A hide can only be triggered if there is no editorFocused, which this test // always sets. verifySetImeVisibility(false /* setVisible */, false /* invoked */); } else { verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */); // Soft input was hidden by default, so it doesn't need to call // {@code IMS#hideSoftInput()}. verifyHideSoftInput(hideSoftInput /* setNotVisible */, false /* hideSoftInput */); verifyHideSoftInput(hideSoftInput /* setNotVisible */, false /* hideSoftInput */); } break; case SOFT_INPUT_STATE_VISIBLE: case SOFT_INPUT_STATE_HIDDEN: case SOFT_INPUT_STATE_UNCHANGED: // Do nothing if (android.view.inputmethod.Flags.refactorInsetsController()) { verifySetImeVisibility(true /* setVisible */, false /* invoked */); verifySetImeVisibility(false /* setVisible */, false /* invoked */); } else { verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */); verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */); } break; case SOFT_INPUT_STATE_ALWAYS_VISIBLE: if (android.view.inputmethod.Flags.refactorInsetsController()) { verifySetImeVisibility(true /* setVisible */, true /* invoked */); verifySetImeVisibility(false /* setVisible */, false /* invoked */); } else { verifyShowSoftInput(true /* setVisible */, true /* showSoftInput */); verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */); } break; case SOFT_INPUT_STATE_ALWAYS_HIDDEN: if (android.view.inputmethod.Flags.refactorInsetsController()) { verifySetImeVisibility(true /* setVisible */, false /* invoked */); // In this case, we don't have to manipulate the requested visible types of // the WindowState, as they're already in the correct state verifySetImeVisibility(false /* setVisible */, false /* invoked */); } else { verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */); // Soft input was hidden by default, so it doesn't need to call // {@code IMS#hideSoftInput()}. verifyHideSoftInput(true /* setNotVisible */, false /* hideSoftInput */); } break; default: throw new IllegalStateException( Loading Loading
services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java +14 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import android.os.ServiceManager; import android.util.ArraySet; import android.view.InputChannel; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.ImeTracker; import android.window.ImeOnBackInvokedDispatcher; import androidx.test.platform.app.InstrumentationRegistry; Loading Loading @@ -260,6 +261,11 @@ public class InputMethodManagerServiceTestBase { unusedUserId -> mMockInputMethodBindingController); spyOn(mInputMethodManagerService); synchronized (ImfLock.class) { doReturn(true).when(mInputMethodManagerService).setImeVisibilityOnFocusedWindowClient( anyBoolean(), any(UserData.class), any(ImeTracker.Token.class)); } // Start a InputMethodManagerService.Lifecycle to publish and manage the lifecycle of // InputMethodManagerService, which is closer to the real situation. InputMethodManagerService.Lifecycle lifecycle = Loading Loading @@ -347,6 +353,14 @@ public class InputMethodManagerServiceTestBase { anyInt() /* flags */, any() /* resultReceiver */); } protected void verifySetImeVisibility(boolean setVisible, boolean invoked) { synchronized (ImfLock.class) { verify(mInputMethodManagerService, times(invoked ? 1 : 0)).setImeVisibilityOnFocusedWindowClient(eq(setVisible), any(UserData.class), any(ImeTracker.Token.class)); } } protected void createSessionForClient(IInputMethodClient client) { synchronized (ImfLock.class) { ClientState cs = mInputMethodManagerService.getClientStateLocked(client); Loading
services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceWindowGainedFocusTest.java +77 −26 Original line number Diff line number Diff line Loading @@ -125,27 +125,52 @@ public class InputMethodManagerServiceWindowGainedFocusTest case SOFT_INPUT_STATE_UNSPECIFIED: boolean showSoftInput = (mSoftInputAdjustment == SOFT_INPUT_ADJUST_RESIZE) || mIsLargeScreen; verifyShowSoftInput( showSoftInput /* setVisible */, showSoftInput /* showSoftInput */); if (android.view.inputmethod.Flags.refactorInsetsController()) { verifySetImeVisibility(true /* setVisible */, showSoftInput /* invoked */); // A hide can only be triggered if there is no editorFocused, which this test // always sets. verifySetImeVisibility(false /* setVisible */, false /* invoked */); } else { verifyShowSoftInput(showSoftInput /* setVisible */, showSoftInput /* showSoftInput */); // Soft input was hidden by default, so it doesn't need to call // {@code IMS#hideSoftInput()}. verifyHideSoftInput(!showSoftInput /* setNotVisible */, false /* hideSoftInput */); verifyHideSoftInput(!showSoftInput /* setNotVisible */, false /* hideSoftInput */); } break; case SOFT_INPUT_STATE_VISIBLE: case SOFT_INPUT_STATE_ALWAYS_VISIBLE: if (android.view.inputmethod.Flags.refactorInsetsController()) { verifySetImeVisibility(true /* setVisible */, true /* invoked */); verifySetImeVisibility(false /* setVisible */, false /* invoked */); } else { verifyShowSoftInput(true /* setVisible */, true /* showSoftInput */); verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */); } break; case SOFT_INPUT_STATE_UNCHANGED: // Do nothing case SOFT_INPUT_STATE_UNCHANGED: if (android.view.inputmethod.Flags.refactorInsetsController()) { verifySetImeVisibility(true /* setVisible */, false /* invoked */); verifySetImeVisibility(false /* setVisible */, false /* invoked */); } else { verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */); verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */); } break; case SOFT_INPUT_STATE_HIDDEN: case SOFT_INPUT_STATE_ALWAYS_HIDDEN: if (android.view.inputmethod.Flags.refactorInsetsController()) { verifySetImeVisibility(true /* setVisible */, false /* invoked */); // In this case, we don't have to manipulate the requested visible types of // the WindowState, as they're already in the correct state verifySetImeVisibility(false /* setVisible */, false /* invoked */); } else { verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */); // Soft input was hidden by default, so it doesn't need to call // {@code IMS#hideSoftInput()}. verifyHideSoftInput(true /* setNotVisible */, false /* hideSoftInput */); } break; default: throw new IllegalStateException( Loading @@ -167,26 +192,52 @@ public class InputMethodManagerServiceWindowGainedFocusTest case SOFT_INPUT_STATE_UNSPECIFIED: boolean hideSoftInput = (mSoftInputAdjustment != SOFT_INPUT_ADJUST_RESIZE) && !mIsLargeScreen; if (android.view.inputmethod.Flags.refactorInsetsController()) { // A show can only be triggered in forward navigation verifySetImeVisibility(false /* setVisible */, false /* invoked */); // A hide can only be triggered if there is no editorFocused, which this test // always sets. verifySetImeVisibility(false /* setVisible */, false /* invoked */); } else { verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */); // Soft input was hidden by default, so it doesn't need to call // {@code IMS#hideSoftInput()}. verifyHideSoftInput(hideSoftInput /* setNotVisible */, false /* hideSoftInput */); verifyHideSoftInput(hideSoftInput /* setNotVisible */, false /* hideSoftInput */); } break; case SOFT_INPUT_STATE_VISIBLE: case SOFT_INPUT_STATE_HIDDEN: case SOFT_INPUT_STATE_UNCHANGED: // Do nothing if (android.view.inputmethod.Flags.refactorInsetsController()) { verifySetImeVisibility(true /* setVisible */, false /* invoked */); verifySetImeVisibility(false /* setVisible */, false /* invoked */); } else { verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */); verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */); } break; case SOFT_INPUT_STATE_ALWAYS_VISIBLE: if (android.view.inputmethod.Flags.refactorInsetsController()) { verifySetImeVisibility(true /* setVisible */, true /* invoked */); verifySetImeVisibility(false /* setVisible */, false /* invoked */); } else { verifyShowSoftInput(true /* setVisible */, true /* showSoftInput */); verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */); } break; case SOFT_INPUT_STATE_ALWAYS_HIDDEN: if (android.view.inputmethod.Flags.refactorInsetsController()) { verifySetImeVisibility(true /* setVisible */, false /* invoked */); // In this case, we don't have to manipulate the requested visible types of // the WindowState, as they're already in the correct state verifySetImeVisibility(false /* setVisible */, false /* invoked */); } else { verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */); // Soft input was hidden by default, so it doesn't need to call // {@code IMS#hideSoftInput()}. verifyHideSoftInput(true /* setNotVisible */, false /* hideSoftInput */); } break; default: throw new IllegalStateException( Loading