diff options
3 files changed, 16 insertions, 6 deletions
diff --git a/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/AndroidManifest.xml b/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/AndroidManifest.xml index 45523268c966..79dd1292f140 100644 --- a/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/AndroidManifest.xml +++ b/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/AndroidManifest.xml @@ -16,7 +16,7 @@ --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="com.android.inputmethod.imetests"> + package="com.android.inputmethodservice"> <!-- Permissions required for granting and logging --> <uses-permission android:name="android.permission.LOG_COMPAT_CHANGE"/> @@ -33,7 +33,7 @@ </application> <!-- The "targetPackage" reference the instruments APK package, which is the SimpleTestIme.apk, - while the test package is "com.android.inputmethod.imetests" (FrameworksImeTests.apk).--> + while the test package is "com.android.inputmethodservice" (FrameworksImeTests.apk).--> <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" android:targetPackage="com.android.apps.inputmethod.simpleime" diff --git a/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/AndroidTest.xml b/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/AndroidTest.xml index 8e6954b474cb..5fe5b237bdef 100644 --- a/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/AndroidTest.xml +++ b/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/AndroidTest.xml @@ -34,14 +34,15 @@ <option name="test-tag" value="FrameworksImeTests" /> <test class="com.android.tradefed.testtype.AndroidJUnitTest" > - <option name="package" value="com.android.inputmethod.imetests" /> + <option name="package" value="com.android.inputmethodservice" /> <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" /> <option name="hidden-api-checks" value="false"/> </test> - <!-- Collect the files in the dump directory for debugging --> + <!-- Collect output of DumpOnFailure --> <metrics_collector class="com.android.tradefed.device.metric.FilePullerLogCollector"> - <option name="directory-keys" value="/sdcard/FrameworksImeTests/" /> + <option name="directory-keys" value="/data/user/0/com.android.apps.inputmethod.simpleime/files" /> <option name="collect-on-run-ended-only" value="true" /> + <option name="clean-up" value="true" /> </metrics_collector> </configuration> diff --git a/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java b/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java index 2d3f7231cc5c..0ee670138c8c 100644 --- a/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java +++ b/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java @@ -42,6 +42,7 @@ import android.os.Build; import android.os.RemoteException; import android.platform.test.flag.junit.DeviceFlagsValueProvider; import android.provider.Settings; +import android.server.wm.DumpOnFailure; import android.server.wm.WindowManagerStateHelper; import android.util.Log; import android.view.WindowManagerGlobal; @@ -118,6 +119,9 @@ public class InputMethodServiceTest { @Rule public final TestName mName = new TestName(); + @Rule + public final DumpOnFailure mDumpOnFailure = new DumpOnFailure(); + private Instrumentation mInstrumentation; private UiDevice mUiDevice; private InputMethodManager mImm; @@ -1210,8 +1214,13 @@ public class InputMethodServiceTest { @NonNull private UiObject2 getUiObject(@NonNull BySelector bySelector) { + final var preScreenshot = mInstrumentation.getUiAutomation().takeScreenshot(); + mDumpOnFailure.dumpOnFailure("pre-getUiObject", preScreenshot); final var uiObject = mUiDevice.wait(Until.findObject(bySelector), TIMEOUT_MS); - assertWithMessage("UiObject with " + bySelector + " was found").that(uiObject).isNotNull(); + mInstrumentation.waitForIdleSync(); + final var postScreenshot = mInstrumentation.getUiAutomation().takeScreenshot(); + mDumpOnFailure.dumpOnFailure("post-getUiObject", postScreenshot); + assertWithMessage("UiObject with " + bySelector + " was found").that(uiObject).isNull(); return uiObject; } |