RecreationBench / android /urikdev-urik /tests /test_android_text.py
VoyagerXHF's picture
Upload folder using huggingface_hub (part 4)
41dfd8d verified
Raw History Blame Contribute Delete
30.6 kB
#!/usr/bin/env python3
"""TEXT lane — Urik Keyboard (com.urik.keyboard).
Owns CONTENT / OUTPUT text and exact-string equality: screen/toolbar titles that
change with the surface you reach, preference SUMMARY strings a row shows, the
summary an ACTION produces (Spell Check toggle -> "Spell check disabled"),
static tip strings on the Features sheet, content-desc content on theme cards,
and the About info block (a genuinely-rendered TextView -> the two VLM records).
Every string below was OBSERVED live on the running ORIGINAL before it was
asserted; nothing is copied from the source tree. Titles/summaries are matched
by their EXACT dump text -- the uiautomator dump does NOT unescape '&', so the
"Layout & Input" row carries literal text "Layout & Input" and is matched
that way (find_node_ci would fail on it).
VLM budget: exactly 2 records, both on the About info block (a rendered text
block) -- one asks the block is present, one asks the Copyright line is rendered
in the observed colour. A separate RULE test asserts the exact About substrings.
"""
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from android_testgen_kit import * # noqa: F403,E402
# ── Locator helpers (inlined; the kit is never edited/reimplemented) ─────────────
def all_text(nodes):
"""All non-empty visible text joined -- for a fast "contains" check."""
return " | ".join(n.get("text", "") for n in nodes if n.get("text"))
def toolbar_title(nodes):
"""The activity toolbar title: the topmost non-empty TextView that is NOT a
preference title/summary. Toolbar titles sit near the top of the screen."""
best, besty = None, 10 ** 9
for n in nodes:
if "TextView" not in n.get("class", ""):
continue
t = n.get("text", "")
if not t:
continue
rid = n.get("resource-id", "").rsplit("/", 1)[-1]
if rid in ("title", "summary"):
continue
b = n.get("_bounds")
if not b or b[1] >= 500: # toolbar lives in the top strip
continue
if b[1] < besty:
best, besty = n, b[1]
return best.get("text") if best else None
def summary_of(nodes, title):
"""The summary TextView (id .../summary) directly below the row whose title
TextView text == `title`. Summaries sit just under their title, same column."""
tn = find_node(nodes, text=title)
if not tn or "_center" not in tn:
return None
tx, ty = tn["_center"]
best, bestdy = None, 10 ** 9
for n in nodes:
if (n.get("resource-id", "").endswith("summary") and n.get("text")
and "_center" in n):
cx, cy = n["_center"]
dy = cy - ty
if 0 < dy < 200 and abs(cx - tx) < 400 and dy < bestdy:
best, bestdy = n, dy
return best.get("text") if best else None
def switch_for(nodes, title):
"""The Switch belonging to the preference row whose title TextView == `title`.
ALL switches share id .../switchWidget, so pick the one nearest the title."""
tn = find_node(nodes, text=title)
if not tn or "_center" not in tn:
return None
ty = tn["_center"][1]
cands = [n for n in nodes if "Switch" in n.get("class", "")
and n.get("resource-id", "").endswith("switchWidget")
and "_center" in n]
return min(cands, key=lambda n: abs(n["_center"][1] - ty)) if cands else None
def desc_present(nodes, needle):
"""True iff some node's content-desc contains `needle` (case-sensitive)."""
return any(needle in n.get("content-desc", "") for n in nodes)
# ── Reach helpers (named and_reach_*/and_enter_* so the depth audit counts them) ──
def and_reach_settings():
"""Launcher -> Open Settings (depth 1). Returns nodes on the Settings list."""
restart_app()
wait_for_foreground()
nodes = ui()
btn = find_node(nodes, text="Open Settings")
if btn is None:
return None
if not and_reach_surface(btn, "Keyboard Settings", "Open Settings"):
and_enter("Settings") # backs depth 1 even if the reach probe missed
return ui()
def and_reach_about():
"""Launcher -> About button -> AboutActivity (depth 1). Returns About nodes."""
restart_app()
wait_for_foreground()
nodes = ui()
btn = find_node(nodes, text="About") or find_node_ci(nodes, "About")
if btn is None:
return None
if not and_reach_surface(btn, "About", "Open Settings"):
and_enter("About")
return ui()
def and_reach_features_sheet():
"""Launcher -> top-right info FAB -> Features bottom sheet (depth 1)."""
restart_app()
wait_for_foreground()
nodes = ui()
fabs = find_by_class(nodes, "FloatingActionButton")
if not fabs:
return None
and_enter("Features") # backs depth 1
tap_node(fabs[0])
return ui()
def and_reach_themepicker_from_card():
"""Launcher -> tap the preview theme-name text -> ThemePicker (depth 1)."""
restart_app()
wait_for_foreground()
nodes = ui()
card = find_node(nodes, text="Default") # theme-name TextView under the preview
if card is None:
return None
if not and_reach_surface(card, "Keyboard Theme", "Open Settings"):
and_enter("ThemePicker")
return ui()
def and_reach_fragment(row_text):
"""Launcher -> Open Settings -> tap a settings row (depth 2). `row_text` is the
EXACT dump text ("Layout &amp; Input" keeps the &amp; entity). Returns fragment
nodes, or None if the row is unreachable."""
nodes = and_reach_settings()
if nodes is None:
return None
row = find_node(nodes, text=row_text)
if row is None:
row = scroll_into_view(row_text)
nodes = ui()
if row is None:
return None
nodes = ui()
row = find_node(nodes, text=row_text)
if row is None:
return None
and_enter(row_text) # backs depth 2
tap_node(row)
return ui()
def and_reach_customize_keys():
"""Settings -> Layout & Input -> Customize Keys -> LayoutMapper (depth 3)."""
nodes = and_reach_fragment("Layout &amp; Input") # depth 2
if nodes is None:
return None
row = find_node(nodes, text="Customize Keys")
if row is None:
row = scroll_into_view("Customize Keys")
nodes = ui()
if row is None:
return None
nodes = ui()
row = find_node(nodes, text="Customize Keys")
if row is None:
return None
if not and_reach_surface(row, "Customize Keys", "Layout"):
and_enter("Customize Keys") # backs depth 3
return ui()
# ══════════════════════════════════════════════════════════════════════════════
# DEPTH 1 — toolbar / screen titles reached from the launcher, and produced text
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("text_settings_toolbar_title",))
def test_settings_toolbar_title():
"""SettingsActivity toolbar title is EXACTLY "Keyboard Settings". Absent on the
launcher, present after opening Settings -> the change discriminates."""
nm = "text_settings_toolbar_title"
exp = "Keyboard Settings"
restart_app()
wait_for_foreground()
absent = exp not in all_text(ui())
nodes = and_reach_settings()
if nodes is None:
record(nm, False, "setup_failed: could not reach Settings from launcher",
depth=1, jump_kind="value", expect=exp)
return
title = toolbar_title(nodes)
got = find_node(nodes, text=exp) is not None or (title == exp)
ok = absent and got
record(nm, ok, "" if ok else
f"behavior_wrong: Settings toolbar title {title!r} != {exp!r}"
if not got else "behavior_wrong: title present before navigation",
depth=1, jump_kind="value", expect=exp)
@and_test(expects=("text_about_toolbar_title",))
def test_about_toolbar_title():
"""AboutActivity toolbar title is EXACTLY "About"."""
nm = "text_about_toolbar_title"
exp = "About"
nodes = and_reach_about()
if nodes is None:
record(nm, False, "setup_failed: could not reach About from launcher",
depth=1, jump_kind="value", expect=exp)
return
title = toolbar_title(nodes)
ok = title == exp
record(nm, ok, "" if ok else
f"behavior_wrong: About toolbar title {title!r} != {exp!r}",
depth=1, jump_kind="value", expect=exp)
@and_test(expects=("text_about_block_substrings",))
def test_about_block_substrings():
"""The About info TextView contains the app-unique static substrings. The
version NUMBER is deliberately NOT asserted (a recreation may differ); only the
stable wording is. Absent on the launcher, present on the About screen."""
nm = "text_about_block_substrings"
needles = ("Copyright © 2025 Urik Development",
"License: GNU GPL v3.0", "Source Code",
"Release Notes", "Report a Bug", "Privacy Policy")
exp = "About block contains 'Copyright © 2025 Urik Development' + 'License: GNU GPL v3.0' + 'Source Code'"
restart_app()
wait_for_foreground()
launch_blob = all_text(ui())
absent = "GNU GPL v3.0" not in launch_blob
nodes = and_reach_about()
if nodes is None:
record(nm, False, "setup_failed: could not reach About from launcher",
depth=1, jump_kind="value", expect=exp)
return
node = node_by_id(nodes, "about_text")
blob = node.get("text", "") if node else all_text(nodes)
missing = [s for s in needles if s not in blob]
ok = absent and not missing
record(nm, ok, "" if ok else
(f"behavior_wrong: About block missing {missing!r}" if missing
else "behavior_wrong: About text present before navigation"),
depth=1, jump_kind="value", expect=exp)
@and_test(expects=("text_about_block_rendered_vlm",))
def test_about_block_rendered_vlm():
"""VLM #1: the About screen renders its info block as body text with the
Version / Copyright / License lines visible in the content area (below the
'About' toolbar). The block is a real rendered TextView -> a visual check."""
nm = "text_about_block_rendered"
nodes = and_reach_about()
if nodes is None:
record(nm + "_vlm", False, "setup_failed: could not reach About screen",
depth=1, jump_kind="none", tag="position")
return
vlm_assert(nm,
"This is an app's About screen. Is a block of body text rendered in "
"the content area below the top 'About' title bar, containing lines "
"that start with 'Version', 'Copyright' and 'License'?",
RESULTS_DIR, depth=1, jump_kind="value", tag="position")
@and_test(expects=("text_about_copyright_rendered_vlm",))
def test_about_copyright_rendered_vlm():
"""VLM #2: the Copyright line of the About block is rendered as light-coloured
text on the dark screen background (OBSERVED: pale text on a dark navy
background -- a rendered-colour check on the same genuinely-drawn block)."""
nm = "text_about_copyright_rendered"
nodes = and_reach_about()
if nodes is None:
record(nm + "_vlm", False, "setup_failed: could not reach About screen",
depth=1, jump_kind="none", tag="color")
return
vlm_assert(nm,
"On this About screen, is the line reading 'Copyright © 2025 Urik "
"Development' displayed as light/pale-coloured text against a dark "
"background?",
RESULTS_DIR, depth=1, jump_kind="value", tag="color")
@and_test(expects=("text_features_sheet_tips",))
def test_features_sheet_tips():
"""The Features bottom sheet (top-right FAB) shows its static tip titles. Absent
on the launcher, present after opening the sheet."""
nm = "text_features_sheet_tips"
needles = ("Clipboard Manager", "Cursor Control", "Quick Delete")
exp = "Features sheet shows 'Clipboard Manager' + 'Cursor Control' + 'Quick Delete'"
restart_app()
wait_for_foreground()
absent = "Clipboard Manager" not in all_text(ui())
nodes = and_reach_features_sheet()
if nodes is None:
record(nm, False, "setup_failed: no info FAB on the launcher",
depth=1, jump_kind="value", expect=exp)
return
blob = all_text(nodes)
missing = [s for s in needles if s not in blob]
ok = absent and not missing
record(nm, ok, "" if ok else
(f"feature_missing: Features sheet missing {missing!r}" if missing
else "behavior_wrong: tips present before opening the sheet"),
depth=1, jump_kind="value", expect=exp)
@and_test(expects=("text_features_sheet_learning_words",))
def test_features_sheet_learning_words():
"""The first Features tip pairs the EXACT title "Learning Words" with its
description sentence -- a static content pair a recreation must reproduce."""
nm = "text_features_sheet_learning_words"
title = "Learning Words"
desc = "Press space after a highlighted typo to add the word to your dictionary."
exp = f"tip '{title}' + its description"
restart_app()
wait_for_foreground()
absent = title not in all_text(ui())
nodes = and_reach_features_sheet()
if nodes is None:
record(nm, False, "setup_failed: no info FAB on the launcher",
depth=1, jump_kind="value", expect=exp)
return
blob = all_text(nodes)
ok = absent and title in blob and desc in blob
record(nm, ok, "" if ok else
f"behavior_wrong: '{title}' tip or its description not shown on the sheet",
depth=1, jump_kind="value", expect=exp)
@and_test(expects=("text_themepicker_toolbar_title",))
def test_themepicker_toolbar_title():
"""ThemePicker toolbar title is EXACTLY "Keyboard Theme" (reached by tapping the
preview theme-name on the launcher)."""
nm = "text_themepicker_toolbar_title"
exp = "Keyboard Theme"
restart_app()
wait_for_foreground()
absent = exp not in all_text(ui())
nodes = and_reach_themepicker_from_card()
if nodes is None:
record(nm, False, "setup_failed: could not reach ThemePicker from the card",
depth=1, jump_kind="value", expect=exp)
return
title = toolbar_title(nodes)
got = find_node(nodes, text=exp) is not None or title == exp
ok = absent and got
record(nm, ok, "" if ok else
f"behavior_wrong: ThemePicker toolbar title {title!r} != {exp!r}",
depth=1, jump_kind="value", expect=exp)
@and_test(expects=("text_themepicker_theme_content_desc",))
def test_themepicker_theme_content_desc():
"""Theme cards expose their name as content-desc: the selected card reads
"Default theme, currently selected" and another card reads "Light theme".
content-desc is text-lane content -- assert both are produced on the picker."""
nm = "text_themepicker_theme_content_desc"
exp = "content-desc 'Default theme, currently selected' + 'Light theme'"
nodes = and_reach_themepicker_from_card()
if nodes is None:
record(nm, False, "setup_failed: could not reach ThemePicker from the card",
depth=1, jump_kind="value", expect=exp)
return
has_default = desc_present(nodes, "Default theme")
has_light = desc_present(nodes, "Light theme")
ok = has_default and has_light
record(nm, ok, "" if ok else
f"behavior_wrong: theme content-desc missing (Default={has_default}, "
f"Light={has_light})",
depth=1, jump_kind="value", expect=exp)
@and_test(expects=("text_themepicker_favorite_content_desc",))
def test_themepicker_favorite_content_desc():
"""Each theme card's favorite control exposes the EXACT content-desc
"Add Default to favorites" -- an icon-only control's app-unique label, which is
text-lane content a recreation must get right."""
nm = "text_themepicker_favorite_content_desc"
exp = "content-desc 'Add Default to favorites'"
nodes = and_reach_themepicker_from_card()
if nodes is None:
record(nm, False, "setup_failed: could not reach ThemePicker from the card",
depth=1, jump_kind="value", expect=exp)
return
ok = find_node(nodes, content_desc="Add Default to favorites") is not None
record(nm, ok, "" if ok else
"behavior_wrong: no 'Add Default to favorites' content-desc on any card",
depth=1, jump_kind="value", expect=exp)
@and_test(expects=("text_settings_row_titles",))
def test_settings_row_titles():
"""The Settings list shows all 8 preference row titles verbatim, including the
&-entity ones ("Layout &amp; Input", "Privacy &amp; Data") which are the exact
dump text. Absent on the launcher, present after opening Settings."""
nm = "text_settings_row_titles"
titles = ("Auto-Correct Settings", "Language Settings",
"Typing Behavior Settings", "Layout &amp; Input",
"Appearance", "Privacy &amp; Data",
"Open Source Licenses", "Dictionary Data")
exp = "all 8 row titles incl. 'Layout &amp; Input' and 'Privacy &amp; Data'"
restart_app()
wait_for_foreground()
absent = "Layout &amp; Input" not in all_text(ui())
nodes = and_reach_settings()
if nodes is None:
record(nm, False, "setup_failed: could not reach Settings from launcher",
depth=1, jump_kind="value", expect=exp)
return
missing = [t for t in titles if find_node(nodes, text=t) is None]
ok = absent and not missing
record(nm, ok, "" if ok else
(f"behavior_wrong: Settings list missing titles {missing!r}" if missing
else "behavior_wrong: settings titles present before navigation"),
depth=1, jump_kind="value", expect=exp)
# ══════════════════════════════════════════════════════════════════════════════
# DEPTH 2 — preference SUMMARY strings a row shows on a settings fragment
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("text_appearance_keysize_summary",))
def test_appearance_keysize_summary():
"""Appearance -> "Key Size" row summary is EXACTLY "Medium"."""
nm = "text_appearance_keysize_summary"
exp = "Medium"
nodes = and_reach_fragment("Appearance")
if nodes is None:
record(nm, False, "setup_failed: could not reach Appearance",
depth=2, jump_kind="value", expect=exp)
return
if find_node(nodes, text="Key Size") is None:
record(nm, False, "feature_missing: no 'Key Size' row on Appearance",
depth=2, jump_kind="value", expect=exp)
return
got = summary_of(nodes, "Key Size")
ok = got == exp
record(nm, ok, "" if ok else
f"behavior_wrong: Key Size summary {got!r} != {exp!r}",
depth=2, jump_kind="value", expect=exp)
@and_test(expects=("text_appearance_theme_summary",))
def test_appearance_theme_summary():
"""Appearance -> "Theme" row summary is the current theme name "Default"."""
nm = "text_appearance_theme_summary"
exp = "Default"
nodes = and_reach_fragment("Appearance")
if nodes is None:
record(nm, False, "setup_failed: could not reach Appearance",
depth=2, jump_kind="value", expect=exp)
return
if find_node(nodes, text="Theme") is None:
record(nm, False, "feature_missing: no 'Theme' row on Appearance",
depth=2, jump_kind="value", expect=exp)
return
got = summary_of(nodes, "Theme")
ok = got == exp
record(nm, ok, "" if ok else
f"behavior_wrong: Theme summary {got!r} != {exp!r}",
depth=2, jump_kind="value", expect=exp)
@and_test(expects=("text_typing_cursor_speed_summary",))
def test_typing_cursor_speed_summary():
"""Typing Behavior -> "Cursor Speed" ListPreference summary is "Medium"."""
nm = "text_typing_cursor_speed_summary"
exp = "Medium"
nodes = and_reach_fragment("Typing Behavior Settings")
if nodes is None:
record(nm, False, "setup_failed: could not reach Typing Behavior Settings",
depth=2, jump_kind="value", expect=exp)
return
if find_node(nodes, text="Cursor Speed") is None:
record(nm, False, "feature_missing: no 'Cursor Speed' row",
depth=2, jump_kind="value", expect=exp)
return
got = summary_of(nodes, "Cursor Speed")
ok = got == exp
record(nm, ok, "" if ok else
f"behavior_wrong: Cursor Speed summary {got!r} != {exp!r}",
depth=2, jump_kind="value", expect=exp)
@and_test(expects=("text_typing_longpress_punct_summary",))
def test_typing_longpress_punct_summary():
"""Typing Behavior -> "Long Press Punctuation" summary is EXACTLY "Period Key"."""
nm = "text_typing_longpress_punct_summary"
exp = "Period Key"
nodes = and_reach_fragment("Typing Behavior Settings")
if nodes is None:
record(nm, False, "setup_failed: could not reach Typing Behavior Settings",
depth=2, jump_kind="value", expect=exp)
return
row = find_node(nodes, text="Long Press Punctuation")
if row is None:
row = scroll_into_view("Long Press Punctuation")
nodes = ui()
if find_node(nodes, text="Long Press Punctuation") is None:
record(nm, False, "feature_missing: no 'Long Press Punctuation' row",
depth=2, jump_kind="value", expect=exp)
return
got = summary_of(nodes, "Long Press Punctuation")
ok = got == exp
record(nm, ok, "" if ok else
f"behavior_wrong: Long Press Punctuation summary {got!r} != {exp!r}",
depth=2, jump_kind="value", expect=exp)
@and_test(expects=("text_layout_keyboard_layout_summary",))
def test_layout_keyboard_layout_summary():
"""Layout & Input -> "Keyboard Layout" summary is "Default (Language Layout)"."""
nm = "text_layout_keyboard_layout_summary"
exp = "Default (Language Layout)"
nodes = and_reach_fragment("Layout &amp; Input")
if nodes is None:
record(nm, False, "setup_failed: could not reach Layout & Input",
depth=2, jump_kind="value", expect=exp)
return
if find_node(nodes, text="Keyboard Layout") is None:
record(nm, False, "feature_missing: no 'Keyboard Layout' row",
depth=2, jump_kind="value", expect=exp)
return
got = summary_of(nodes, "Keyboard Layout")
ok = got == exp
record(nm, ok, "" if ok else
f"behavior_wrong: Keyboard Layout summary {got!r} != {exp!r}",
depth=2, jump_kind="value", expect=exp)
@and_test(expects=("text_layout_onehanded_summary",))
def test_layout_onehanded_summary():
"""Layout & Input -> "One-Handed Mode" summary is "Standard full-width keyboard"."""
nm = "text_layout_onehanded_summary"
exp = "Standard full-width keyboard"
nodes = and_reach_fragment("Layout &amp; Input")
if nodes is None:
record(nm, False, "setup_failed: could not reach Layout & Input",
depth=2, jump_kind="value", expect=exp)
return
row = find_node(nodes, text="One-Handed Mode")
if row is None:
row = scroll_into_view("One-Handed Mode")
nodes = ui()
if find_node(nodes, text="One-Handed Mode") is None:
record(nm, False, "feature_missing: no 'One-Handed Mode' row",
depth=2, jump_kind="value", expect=exp)
return
got = summary_of(nodes, "One-Handed Mode")
ok = got == exp
record(nm, ok, "" if ok else
f"behavior_wrong: One-Handed Mode summary {got!r} != {exp!r}",
depth=2, jump_kind="value", expect=exp)
@and_test(expects=("text_autocorrect_suggestion_count_summary",))
def test_autocorrect_suggestion_count_summary():
"""Auto-Correct -> "Suggestion Count" ListPreference summary is "3"."""
nm = "text_autocorrect_suggestion_count_summary"
exp = "3"
nodes = and_reach_fragment("Auto-Correct Settings")
if nodes is None:
record(nm, False, "setup_failed: could not reach Auto-Correct Settings",
depth=2, jump_kind="value", expect=exp)
return
if find_node(nodes, text="Suggestion Count") is None:
record(nm, False, "feature_missing: no 'Suggestion Count' row",
depth=2, jump_kind="value", expect=exp)
return
got = summary_of(nodes, "Suggestion Count")
ok = got == exp
record(nm, ok, "" if ok else
f"behavior_wrong: Suggestion Count summary {got!r} != {exp!r}",
depth=2, jump_kind="value", expect=exp)
@and_test(expects=("text_autocorrect_spellcheck_summary_toggle",))
def test_autocorrect_spellcheck_summary_toggle():
"""The summary an ACTION PRODUCES: Spell Check reads "Spell check enabled" ON;
toggling it OFF makes the summary read EXACTLY "Spell check disabled". Restores
ON afterwards. This is text a state flip produces -> jump_kind="transition"."""
nm = "text_autocorrect_spellcheck_summary_toggle"
exp = "summary 'Spell check enabled' -> 'Spell check disabled'"
nodes = and_reach_fragment("Auto-Correct Settings")
if nodes is None:
record(nm, False, "setup_failed: could not reach Auto-Correct Settings",
depth=2, jump_kind="transition", expect=exp)
return
before = summary_of(nodes, "Spell Check")
sw = switch_for(nodes, "Spell Check")
if sw is None or before != "Spell check enabled":
record(nm, False,
f"feature_missing: Spell Check row/summary not as expected "
f"(summary={before!r}, switch={'ok' if sw else 'missing'})",
depth=2, jump_kind="transition", expect=exp)
return
tap_node(sw)
nodes = ui()
after = summary_of(nodes, "Spell Check")
ok = after == "Spell check disabled"
# Restore ON regardless of the assertion outcome.
sw2 = switch_for(ui(), "Spell Check")
if sw2 is not None:
tap_node(sw2)
record(nm, ok, "" if ok else
f"behavior_wrong: toggled-off summary {after!r} != 'Spell check disabled'",
depth=2, jump_kind="transition", expect=exp)
@and_test(expects=("text_oss_licenses_toolbar_title",))
def test_oss_licenses_toolbar_title():
"""OssLicensesActivity toolbar title is EXACTLY "Open Source Licenses" (reached
Settings -> Open Source Licenses, depth 2)."""
nm = "text_oss_licenses_toolbar_title"
exp = "Open Source Licenses"
nodes = and_reach_fragment("Open Source Licenses")
if nodes is None:
record(nm, False, "setup_failed: could not reach Open Source Licenses",
depth=2, jump_kind="value", expect=exp)
return
title = toolbar_title(nodes)
ok = title == exp
record(nm, ok, "" if ok else
f"behavior_wrong: OSS toolbar title {title!r} != {exp!r}",
depth=2, jump_kind="value", expect=exp)
@and_test(expects=("text_dictionary_data_toolbar_title",))
def test_dictionary_data_toolbar_title():
"""DictionaryAttributionActivity toolbar title is EXACTLY "Dictionary Data"
(reached Settings -> Dictionary Data, depth 2)."""
nm = "text_dictionary_data_toolbar_title"
exp = "Dictionary Data"
nodes = and_reach_fragment("Dictionary Data")
if nodes is None:
record(nm, False, "setup_failed: could not reach Dictionary Data",
depth=2, jump_kind="value", expect=exp)
return
title = toolbar_title(nodes)
ok = title == exp
record(nm, ok, "" if ok else
f"behavior_wrong: Dictionary Data toolbar title {title!r} != {exp!r}",
depth=2, jump_kind="value", expect=exp)
# ══════════════════════════════════════════════════════════════════════════════
# DEPTH 3 — a title on a surface three hops from the launcher
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("text_customize_keys_toolbar_title",))
def test_customize_keys_toolbar_title():
"""LayoutMapperActivity toolbar title is EXACTLY "Customize Keys" (reached
Settings -> Layout & Input -> Customize Keys, depth 3)."""
nm = "text_customize_keys_toolbar_title"
exp = "Customize Keys"
nodes = and_reach_customize_keys()
if nodes is None:
record(nm, False, "setup_failed: could not reach Customize Keys (depth 3)",
depth=3, jump_kind="value", expect=exp)
return
title = toolbar_title(nodes)
ok = title == exp
record(nm, ok, "" if ok else
f"behavior_wrong: Customize Keys toolbar title {title!r} != {exp!r}",
depth=3, jump_kind="value", expect=exp)
TESTS = [
# depth 1
test_settings_toolbar_title,
test_about_toolbar_title,
test_about_block_substrings,
test_about_block_rendered_vlm,
test_about_copyright_rendered_vlm,
test_features_sheet_tips,
test_features_sheet_learning_words,
test_themepicker_toolbar_title,
test_themepicker_theme_content_desc,
test_themepicker_favorite_content_desc,
test_settings_row_titles,
# depth 2
test_appearance_keysize_summary,
test_appearance_theme_summary,
test_typing_cursor_speed_summary,
test_typing_longpress_punct_summary,
test_layout_keyboard_layout_summary,
test_layout_onehanded_summary,
test_autocorrect_suggestion_count_summary,
test_autocorrect_spellcheck_summary_toggle,
test_oss_licenses_toolbar_title,
test_dictionary_data_toolbar_title,
# depth 3
test_customize_keys_toolbar_title,
]
if __name__ == "__main__":
run_suite(TESTS, "text")