From c233b796dffa5bf679e63f0d00dab523af35d3cd Mon Sep 17 00:00:00 2001 From: matejcik Date: Fri, 9 Apr 2021 11:41:50 +0200 Subject: [PATCH] fix(tests): avoid race condition when generating UI test screenshots --- tests/ui_tests/__init__.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/ui_tests/__init__.py b/tests/ui_tests/__init__.py index a5e9d5bd1..5c035d4d2 100644 --- a/tests/ui_tests/__init__.py +++ b/tests/ui_tests/__init__.py @@ -99,13 +99,18 @@ def screen_recording(client, request): try: client.debug.start_recording(str(screen_path)) yield - if test_ui == "record": - _process_recorded(screen_path, test_name) - else: - _process_tested(screens_test_path, test_name) finally: + # Wait for response to Initialize, which gives the emulator time to catch up + # and redraw the homescreen. Otherwise there's a race condition between that + # and stopping recording. + client.init_device() client.debug.stop_recording() + if test_ui == "record": + _process_recorded(screen_path, test_name) + else: + _process_tested(screens_test_path, test_name) + def list_missing(): return set(FILE_HASHES.keys()) - PROCESSED