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

Commit de19f0da authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Mock out one more overload of Context#registerReceiver()

This is a preparation before making

  InputMethodManagerService#mImeDrawsImeNavBarRes

multi-user ready.

Instantiating InputMethodManagerService results in invoking

  SystemLocaleWrapper#onStart(),

which internally registers a BroadcastReceiver.  All the tests based
on InputMethodManagerServiceTestBase are now failing to unregister
such receivers.

Let's make it no-op by mocking

  Context#registerReceiver(
      BroadcastReceiver, IntentFilter, String, Handler)

for now.

Bug: 345519864
Test: atest FrameworksInputMethodSystemServerTests
Flag: TEST_ONLY
Change-Id: Ia457d631eda0f04a7acdd92315b896a97aa4fcb1
parent c7aa0be4
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -35,12 +35,15 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.app.ActivityManagerInternal;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.IntentFilter;
import android.content.pm.PackageManagerInternal;
import android.content.res.Configuration;
import android.hardware.input.IInputManager;
import android.hardware.input.InputManagerGlobal;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.os.Process;
import android.os.RemoteException;
@@ -182,6 +185,9 @@ public class InputMethodManagerServiceTestBase {
        doNothing().when(mContext).enforceCallingPermission(anyString(), anyString());
        doNothing().when(mContext).sendBroadcastAsUser(any(), any());
        doReturn(null).when(mContext).registerReceiver(any(), any());
        doReturn(null).when(mContext).registerReceiver(
                any(BroadcastReceiver.class),
                any(IntentFilter.class), anyString(), any(Handler.class));
        doReturn(null)
                .when(mContext)
                .registerReceiverAsUser(any(), any(), any(), anyString(), any(), anyInt());