diff options
| author | 2025-03-03 11:56:39 +0100 | |
|---|---|---|
| committer | 2025-03-03 04:49:14 -0800 | |
| commit | d097891e7ce6fd25e8f443d48245578dd7a30fa5 (patch) | |
| tree | b9efc9e25a329b6e653e3e76e1e14dc369b80370 | |
| parent | fc2d083585668c9b8f6c689cda1143c932802ecd (diff) | |
Dump WindowHierarcy on getUiObject failure
This adds an additional dump of the window hierarcy when getUiObject
fails, to complement the dump of the screenshot on failure. This should
point why the screenshot shows the button being visible, but UiDevice
doesn't find it.
Flag: EXEMPT test debug
Bug: 395783236
Test: atest InputMethodServiceTest#testBackButtonClick
InputMethodServiceTest#testBackButtonLongClick
InputMethodServiceTest#testImeSwitchButtonClick
InputMethodServiceTest#testImeSwitchButtonLongClick
Change-Id: I210249f43c6c53f3f185f17645e563732e13e072
| -rw-r--r-- | services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java b/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java index 2cd860ae6c12..e263e85f020f 100644 --- a/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java +++ b/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java @@ -77,6 +77,8 @@ import org.junit.Test; import org.junit.rules.TestName; import org.junit.runner.RunWith; +import java.io.ByteArrayOutputStream; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Objects; import java.util.concurrent.CountDownLatch; @@ -1294,6 +1296,14 @@ public class InputMethodServiceTest { mInstrumentation.waitForIdleSync(); final var postScreenshot = mInstrumentation.getUiAutomation().takeScreenshot(); mDumpOnFailure.dumpOnFailure("post-getUiObject", postScreenshot); + try { + final var outputStream = new ByteArrayOutputStream(); + mUiDevice.dumpWindowHierarchy(outputStream); + final String windowHierarchy = outputStream.toString(StandardCharsets.UTF_8); + mDumpOnFailure.dumpOnFailure("post-getUiObject", windowHierarchy); + } catch (Exception e) { + Log.i(TAG, "Failed to dump windowHierarchy", e); + } assertWithMessage("UiObject with " + bySelector + " was found").that(uiObject).isNotNull(); return uiObject; } |