summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Cosmin Băieș <cosminbaies@google.com> 2025-02-20 14:02:17 +0100
committer Cosmin Băieș <cosminbaies@google.com> 2025-02-20 14:02:17 +0100
commitfbcfb86b9af76046781df1d130bcb42d99ec8418 (patch)
treeb540357ec66de13adcb6c34b3e38a3df8e00d373
parent4fb4149e4df534796ded579fae56d4f8cf56118b (diff)
Fix orientation change race conditions in IME test
During setup we first launch the activity and then set the orientation to natural. In most cases this is already the current orientation, so nothing changes. However if the previous test changed to a different orientation, this will trigger an activity re-creation. This could be slightly delayed after the setup, so we might have input_focus and temporarily lose it during the test, which will fail any IME requests. This also removes the freezeRotation call, as setting an orientation also freezes the rotation. Additionally adds a check to restore the orientation to natural during teardown. Flag: EXEMPT testfix Bug: 397765263 Test: atest InputMethodServiceTest Change-Id: I383bebd027eca7155c55ca0f450589f0255e589e
-rw-r--r--services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java b/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java
index 2d3f7231cc5c..03d8da525f1e 100644
--- a/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java
+++ b/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java
@@ -139,10 +139,9 @@ public class InputMethodServiceTest {
if (!mOriginalVerboseImeTrackerLoggingEnabled) {
setVerboseImeTrackerLogging(true);
}
+ mUiDevice.setOrientationNatural();
prepareIme();
prepareActivity();
- mUiDevice.freezeRotation();
- mUiDevice.setOrientationNatural();
// Waits for input binding ready.
eventually(() -> {
mInputMethodService = InputMethodServiceWrapper.getInstance();
@@ -169,6 +168,9 @@ public class InputMethodServiceTest {
@After
public void tearDown() throws Exception {
+ if (!mUiDevice.isNaturalOrientation()) {
+ mUiDevice.setOrientationNatural();
+ }
mUiDevice.unfreezeRotation();
if (!mOriginalVerboseImeTrackerLoggingEnabled) {
setVerboseImeTrackerLogging(false);