Merge "Remove check for result of IMM#showSoftInput and hideSoftInput" into udc-dev

This commit is contained in:
Ziqi Chen
2023-06-01 01:28:55 +00:00
committed by Android (Google) Code Review
3 changed files with 13 additions and 31 deletions

View File

@@ -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

View File

@@ -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);
}
}

View File

@@ -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);
@@ -503,8 +493,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);