#!/usr/bin/env python3 """TEXT lane behavioral suite for FlashDim. Sole owner of exact-string equality: this file asserts the CONTENT strings that an interaction PRODUCES or REVEALS — dynamic status text, validation error messages, dialog titles opened by an action, dynamically-formatted labels, produced suffix/counter content. It cedes the computed numeric level VALUE ("N / 10" arithmetic) to the computation lane. Every dynamic string is asserted ABSENT before the trigger and PRESENT after, so a dead layout-clone that only shows static launch labels FAILS. Run: ADB_PATH=/opt/android/platform-tools/adb DEVICE_SERIAL=emulator-5554 \ python3 test_android_text.py com.cyb3rko.flashdim.dev """ import os import sys sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from android_testgen_kit import * # noqa: F403,E402 RESULTS_DIR = sys.argv[2] if len(sys.argv) > 2 else "results" # ───────────────────────────────────────────────────────────────────────────── # Helpers # ───────────────────────────────────────────────────────────────────────────── def all_text(nodes): """Every non-empty text on the surface, pipe-joined, for substring probes.""" return " | ".join(n.get("text", "") for n in nodes if n.get("text")) def norm(s): """Normalise a produced string for tolerant-but-word-faithful comparison. The uiautomator dump serialises embedded newlines as the literal entity ` `; collapse that (and real newlines/whitespace) so the WORDS decide the match, never the line breaks.""" return " ".join((s or "").replace(" ", " ").split()).casefold() def _go_home(): """FlashDim's task back-stack survives force_stop, so restart_app() can resume on SettingsActivity. Back out until home's level_indicator shows.""" for _ in range(4): if node_by_id(ui(), "level_indicator"): return True back() settle("tap") return node_by_id(ui(), "level_indicator") is not None def _home(): """Fresh app on the home surface. Own entry point for every test.""" restart_app() wait_for_foreground() return _go_home() def _home_clean(): """Home surface on freshly-wiped data (for the settings default summary).""" clear_data() restart_app() wait_for_foreground() return _go_home() # ───────────────────────────────────────────────────────────────────────────── # Depth backers — one and_enter_() per dialog/activity we cross. # ───────────────────────────────────────────────────────────────────────────── def and_enter_morse_dialog(): """home → tap morse_button → 'Flash morse code' AlertDialog. Returns node of the message EditText (text_input_text) or None on failure.""" tap_node(node_by_id(ui(), "morse_button")) settle("tap") and_enter("morse_dialog") return node_by_id(ui(), "text_input_text") def and_enter_interval_dialog(): """home → tap interval_button → 'Interval Flash' AlertDialog. Returns True once the dialog title is present.""" tap_node(node_by_id(ui(), "interval_button")) settle("tap") and_enter("interval_dialog") at = node_by_id(ui(), "alertTitle") return bool(at and norm(at.get("text")) == norm("Interval Flash")) def and_enter_about_dialog(): """home → toolbar Icon Credits → 'About' AlertDialog. Returns True once the About title is present.""" tap_node(find_node(ui(), content_desc="Icon Credits")) settle("tap") and_enter("about_dialog") at = node_by_id(ui(), "alertTitle") return bool(at and norm(at.get("text")) == norm("About")) def and_enter_links_dialog(): """home → toolbar Visit-on-GitHub → 'Links' AlertDialog. Returns True once the Links title is present.""" tap_node(find_node(ui(), content_desc="Visit on GitHub")) settle("tap") and_enter("links_dialog") at = node_by_id(ui(), "alertTitle") return bool(at and norm(at.get("text")) == norm("Links")) def and_enter_settings(): """home → toolbar Settings → SettingsActivity. Returns True once a settings row is present.""" tap_node(find_node(ui(), content_desc="Settings")) settle("tap") and_enter("settings") return find_node_ci(ui(), "Preferred level") is not None # ═════════════════════════════════════════════════════════════════════════════ # SECTION A — Home dynamic status text produced by a tap (depth 0, transition). # ═════════════════════════════════════════════════════════════════════════════ @and_test(expects=("text_sos_mode_indicator",)) def test_sos_mode_indicator(): """Tapping SOS flips level_indicator from a numeric level to the produced literal 'SOS mode'. Absent before, present after.""" if not _home(): record("text_sos_mode_indicator", False, "setup_failed: home surface not reached", depth=0, jump_kind="transition", expect="level_indicator == 'SOS mode'") return before = node_by_id(ui(), "level_indicator") if not before: record("text_sos_mode_indicator", False, "setup_failed: level_indicator missing on home", depth=0, jump_kind="transition", expect="level_indicator == 'SOS mode'") return absent = norm(before.get("text")) != norm("SOS mode") sos = node_by_id(ui(), "sos_button") if not sos: record("text_sos_mode_indicator", False, "feature_missing: no sos_button on home", depth=0, jump_kind="transition", expect="level_indicator == 'SOS mode'") return tap_node(sos) settle("tap") after = node_by_id(ui(), "level_indicator") present = bool(after and norm(after.get("text")) == norm("SOS mode")) ok = absent and present record("text_sos_mode_indicator", ok, "" if ok else "behavior_wrong: level_indicator did not become 'SOS mode' after SOS tap", depth=0, jump_kind="transition", expect="level_indicator text == 'SOS mode'") @and_test(expects=("text_sos_quick_actions_morse",)) def test_sos_quick_actions_morse(): """SOS also rewrites quick_actions_view from 'Quick Actions' to a produced 'Morse:\\nS (...)' block. Assert it starts with 'Morse:' and carries the dynamically-formatted letter portion 'S (' — content it PRODUCED.""" if not _home(): record("text_sos_quick_actions_morse", False, "setup_failed: home surface not reached", depth=0, jump_kind="transition", expect="quick_actions_view starts 'Morse:' + 'S ('") return qa = node_by_id(ui(), "quick_actions_view") if not qa: record("text_sos_quick_actions_morse", False, "setup_failed: quick_actions_view missing on home", depth=0, jump_kind="transition", expect="quick_actions_view starts 'Morse:' + 'S ('") return absent = "morse:" not in norm(qa.get("text")) sos = node_by_id(ui(), "sos_button") if not sos: record("text_sos_quick_actions_morse", False, "feature_missing: no sos_button on home", depth=0, jump_kind="transition", expect="quick_actions_view starts 'Morse:' + 'S ('") return tap_node(sos) settle("tap") after = node_by_id(ui(), "quick_actions_view") txt = norm(after.get("text")) if after else "" # produced content: header 'Morse:' + the dynamically-formatted letter 'S (' present = txt.startswith("morse:") and "s (" in txt ok = absent and present record("text_sos_quick_actions_morse", ok, "" if ok else "behavior_wrong: quick_actions_view did not show produced 'Morse:' + letter after SOS", depth=0, jump_kind="transition", expect="quick_actions_view produced 'Morse:' header with letter 'S ('") @and_test(expects=("text_quick_actions_restored_off",)) def test_quick_actions_restored_off(): """After SOS makes quick_actions_view a Morse block, tapping Off restores it to exactly 'Quick Actions'. Assert the Morse content is PRESENT first, then ABSENT and 'Quick Actions' back — a produced-string flip in both directions.""" if not _home(): record("text_quick_actions_restored_off", False, "setup_failed: home surface not reached", depth=0, jump_kind="transition", expect="quick_actions_view == 'Quick Actions' after Off") return sos = node_by_id(ui(), "sos_button") if not sos: record("text_quick_actions_restored_off", False, "feature_missing: no sos_button on home", depth=0, jump_kind="transition", expect="quick_actions_view == 'Quick Actions' after Off") return tap_node(sos) settle("tap") mid = node_by_id(ui(), "quick_actions_view") in_morse = bool(mid and "morse:" in norm(mid.get("text"))) off = node_by_id(ui(), "off_button") if not off: record("text_quick_actions_restored_off", False, "feature_missing: no off_button on home", depth=0, jump_kind="transition", expect="quick_actions_view == 'Quick Actions' after Off") return tap_node(off) settle("tap") after = node_by_id(ui(), "quick_actions_view") restored = bool(after and norm(after.get("text")) == norm("Quick Actions")) ok = in_morse and restored record("text_quick_actions_restored_off", ok, "" if ok else "behavior_wrong: quick_actions_view did not restore to 'Quick Actions' after Off", depth=0, jump_kind="transition", expect="quick_actions_view restored to 'Quick Actions' after Off") @and_test(expects=("text_indicator_restored_off",)) def test_indicator_restored_off(): """SOS sets level_indicator to 'SOS mode'; tapping Off restores it to the numeric '0 / 10'. Assert 'SOS mode' is PRESENT after SOS then ABSENT after Off (the string content flip, not the number itself).""" if not _home(): record("text_indicator_restored_off", False, "setup_failed: home surface not reached", depth=0, jump_kind="transition", expect="level_indicator no longer 'SOS mode' after Off") return sos = node_by_id(ui(), "sos_button") if not sos: record("text_indicator_restored_off", False, "feature_missing: no sos_button on home", depth=0, jump_kind="transition", expect="level_indicator no longer 'SOS mode' after Off") return tap_node(sos) settle("tap") mid = node_by_id(ui(), "level_indicator") in_sos = bool(mid and norm(mid.get("text")) == norm("SOS mode")) off = node_by_id(ui(), "off_button") if not off: record("text_indicator_restored_off", False, "feature_missing: no off_button on home", depth=0, jump_kind="transition", expect="level_indicator no longer 'SOS mode' after Off") return tap_node(off) settle("tap") after = node_by_id(ui(), "level_indicator") restored = bool(after and norm(after.get("text")) != norm("SOS mode") and after.get("text", "").strip() != "") ok = in_sos and restored record("text_indicator_restored_off", ok, "" if ok else "behavior_wrong: level_indicator did not leave 'SOS mode' after Off", depth=0, jump_kind="transition", expect="level_indicator content left 'SOS mode' after Off") # ═════════════════════════════════════════════════════════════════════════════ # SECTION B — Morse dialog validation error messages (depth 1). The strongest # text tests: exact produced error strings triggered by tapping Flash. # ═════════════════════════════════════════════════════════════════════════════ @and_test(expects=("text_morse_error_empty",)) def test_morse_error_empty(): """Tap Flash with an empty message → TextInputLayout produces the exact error 'Please enter your message'. Absent on open, present after Flash.""" if not _home(): record("text_morse_error_empty", False, "setup_failed: home surface not reached", depth=1, jump_kind="transition", expect="error 'Please enter your message'") return field = and_enter_morse_dialog() if not field: record("text_morse_error_empty", False, "setup_failed: morse dialog / message field not reached", depth=1, jump_kind="transition", expect="error 'Please enter your message'") return absent = "please enter your message" not in norm(all_text(ui())) flash = node_by_id(ui(), "button1") or find_node_ci(ui(), "Flash") if not flash: record("text_morse_error_empty", False, "feature_missing: no Flash button in morse dialog", depth=1, jump_kind="transition", expect="error 'Please enter your message'") return tap_node(flash) settle("tap") present = "please enter your message" in norm(all_text(ui())) ok = absent and present record("text_morse_error_empty", ok, "" if ok else "behavior_wrong: empty-message Flash did not produce 'Please enter your message'", depth=1, jump_kind="transition", expect="error text == 'Please enter your message'") @and_test(expects=("text_morse_error_invalid_chars",)) def test_morse_error_invalid_chars(): """Type invalid characters ('!!!') then tap Flash → exact error 'Use characters a–z, A–Z, 0–9 and space' (note EN DASH U+2013). Absent before, present after.""" if not _home(): record("text_morse_error_invalid_chars", False, "setup_failed: home surface not reached", depth=1, jump_kind="transition", expect="error 'Use characters a–z, A–Z, 0–9 and space'") return field = and_enter_morse_dialog() if not field: record("text_morse_error_invalid_chars", False, "setup_failed: morse dialog / message field not reached", depth=1, jump_kind="transition", expect="error 'Use characters a–z, A–Z, 0–9 and space'") return expected = "Use characters a–z, A–Z, 0–9 and space" absent = norm(expected) not in norm(all_text(ui())) type_text(field, "!!!") flash = node_by_id(ui(), "button1") or find_node_ci(ui(), "Flash") if not flash: record("text_morse_error_invalid_chars", False, "feature_missing: no Flash button in morse dialog", depth=1, jump_kind="transition", expect="error " + repr(expected)) return tap_node(flash) settle("tap") present = norm(expected) in norm(all_text(ui())) ok = absent and present record("text_morse_error_invalid_chars", ok, "" if ok else "behavior_wrong: invalid-char Flash did not produce the a–z/A–Z/0–9 error", depth=1, jump_kind="transition", expect="error text == 'Use characters a–z, A–Z, 0–9 and space'") @and_test(expects=("text_morse_hint_on_open",)) def test_morse_hint_on_open(): """The message field's hint 'Your Message' is produced-on-open dialog content (absent on home, present once the dialog is up). depth 1.""" if not _home(): record("text_morse_hint_on_open", False, "setup_failed: home surface not reached", depth=1, jump_kind="transition", expect="morse hint 'Your Message'") return absent = "your message" not in norm(all_text(ui())) field = and_enter_morse_dialog() if not field: record("text_morse_hint_on_open", False, "setup_failed: morse dialog not reached", depth=1, jump_kind="transition", expect="morse hint 'Your Message'") return present = "your message" in norm(all_text(ui())) ok = absent and present record("text_morse_hint_on_open", ok, "" if ok else "behavior_wrong: 'Your Message' hint not shown when morse dialog opened", depth=1, jump_kind="transition", expect="hint text == 'Your Message'") # ═════════════════════════════════════════════════════════════════════════════ # SECTION C — Interval dialog produced text (depth 1). # ═════════════════════════════════════════════════════════════════════════════ @and_test(expects=("text_interval_seizure_warning", "text_interval_seizure_warning_vlm")) def test_interval_seizure_warning(): """Opening the interval dialog produces the seizure-warning line '⚠️ Seizure Warning: Flashing light'. Match the core words 'Seizure Warning' + 'Flashing light' (emoji/bold render outside the text run). Absent on home, present in the dialog. depth 1.""" if not _home(): record("text_interval_seizure_warning", False, "setup_failed: home surface not reached", depth=1, jump_kind="transition", expect="'Seizure Warning' + 'Flashing light'") return absent = "seizure warning" not in norm(all_text(ui())) if not and_enter_interval_dialog(): record("text_interval_seizure_warning", False, "setup_failed: interval dialog not reached", depth=1, jump_kind="transition", expect="'Seizure Warning' + 'Flashing light'") return warn = node_by_id(ui(), "seizure_warning") txt = norm(warn.get("text")) if warn else norm(all_text(ui())) present = "seizure warning" in txt and "flashing light" in txt ok = absent and present record("text_interval_seizure_warning", ok, "" if ok else "behavior_wrong: seizure warning line not produced when interval dialog opened", depth=1, jump_kind="transition", expect="seizure_warning contains 'Seizure Warning' and 'Flashing light'") # VLM: the warning renders a yellow caution-triangle emoji that never reaches # the view-tree text — a rendered-shape property only the VLM can confirm. vlm_assert("text_interval_seizure_warning", "In this Interval Flash dialog, is there a yellow/orange " "triangular caution warning icon immediately to the LEFT of the " "bold words 'Seizure Warning'?", RESULTS_DIR, expect="YES", depth=1, jump_kind="transition", tag="shape") @and_test(expects=("text_interval_suffix_ms_time_mode",)) def test_interval_suffix_ms_time_mode(): """In TIME mode the input carries the produced suffix 'ms'; switching to BPM the 'ms' suffix disappears. Assert suffix == 'ms' in TIME and its ABSENCE after BPM — a produced-content change. depth 1.""" if not _home(): record("text_interval_suffix_ms_time_mode", False, "setup_failed: home surface not reached", depth=1, jump_kind="transition", expect="suffix 'ms' in TIME, gone in BPM") return if not and_enter_interval_dialog(): record("text_interval_suffix_ms_time_mode", False, "setup_failed: interval dialog not reached", depth=1, jump_kind="transition", expect="suffix 'ms' in TIME, gone in BPM") return suffix = node_by_id(ui(), "textinput_suffix_text") in_time = bool(suffix and norm(suffix.get("text")) == norm("ms")) bpm = node_by_id(ui(), "bpm_button") or find_node_ci(ui(), "BPM") if not bpm: record("text_interval_suffix_ms_time_mode", False, "feature_missing: no BPM toggle in interval dialog", depth=1, jump_kind="transition", expect="suffix 'ms' in TIME, gone in BPM") return tap_node(bpm) settle("tap") suffix2 = node_by_id(ui(), "textinput_suffix_text") gone = (suffix2 is None) or (norm(suffix2.get("text")) != norm("ms")) ok = in_time and gone record("text_interval_suffix_ms_time_mode", ok, "" if ok else "behavior_wrong: suffix 'ms' not produced in TIME mode or not removed in BPM mode", depth=1, jump_kind="transition", expect="suffix text == 'ms' in TIME mode, absent after BPM") @and_test(expects=("text_interval_counter_time_vs_bpm",)) def test_interval_counter_time_vs_bpm(): """The character counter is produced content: '3/5' in TIME, '3/3' after BPM. Assert the exact '3/5' string in TIME then '3/3' after switching.""" if not _home(): record("text_interval_counter_time_vs_bpm", False, "setup_failed: home surface not reached", depth=1, jump_kind="transition", expect="counter '3/5' TIME then '3/3' BPM") return if not and_enter_interval_dialog(): record("text_interval_counter_time_vs_bpm", False, "setup_failed: interval dialog not reached", depth=1, jump_kind="transition", expect="counter '3/5' TIME then '3/3' BPM") return counter = node_by_id(ui(), "textinput_counter") in_time = bool(counter and norm(counter.get("text")) == norm("3/5")) bpm = node_by_id(ui(), "bpm_button") or find_node_ci(ui(), "BPM") if not bpm: record("text_interval_counter_time_vs_bpm", False, "feature_missing: no BPM toggle in interval dialog", depth=1, jump_kind="transition", expect="counter '3/5' TIME then '3/3' BPM") return tap_node(bpm) settle("tap") counter2 = node_by_id(ui(), "textinput_counter") in_bpm = bool(counter2 and norm(counter2.get("text")) == norm("3/3")) ok = in_time and in_bpm record("text_interval_counter_time_vs_bpm", ok, "" if ok else "behavior_wrong: counter not '3/5' in TIME and '3/3' in BPM", depth=1, jump_kind="transition", expect="counter text == '3/5' in TIME, '3/3' after BPM") @and_test(expects=("text_interval_value_not_allowed",)) def test_interval_value_not_allowed(): """Switch to BPM (range 10–200), clear the input and type '5' (below min), tap Flash → the produced error 'Value not allowed'. Absent before, present after. depth 1.""" if not _home(): record("text_interval_value_not_allowed", False, "setup_failed: home surface not reached", depth=1, jump_kind="transition", expect="error 'Value not allowed'") return if not and_enter_interval_dialog(): record("text_interval_value_not_allowed", False, "setup_failed: interval dialog not reached", depth=1, jump_kind="transition", expect="error 'Value not allowed'") return bpm = node_by_id(ui(), "bpm_button") or find_node_ci(ui(), "BPM") if not bpm: record("text_interval_value_not_allowed", False, "feature_missing: no BPM toggle in interval dialog", depth=1, jump_kind="transition", expect="error 'Value not allowed'") return tap_node(bpm) settle("tap") absent = "value not allowed" not in norm(all_text(ui())) inp = node_by_id(ui(), "number_input_text") if not inp: record("text_interval_value_not_allowed", False, "setup_failed: number input not found in interval dialog", depth=1, jump_kind="transition", expect="error 'Value not allowed'") return # focus + clear the existing value, then type an out-of-range one tap_node(inp) settle("keyboard") for _ in range(6): press_key("KEYCODE_DEL") settle("text") type_text(node_by_id(ui(), "number_input_text"), "5") flash = node_by_id(ui(), "flash_button") or find_node_ci(ui(), "Flash") if not flash: record("text_interval_value_not_allowed", False, "feature_missing: no Flash button in interval dialog", depth=1, jump_kind="transition", expect="error 'Value not allowed'") return tap_node(flash) settle("tap") present = "value not allowed" in norm(all_text(ui())) ok = absent and present # stop any flashing that may have started, keep isolation clean stop = node_by_id(ui(), "stop_button") if stop: tap_node(stop) settle("tap") record("text_interval_value_not_allowed", ok, "" if ok else "behavior_wrong: out-of-range BPM value did not produce 'Value not allowed'", depth=1, jump_kind="transition", expect="error text == 'Value not allowed'") # ═════════════════════════════════════════════════════════════════════════════ # SECTION D — Dialog titles / descriptions revealed by an action (depth 1–2). # ═════════════════════════════════════════════════════════════════════════════ @and_test(expects=("text_about_dialog_title", "text_about_dialog_title_vlm")) def test_about_dialog_title(): """Tapping the toolbar Icon-Credits action reveals the About dialog whose alertTitle == 'About'. Absent on home, present in the dialog. depth 1.""" if not _home(): record("text_about_dialog_title", False, "setup_failed: home surface not reached", depth=1, jump_kind="transition", expect="alertTitle == 'About'") return absent_before = find_node_ci(ui(), "Show Icon Credits") is None if not and_enter_about_dialog(): record("text_about_dialog_title", False, "feature_missing: About dialog / title 'About' not revealed", depth=1, jump_kind="transition", expect="alertTitle == 'About'") return at = node_by_id(ui(), "alertTitle") present = bool(at and norm(at.get("text")) == norm("About")) ok = absent_before and present record("text_about_dialog_title", ok, "" if ok else "behavior_wrong: About dialog title 'About' not produced by Icon-Credits action", depth=1, jump_kind="transition", expect="alertTitle text == 'About'") # VLM: the About body is a multi-line device/version block that renders as # free-form drawn text rows — confirm the produced multi-line info block. vlm_assert("text_about_dialog_title", "In this About dialog, is there a multi-line block of " "device/version information showing labels such as 'Version', " "'Model' and 'OS' on separate lines?", RESULTS_DIR, expect="YES", depth=1, jump_kind="transition", tag="layout") @and_test(expects=("text_icon_credits_dialog_title",)) def test_icon_credits_dialog_title(): """About → tap 'Show Icon Credits' → a second dialog whose alertTitle == 'Icon Credits'. Depth 2, backed by and_enter_about_dialog() then the tap. Assert the title 'Icon Credits' is ABSENT in the About dialog and PRESENT in the second dialog.""" if not _home(): record("text_icon_credits_dialog_title", False, "setup_failed: home surface not reached", depth=2, jump_kind="transition", expect="second alertTitle == 'Icon Credits'") return if not and_enter_about_dialog(): record("text_icon_credits_dialog_title", False, "setup_failed: About dialog not reached", depth=2, jump_kind="transition", expect="second alertTitle == 'Icon Credits'") return at1 = node_by_id(ui(), "alertTitle") absent = bool(at1 and norm(at1.get("text")) != norm("Icon Credits")) btn = node_by_id(ui(), "button1") or find_node_ci(ui(), "Show Icon Credits") if not btn: record("text_icon_credits_dialog_title", False, "feature_missing: no 'Show Icon Credits' button in About dialog", depth=2, jump_kind="transition", expect="second alertTitle == 'Icon Credits'") return tap_node(btn) settle("tap") and_enter("icon_credits_dialog") at2 = node_by_id(ui(), "alertTitle") present = bool(at2 and norm(at2.get("text")) == norm("Icon Credits")) ok = absent and present record("text_icon_credits_dialog_title", ok, "" if ok else "behavior_wrong: 'Show Icon Credits' did not open a dialog titled 'Icon Credits'", depth=2, jump_kind="transition", expect="second-dialog alertTitle text == 'Icon Credits'") @and_test(expects=("text_links_dialog_title",)) def test_links_dialog_title(): """Toolbar Visit-on-GitHub action reveals the Links dialog whose alertTitle == 'Links'. Absent on home, present in the dialog. depth 1.""" if not _home(): record("text_links_dialog_title", False, "setup_failed: home surface not reached", depth=1, jump_kind="transition", expect="alertTitle == 'Links'") return absent_before = "repository on github" not in norm(all_text(ui())) if not and_enter_links_dialog(): record("text_links_dialog_title", False, "feature_missing: Links dialog / title 'Links' not revealed", depth=1, jump_kind="transition", expect="alertTitle == 'Links'") return at = node_by_id(ui(), "alertTitle") present = bool(at and norm(at.get("text")) == norm("Links")) ok = absent_before and present record("text_links_dialog_title", ok, "" if ok else "behavior_wrong: Links dialog title 'Links' not produced by GitHub action", depth=1, jump_kind="transition", expect="alertTitle text == 'Links'") @and_test(expects=("text_links_github_desc",)) def test_links_github_desc(): """Inside the Links dialog the GitHub row description is produced content == 'Repository on GitHub'. Absent on home, present in the dialog. depth 1.""" if not _home(): record("text_links_github_desc", False, "setup_failed: home surface not reached", depth=1, jump_kind="transition", expect="github_desc == 'Repository on GitHub'") return absent = "repository on github" not in norm(all_text(ui())) if not and_enter_links_dialog(): record("text_links_github_desc", False, "setup_failed: Links dialog not reached", depth=1, jump_kind="transition", expect="github_desc == 'Repository on GitHub'") return desc = node_by_id(ui(), "github_desc") txt = norm(desc.get("text")) if desc else norm(all_text(ui())) present = "repository on github" in txt ok = absent and present record("text_links_github_desc", ok, "" if ok else "behavior_wrong: Links GitHub row description 'Repository on GitHub' not produced", depth=1, jump_kind="transition", expect="github_desc text == 'Repository on GitHub'") @and_test(expects=("text_links_matrix_desc",)) def test_links_matrix_desc(): """Inside the Links dialog the Matrix row description is produced content == 'Matrix chat room (questions, feedback, discussions)'. depth 1.""" if not _home(): record("text_links_matrix_desc", False, "setup_failed: home surface not reached", depth=1, jump_kind="transition", expect="matrix_desc == 'Matrix chat room (questions, feedback, discussions)'") return expected = "Matrix chat room (questions, feedback, discussions)" absent = norm(expected) not in norm(all_text(ui())) if not and_enter_links_dialog(): record("text_links_matrix_desc", False, "setup_failed: Links dialog not reached", depth=1, jump_kind="transition", expect="matrix_desc == " + repr(expected)) return desc = node_by_id(ui(), "matrix_desc") txt = norm(desc.get("text")) if desc else norm(all_text(ui())) present = norm(expected) in txt ok = absent and present record("text_links_matrix_desc", ok, "" if ok else "behavior_wrong: Links Matrix row description not produced exactly", depth=1, jump_kind="transition", expect="matrix_desc text == 'Matrix chat room (questions, feedback, discussions)'") # ═════════════════════════════════════════════════════════════════════════════ # SECTION E — Settings summary produced text (depth 1). # ═════════════════════════════════════════════════════════════════════════════ @and_test(expects=("text_settings_preferred_level_summary",)) def test_settings_preferred_level_summary(): """The 'Preferred level' summary is dynamically formatted with the current level appended: it contains 'Dim level' and ends with ': 10' on fresh data. Absent on home, present in Settings. depth 1.""" if not _home_clean(): record("text_settings_preferred_level_summary", False, "setup_failed: home surface not reached after clear_data", depth=1, jump_kind="transition", expect="Preferred-level summary contains 'Dim level', ends ': 10'") return absent = "dim level" not in norm(all_text(ui())) if not and_enter_settings(): record("text_settings_preferred_level_summary", False, "feature_missing: Settings / 'Preferred level' not reached", depth=1, jump_kind="transition", expect="Preferred-level summary contains 'Dim level', ends ': 10'") return # the summary is the TextView that carries the produced 'Dim level ... : N' n = ui() summary = None for x in n: t = norm(x.get("text")) if "dim level" in t: summary = x.get("text", "") break present = (summary is not None and "dim level" in norm(summary) and summary.rstrip().endswith(": 10")) ok = absent and present record("text_settings_preferred_level_summary", ok, "" if ok else "behavior_wrong: Preferred-level summary did not produce 'Dim level...: 10'", depth=1, jump_kind="transition", expect="Preferred-level summary contains 'Dim level' and ends ': 10'") @and_test(expects=("text_settings_about_row_summary",)) def test_settings_about_row_summary(): """The Settings about-row shows produced title/summary 'FlashDim Dev' / 'by Cyb3rKo'. Assert the summary 'by Cyb3rKo' is ABSENT on home and PRESENT once Settings is open. depth 1.""" if not _home(): record("text_settings_about_row_summary", False, "setup_failed: home surface not reached", depth=1, jump_kind="transition", expect="about-row summary 'by Cyb3rKo'") return absent = "by cyb3rko" not in norm(all_text(ui())) if not and_enter_settings(): record("text_settings_about_row_summary", False, "feature_missing: Settings not reached", depth=1, jump_kind="transition", expect="about-row summary 'by Cyb3rKo'") return present = "by cyb3rko" in norm(all_text(ui())) ok = absent and present record("text_settings_about_row_summary", ok, "" if ok else "behavior_wrong: Settings about-row summary 'by Cyb3rKo' not produced", depth=1, jump_kind="transition", expect="about-row summary text == 'by Cyb3rKo'") @and_test(expects=("text_settings_instant_flash_summary",)) def test_settings_instant_flash_summary(): """The 'Instant flash' preference shows the produced summary 'Activate flashlight on app startup'. Absent on home, present in Settings. depth 1.""" if not _home(): record("text_settings_instant_flash_summary", False, "setup_failed: home surface not reached", depth=1, jump_kind="transition", expect="summary 'Activate flashlight on app startup'") return expected = "Activate flashlight on app startup" absent = norm(expected) not in norm(all_text(ui())) if not and_enter_settings(): record("text_settings_instant_flash_summary", False, "feature_missing: Settings not reached", depth=1, jump_kind="transition", expect="summary " + repr(expected)) return present = norm(expected) in norm(all_text(ui())) ok = absent and present record("text_settings_instant_flash_summary", ok, "" if ok else "behavior_wrong: 'Instant flash' summary 'Activate flashlight on app startup' not produced", depth=1, jump_kind="transition", expect="summary text == 'Activate flashlight on app startup'") TESTS = [ # Section A — home dynamic status (depth 0) test_sos_mode_indicator, test_sos_quick_actions_morse, test_quick_actions_restored_off, test_indicator_restored_off, # Section B — morse validation errors (depth 1) test_morse_error_empty, test_morse_error_invalid_chars, test_morse_hint_on_open, # Section C — interval produced text (depth 1) test_interval_seizure_warning, test_interval_suffix_ms_time_mode, test_interval_counter_time_vs_bpm, test_interval_value_not_allowed, # Section D — dialog titles / descriptions (depth 1–2) test_about_dialog_title, test_icon_credits_dialog_title, test_links_dialog_title, test_links_github_desc, test_links_matrix_desc, # Section E — settings summaries (depth 1) test_settings_preferred_level_summary, test_settings_about_row_summary, test_settings_instant_flash_summary, ] if __name__ == "__main__": run_suite(TESTS, "text")