From bc9aa0f417f038d2cbf89a79efd6ce06775863a5 Mon Sep 17 00:00:00 2001 From: David Saff Date: Thu, 29 Sep 2022 10:41:06 -0400 Subject: [PATCH] Use SysuiTestCase#runShellCommand. This (a) makes the test run rather than fail for trying to get the global instrumentation. (b) May deflake the test (once it is passing) by waiting for shell commands to complete before moving on. Bug: 176891566 Bug: 249756667 Test: com.android.systemui.globalactions.GlobalActionsImeTest Change-Id: I7dbf1b5443a501bb71dafc7bbd89b43b2a09a0b2 --- .../systemui/globalactions/GlobalActionsImeTest.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsImeTest.java b/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsImeTest.java index d418836b57530..7f55d388c34f2 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsImeTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsImeTest.java @@ -49,6 +49,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import java.io.IOException; import java.util.concurrent.TimeUnit; import java.util.function.BooleanSupplier; @@ -148,8 +149,12 @@ public class GlobalActionsImeTest extends SysuiTestCase { return false; } - private static void executeShellCommand(String cmd) { - InstrumentationRegistry.getInstrumentation().getUiAutomation().executeShellCommand(cmd); + private void executeShellCommand(String cmd) { + try { + runShellCommand(cmd); + } catch (IOException e) { + throw new RuntimeException(e); + } } /**