summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-09-13 17:09:49 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-09-13 17:09:49 +0000
commit5328f80a4713521423bfc85fc36fd68fefd46ae3 (patch)
tree0e32ead2703e4fa63856d0993116a2a789664180
parentc4c481e698b581d85d8f15426cb8633309d5d547 (diff)
parent5897ff75bf47f179693dcbe084063f97f385819a (diff)
Merge "AnrTest: Use try-with-resources to close UinputTouchScreen" into main
-rw-r--r--tests/Input/src/com/android/test/input/AnrTest.kt10
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/Input/src/com/android/test/input/AnrTest.kt b/tests/Input/src/com/android/test/input/AnrTest.kt
index d32cedb24a36..cd6ab30d8678 100644
--- a/tests/Input/src/com/android/test/input/AnrTest.kt
+++ b/tests/Input/src/com/android/test/input/AnrTest.kt
@@ -166,12 +166,12 @@ class AnrTest {
val displayManager =
instrumentation.context.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
val display = displayManager.getDisplay(obj.getDisplayId())
- val touchScreen = UinputTouchScreen(instrumentation, display)
-
val rect: Rect = obj.visibleBounds
- val pointer = touchScreen.touchDown(rect.centerX(), rect.centerY())
- pointer.lift()
- touchScreen.close()
+ UinputTouchScreen(instrumentation, display).use { touchScreen ->
+ touchScreen
+ .touchDown(rect.centerX(), rect.centerY())
+ .lift()
+ }
}
private fun triggerAnr() {