Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2351daed authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Stub out setNonSelectedSystemImesDisabledUntilUsed()

  InputMethodUtils#setNonSelectedSystemImesDisabledUntilUsed()

actually tries to change the IME component state, which needs to be
stubbed out in unit tests.

Bug: 352615651
Test: test FrameworksInputMethodSystemServerTests
Flag: TEST_ONLY
Change-Id: I372b2f0b924898e557fd673cecaaf6145e8d2af8
parent 6fc71695
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.notNull;
@@ -38,6 +39,7 @@ import android.app.ActivityManagerInternal;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.pm.PackageManagerInternal;
import android.content.res.Configuration;
import android.hardware.input.IInputManager;
@@ -157,6 +159,7 @@ public class InputMethodManagerServiceTestBase {
                mockitoSession()
                        .initMocks(this)
                        .strictness(Strictness.LENIENT)
                        .spyStatic(InputMethodUtils.class)
                        .mockStatic(ServiceManager.class)
                        .mockStatic(SystemServerInitThreadPool.class)
                        .startMocking();
@@ -227,6 +230,10 @@ public class InputMethodManagerServiceTestBase {
                .thenReturn(TEST_IME_TARGET_INFO);
        when(mMockInputMethodClient.asBinder()).thenReturn(mMockInputMethodBinder);

        // This changes the real IME component state. Not appropriate to do in tests.
        doNothing().when(() -> InputMethodUtils.setNonSelectedSystemImesDisabledUntilUsed(
                        any(PackageManager.class), anyList()));

        // Used by lazy initializing draw IMS nav bar at InputMethodManagerService#systemRunning(),
        // which is ok to be mocked out for now.
        doReturn(null).when(() -> SystemServerInitThreadPool.submit(any(), anyString()));