VoyagerXHF's picture
Upload folder using huggingface_hub (part 3)
c1c6a0c verified
Raw History Blame Contribute Delete
36.7 kB
#!/usr/bin/env python3
"""TEXT lane — Simple Time Tracker.
SOLE OWNER of exact-string equality. Every test here follows the discipline
TRIGGER -> the app PRODUCES a string -> assert that EXACT (normalised) string.
The strongest targets are content strings the app WRITES as a consequence of a
user action, which a dead shell that only echoes chrome cannot fake:
* an activity NAME typed into the Add screen, echoed back on its Timers tile
(absent before the create -> present after) — the flagship produced string;
* the same name reproduced on the Records-tab row and the Statistics legend,
plus the produced "-" time separator and the produced "100%" percent label;
* the "More" <-> "Less" toggler label FLIP on the Add screen;
* contextual hints the app authors as a consequence of REACHING / EMPTYING a
surface ("Click on activity to start tracking", "Click on record to edit",
the Timers big-hint, Pomodoro's "Focus"/"25"/"00"/"m"/"s");
* a few app-authored Settings titles / subtitle as content copy.
NOT owned here: a computed duration (computation), a checked bit (states), tree
shape (structure), reachability (navigation). Where a value like "100%" is also
a computed number, this lane asserts it strictly as the exact STRING "100%".
CANVAS-ONLY text (2 VLM): the running-record card is a custom-drawn view whose
"activity / elapsed time / Click on card to stop tracking" text NEVER reaches
the uiautomator tree, and the Statistics pie chart draws its slices on canvas.
Those two are the only legitimate VLM questions here — every other string is
dump-readable and stays a rule assertion.
GROUND TRUTH re-derived live on the running original (v1.58 debug): every
asserted string below was read out of a fresh ui() on the real app; nothing is
read from source. DUMPS ARE SLOW (~11s) so each test minimises ui() calls, opens
its OWN entry point (clear_data / restart), and any test that starts a timer
stops it so it never desyncs a later test.
"""
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from android_testgen_kit import * # noqa: F403,E402
PACKAGE = sys.argv[1] if len(sys.argv) > 1 else os.environ.get("PACKAGE", "")
RESULTS_DIR = (sys.argv[2] if len(sys.argv) > 2
else os.environ.get("RESULTS_DIR", os.path.dirname(os.path.abspath(__file__))))
init(module="text", package=PACKAGE, results_dir=RESULTS_DIR)
# ── local recipes (from recon; kit-only, nothing hardcoded) ────────────────────
def tile(nodes, label):
"""The clickable tile CONTAINER whose bounds enclose the name TextView. Tapping
it STARTS/STOPS a timer or (long-pressed) opens the activity editor."""
name = next((n for n in nodes if (n.get("text") or "") == label
and (n.get("resource-id") or "").endswith("tvRecordTypeItemName")), None)
if not name:
return None
nb = name["_bounds"]
for n in nodes:
if (n.get("resource-id") or "").endswith("viewRecordTypeItem") \
and n.get("clickable") == "true":
b = n["_bounds"]
if b[0] <= nb[0] and b[2] >= nb[2] and b[1] <= nb[1] and b[3] >= nb[3]:
return n
return None
def tab_trigger(nodes, desc):
return next((n for n in nodes if (n.get("content-desc") or "") == desc), None)
def open_fresh():
"""Clean ENTRY POINT: a virgin database + a fresh launch. Setup only — every
asserted string below is then PRODUCED by a real in-app action."""
clear_data()
launch_app()
wait_for_foreground()
settle("launch")
return ui()
def create_activity(name, method="auto"):
"""From Timers: Add tile -> type name -> SAVE. Leaves you on Timers."""
tap_node(tile(ui(), "Add"))
settle("nav")
type_text(node_by_id(ui(), "etChangeRecordTypeName"), name, method=method)
hide_keyboard()
tap_node(node_by_id(ui(), "btnChangeRecordTypeSave"))
settle("nav")
return ui()
def and_enter_add_screen():
"""From Timers: tap the Add tile -> the change-activity screen. NAME backs the
depth claim; counts one surface and confirms the name field is present."""
t = tile(ui(), "Add")
if not t or not tap_node(t):
return False
settle("nav")
and_enter("add_activity")
return node_by_id(ui(), "etChangeRecordTypeName") is not None
def start_timer(name):
t = tile(ui(), name)
if not t:
return False
tap_node(t)
settle("nav")
return True
def stop_timer():
"""Tap the CANVAS running card at the top of rvRunningRecordsList to STOP."""
rv = node_by_id(ui(), "rvRunningRecordsList")
if not rv:
return False
s = get_screen_info()
tap(s["center_x"], rv["_bounds"][1] + 90)
settle("nav")
settle("nav")
return True
def seed_record(name):
"""Create `name`, then start+stop once so a completed record exists AND the
Records tab's tree materialises."""
create_activity(name)
if not start_timer(name):
return False
return stop_timer()
def texts_with_id(rid_suffix, nodes=None):
nodes = ui() if nodes is None else nodes
return [n.get("text") or "" for n in nodes
if (n.get("resource-id") or "").endswith(rid_suffix)]
def text_of(rid_suffix, nodes=None):
vals = texts_with_id(rid_suffix, nodes)
return vals[0] if vals else None
def all_text(nodes=None):
nodes = ui() if nodes is None else nodes
return " | ".join(n.get("text", "") for n in nodes if n.get("text"))
def and_reach_records():
"""Switch to the Records tab and CONFIRM the jump: btnRecordsContainerAdd (a
Records-only anchor) appeared. Records' tree only exists once a record does,
so call only after seed_record()."""
t = tab_trigger(ui(), "Records")
if not t:
return False
tap_node(t)
settle("nav")
settle("nav")
and_enter("records")
return node_by_id(ui(), "btnRecordsContainerAdd") is not None
def and_reach_statistics():
"""Switch to the Statistics tab. NAME backs the depth claim."""
t = tab_trigger(ui(), "Statistics")
if not t:
return False
tap_node(t)
settle("nav")
settle("nav")
and_enter("statistics")
return True
def and_enter_settings():
"""Switch to the Settings tab. NAME backs the depth claim."""
t = tab_trigger(ui(), "Settings")
if not t:
return False
tap_node(t)
settle("nav")
and_enter("settings")
return find_node_ci(ui(), "Allow multitasking") is not None
def and_enter_pomodoro():
"""From Timers: tap the Pomodoro tile -> the full-screen Pomodoro timer.
NAME backs the depth claim; confirms the minutes label is present."""
t = tile(ui(), "Pomodoro")
if not t or not tap_node(t):
return False
settle("nav")
and_enter("pomodoro")
return node_by_id(ui(), "tvPomodoroTimerMinutes") is not None
# ══════════════════════════════════════════════════════════════════════════════
# A1. Activity NAME echoed on its tile — the flagship produced string [+VLM canvas]
# Also spends VLM #1: the running-record CARD text (canvas-only, not in ui()).
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("text_tile_name_echo", "text_running_card_text_vlm"))
def test_tile_name_echo():
open_fresh()
NAME = "ReadFocus"
absent_before = tile(ui(), NAME) is None
add = tile(ui(), "Add")
if add is None:
record("text_tile_name_echo", False,
"setup_failed: no Add tile on the Timers surface to create an activity",
depth=0, jump_kind="value", expect=f"tile text == {NAME!r}")
vlm_assert("text_running_card_text", "unreachable", RESULTS_DIR,
expect="YES", depth=0, jump_kind="none", tag="content")
return
create_activity(NAME)
got = texts_with_id("tvRecordTypeItemName")
present_after = NAME in got
ok = absent_before and present_after
record("text_tile_name_echo", ok,
"" if ok else "behavior_wrong: created activity name not echoed exactly on a "
f"tile (absent_before={absent_before}, tile names={got})",
depth=0, jump_kind="value",
expect=f"tvRecordTypeItemName text == {NAME!r} (absent before create)")
# VLM #1: start the timer so the CANVAS running card renders, ask about its
# text (activity name + running time + stop hint) — none of which is in ui().
if start_timer(NAME):
vlm_assert("text_running_card_text",
f"Does the wide coloured card at the very TOP of the screen show the "
f"activity name '{NAME}' together with a running elapsed time, and the "
"hint text 'Click on card to stop tracking' below it? Answer YES only "
"if that hint text is visible.",
RESULTS_DIR, expect="YES", depth=0, jump_kind="value", tag="content")
stop_timer() # never leave a timer running for the next test
else:
vlm_assert("text_running_card_text", "unreachable", RESULTS_DIR,
expect="YES", depth=0, jump_kind="none", tag="content")
# ══════════════════════════════════════════════════════════════════════════════
# A2. Activity name with a SPACE echoed exactly on its tile
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("text_tile_name_with_space",))
def test_tile_name_with_space():
open_fresh()
NAME = "Deep Work"
absent_before = NAME not in texts_with_id("tvRecordTypeItemName")
if tile(ui(), "Add") is None:
record("text_tile_name_with_space", False,
"setup_failed: no Add tile to create an activity",
depth=0, jump_kind="value", expect=f"tile text == {NAME!r}")
return
create_activity(NAME)
got = texts_with_id("tvRecordTypeItemName")
ok = absent_before and (NAME in got)
record("text_tile_name_with_space", ok,
"" if ok else "behavior_wrong: multi-word activity name not preserved exactly on "
f"its tile (got {got})",
depth=0, jump_kind="value",
expect=f"tvRecordTypeItemName text == {NAME!r} (space preserved)")
# ══════════════════════════════════════════════════════════════════════════════
# A3. Mixed-case + digit activity name echoed EXACTLY (case & digits preserved).
# (An accented name is not typeable through Clipper OR ADB-Keyboard into this
# custom name field on the test emulator, so that round-trip is unobservable —
# a second ASCII produced-string case keeps the denominator strong instead.)
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("text_tile_name_alnum",))
def test_tile_name_alnum():
open_fresh()
NAME = "Yoga2Go"
absent_before = NAME not in texts_with_id("tvRecordTypeItemName")
if tile(ui(), "Add") is None:
record("text_tile_name_alnum", False,
"setup_failed: no Add tile to create an activity",
depth=0, jump_kind="value", expect=f"tile text == {NAME!r}")
return
create_activity(NAME)
got = texts_with_id("tvRecordTypeItemName")
ok = absent_before and (NAME in got) # exact, case-sensitive match
record("text_tile_name_alnum", ok,
"" if ok else "behavior_wrong: mixed-case/digit activity name not echoed exactly "
f"on its tile (got {got})",
depth=0, jump_kind="value",
expect=f"tvRecordTypeItemName text == {NAME!r} (case & digits preserved)")
# ══════════════════════════════════════════════════════════════════════════════
# B. RECORD ROW: the activity name + the "-" time separator produced on the row
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("text_record_row_name", "text_record_row_separator"))
def test_record_row_strings():
open_fresh()
NAME = "RowKit"
if not seed_record(NAME):
for nm in ("text_record_row_name", "text_record_row_separator"):
record(nm, False,
"setup_failed: could not seed a record via start->stop",
depth=1, jump_kind="value", expect=f"record row for {NAME!r}")
return
if not and_reach_records():
for nm in ("text_record_row_name", "text_record_row_separator"):
record(nm, False,
"setup_failed: Records tab did not render its add anchor",
depth=1, jump_kind="value", expect=f"record row for {NAME!r}")
return
nodes = ui()
names = texts_with_id("tvRecordItemName", nodes)
ok_name = NAME in names
record("text_record_row_name", ok_name,
"" if ok_name else "behavior_wrong: record row name does not match the created "
f"activity exactly (got {names})",
depth=1, jump_kind="value",
expect=f"tvRecordItemName text == {NAME!r} on the produced record row")
seps = [s.strip() for s in texts_with_id("tvRecordItemTimeSeparator", nodes)]
ok_sep = "-" in seps
record("text_record_row_separator", ok_sep,
"" if ok_sep else "behavior_wrong: record row time separator is not '-' "
f"(got {seps})",
depth=1, jump_kind="value",
expect="tvRecordItemTimeSeparator text == '-' on the produced record row")
# ══════════════════════════════════════════════════════════════════════════════
# C. STATISTICS legend: activity NAME + the produced "100%" percent STRING [+VLM]
# Spends VLM #2: the pie chart is a custom canvas view (its slices are drawn,
# not in ui()).
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("text_stats_legend_name", "text_stats_percent",
"text_stats_pie_chart_vlm"))
def test_statistics_strings():
open_fresh()
NAME = "StatKit"
if not seed_record(NAME):
for nm in ("text_stats_legend_name", "text_stats_percent"):
record(nm, False, "setup_failed: could not seed the single record",
depth=1, jump_kind="value", expect=f"legend for {NAME!r}")
vlm_assert("text_stats_pie_chart", "unreachable", RESULTS_DIR,
expect="YES", depth=1, jump_kind="none", tag="shape")
return
if not and_reach_statistics():
for nm in ("text_stats_legend_name", "text_stats_percent"):
record(nm, False, "setup_failed: Statistics tab not reachable",
depth=1, jump_kind="value", expect=f"legend for {NAME!r}")
vlm_assert("text_stats_pie_chart", "unreachable", RESULTS_DIR,
expect="YES", depth=1, jump_kind="none", tag="shape")
return
nodes = ui()
names = texts_with_id("tvStatisticsItemName", nodes)
ok_name = NAME in names
record("text_stats_legend_name", ok_name,
"" if ok_name else "behavior_wrong: statistics legend name does not match the "
f"single activity exactly (got {names})",
depth=1, jump_kind="value",
expect=f"tvStatisticsItemName text == {NAME!r}")
pcts = [p.strip() for p in texts_with_id("tvStatisticsItemPercent", nodes)]
ok_pct = "100%" in pcts
record("text_stats_percent", ok_pct,
"" if ok_pct else "behavior_wrong: sole activity's statistics percent is not the "
f"string '100%' (got {pcts})",
depth=1, jump_kind="value",
expect="tvStatisticsItemPercent text == '100%' for the sole activity")
# VLM #2: the pie chart itself is canvas-drawn.
vlm_assert("text_stats_pie_chart",
"Is there a round pie / doughnut chart drawn on this Statistics screen, "
"above the legend row?",
RESULTS_DIR, expect="YES", depth=1, jump_kind="value", tag="shape")
# ══════════════════════════════════════════════════════════════════════════════
# D. "More" <-> "Less" toggler LABEL flip on the Add-activity screen (produced)
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("text_more_less_flip",))
def test_more_less_flip():
open_fresh()
if not and_enter_add_screen():
record("text_more_less_flip", False,
"setup_failed: could not open the Add-activity screen",
depth=1, jump_kind="transition", expect="More->Less->More")
return
tog = node_by_id(ui(), "tvChangeRecordTypeMoreFieldsText")
if tog is None:
record("text_more_less_flip", False,
"feature_missing: no More/Less toggler on the Add-activity screen",
depth=1, jump_kind="transition", expect="More->Less->More")
return
first = (tog.get("text") or "").strip()
tap_node(tog)
settle("nav")
tog2 = node_by_id(ui(), "tvChangeRecordTypeMoreFieldsText")
second = (tog2.get("text") or "").strip() if tog2 else ""
if tog2:
tap_node(tog2)
settle("nav")
tog3 = node_by_id(ui(), "tvChangeRecordTypeMoreFieldsText")
third = (tog3.get("text") or "").strip() if tog3 else ""
ok = (first.lower() == "more" and second.lower() == "less"
and third.lower() == "more")
record("text_more_less_flip", ok,
"" if ok else "behavior_wrong: toggler label did not flip More->Less->More "
f"(observed {first!r} -> {second!r} -> {third!r})",
depth=1, jump_kind="transition",
expect=f"toggler label {first!r}->'Less'->'More' across two taps")
# ══════════════════════════════════════════════════════════════════════════════
# E1. Timers BIG HINT copy on a fresh/empty database (produced by emptying)
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("text_timers_big_hint",))
def test_timers_big_hint():
open_fresh()
hint = text_of("tvHintBigText")
EXPECT = "To start tracking, add activities by clicking on Add button"
if hint is None:
record("text_timers_big_hint", False,
"feature_missing: no tvHintBigText on the fresh Timers surface",
depth=0, jump_kind="value", expect=f"hint startswith {EXPECT!r}")
return
norm = hint.strip().casefold()
ok = norm.startswith(EXPECT.casefold())
record("text_timers_big_hint", ok,
"" if ok else "behavior_wrong: Timers empty-state big hint copy differs "
f"(got {hint!r})",
depth=0, jump_kind="value",
expect=f"tvHintBigText startswith {EXPECT!r}")
# ══════════════════════════════════════════════════════════════════════════════
# E2. Empty-item hints appear AFTER creating an activity (contextual, produced)
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("text_empty_item_hint", "text_empty_item_subhint"))
def test_empty_item_hints():
open_fresh()
EXPECT_MAIN = "Click on activity to start tracking"
EXPECT_SUB = "Long click to edit"
before = all_text().lower()
absent_before = EXPECT_MAIN.lower() not in before
if tile(ui(), "Add") is None:
for nm in ("text_empty_item_hint", "text_empty_item_subhint"):
record(nm, False, "setup_failed: no Add tile to create an activity",
depth=0, jump_kind="value", expect="empty-item hint appears")
return
create_activity("HintKit")
nodes = ui()
main = text_of("tvEmptyItem", nodes)
sub = text_of("tvEmptyItemHint", nodes)
ok_main = (main is not None
and main.strip().casefold() == EXPECT_MAIN.casefold()
and absent_before)
record("text_empty_item_hint", ok_main,
"" if ok_main else "behavior_wrong: empty-item hint copy differs / not produced by "
f"creating an activity (absent_before={absent_before}, got {main!r})",
depth=0, jump_kind="value",
expect=f"tvEmptyItem text == {EXPECT_MAIN!r} (appears after first activity)")
ok_sub = (sub is not None and sub.strip().casefold() == EXPECT_SUB.casefold())
record("text_empty_item_subhint", ok_sub,
"" if ok_sub else f"behavior_wrong: empty-item sub-hint copy differs (got {sub!r})",
depth=0, jump_kind="value",
expect=f"tvEmptyItemHint text == {EXPECT_SUB!r}")
# ══════════════════════════════════════════════════════════════════════════════
# E3. Records-tab hint copy (produced once the Records surface renders)
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("text_records_hint",))
def test_records_hint():
open_fresh()
NAME = "RecHintKit"
EXPECT = "Click on record to edit"
if not (seed_record(NAME) and and_reach_records()):
record("text_records_hint", False,
"setup_failed: could not reach a rendered Records tab",
depth=1, jump_kind="value", expect=f"hint == {EXPECT!r}")
return
hint = text_of("tvHintItemText")
ok = hint is not None and hint.strip().casefold() == EXPECT.casefold()
record("text_records_hint", ok,
"" if ok else f"behavior_wrong: Records hint copy differs (got {hint!r})",
depth=1, jump_kind="value",
expect=f"tvHintItemText text == {EXPECT!r}")
# ══════════════════════════════════════════════════════════════════════════════
# E4. Statistics-tab hint copy (produced once a record exists)
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("text_statistics_hint",))
def test_statistics_hint():
open_fresh()
NAME = "StatHintKit"
EXPECT = "Click on card to view detailed statistics"
if not (seed_record(NAME) and and_reach_statistics()):
record("text_statistics_hint", False,
"setup_failed: could not reach the Statistics tab with a record present",
depth=1, jump_kind="value", expect=f"hint == {EXPECT!r}")
return
blob = all_text().casefold()
ok = EXPECT.casefold() in blob
record("text_statistics_hint", ok,
"" if ok else "behavior_wrong: Statistics hint copy not found "
f"(expected {EXPECT!r})",
depth=1, jump_kind="value",
expect=f"Statistics hint text contains {EXPECT!r}")
# ══════════════════════════════════════════════════════════════════════════════
# F1. Add-screen field labels the app authors: "Color" and "Icon"
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("text_add_field_labels",))
def test_add_field_labels():
open_fresh()
if not and_enter_add_screen():
record("text_add_field_labels", False,
"setup_failed: could not open the Add-activity screen",
depth=1, jump_kind="value",
expect="Add-activity screen shows field labels 'Color' and 'Icon'")
return
blob = all_text().casefold()
ok = ("color" in blob) and ("icon" in blob)
record("text_add_field_labels", ok,
"" if ok else "behavior_wrong: Add-activity screen missing the 'Color' and 'Icon' "
f"field labels (screen text: {all_text()[:120]!r})",
depth=1, jump_kind="value",
expect="Add-activity screen shows field labels 'Color' and 'Icon'")
# ══════════════════════════════════════════════════════════════════════════════
# F2. Name-field HINT on the Add screen (app-authored input hint)
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("text_name_field_hint",))
def test_name_field_hint():
open_fresh()
if not and_enter_add_screen():
record("text_name_field_hint", False,
"setup_failed: could not open the Add-activity screen",
depth=1, jump_kind="value", expect="name field hint == 'Enter new name'")
return
et = node_by_id(ui(), "etChangeRecordTypeName")
if et is None:
record("text_name_field_hint", False,
"feature_missing: no name EditText on the Add-activity screen",
depth=1, jump_kind="value", expect="name field hint == 'Enter new name'")
return
hint = (et.get("text") or "").strip() # empty field renders its hint as text
ok = hint.casefold() == "enter new name"
record("text_name_field_hint", ok,
"" if ok else f"behavior_wrong: name-field hint copy differs (got {hint!r})",
depth=1, jump_kind="value",
expect="etChangeRecordTypeName hint text == 'Enter new name'")
# ══════════════════════════════════════════════════════════════════════════════
# F3. SAVE button label on the Add screen (produced button copy)
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("text_save_button_label",))
def test_save_button_label():
open_fresh()
if not and_enter_add_screen():
record("text_save_button_label", False,
"setup_failed: could not open the Add-activity screen",
depth=1, jump_kind="value", expect="Save button label == 'Save'")
return
btn = node_by_id(ui(), "btnChangeRecordTypeSave")
if btn is None:
record("text_save_button_label", False,
"feature_missing: no Save button on the Add-activity screen",
depth=1, jump_kind="value", expect="Save button label == 'Save'")
return
label = (btn.get("text") or "").strip()
ok = label.casefold() == "save"
record("text_save_button_label", ok,
"" if ok else f"behavior_wrong: Save button label differs (got {label!r})",
depth=1, jump_kind="value",
expect="btnChangeRecordTypeSave text == 'Save' (case-insensitive)")
# ══════════════════════════════════════════════════════════════════════════════
# G1. Settings item TITLES the app authors (Allow multitasking / Dark mode / Language)
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("text_settings_titles",))
def test_settings_titles():
open_fresh()
if not and_enter_settings():
record("text_settings_titles", False,
"setup_failed: Settings tab did not render 'Allow multitasking'",
depth=1, jump_kind="value", expect="Settings titles present")
return
titles = [t.strip() for t in texts_with_id("tvItemSettingsTitle")]
low = [t.casefold() for t in titles]
want = ["allow multitasking", "dark mode", "language"]
missing = [w for w in want if w not in low]
ok = not missing
record("text_settings_titles", ok,
"" if ok else f"behavior_wrong: Settings missing expected titles {missing} "
f"(got {titles})",
depth=1, jump_kind="value",
expect="tvItemSettingsTitle set includes 'Allow multitasking','Dark mode','Language'")
# ══════════════════════════════════════════════════════════════════════════════
# G2. Multitasking SUBTITLE — app-authored copy
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("text_multitasking_subtitle",))
def test_multitasking_subtitle():
open_fresh()
# Exact live copy (recon's wording was stale — trust the running app).
EXPECT = "If disabled, starting new timer will automatically stop other activities."
if not and_enter_settings():
record("text_multitasking_subtitle", False,
"setup_failed: Settings tab did not render",
depth=1, jump_kind="value", expect=f"subtitle == {EXPECT!r}")
return
subs = [s.strip() for s in texts_with_id("tvItemSettingsSubtitle")]
ok = any(s.casefold() == EXPECT.casefold() for s in subs)
record("text_multitasking_subtitle", ok,
"" if ok else "behavior_wrong: multitasking subtitle copy differs from the "
f"observed string (expected {EXPECT!r}, subtitles {subs})",
depth=1, jump_kind="value",
expect=f"tvItemSettingsSubtitle text == {EXPECT!r}")
# ══════════════════════════════════════════════════════════════════════════════
# I1. Pomodoro static labels: minutes "25", seconds "00", cycle hint "Focus"
# (depth 1 — entered via and_enter_pomodoro; do NOT start the countdown)
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("text_pomodoro_time", "text_pomodoro_focus"))
def test_pomodoro_labels():
open_fresh()
if not and_enter_pomodoro():
for nm in ("text_pomodoro_time", "text_pomodoro_focus"):
record(nm, False,
"setup_failed: could not enter the Pomodoro screen",
depth=1, jump_kind="value", expect="Pomodoro labels")
return
nodes = ui()
mins = (text_of("tvPomodoroTimerMinutes", nodes) or "").strip()
secs = (text_of("tvPomodoroTimerSeconds", nodes) or "").strip()
ok_time = (mins == "25" and secs == "00")
record("text_pomodoro_time", ok_time,
"" if ok_time else "behavior_wrong: Pomodoro initial time labels are not 25:00 "
f"(minutes={mins!r}, seconds={secs!r})",
depth=1, jump_kind="value",
expect="tvPomodoroTimerMinutes=='25' and tvPomodoroTimerSeconds=='00'")
hint = (text_of("tvPomodoroCycleHint", nodes) or "").strip()
ok_focus = hint.casefold() == "focus"
record("text_pomodoro_focus", ok_focus,
"" if ok_focus else f"behavior_wrong: Pomodoro cycle hint is not 'Focus' (got {hint!r})",
depth=1, jump_kind="value",
expect="tvPomodoroCycleHint text == 'Focus'")
# ══════════════════════════════════════════════════════════════════════════════
# I2. Pomodoro minute/second LEGENDS "m" / "s" (app-authored units)
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("text_pomodoro_legends",))
def test_pomodoro_legends():
open_fresh()
if not and_enter_pomodoro():
record("text_pomodoro_legends", False,
"setup_failed: could not enter the Pomodoro screen",
depth=1, jump_kind="value", expect="legends 'm' and 's'")
return
nodes = ui()
m = (text_of("tvPomodoroTimerMinutesLegend", nodes) or "").strip()
s = (text_of("tvPomodoroTimerSecondsLegend", nodes) or "").strip()
ok = (m.casefold() == "m" and s.casefold() == "s")
record("text_pomodoro_legends", ok,
"" if ok else "behavior_wrong: Pomodoro minute/second legends are not 'm'/'s' "
f"(minutes legend={m!r}, seconds legend={s!r})",
depth=1, jump_kind="value",
expect="tvPomodoroTimerMinutesLegend=='m' and SecondsLegend=='s'")
TESTS = [
test_tile_name_echo,
test_tile_name_with_space,
test_tile_name_alnum,
test_record_row_strings,
test_statistics_strings,
test_more_less_flip,
test_timers_big_hint,
test_empty_item_hints,
test_records_hint,
test_statistics_hint,
test_add_field_labels,
test_name_field_hint,
test_save_button_label,
test_settings_titles,
test_multitasking_subtitle,
test_pomodoro_labels,
test_pomodoro_legends,
]
if __name__ == "__main__":
if not device_online():
print("Device not online — aborting.")
sys.exit(1)
run_suite(TESTS, "text")