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

Commit ecb96204 authored by Felix Stern's avatar Felix Stern
Browse files

Adjusting DefaultImeVisibilityApplierTest for refactor

Test: atest FrameworksInputMethodSystemServerTests:com.android.server.inputmethod.DefaultImeVisibilityApplierTest
Flag: android.view.inputmethod.refactor_insets_controller
Bug: 355145573
Change-Id: I5cc93171e1562be136804f9647d5e834d4fc64b7
parent 2c399676
Loading
Loading
Loading
Loading
+33 −5
Original line number Diff line number Diff line
@@ -45,7 +45,11 @@ import android.annotation.Nullable;
import android.os.Binder;
import android.os.IBinder;
import android.os.RemoteException;
import android.platform.test.annotations.RequiresFlagsDisabled;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.view.Display;
import android.view.inputmethod.Flags;
import android.view.inputmethod.ImeTracker;

import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -58,6 +62,7 @@ import com.android.internal.inputmethod.StartInputFlags;
import com.android.internal.inputmethod.StartInputReason;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

@@ -70,6 +75,9 @@ import org.junit.runner.RunWith;
 */
@RunWith(AndroidJUnit4.class)
public class DefaultImeVisibilityApplierTest extends InputMethodManagerServiceTestBase {

    @Rule
    public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
    private DefaultImeVisibilityApplier mVisibilityApplier;

    @Before
@@ -112,6 +120,7 @@ public class DefaultImeVisibilityApplierTest extends InputMethodManagerServiceTe
    }

    @Test
    @RequiresFlagsDisabled(Flags.FLAG_REFACTOR_INSETS_CONTROLLER)
    public void testApplyImeVisibility_showIme() {
        final var statsToken = ImeTracker.Token.empty();
        synchronized (ImfLock.class) {
@@ -122,6 +131,7 @@ public class DefaultImeVisibilityApplierTest extends InputMethodManagerServiceTe
    }

    @Test
    @RequiresFlagsDisabled(Flags.FLAG_REFACTOR_INSETS_CONTROLLER)
    public void testApplyImeVisibility_hideIme() {
        final var statsToken = ImeTracker.Token.empty();
        synchronized (ImfLock.class) {
@@ -141,8 +151,13 @@ public class DefaultImeVisibilityApplierTest extends InputMethodManagerServiceTe
            mVisibilityApplier.applyImeVisibility(mWindowToken, ImeTracker.Token.empty(),
                    STATE_HIDE_IME_EXPLICIT, eq(SoftInputShowHideReason.NOT_SET), mUserId);
        }
        if (Flags.refactorInsetsController()) {
            verifySetImeVisibility(true /* setVisible */, false /* invoked */);
            verifySetImeVisibility(false /* setVisible */, true /* invoked */);
        } else {
            verifyHideSoftInput(true, true);
        }
    }

    @Test
    public void testApplyImeVisibility_hideNotAlways() throws Exception {
@@ -153,8 +168,13 @@ public class DefaultImeVisibilityApplierTest extends InputMethodManagerServiceTe
            mVisibilityApplier.applyImeVisibility(mWindowToken, ImeTracker.Token.empty(),
                    STATE_HIDE_IME_NOT_ALWAYS, eq(SoftInputShowHideReason.NOT_SET), mUserId);
        }
        if (Flags.refactorInsetsController()) {
            verifySetImeVisibility(true /* setVisible */, false /* invoked */);
            verifySetImeVisibility(false /* setVisible */, true /* invoked */);
        } else {
            verifyHideSoftInput(true, true);
        }
    }

    @Test
    public void testApplyImeVisibility_showImeImplicit() throws Exception {
@@ -162,10 +182,16 @@ public class DefaultImeVisibilityApplierTest extends InputMethodManagerServiceTe
            mVisibilityApplier.applyImeVisibility(mWindowToken, ImeTracker.Token.empty(),
                    STATE_SHOW_IME_IMPLICIT, eq(SoftInputShowHideReason.NOT_SET), mUserId);
        }
        if (Flags.refactorInsetsController()) {
            verifySetImeVisibility(true /* setVisible */, true /* invoked */);
            verifySetImeVisibility(false /* setVisible */, false /* invoked */);
        } else {
            verifyShowSoftInput(true, true, 0 /* showFlags */);
        }
    }

    @Test
    @RequiresFlagsDisabled(Flags.FLAG_REFACTOR_INSETS_CONTROLLER)
    public void testApplyImeVisibility_hideImeFromTargetOnSecondaryDisplay() {
        // Init a IME target client on the secondary display to show IME.
        mInputMethodManagerService.addClient(mMockInputMethodClient, mMockRemoteInputConnection,
@@ -234,8 +260,10 @@ public class DefaultImeVisibilityApplierTest extends InputMethodManagerServiceTe
            verify(mVisibilityApplier).applyImeVisibility(
                    eq(mWindowToken), any(), eq(STATE_HIDE_IME),
                    eq(SoftInputShowHideReason.NOT_SET), eq(mUserId) /* userId */);
            verify(mInputMethodManagerService.mWindowManagerInternal).hideIme(
                    eq(mWindowToken), eq(displayIdToShowIme), and(not(eq(statsToken)), notNull()));
            if (!Flags.refactorInsetsController()) {
                verify(mInputMethodManagerService.mWindowManagerInternal).hideIme(eq(mWindowToken),
                        eq(displayIdToShowIme), and(not(eq(statsToken)), notNull()));
            }
        }
    }