test(ci): poll UI dump for pin shortcut dialog before fallback

This commit is contained in:
Adam M. Szalkowski 2026-09-06 18:57:23 +02:00
parent d6ee97596d
commit 405dfb49b3

View file

@ -292,7 +292,8 @@ def test_upgrade_flow():
print("Confirming System Pin Shortcut dialog...")
pinPattern = re.compile(r'(?i)(add automatically|add to home screen|\badd\b|allow|ok)')
clicked_pin = False
for attempt in range(5):
for attempt in range(10):
time.sleep(1)
xml = dump_ui()
for match in re.finditer(r'<node ([^>]+)>', xml):
attr = match.group(1)
@ -302,7 +303,7 @@ def test_upgrade_flow():
dm = re.search(r'content-desc="([^"]*)"', attr)
if dm: node_text += " " + dm.group(1)
if pinPattern.search(node_text):
if pinPattern.search(node_text) or 'button1' in attr or 'btn_add' in attr:
bounds_match = re.search(r'bounds="\[(\d+),(\d+)\]\[(\d+),(\d+)\]"', attr)
if bounds_match:
x1, y1, x2, y2 = map(int, bounds_match.groups())
@ -315,7 +316,9 @@ def test_upgrade_flow():
break
if clicked_pin:
break
print("Retrying pin dialog search / DPAD navigation...")
if not clicked_pin:
print("Fallback pin dialog tap...")
adb_shell("input keyevent KEYCODE_DPAD_RIGHT", check=False)
adb_shell("input keyevent KEYCODE_ENTER", check=False)
time.sleep(1)