From 1fa5412855e38528899365dd600edbe5345f736d Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Wed, 6 Nov 2024 17:02:26 +0100 Subject: [PATCH] e2e: close ANR popup in case if exception happened --- tests/e2e/testRunner.ts | 3 +++ tests/e2e/utils/closeANRPopup.ts | 13 +++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 tests/e2e/utils/closeANRPopup.ts diff --git a/tests/e2e/testRunner.ts b/tests/e2e/testRunner.ts index 5485385ad8c9..8efeef85dcf5 100644 --- a/tests/e2e/testRunner.ts +++ b/tests/e2e/testRunner.ts @@ -22,6 +22,7 @@ import compare from './compare/compare'; import defaultConfig from './config'; import createServerInstance from './server'; import reversePort from './utils/androidReversePort'; +import closeANRPopup from './utils/closeANRPopup'; import installApp from './utils/installApp'; import killApp from './utils/killApp'; import launchApp from './utils/launchApp'; @@ -287,6 +288,7 @@ const runTests = async (): Promise => { // eslint-disable-next-line @typescript-eslint/restrict-template-expressions Logger.error(`Warmup failed with error: ${e}`); + closeANRPopup(); MeasureUtils.stop('error-warmup'); server.clearAllTestDoneListeners(); @@ -314,6 +316,7 @@ const runTests = async (): Promise => { // eslint-disable-next-line @typescript-eslint/restrict-template-expressions Logger.error(`Unexpected error during test execution: ${e}. `); MeasureUtils.stop('error'); + closeANRPopup(); server.clearAllTestDoneListeners(); errorCountRef.errorCount += 1; if (testIteration === 0 || errorCountRef.errorCount === errorCountRef.allowedExceptions) { diff --git a/tests/e2e/utils/closeANRPopup.ts b/tests/e2e/utils/closeANRPopup.ts new file mode 100644 index 000000000000..1763bc183ad4 --- /dev/null +++ b/tests/e2e/utils/closeANRPopup.ts @@ -0,0 +1,13 @@ +import execAsync from './execAsync'; +import type {PromiseWithAbort} from './execAsync'; + +const closeANRPopup = function (platform = 'android'): PromiseWithAbort { + if (platform !== 'android') { + throw new Error(`closeANRPopup() missing implementation for platform: ${platform}`); + } + + // Press "Enter" to close the ANR popup + return execAsync(`adb shell input keyevent KEYCODE_ENTER`); +}; + +export default closeANRPopup;