diff options
| author | 2024-09-13 17:09:49 +0000 | |
|---|---|---|
| committer | 2024-09-13 17:09:49 +0000 | |
| commit | 5328f80a4713521423bfc85fc36fd68fefd46ae3 (patch) | |
| tree | 0e32ead2703e4fa63856d0993116a2a789664180 | |
| parent | c4c481e698b581d85d8f15426cb8633309d5d547 (diff) | |
| parent | 5897ff75bf47f179693dcbe084063f97f385819a (diff) | |
Merge "AnrTest: Use try-with-resources to close UinputTouchScreen" into main
| -rw-r--r-- | tests/Input/src/com/android/test/input/AnrTest.kt | 10 |
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() { |