Loading tests/Input/src/com/android/test/input/AnrTest.kt +6 −5 Original line number Diff line number Diff line Loading @@ -100,6 +100,7 @@ class AnrTest { private fun clickCloseAppOnAnrDialog() { // Find anr dialog and kill app val timestamp = System.currentTimeMillis() val uiDevice: UiDevice = UiDevice.getInstance(instrumentation) val closeAppButton: UiObject2? = uiDevice.wait(Until.findObject(By.res("android:id/aerr_close")), 20000) Loading @@ -107,7 +108,6 @@ class AnrTest { fail("Could not find anr dialog") return } val initialReasons = getExitReasons() closeAppButton.click() /** * We must wait for the app to be fully closed before exiting this test. This is because Loading @@ -116,7 +116,7 @@ class AnrTest { * the killing logic will apply to the newly launched 'am start' instance, and the second * test will fail because the unresponsive activity will never be launched. */ waitForNewExitReason(initialReasons[0].timestamp) waitForNewExitReasonAfter(timestamp) } private fun clickWaitOnAnrDialog() { Loading @@ -140,12 +140,13 @@ class AnrTest { return infos } private fun waitForNewExitReason(previousExitTimestamp: Long) { private fun waitForNewExitReasonAfter(timestamp: Long) { PollingCheck.waitFor { getExitReasons()[0].timestamp > previousExitTimestamp val reasons = getExitReasons() !reasons.isEmpty() && reasons[0].timestamp >= timestamp } val reasons = getExitReasons() assertTrue(reasons[0].timestamp > previousExitTimestamp) assertTrue(reasons[0].timestamp > timestamp) assertEquals(ApplicationExitInfo.REASON_ANR, reasons[0].reason) } Loading Loading
tests/Input/src/com/android/test/input/AnrTest.kt +6 −5 Original line number Diff line number Diff line Loading @@ -100,6 +100,7 @@ class AnrTest { private fun clickCloseAppOnAnrDialog() { // Find anr dialog and kill app val timestamp = System.currentTimeMillis() val uiDevice: UiDevice = UiDevice.getInstance(instrumentation) val closeAppButton: UiObject2? = uiDevice.wait(Until.findObject(By.res("android:id/aerr_close")), 20000) Loading @@ -107,7 +108,6 @@ class AnrTest { fail("Could not find anr dialog") return } val initialReasons = getExitReasons() closeAppButton.click() /** * We must wait for the app to be fully closed before exiting this test. This is because Loading @@ -116,7 +116,7 @@ class AnrTest { * the killing logic will apply to the newly launched 'am start' instance, and the second * test will fail because the unresponsive activity will never be launched. */ waitForNewExitReason(initialReasons[0].timestamp) waitForNewExitReasonAfter(timestamp) } private fun clickWaitOnAnrDialog() { Loading @@ -140,12 +140,13 @@ class AnrTest { return infos } private fun waitForNewExitReason(previousExitTimestamp: Long) { private fun waitForNewExitReasonAfter(timestamp: Long) { PollingCheck.waitFor { getExitReasons()[0].timestamp > previousExitTimestamp val reasons = getExitReasons() !reasons.isEmpty() && reasons[0].timestamp >= timestamp } val reasons = getExitReasons() assertTrue(reasons[0].timestamp > previousExitTimestamp) assertTrue(reasons[0].timestamp > timestamp) assertEquals(ApplicationExitInfo.REASON_ANR, reasons[0].reason) } Loading