Datasets:
File size: 30,612 Bytes
41dfd8d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 | #!/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 & Input" keeps the & 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 & 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 & Input", "Privacy & 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 & Input",
"Appearance", "Privacy & Data",
"Open Source Licenses", "Dictionary Data")
exp = "all 8 row titles incl. 'Layout & Input' and 'Privacy & Data'"
restart_app()
wait_for_foreground()
absent = "Layout & 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 & 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 & 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")
|