diff options
| author | 2024-07-29 07:52:01 +0000 | |
|---|---|---|
| committer | 2024-07-29 07:52:01 +0000 | |
| commit | 7cbbbdd76e45e2219659348fa732e539092582dd (patch) | |
| tree | 0018f6050f42363a63bb8fc408d0c9c7219051dd | |
| parent | 59002e70d74c31d8c8c6ebf1e161dfedfbfaa85c (diff) | |
| parent | 5cdac6c2bfa24835f62526c6c4642e07a22fa48e (diff) | |
Merge "Rename InputMethodManagerServiceTestBase#mCallingUserId to mUserId" into main
4 files changed, 15 insertions, 21 deletions
diff --git a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/DefaultImeVisibilityApplierTest.java b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/DefaultImeVisibilityApplierTest.java index 9e46f2f88561..efcc23f35c78 100644 --- a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/DefaultImeVisibilityApplierTest.java +++ b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/DefaultImeVisibilityApplierTest.java @@ -70,14 +70,11 @@ import org.junit.runner.RunWith; public class DefaultImeVisibilityApplierTest extends InputMethodManagerServiceTestBase { private DefaultImeVisibilityApplier mVisibilityApplier; - private int mUserId = 0; - @Before public void setUp() throws RemoteException { super.setUp(); synchronized (ImfLock.class) { mVisibilityApplier = mInputMethodManagerService.getVisibilityApplierLocked(); - mUserId = mInputMethodManagerService.getCurrentImeUserIdLocked(); mInputMethodManagerService.setAttachedClientForTesting(requireNonNull( mInputMethodManagerService.getClientStateLocked(mMockInputMethodClient))); } @@ -248,7 +245,7 @@ public class DefaultImeVisibilityApplierTest extends InputMethodManagerServiceTe mMockRemoteInputConnection /* inputConnection */, mMockRemoteAccessibilityInputConnection /* remoteAccessibilityInputConnection */, mTargetSdkVersion /* unverifiedTargetSdkVersion */, - mCallingUserId /* userId */, + mUserId /* userId */, mMockImeOnBackInvokedDispatcher /* imeDispatcher */); } } diff --git a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodBindingControllerTest.java b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodBindingControllerTest.java index 4d28b3c854ff..1e3b7e9e05f4 100644 --- a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodBindingControllerTest.java +++ b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodBindingControllerTest.java @@ -140,8 +140,7 @@ public class InputMethodBindingControllerTest extends InputMethodManagerServiceT final InputMethodInfo info; synchronized (ImfLock.class) { mBindingController.setSelectedMethodId(TEST_IME_ID); - info = InputMethodSettingsRepository.get(mCallingUserId).getMethodMap() - .get(TEST_IME_ID); + info = InputMethodSettingsRepository.get(mUserId).getMethodMap().get(TEST_IME_ID); } assertThat(info).isNotNull(); assertThat(info.getId()).isEqualTo(TEST_IME_ID); diff --git a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java index 1dc5126e9a7e..461697cfa7cf 100644 --- a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java +++ b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java @@ -50,7 +50,6 @@ import android.os.IBinder; import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; -import android.os.UserHandle; import android.util.ArraySet; import android.view.InputChannel; import android.view.inputmethod.EditorInfo; @@ -128,7 +127,7 @@ public class InputMethodManagerServiceTestBase { protected Context mContext; protected MockitoSession mMockingSession; protected int mTargetSdkVersion; - protected int mCallingUserId; + protected int mUserId; protected EditorInfo mEditorInfo; protected IInputMethodInvoker mMockInputMethodInvoker; protected InputMethodManagerService mInputMethodManagerService; @@ -165,12 +164,12 @@ public class InputMethodManagerServiceTestBase { .spyStatic(AdditionalSubtypeUtils.class) .startMocking(); - mContext = spy(InstrumentationRegistry.getInstrumentation().getContext()); + mContext = spy(InstrumentationRegistry.getInstrumentation().getTargetContext()); mTargetSdkVersion = mContext.getApplicationInfo().targetSdkVersion; mIsLargeScreen = mContext.getResources().getConfiguration() .isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE); - mCallingUserId = UserHandle.getCallingUserId(); + mUserId = mContext.getUserId(); mEditorInfo = new EditorInfo(); mEditorInfo.packageName = TEST_EDITOR_PKG_NAME; @@ -202,7 +201,7 @@ public class InputMethodManagerServiceTestBase { // Injecting and mocked InputMethodBindingController and InputMethod. mMockInputMethodInvoker = IInputMethodInvoker.create(mMockInputMethod); mInputManagerGlobalSession = InputManagerGlobal.createTestSession(mMockIInputManager); - when(mMockInputMethodBindingController.getUserId()).thenReturn(mCallingUserId); + when(mMockInputMethodBindingController.getUserId()).thenReturn(mUserId); synchronized (ImfLock.class) { when(mMockInputMethodBindingController.getCurMethod()) .thenReturn(mMockInputMethodInvoker); @@ -222,7 +221,7 @@ public class InputMethodManagerServiceTestBase { .thenReturn(new int[] {0}); when(mMockUserManagerInternal.getUserIds()).thenReturn(new int[] {0}); when(mMockActivityManagerInternal.isSystemReady()).thenReturn(true); - when(mMockActivityManagerInternal.getCurrentUserId()).thenReturn(mCallingUserId); + when(mMockActivityManagerInternal.getCurrentUserId()).thenReturn(mUserId); when(mMockPackageManagerInternal.getPackageUid(anyString(), anyLong(), anyInt())) .thenReturn(Binder.getCallingUid()); when(mMockPackageManagerInternal.isSameApp(anyString(), anyLong(), anyInt(), anyInt())) @@ -272,14 +271,13 @@ public class InputMethodManagerServiceTestBase { // Certain tests rely on TEST_IME_ID that is installed with AndroidTest.xml. // TODO(b/352615651): Consider just synthesizing test InputMethodInfo then injecting it. - AdditionalSubtypeMapRepository.initializeIfNecessary(mCallingUserId); + AdditionalSubtypeMapRepository.initializeIfNecessary(mUserId); final var settings = InputMethodManagerService.queryInputMethodServicesInternal(mContext, - mCallingUserId, AdditionalSubtypeMapRepository.get(mCallingUserId), - DirectBootAwareness.AUTO); - InputMethodSettingsRepository.put(mCallingUserId, settings); + mUserId, AdditionalSubtypeMapRepository.get(mUserId), DirectBootAwareness.AUTO); + InputMethodSettingsRepository.put(mUserId, settings); // Emulate that the user initialization is done. - mInputMethodManagerService.getUserData(mCallingUserId).mBackgroundLoadLatch.countDown(); + mInputMethodManagerService.getUserData(mUserId).mBackgroundLoadLatch.countDown(); // After this boot phase, services can broadcast Intents. lifecycle.onBootPhase(SystemService.PHASE_ACTIVITY_MANAGER_READY); @@ -291,7 +289,7 @@ public class InputMethodManagerServiceTestBase { @After public void tearDown() { - InputMethodSettingsRepository.remove(mCallingUserId); + InputMethodSettingsRepository.remove(mUserId); if (mInputMethodManagerService != null) { mInputMethodManagerService.mInputMethodDeviceConfigs.destroy(); @@ -347,8 +345,8 @@ public class InputMethodManagerServiceTestBase { synchronized (ImfLock.class) { ClientState cs = mInputMethodManagerService.getClientStateLocked(client); cs.mCurSession = new InputMethodManagerService.SessionState(cs, - mMockInputMethodInvoker, mMockInputMethodSession, mock( - InputChannel.class), mCallingUserId); + mMockInputMethodInvoker, mMockInputMethodSession, mock(InputChannel.class), + mUserId); } } } diff --git a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceWindowGainedFocusTest.java b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceWindowGainedFocusTest.java index ffc4df8f2069..c5b5668c67bc 100644 --- a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceWindowGainedFocusTest.java +++ b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceWindowGainedFocusTest.java @@ -263,7 +263,7 @@ public class InputMethodManagerServiceWindowGainedFocusTest mMockRemoteInputConnection /* inputConnection */, mMockRemoteAccessibilityInputConnection /* remoteAccessibilityInputConnection */, mTargetSdkVersion /* unverifiedTargetSdkVersion */, - mCallingUserId /* userId */, + mUserId /* userId */, mMockImeOnBackInvokedDispatcher /* imeDispatcher */); } |