From 058140012bb0e4623ed7dd59da9640328a25fb06 Mon Sep 17 00:00:00 2001 From: Isaac Udy Date: Thu, 19 Oct 2023 23:01:44 +1300 Subject: [PATCH] Tweak the closeWithBackPressed method to use main thread to request focus --- .../enro/test/application/fragment/UnboundBottomSheetRobot.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/application/src/androidTest/java/dev/enro/test/application/fragment/UnboundBottomSheetRobot.kt b/tests/application/src/androidTest/java/dev/enro/test/application/fragment/UnboundBottomSheetRobot.kt index e00a70f0..539079de 100644 --- a/tests/application/src/androidTest/java/dev/enro/test/application/fragment/UnboundBottomSheetRobot.kt +++ b/tests/application/src/androidTest/java/dev/enro/test/application/fragment/UnboundBottomSheetRobot.kt @@ -42,7 +42,9 @@ class UnboundBottomSheetRobot( // on API 30 Espresso seems to fail to call "pressBack" unless the fragment's View is // manually requested for focus. This does not occur on API 23, 27 or 33. I believe this // is a bug in Espresso/API 30 specifically. - fragment.requireView().requestFocus() + composeRule.runOnUiThread { + fragment.requireView().requestFocus() + } // dirty hack to wait for the focus to come through, because waiting for // requireView().isFocused isn't working Thread.sleep(1000)