Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NoQA] e2e: close ANR popup in case if exception happened #52121

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions tests/e2e/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -287,6 +288,7 @@ const runTests = async (): Promise<void> => {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
Logger.error(`Warmup failed with error: ${e}`);

await closeANRPopup();
MeasureUtils.stop('error-warmup');
server.clearAllTestDoneListeners();

Expand All @@ -310,10 +312,11 @@ const runTests = async (): Promise<void> => {

// We run each test multiple time to average out the results
for (let testIteration = 0; testIteration < config.RUNS; testIteration++) {
const onError = (e: Error) => {
const onError = async (e: Error) => {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
Logger.error(`Unexpected error during test execution: ${e}. `);
MeasureUtils.stop('error');
await closeANRPopup();
server.clearAllTestDoneListeners();
errorCountRef.errorCount += 1;
if (testIteration === 0 || errorCountRef.errorCount === errorCountRef.allowedExceptions) {
Expand Down Expand Up @@ -341,7 +344,7 @@ const runTests = async (): Promise<void> => {
// Run the test on the delta app:
await runTestIteration(config.DELTA_APP_PACKAGE, deltaIterationText, config.BRANCH_DELTA, launchArgs);
} catch (e) {
onError(e as Error);
await onError(e as Error);
}
}
} catch (exception) {
Expand Down
13 changes: 13 additions & 0 deletions tests/e2e/utils/closeANRPopup.ts
Original file line number Diff line number Diff line change
@@ -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;
Loading