Datasets:
Download android/rbn-apps-quick-tile-settings/tests/test_android_text.py from Qwen/RecreationBench: direct link, hf CLI and curl.
- Browser
- Download file 30.3 kB
-
https://huggingface.co/datasets/Qwen/RecreationBench/resolve/main/android/rbn-apps-quick-tile-settings/tests/test_android_text.py
- Command line
-
hf download hf://datasets/Qwen/RecreationBench/android/rbn-apps-quick-tile-settings/tests/test_android_text.py
-
curl -L -o test_android_text.py https://huggingface.co/datasets/Qwen/RecreationBench/resolve/main/android/rbn-apps-quick-tile-settings/tests/test_android_text.py
30.3 kB
| #!/usr/bin/env python3 | |
| """TEXT lane — QuickTile Settings. | |
| Sole owner of exact-string equality: every test here asserts the EXACT visible | |
| string an interaction PRODUCES (a dialog title/body an action opens, a reveal | |
| label a toggle exposes, a warning a tab swap shows). The discriminating half is | |
| always the CHANGE: the string is ABSENT before the trigger and PRESENT after, so | |
| a hardcoded shell that renders the label at launch cannot pass. | |
| Strings were captured live from the ORIGINAL app's uiautomator dump; each is a | |
| content fact (never a version/build string). Run: | |
| python3 test_android_text.py com.rbn.qtsettings /workspace/testgen/eval | |
| """ | |
| import os | |
| import sys | |
| sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) | |
| from android_testgen_kit import * # noqa: F403,E402 | |
| # ── helpers ────────────────────────────────────────────────────────────────── | |
| def all_text(nodes): | |
| """Every non-empty `text` on the surface, pipe-joined (for substring checks).""" | |
| return " | ".join(n.get("text", "") for n in nodes if n.get("text")) | |
| def text_present(nodes, needle): | |
| """Case-insensitive substring over the joined visible text.""" | |
| return needle.strip().lower() in all_text(nodes).lower() | |
| def has_exact_text(nodes, value): | |
| """A standalone TextView whose `text` EQUALS value (avoids the substring trap | |
| where a title is contained in a trigger's content-desc).""" | |
| v = value.strip() | |
| for n in nodes: | |
| if n.get("text", "").strip() == v: | |
| return True | |
| return False | |
| def open_main_default(): | |
| """Guaranteed clean default surface (pm clear wipes to defaults, then launch).""" | |
| clear_data() | |
| launch_app() | |
| wait_for_foreground() | |
| def and_enter_dialog(trigger_desc="", trigger_text=""): | |
| """Tap a trigger that opens an overlay dialog, then count one surface. | |
| Backs a declared depth>=1 for dialog-body tests: it is a real member of the | |
| and_enter* family, so the depth audit sees the navigation it was told about. | |
| Returns True when the trigger was found and tapped. | |
| """ | |
| n = None | |
| if trigger_desc: | |
| n = find_node(ui(), content_desc=trigger_desc) | |
| if n is None and trigger_text: | |
| n = find_node(ui(), text=trigger_text) or find_node_ci(ui(), trigger_text) | |
| if n is None or not tap_node(n): | |
| return False | |
| and_enter(trigger_desc or trigger_text) | |
| return True | |
| def and_enter_shortcut_screen(): | |
| """Navigate Main -> Shortcut Actions, counting one surface (backs depth>=1).""" | |
| ic = find_node(ui(), content_desc="Open shortcut settings") | |
| if ic is None or not tap_node(ic): | |
| return False | |
| and_enter("Shortcut Actions") | |
| return True | |
| def open_usb_tab(): | |
| """Swap to the USB Debugging tab (a page swap within S0, depth 0).""" | |
| tab = find_node(ui(), text="USB Debugging") | |
| return bool(tab) and tap_node(tab) | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| # About dialog (D1) — labels an action (Help icon) produces | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| def test_about_features_label(): | |
| open_main_default() | |
| absent = not text_present(ui(), "Features") | |
| if not and_enter_dialog(trigger_desc="Help / Grant Permission"): | |
| record("text_about_features_label", False, | |
| "setup_failed: Help / Grant Permission icon not found on main surface", | |
| depth=1, jump_kind="value", expect="'Features' header in About dialog") | |
| return | |
| present = has_exact_text(ui(), "Features") | |
| ok = absent and present | |
| record("text_about_features_label", ok, | |
| "" if ok else "behavior_wrong: About dialog did not show the 'Features' header", | |
| depth=1, jump_kind="value", expect="About dialog shows header 'Features'") | |
| def test_about_developer_label(): | |
| open_main_default() | |
| absent = not text_present(ui(), "Developer") | |
| if not and_enter_dialog(trigger_desc="Help / Grant Permission"): | |
| record("text_about_developer_label", False, | |
| "setup_failed: Help / Grant Permission icon not found on main surface", | |
| depth=1, jump_kind="value", expect="'Developer' header in About dialog") | |
| return | |
| present = has_exact_text(ui(), "Developer") | |
| ok = absent and present | |
| record("text_about_developer_label", ok, | |
| "" if ok else "behavior_wrong: About dialog did not show the 'Developer' header", | |
| depth=1, jump_kind="value", expect="About dialog shows header 'Developer'") | |
| def test_about_permission_help_label(): | |
| open_main_default() | |
| absent = not text_present(ui(), "Permission Setup Help") | |
| if not and_enter_dialog(trigger_desc="Help / Grant Permission"): | |
| record("text_about_permission_help_label", False, | |
| "setup_failed: Help / Grant Permission icon not found on main surface", | |
| depth=1, jump_kind="value", expect="'Permission Setup Help' in About dialog") | |
| return | |
| present = has_exact_text(ui(), "Permission Setup Help") | |
| ok = absent and present | |
| record("text_about_permission_help_label", ok, | |
| "" if ok else "behavior_wrong: About dialog missing 'Permission Setup Help' button", | |
| depth=1, jump_kind="value", | |
| expect="About dialog shows button 'Permission Setup Help'") | |
| def test_about_feature_bullet(): | |
| # The Features list bullet text — a content fact the About dialog produces. | |
| open_main_default() | |
| bullet = "Private DNS tile with custom hostname support" | |
| absent = not text_present(ui(), bullet) | |
| if not and_enter_dialog(trigger_desc="Help / Grant Permission"): | |
| record("text_about_feature_bullet", False, | |
| "setup_failed: Help / Grant Permission icon not found on main surface", | |
| depth=1, jump_kind="value", expect=f"bullet '{bullet}'") | |
| vlm_assert("text_about_feature_bullet", | |
| "Is there a bulleted 'Features' list in the dialog with an entry " | |
| "about a Private DNS tile with custom hostname support?", | |
| RESULTS_DIR, tag="layout", depth=1) | |
| return | |
| present = text_present(ui(), bullet) | |
| ok = absent and present | |
| record("text_about_feature_bullet", ok, | |
| "" if ok else "behavior_wrong: About Features list missing the DNS-tile bullet", | |
| depth=1, jump_kind="value", | |
| expect=f"About Features list contains '{bullet}'") | |
| # The bulleted block as RENDERED (layout of a multi-line list under 'Features'). | |
| vlm_assert("text_about_feature_bullet", | |
| "In this dialog, is there a section headed 'Features' followed by a " | |
| "vertical bulleted list of several short feature lines?", | |
| RESULTS_DIR, tag="layout", depth=1) | |
| def test_about_description(): | |
| open_main_default() | |
| phrase = "Quick Settings tiles" | |
| absent = not text_present(ui(), phrase) | |
| if not and_enter_dialog(trigger_desc="Help / Grant Permission"): | |
| record("text_about_description", False, | |
| "setup_failed: Help / Grant Permission icon not found on main surface", | |
| depth=1, jump_kind="value", expect=f"description contains '{phrase}'") | |
| return | |
| present = text_present(ui(), phrase) | |
| ok = absent and present | |
| record("text_about_description", ok, | |
| "" if ok else "behavior_wrong: About description missing 'Quick Settings tiles'", | |
| depth=1, jump_kind="value", | |
| expect=f"About dialog description contains '{phrase}'") | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| # DNS Info dialogs (D4) — the TITLE + a body phrase each tap produces | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| def test_dnsinfo_cloudflare_title(): | |
| open_main_default() | |
| title = "About Cloudflare (1.1.1.1)" | |
| # The trigger content-desc is "Info about Cloudflare (1.1.1.1)" which CONTAINS | |
| # the title, so assert the standalone TextView whose text EQUALS the title. | |
| absent = not has_exact_text(ui(), title) | |
| if not and_enter_dialog(trigger_desc="Info about Cloudflare (1.1.1.1)"): | |
| record("text_dnsinfo_cloudflare_title", False, | |
| "setup_failed: 'Info about Cloudflare (1.1.1.1)' icon not found", | |
| depth=1, jump_kind="value", expect=f"dialog title '{title}'") | |
| return | |
| present = has_exact_text(ui(), title) | |
| ok = absent and present | |
| record("text_dnsinfo_cloudflare_title", ok, | |
| "" if ok else "behavior_wrong: Cloudflare info dialog title is not " | |
| "'About Cloudflare (1.1.1.1)'", | |
| depth=1, jump_kind="value", expect=f"dialog title equals '{title}'") | |
| def test_dnsinfo_cloudflare_body(): | |
| open_main_default() | |
| phrase = "is known for its high speed" | |
| absent = not text_present(ui(), phrase) | |
| if not and_enter_dialog(trigger_desc="Info about Cloudflare (1.1.1.1)"): | |
| record("text_dnsinfo_cloudflare_body", False, | |
| "setup_failed: 'Info about Cloudflare (1.1.1.1)' icon not found", | |
| depth=1, jump_kind="value", expect=f"body contains '{phrase}'") | |
| return | |
| present = text_present(ui(), phrase) | |
| ok = absent and present | |
| record("text_dnsinfo_cloudflare_body", ok, | |
| "" if ok else "behavior_wrong: Cloudflare info body missing 'is known for " | |
| "its high speed'", | |
| depth=1, jump_kind="value", expect=f"Cloudflare info body contains '{phrase}'") | |
| def test_dnsinfo_adguard_title(): | |
| open_main_default() | |
| title = "About AdGuard DNS" | |
| absent = not has_exact_text(ui(), title) | |
| if not and_enter_dialog(trigger_desc="Info about AdGuard DNS"): | |
| record("text_dnsinfo_adguard_title", False, | |
| "setup_failed: 'Info about AdGuard DNS' icon not found", | |
| depth=1, jump_kind="value", expect=f"dialog title '{title}'") | |
| return | |
| present = has_exact_text(ui(), title) | |
| ok = absent and present | |
| record("text_dnsinfo_adguard_title", ok, | |
| "" if ok else "behavior_wrong: AdGuard info dialog title is not 'About AdGuard DNS'", | |
| depth=1, jump_kind="value", expect=f"dialog title equals '{title}'") | |
| def test_dnsinfo_adguard_body(): | |
| open_main_default() | |
| phrase = "blocks ads, trackers, and known malicious domains" | |
| absent = not text_present(ui(), phrase) | |
| if not and_enter_dialog(trigger_desc="Info about AdGuard DNS"): | |
| record("text_dnsinfo_adguard_body", False, | |
| "setup_failed: 'Info about AdGuard DNS' icon not found", | |
| depth=1, jump_kind="value", expect=f"body contains '{phrase}'") | |
| return | |
| present = text_present(ui(), phrase) | |
| ok = absent and present | |
| record("text_dnsinfo_adguard_body", ok, | |
| "" if ok else "behavior_wrong: AdGuard info body missing the ad/tracker-blocking phrase", | |
| depth=1, jump_kind="value", expect=f"AdGuard info body contains '{phrase}'") | |
| def test_dnsinfo_quad9_title(): | |
| open_main_default() | |
| title = "About Quad9 Security" | |
| absent = not has_exact_text(ui(), title) | |
| if not and_enter_dialog(trigger_desc="Info about Quad9 Security"): | |
| record("text_dnsinfo_quad9_title", False, | |
| "setup_failed: 'Info about Quad9 Security' icon not found", | |
| depth=1, jump_kind="value", expect=f"dialog title '{title}'") | |
| return | |
| present = has_exact_text(ui(), title) | |
| ok = absent and present | |
| record("text_dnsinfo_quad9_title", ok, | |
| "" if ok else "behavior_wrong: Quad9 info dialog title is not 'About Quad9 Security'", | |
| depth=1, jump_kind="value", expect=f"dialog title equals '{title}'") | |
| def test_dnsinfo_quad9_body(): | |
| open_main_default() | |
| phrase = "focuses on security by blocking domains associated with malware" | |
| absent = not text_present(ui(), phrase) | |
| if not and_enter_dialog(trigger_desc="Info about Quad9 Security"): | |
| record("text_dnsinfo_quad9_body", False, | |
| "setup_failed: 'Info about Quad9 Security' icon not found", | |
| depth=1, jump_kind="value", expect=f"body contains '{phrase}'") | |
| return | |
| present = text_present(ui(), phrase) | |
| ok = absent and present | |
| record("text_dnsinfo_quad9_body", ok, | |
| "" if ok else "behavior_wrong: Quad9 info body missing the malware-blocking phrase", | |
| depth=1, jump_kind="value", expect=f"Quad9 info body contains '{phrase}'") | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| # Add Hostname dialog (D2) — title + a field label the button produces | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| def test_add_hostname_title(): | |
| open_main_default() | |
| title = "Add Hostname" | |
| absent = not has_exact_text(ui(), title) | |
| if not and_enter_dialog(trigger_desc="Add Custom Hostname", | |
| trigger_text="Add Custom Hostname"): | |
| record("text_add_hostname_title", False, | |
| "setup_failed: 'Add Custom Hostname' control not found on main surface", | |
| depth=1, jump_kind="value", expect=f"dialog title '{title}'") | |
| return | |
| present = has_exact_text(ui(), title) | |
| ok = absent and present | |
| record("text_add_hostname_title", ok, | |
| "" if ok else "behavior_wrong: Add-hostname dialog title is not 'Add Hostname'", | |
| depth=1, jump_kind="value", expect=f"dialog title equals '{title}'") | |
| def test_add_hostname_field_labels(): | |
| open_main_default() | |
| label = "Hostname (e.g., dns.example.com)" | |
| absent = not text_present(ui(), label) | |
| if not and_enter_dialog(trigger_desc="Add Custom Hostname", | |
| trigger_text="Add Custom Hostname"): | |
| record("text_add_hostname_field_labels", False, | |
| "setup_failed: 'Add Custom Hostname' control not found on main surface", | |
| depth=1, jump_kind="value", expect=f"field label '{label}'") | |
| return | |
| nodes = ui() | |
| present = text_present(nodes, label) and text_present(nodes, "Display Name") | |
| ok = absent and present | |
| record("text_add_hostname_field_labels", ok, | |
| "" if ok else "behavior_wrong: Add-hostname dialog missing 'Display Name' / " | |
| "'Hostname (e.g., dns.example.com)' labels", | |
| depth=1, jump_kind="value", | |
| expect=f"dialog shows 'Display Name' and '{label}'") | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| # Network Type Info dialog (D5) — title the Info icon produces (body is opaque) | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| def test_network_info_title(): | |
| open_main_default() | |
| title = "Network Type Detection" | |
| # Trigger content-desc equals the title too, so assert a standalone TextView. | |
| absent = not has_exact_text(ui(), title) | |
| if not and_enter_dialog(trigger_desc="Network Type Detection"): | |
| record("text_network_info_title", False, | |
| "setup_failed: 'Network Type Detection' info icon not found", | |
| depth=1, jump_kind="value", expect=f"dialog title '{title}'") | |
| return | |
| # A Close button appearing proves the dialog opened (not just the row's icon desc). | |
| nodes = ui() | |
| present = has_exact_text(nodes, title) and text_present(nodes, "Close") | |
| ok = absent and present | |
| record("text_network_info_title", ok, | |
| "" if ok else "behavior_wrong: Network Type info dialog title/Close not shown", | |
| depth=1, jump_kind="value", | |
| expect=f"dialog title equals '{title}' with a Close button") | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| # USB tab warning — the red string the tab swap produces (present USB / absent DNS) | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| def test_usb_warning(): | |
| open_main_default() | |
| warn = "Developer options are disabled. USB Debugging cannot be configured." | |
| absent_on_dns = not text_present(ui(), warn) | |
| if not open_usb_tab(): | |
| record("text_usb_warning", False, | |
| "setup_failed: 'USB Debugging' tab not found", | |
| depth=0, jump_kind="value", expect=f"USB tab shows '{warn}'") | |
| vlm_assert("text_usb_warning", | |
| "Is a warning message about Developer options being disabled shown " | |
| "in a red/error-coloured style near the top of the content area?", | |
| RESULTS_DIR, tag="color", depth=0) | |
| return | |
| present_on_usb = has_exact_text(ui(), warn) | |
| ok = absent_on_dns and present_on_usb | |
| record("text_usb_warning", ok, | |
| "" if ok else "behavior_wrong: USB tab did not produce the disabled-dev-options warning", | |
| depth=0, jump_kind="value", | |
| expect=f"USB tab shows exactly '{warn}' (absent on DNS tab)") | |
| # The warning as RENDERED — a faithful recreation shows it in a red/error style. | |
| vlm_assert("text_usb_warning", | |
| "Is there a warning line stating that Developer options are disabled and " | |
| "USB Debugging cannot be configured, shown in a red or error-coloured text?", | |
| RESULTS_DIR, tag="color", depth=0) | |
| def test_usb_tile_heading_swap(): | |
| # The tab swap produces the "USB Debugging Tile" heading (absent on DNS tab, | |
| # where the heading is "Private DNS Tile"). | |
| open_main_default() | |
| heading = "USB Debugging Tile" | |
| absent_on_dns = not has_exact_text(ui(), heading) | |
| if not open_usb_tab(): | |
| record("text_usb_tile_heading_swap", False, | |
| "setup_failed: 'USB Debugging' tab not found", | |
| depth=0, jump_kind="value", expect=f"USB tab heading '{heading}'") | |
| return | |
| present_on_usb = has_exact_text(ui(), heading) | |
| ok = absent_on_dns and present_on_usb | |
| record("text_usb_tile_heading_swap", ok, | |
| "" if ok else "behavior_wrong: USB tab did not show the 'USB Debugging Tile' heading", | |
| depth=0, jump_kind="value", | |
| expect=f"USB tab heading equals '{heading}' (absent on DNS tab)") | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| # Shortcut Actions screen (S1) — title + expanded info-pill paragraph | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| def test_shortcut_screen_title(): | |
| open_main_default() | |
| title = "Shortcut Actions" | |
| absent = not has_exact_text(ui(), title) | |
| if not and_enter_shortcut_screen(): | |
| record("text_shortcut_screen_title", False, | |
| "setup_failed: 'Open shortcut settings' icon not found on main surface", | |
| depth=1, jump_kind="value", expect=f"screen title '{title}'") | |
| return | |
| present = has_exact_text(ui(), title) | |
| ok = absent and present | |
| record("text_shortcut_screen_title", ok, | |
| "" if ok else "behavior_wrong: Shortcut screen title is not 'Shortcut Actions'", | |
| depth=1, jump_kind="value", expect=f"screen title equals '{title}'") | |
| def test_shortcut_pill_expanded(): | |
| # Tapping the info pill expands a long explanatory paragraph (AnimatedVisibility). | |
| open_main_default() | |
| phrase = "Choose which actions are exposed as Android app shortcuts" | |
| if not and_enter_shortcut_screen(): | |
| record("text_shortcut_pill_expanded", False, | |
| "setup_failed: 'Open shortcut settings' icon not found on main surface", | |
| depth=1, jump_kind="value", expect=f"expanded pill contains '{phrase}'") | |
| vlm_assert("text_shortcut_pill_expanded", | |
| "Below the 'Active shortcuts' pill, is a long multi-paragraph block " | |
| "of explanatory text displayed?", | |
| RESULTS_DIR, tag="layout", depth=1) | |
| return | |
| absent = not text_present(ui(), phrase) | |
| pill = (find_node(ui(), text="Active shortcuts: 0 / 15") | |
| or find_node_ci(ui(), "Active shortcuts: 0 / 15")) | |
| if pill is None or not tap_node(pill): | |
| record("text_shortcut_pill_expanded", False, | |
| "setup_failed: 'Active shortcuts: 0 / 15' pill not found/tappable", | |
| depth=1, jump_kind="value", expect=f"expanded pill contains '{phrase}'") | |
| vlm_assert("text_shortcut_pill_expanded", | |
| "Below the 'Active shortcuts' pill, is a long multi-paragraph block " | |
| "of explanatory text displayed?", | |
| RESULTS_DIR, tag="layout", depth=1) | |
| return | |
| present = text_present(ui(), phrase) | |
| ok = absent and present | |
| record("text_shortcut_pill_expanded", ok, | |
| "" if ok else "behavior_wrong: tapping the pill did not reveal the explanatory paragraph", | |
| depth=1, jump_kind="value", | |
| expect=f"expanded pill text contains '{phrase}'") | |
| # The expanded paragraph as RENDERED (a tall text block appears under the pill). | |
| vlm_assert("text_shortcut_pill_expanded", | |
| "Directly under the 'Active shortcuts' pill near the top, is a long " | |
| "multi-paragraph block of explanatory text now displayed?", | |
| RESULTS_DIR, tag="layout", depth=1) | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| # "Allow disabled shortcuts?" warning dialog (S1) — title + body a toggle produces | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| def test_allow_disabled_warning_title(): | |
| open_main_default() | |
| title = "Allow disabled shortcuts?" | |
| if not and_enter_shortcut_screen(): | |
| record("text_allow_disabled_warning_title", False, | |
| "setup_failed: could not reach the Shortcut Actions screen", | |
| depth=1, jump_kind="value", expect=f"warning title '{title}'") | |
| return | |
| absent = not has_exact_text(ui(), title) | |
| lbl = find_node(ui(), text="Allow disabled pinned shortcuts") | |
| if lbl is None or not tap_node(lbl): | |
| record("text_allow_disabled_warning_title", False, | |
| "setup_failed: 'Allow disabled pinned shortcuts' toggle not found", | |
| depth=1, jump_kind="value", expect=f"warning title '{title}'") | |
| return | |
| present = has_exact_text(ui(), title) | |
| ok = absent and present | |
| record("text_allow_disabled_warning_title", ok, | |
| "" if ok else "behavior_wrong: enabling the toggle did not show the " | |
| "'Allow disabled shortcuts?' warning title", | |
| depth=1, jump_kind="value", expect=f"warning dialog title equals '{title}'") | |
| def test_allow_disabled_warning_body(): | |
| open_main_default() | |
| phrase = "weakens the default safety behavior" | |
| button = "Enable anyway" | |
| if not and_enter_shortcut_screen(): | |
| record("text_allow_disabled_warning_body", False, | |
| "setup_failed: could not reach the Shortcut Actions screen", | |
| depth=1, jump_kind="value", expect=f"warning body contains '{phrase}'") | |
| return | |
| absent = not text_present(ui(), phrase) | |
| lbl = find_node(ui(), text="Allow disabled pinned shortcuts") | |
| if lbl is None or not tap_node(lbl): | |
| record("text_allow_disabled_warning_body", False, | |
| "setup_failed: 'Allow disabled pinned shortcuts' toggle not found", | |
| depth=1, jump_kind="value", expect=f"warning body contains '{phrase}'") | |
| return | |
| nodes = ui() | |
| present = text_present(nodes, phrase) and text_present(nodes, button) | |
| ok = absent and present | |
| record("text_allow_disabled_warning_body", ok, | |
| "" if ok else "behavior_wrong: warning dialog body/'Enable anyway' button not shown", | |
| depth=1, jump_kind="value", | |
| expect=f"warning body contains '{phrase}' and button '{button}'") | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| # Conditional reveal labels — produced when a checkbox is toggled ON | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| def test_vpn_mode_reveal(): | |
| open_main_default() | |
| label = "VPN Detection Mode:" | |
| absent = not has_exact_text(ui(), label) | |
| toggle = find_node(ui(), text="Automatically disable DNS on VPN connections") | |
| if toggle is None or not tap_node(toggle): | |
| record("text_vpn_mode_reveal", False, | |
| "setup_failed: VPN toggle label not found on DNS tab", | |
| depth=0, jump_kind="transition", expect=f"reveal label '{label}'") | |
| return | |
| nodes = ui() | |
| present = has_exact_text(nodes, label) and text_present(nodes, "Tile-Only Detection") | |
| ok = absent and present | |
| record("text_vpn_mode_reveal", ok, | |
| "" if ok else "behavior_wrong: toggling VPN option did not reveal 'VPN Detection Mode:'", | |
| depth=0, jump_kind="transition", | |
| expect=f"'{label}' absent before toggle, present after") | |
| def test_network_wifi_reveal(): | |
| open_main_default() | |
| label = "DNS on WiFi:" | |
| absent = not has_exact_text(ui(), label) | |
| toggle = find_node(ui(), text="Auto-switch DNS based on network type") | |
| if toggle is None or not tap_node(toggle): | |
| record("text_network_wifi_reveal", False, | |
| "setup_failed: network auto-switch toggle label not found on DNS tab", | |
| depth=0, jump_kind="transition", expect=f"reveal label '{label}'") | |
| return | |
| present = has_exact_text(ui(), label) | |
| ok = absent and present | |
| record("text_network_wifi_reveal", ok, | |
| "" if ok else "behavior_wrong: toggling network auto-switch did not reveal 'DNS on WiFi:'", | |
| depth=0, jump_kind="transition", | |
| expect=f"'{label}' absent before toggle, present after") | |
| TESTS = [ | |
| test_about_features_label, | |
| test_about_developer_label, | |
| test_about_permission_help_label, | |
| test_about_feature_bullet, | |
| test_about_description, | |
| test_dnsinfo_cloudflare_title, | |
| test_dnsinfo_cloudflare_body, | |
| test_dnsinfo_adguard_title, | |
| test_dnsinfo_adguard_body, | |
| test_dnsinfo_quad9_title, | |
| test_dnsinfo_quad9_body, | |
| test_add_hostname_title, | |
| test_add_hostname_field_labels, | |
| test_network_info_title, | |
| test_usb_warning, | |
| test_usb_tile_heading_swap, | |
| test_shortcut_screen_title, | |
| test_shortcut_pill_expanded, | |
| test_allow_disabled_warning_title, | |
| test_allow_disabled_warning_body, | |
| test_vpn_mode_reveal, | |
| test_network_wifi_reveal, | |
| ] | |
| if __name__ == "__main__": | |
| if not device_online(): | |
| print("Device offline — cannot run the text lane") | |
| sys.exit(1) | |
| run_suite(TESTS, "text") | |