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

Commit 4d334cc8 authored by czq's avatar czq
Browse files

Remove check for result of IMM#showSoftInput and hideSoftInput

Bug: 280141638
Test: atest com.android.inputmethod.stresstest.DefaultImeVisibilityTest#showHideDefaultIme
Change-Id: I5c4e1ea528fdefb676f0db7943098778686624de
parent f45c4830
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -199,8 +199,7 @@ public final class AutoShowTest {
                        Collections.singletonList(REQUEST_FOCUS_ON_CREATE));
        TestActivity firstActivity = TestActivity.start(intent1);
        // Show Ime with InputMethodManager to ensure the keyboard is on.
        boolean succ = callOnMainSync(firstActivity::showImeWithInputMethodManager);
        assertThat(succ).isTrue();
        callOnMainSync(firstActivity::showImeWithInputMethodManager);
        SystemClock.sleep(1000);
        mInstrumentation.waitForIdleSync();

@@ -264,8 +263,7 @@ public final class AutoShowTest {
                        Collections.singletonList(REQUEST_FOCUS_ON_CREATE));
        ImeStressTestUtil.TestActivity secondActivity = activity.startSecondTestActivity(intent2);
        // Show Ime with InputMethodManager to ensure the keyboard is shown on the second activity
        boolean succ = callOnMainSync(secondActivity::showImeWithInputMethodManager);
        assertThat(succ).isTrue();
        callOnMainSync(secondActivity::showImeWithInputMethodManager);
        SystemClock.sleep(1000);
        mInstrumentation.waitForIdleSync();
        // Close the second activity
+2 −7
Original line number Diff line number Diff line
@@ -26,8 +26,6 @@ import static com.android.inputmethod.stresstest.ImeStressTestUtil.verifyWindowA
import static com.android.inputmethod.stresstest.ImeStressTestUtil.waitOnMainUntilImeIsHidden;
import static com.android.inputmethod.stresstest.ImeStressTestUtil.waitOnMainUntilImeIsShown;

import static com.google.common.truth.Truth.assertThat;

import android.content.Intent;
import android.platform.test.annotations.RootPermissionTest;
import android.platform.test.rule.UnlockScreenRule;
@@ -83,14 +81,11 @@ public final class DefaultImeVisibilityTest {
        ImeStressTestUtil.TestActivity activity = ImeStressTestUtil.TestActivity.start(intent);
        EditText editText = activity.getEditText();
        for (int i = 0; i < NUM_TEST_ITERATIONS; i++) {

            boolean showResult = callOnMainSync(activity::showImeWithInputMethodManager);
            assertThat(showResult).isTrue();
            callOnMainSync(activity::showImeWithInputMethodManager);
            verifyWindowAndViewFocus(editText, true, true);
            waitOnMainUntilImeIsShown(editText);

            boolean hideResult = callOnMainSync(activity::hideImeWithInputMethodManager);
            assertThat(hideResult).isTrue();
            callOnMainSync(activity::hideImeWithInputMethodManager);
            waitOnMainUntilImeIsHidden(editText);
        }
    }
+9 −20
Original line number Diff line number Diff line
@@ -102,12 +102,10 @@ public final class ImeOpenCloseStressTest {
        for (int i = 0; i < iterNum; i++) {
            String msgPrefix = "Iteration #" + i + " ";
            Log.i(TAG, msgPrefix + "start");
            boolean showResult = callOnMainSync(activity::showImeWithInputMethodManager);
            assertThat(showResult).isEqualTo(!(hasUnfocusableWindowFlags(activity)));
            callOnMainSync(activity::showImeWithInputMethodManager);
            verifyShowBehavior(activity);

            boolean hideResult = callOnMainSync(activity::hideImeWithInputMethodManager);
            assertThat(hideResult).isEqualTo(!(hasUnfocusableWindowFlags(activity)));
            callOnMainSync(activity::hideImeWithInputMethodManager);

            verifyHideBehavior(activity);
        }
@@ -128,14 +126,12 @@ public final class ImeOpenCloseStressTest {
        for (int i = 0; i < NUM_TEST_ITERATIONS; i++) {
            String msgPrefix = "Iteration #" + i + " ";
            Log.i(TAG, msgPrefix + "start");
            boolean showResult = callOnMainSync(activity::showImeWithInputMethodManager);
            assertThat(showResult).isTrue();
            callOnMainSync(activity::showImeWithInputMethodManager);
            waitOnMainUntil(
                    msgPrefix + "IME should be visible",
                    () -> !activity.isAnimating() && isImeShown(editText));

            boolean hideResult = callOnMainSync(activity::hideImeWithInputMethodManager);
            assertThat(hideResult).isTrue();
            callOnMainSync(activity::hideImeWithInputMethodManager);
            waitOnMainUntil(
                    msgPrefix + "IME should be hidden",
                    () -> !activity.isAnimating() && !isImeShown(editText));
@@ -156,17 +152,13 @@ public final class ImeOpenCloseStressTest {
        List<Integer> intervals = new ArrayList<>();
        for (int i = 10; i < 100; i += 10) intervals.add(i);
        for (int i = 100; i < 1000; i += 50) intervals.add(i);
        boolean firstHide = false;
        for (int intervalMillis : intervals) {
            String msgPrefix = "Interval = " + intervalMillis + " ";
            Log.i(TAG, msgPrefix + " start");
            boolean hideResult = callOnMainSync(activity::hideImeWithInputMethodManager);
            assertThat(hideResult).isEqualTo(firstHide);
            firstHide = true;
            callOnMainSync(activity::hideImeWithInputMethodManager);
            SystemClock.sleep(intervalMillis);

            boolean showResult = callOnMainSync(activity::showImeWithInputMethodManager);
            assertThat(showResult).isTrue();
            callOnMainSync(activity::showImeWithInputMethodManager);
            verifyShowBehavior(activity);
        }
    }
@@ -247,8 +239,7 @@ public final class ImeOpenCloseStressTest {
        TestActivity activity = TestActivity.start(intent);

        // Show InputMethodManager without requesting focus
        boolean showResult = callOnMainSync(activity::showImeWithInputMethodManager);
        assertThat(showResult).isFalse();
        callOnMainSync(activity::showImeWithInputMethodManager);

        int windowFlags = activity.getWindow().getAttributes().flags;
        EditText editText = activity.getEditText();
@@ -474,8 +465,7 @@ public final class ImeOpenCloseStressTest {
                        Collections.singletonList(REQUEST_FOCUS_ON_CREATE));
        TestActivity activity = TestActivity.start(intent1);
        // Show Ime with InputMethodManager to ensure the keyboard is shown on the second activity
        boolean showResult = callOnMainSync(activity::showImeWithInputMethodManager);
        assertThat(showResult).isEqualTo(!(hasUnfocusableWindowFlags(activity)));
        callOnMainSync(activity::showImeWithInputMethodManager);

        Thread.sleep(1000);
        verifyShowBehavior(activity);
@@ -502,8 +492,7 @@ public final class ImeOpenCloseStressTest {
                        Collections.singletonList(REQUEST_FOCUS_ON_CREATE));
        TestActivity activity = TestActivity.start(intent);
        // Show Ime with InputMethodManager to ensure the keyboard is shown on the second activity
        boolean showResult = callOnMainSync(activity::showImeWithInputMethodManager);
        assertThat(showResult).isEqualTo(!(hasUnfocusableWindowFlags(activity)));
        callOnMainSync(activity::showImeWithInputMethodManager);
        Thread.sleep(2000);
        verifyShowBehavior(activity);