From fd0ac0ea8ceb23d6e7cd90d4e83c92c449e7d041 Mon Sep 17 00:00:00 2001 From: vadimt Date: Fri, 21 May 2021 10:43:56 -0700 Subject: [PATCH] Improve diagnostics when cannot install wellbeing test apk This apk is used for Wellbeing tests. Test: local Bug: 187761685 Change-Id: I66f7c308b70b6bd048806d6417417a6e398605db --- tests/src/com/android/launcher3/util/TestUtil.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/src/com/android/launcher3/util/TestUtil.java b/tests/src/com/android/launcher3/util/TestUtil.java index 55e57440c8..67f3902095 100644 --- a/tests/src/com/android/launcher3/util/TestUtil.java +++ b/tests/src/com/android/launcher3/util/TestUtil.java @@ -22,6 +22,8 @@ import android.content.res.Resources; import androidx.test.uiautomator.UiDevice; +import org.junit.Assert; + import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -48,7 +50,10 @@ public class TestUtil { in.close(); out.close(); - UiDevice.getInstance(getInstrumentation()).executeShellCommand("pm install " + apkFilename); + final String result = UiDevice.getInstance(getInstrumentation()) + .executeShellCommand("pm install " + apkFilename); + Assert.assertTrue("Failed to install wellbeing test apk; make sure the device is rooted", + "Success".equals(result.replaceAll("\\s+", ""))); } public static void uninstallDummyApp() throws IOException {