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

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

Merge "Adjusting DefaultImeVisibilityApplierTest for refactor" into main

parents 64fe4ee9 ecb96204
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()));
            }
        }
    }