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

Commit d420252e authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move setAttachedClientForTesting() to DefaultImeVisibilityApplierTest" into main

parents 559efa67 0c728209
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -1844,13 +1844,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        }
    }

    @VisibleForTesting
    void setAttachedClientForTesting(@NonNull ClientState cs) {
        synchronized (ImfLock.class) {
            getUserData(mCurrentUserId).mCurClient = cs;
        }
    }

    @GuardedBy("ImfLock.class")
    private boolean isShowRequestedForCurrentWindow(@UserIdInt int userId) {
        final var userData = getUserData(userId);
+14 −3
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import static org.mockito.Mockito.when;

import static java.util.Objects.requireNonNull;

import android.annotation.Nullable;
import android.os.Binder;
import android.os.IBinder;
import android.os.RemoteException;
@@ -50,6 +51,7 @@ import android.view.inputmethod.ImeTracker;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import com.android.dx.mockito.inline.extended.ExtendedMockito;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.inputmethod.InputBindResult;
import com.android.internal.inputmethod.SoftInputShowHideReason;
import com.android.internal.inputmethod.StartInputFlags;
@@ -75,7 +77,7 @@ public class DefaultImeVisibilityApplierTest extends InputMethodManagerServiceTe
        super.setUp();
        synchronized (ImfLock.class) {
            mVisibilityApplier = mInputMethodManagerService.getVisibilityApplierLocked();
            mInputMethodManagerService.setAttachedClientForTesting(requireNonNull(
            setAttachedClientLocked(requireNonNull(
                    mInputMethodManagerService.getClientStateLocked(mMockInputMethodClient)));
        }
    }
@@ -168,7 +170,9 @@ public class DefaultImeVisibilityApplierTest extends InputMethodManagerServiceTe
        // Init a IME target client on the secondary display to show IME.
        mInputMethodManagerService.addClient(mMockInputMethodClient, mMockRemoteInputConnection,
                10 /* selfReportedDisplayId */);
        mInputMethodManagerService.setAttachedClientForTesting(null);
        synchronized (ImfLock.class) {
            setAttachedClientLocked(null);
        }
        startInputOrWindowGainedFocus(mWindowToken, SOFT_INPUT_STATE_ALWAYS_VISIBLE);

        final var statsToken = ImeTracker.Token.empty();
@@ -206,7 +210,9 @@ public class DefaultImeVisibilityApplierTest extends InputMethodManagerServiceTe

    @Test
    public void testApplyImeVisibility_hideImeWhenUnbinding() {
        mInputMethodManagerService.setAttachedClientForTesting(null);
        synchronized (ImfLock.class) {
            setAttachedClientLocked(null);
        }
        startInputOrWindowGainedFocus(mWindowToken, SOFT_INPUT_STATE_ALWAYS_VISIBLE);
        ExtendedMockito.spyOn(mVisibilityApplier);

@@ -233,6 +239,11 @@ public class DefaultImeVisibilityApplierTest extends InputMethodManagerServiceTe
        }
    }

    @GuardedBy("ImfLock.class")
    private void setAttachedClientLocked(@Nullable ClientState cs) {
        mInputMethodManagerService.getUserData(mUserId).mCurClient = cs;
    }

    private InputBindResult startInputOrWindowGainedFocus(IBinder windowToken, int softInputMode) {
        return mInputMethodManagerService.startInputOrWindowGainedFocus(
                StartInputReason.WINDOW_FOCUS_GAIN /* startInputReason */,