Datasets:
File size: 30,172 Bytes
c1c6a0c | 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 712 713 714 715 716 717 | #!/usr/bin/env python3
"""COMPUTATION lane — CORE FUNCTION input->output for EasyNotes.
This lane owns jump_kind="value": it drives the app through the real user path,
then reads the SPECIFIC value the running original produced back out of a fresh
ui() and asserts it. Every expected value below was OBSERVED live on the original
before this file was written — none is derived from the source or from arithmetic.
Ground truth (verified live against com.kin.easynotes.debug):
* Search filter (Home, depth 0): the Search EditText filters cards by
note.name OR note.description, case-insensitive `contains`. Typing "Alpha"
with cards AlphaNote/BetaNote leaves ONLY AlphaNote; typing "banana" (only in
BetaNote's body) leaves ONLY BetaNote. Clearing (content-desc "Clear")
restores BOTH. A gibberish query yields the "No notes found." placeholder and
zero cards.
* Word count / Character count (Note Info bottom-sheet, depth 3): the modal
shows a "Words" label with a numeric value to its right and a "Characters"
label with a numeric value to its right. Observed:
"Milk Eggs Bread" -> Words 3, Characters 15
"one two" -> Words 2, Characters 7
"a" -> Words 1, Characters 1
(Source: words = text.split(\\s+).size, chars = text.length — but the numbers
below are the ones OBSERVED, which is the ground truth.)
* Note total (Settings -> Tools, depth 2): the "Notes" row shows a number equal
to the number of notes. With 3 notes created it reads "3".
* Markdown insertion (Edit page, Description focused, depth 1): tapping a
toolbar button inserts its markdown token into the Description value. On an
empty field: Checkbox -> "[ ] "; (forward-arrow to set 2) Bold -> "****";
Header -> "# ". All set-1 buttons AND both paginator arrows share
content-desc "Bullet List"; Checkbox/Bold/Header carry unique descs.
* Font Size dialog (Colors & Styles -> Font Size, depth 3): shows a
"Font Size: N" label (default 16, range 12..18) plus a "Preview" title and a
rendered preview sentence.
* Markdown render (Preview, depth 1): body "This is **bold** text" renders in
the view tree as "This is bold text" (the ** markers are STRIPPED); the bold
weight itself is only visible to the VLM.
Toggle icons on the Edit/Preview top bar are two clickable `View` nodes with
empty content-desc between Back and Done: pencil (left, -> Edit) and eye (right,
-> Preview). We locate the eye as the right-most of that pair (no pixel literal).
"""
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from android_testgen_kit import * # noqa: F403,F401
# ── distinctive titles/bodies (so a read-back cannot match pre-existing text) ───
A_TITLE = "AlphaNote"
B_TITLE = "BetaNote"
A_BODY = "apple fruit"
B_BODY = "banana fruit"
NOMATCH = "zzqqxnope"
# ══════════════════════════════════════════════════════════════════════════════
# Helpers (the and_enter_* NAMES back every declared depth>=1)
# ══════════════════════════════════════════════════════════════════════════════
def sorted_edittexts(nodes):
"""EditTexts top-to-bottom: on the Edit page [0]=Name, [1]=Description."""
return sorted(find_by_class(nodes, "EditText"),
key=lambda e: e.get("_bounds", (0, 0, 0, 0))[1])
def _on_home(nodes=None):
return find_node(nodes or ui(), content_desc="New Note") is not None
def ensure_home():
"""Return to Home, launcher-proof. Leaving Edit/Preview can pop PAST Home to
the launcher, so key ONLY off the New Note FAB and relaunch until it shows."""
for _ in range(4):
if _on_home():
return
back()
settle("tap")
if _on_home():
return
launch_app()
wait_for_foreground()
settle("tap")
if not _on_home():
launch_app()
wait_for_foreground()
settle("dump")
def open_editor():
"""Tap the New Note FAB -> Edit page. Returns True on success."""
fab = find_node(ui(), content_desc="New Note")
return bool(fab and tap_node(fab))
def type_note_fields(name, body):
"""On the Edit page, type Name then Description (re-dumping between)."""
settle("tap")
ets = sorted_edittexts(ui())
if not ets:
return False
if name:
type_text(ets[0], name)
if body:
ets = sorted_edittexts(ui())
if len(ets) < 2:
return False
type_text(ets[1], body)
return True
def create_note(name, body=""):
"""Full create path: FAB -> type -> Back (auto-saves) -> Home."""
if not open_editor():
return False
if not type_note_fields(name, body):
return False
hide_keyboard()
b = find_node(ui(), content_desc="Back")
if b:
tap_node(b)
ensure_home()
return True
def home_search_field():
"""The Home search EditText (the only EditText on Home)."""
ets = find_by_class(ui(), "EditText")
return ets[0] if ets else None
def visible_titles(nodes, wanted):
"""Which of `wanted` note titles are visible (case-insensitive — EasyNotes
capitalises the first char of a displayed title)."""
low = {w.lower() for w in wanted}
seen = set()
for n in nodes:
t = n.get("text", "").strip().lower()
if t in low:
seen.add(t)
return seen
def eye_toggle(nodes):
"""The Preview (eye) toggle: the right-most of the two empty-desc clickable
View nodes in the top bar (the left one is the Edit pencil). Located by
structure, never by a pixel literal."""
s = get_screen_info()
cands = []
for n in nodes:
b = n.get("_bounds")
if not b:
continue
if n.get("clickable") != "true":
continue
if n.get("content-desc", "").strip() or n.get("text", "").strip():
continue
if n.get("class", "").rsplit(".", 1)[-1] != "View":
continue
cx, cy = n["_center"]
# top bar, and horizontally in the central third (between Back and Done)
if cy < s["height"] * 0.12 and s["width"] * 0.3 < cx < s["width"] * 0.7:
cands.append(n)
if not cands:
return None
cands.sort(key=lambda n: n["_center"][0])
return cands[-1] # eye is the right one; pencil is the left
def find_contains(nodes, sub):
"""Substring match on text/content-desc (handles '&' escaping and wraps)."""
s = sub.lower()
for n in nodes:
if s in n.get("text", "").lower() or s in n.get("content-desc", "").lower():
return n
return None
def and_enter_note_info(name, body):
"""Home -> New Note -> type -> eye(Preview) -> Info(More) -> Information.
Opens the Note Info bottom-sheet. Backs depth (3 surfaces crossed:
editor, preview, info-sheet)."""
if not open_editor():
return False
and_enter("editor")
if not type_note_fields(name, body):
return False
eye = eye_toggle(ui())
if not eye or not tap_node(eye):
return False
settle("tap")
and_enter("preview")
info = find_node(ui(), content_desc="Info")
if not info or not tap_node(info):
return False
settle("tap")
item = find_contains(ui(), "Information")
if not item or not tap_node(item):
return False
settle("tap")
and_enter("info_sheet")
return True
def read_row_number(nodes, label):
"""The numeric value shown on the SAME ROW to the RIGHT of `label` (the Note
Info modal layout: 'Words' | '3')."""
lab = None
for n in nodes:
if n.get("text", "").strip().lower() == label.lower():
lab = n
break
if not lab:
return None
ly = lab["_center"][1]
lx = lab["_center"][0]
best = None
for n in nodes:
t = n.get("text", "").strip()
if t.isdigit() and abs(n["_center"][1] - ly) < 45 and n["_center"][0] > lx:
best = t
return best
def read_number_below(nodes, label, max_dx=200, max_dy=140):
"""The numeric value shown BELOW `label` (the Tools layout: 'Notes' over '3')."""
lab = None
for n in nodes:
if n.get("text", "").strip().lower() == label.lower():
lab = n
break
if not lab:
return None
lx, ly = lab["_center"]
best = None
for n in nodes:
t = n.get("text", "").strip()
if t.isdigit() and 0 <= n["_center"][1] - ly < max_dy \
and abs(n["_center"][0] - lx) < max_dx:
best = t
return best
def and_enter_settings():
"""Home -> Settings gear. Backs depth 1."""
gear = find_node(ui(), content_desc="Settings")
if not gear or not tap_node(gear):
return False
settle("tap")
and_enter("settings")
return True
def and_enter_tools():
"""Home -> Settings -> Tools. Backs depth 2."""
if not and_enter_settings():
return False
tools = find_contains(ui(), "Tools")
if not tools or not tap_node(tools):
return False
settle("tap")
and_enter("tools")
return True
def and_enter_font_size_dialog():
"""Home -> Settings -> Colors & Styles -> Font Size dialog. Backs depth 3."""
if not and_enter_settings():
return False
colors = find_contains(ui(), "Colors")
if not colors or not tap_node(colors):
return False
settle("tap")
and_enter("colors")
fs = None
for _ in range(6):
fs = find_contains(ui(), "Font Size")
if fs:
break
scroll_down(0.5)
if not fs or not tap_node(fs):
return False
settle("tap")
and_enter("font_size_dialog")
return True
def focus_description():
"""FAB -> Edit page -> focus the Description EditText so the markdown toolbar
appears. Returns the fresh Description node (or None)."""
if not open_editor():
return None
settle("tap")
ets = sorted_edittexts(ui())
if len(ets) < 2:
return None
tap_node(ets[1])
settle("keyboard")
ets = sorted_edittexts(ui())
return ets[1] if len(ets) >= 2 else None
def description_value():
ets = sorted_edittexts(ui())
return ets[-1].get("text", "") if ets else ""
def toolbar_forward_arrow(nodes):
"""The RIGHT paginator arrow of the markdown toolbar (advances set 1 -> 2):
the right-most 'Bullet List' View in the bottom toolbar region."""
s = get_screen_info()
bl = [n for n in nodes
if n.get("content-desc") == "Bullet List"
and n.get("_bounds") and n["_bounds"][1] > s["height"] * 0.5]
if not bl:
return None
bl.sort(key=lambda n: n["_center"][0])
return bl[-1]
def _norm(v):
return (v or "").strip()
# ══════════════════════════════════════════════════════════════════════════════
# SEARCH FILTER (depth 0, jump_kind="value" — the count/content of the result)
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("computation_search_filter_by_name",))
def test_search_filter_by_name():
clear_data()
restart_app()
wait_for_foreground()
ok = create_note(A_TITLE, A_BODY) and create_note(B_TITLE, B_BODY)
before = visible_titles(ui(), (A_TITLE, B_TITLE))
both_present = before == {A_TITLE.lower(), B_TITLE.lower()}
sf = home_search_field()
typed = bool(sf) and type_text(sf, "Alpha")
after = visible_titles(ui(), (A_TITLE, B_TITLE))
# ONLY AlphaNote must remain (positive present, negative absent).
only_alpha = (A_TITLE.lower() in after) and (B_TITLE.lower() not in after)
passed = ok and both_present and typed and only_alpha
record("computation_search_filter_by_name", passed,
"" if passed else
f"behavior_wrong: query 'Alpha' -> visible {sorted(after)}, "
f"expected only {A_TITLE!r} (both_before={both_present})",
depth=0, jump_kind="value",
expect="query 'Alpha' -> only AlphaNote card visible")
@and_test(expects=("computation_search_filter_by_body",))
def test_search_filter_by_body():
clear_data()
restart_app()
wait_for_foreground()
ok = create_note(A_TITLE, A_BODY) and create_note(B_TITLE, B_BODY)
sf = home_search_field()
# 'banana' appears ONLY in BetaNote's DESCRIPTION, not any title.
typed = bool(sf) and type_text(sf, "banana")
after = visible_titles(ui(), (A_TITLE, B_TITLE))
only_beta = (B_TITLE.lower() in after) and (A_TITLE.lower() not in after)
passed = ok and typed and only_beta
record("computation_search_filter_by_body", passed,
"" if passed else
f"behavior_wrong: body query 'banana' -> visible {sorted(after)}, "
f"expected only {B_TITLE!r}",
depth=0, jump_kind="value",
expect="body query 'banana' -> only BetaNote card visible")
@and_test(expects=("computation_search_clear_restores",))
def test_search_clear_restores():
clear_data()
restart_app()
wait_for_foreground()
ok = create_note(A_TITLE, A_BODY) and create_note(B_TITLE, B_BODY)
sf = home_search_field()
typed = bool(sf) and type_text(sf, "Alpha")
filtered = visible_titles(ui(), (A_TITLE, B_TITLE))
was_filtered = filtered == {A_TITLE.lower()}
clr = find_node(ui(), content_desc="Clear")
cleared = bool(clr) and tap_node(clr)
settle("tap")
after = visible_titles(ui(), (A_TITLE, B_TITLE))
restored = after == {A_TITLE.lower(), B_TITLE.lower()}
passed = ok and typed and was_filtered and cleared and restored
record("computation_search_clear_restores", passed,
"" if passed else
f"behavior_wrong: after Clear visible {sorted(after)}, "
f"expected both (was_filtered={was_filtered}, cleared={cleared})",
depth=0, jump_kind="value",
expect="after Clear both AlphaNote and BetaNote return")
@and_test(expects=("computation_search_no_match",))
def test_search_no_match():
clear_data()
restart_app()
wait_for_foreground()
ok = create_note(A_TITLE, A_BODY) and create_note(B_TITLE, B_BODY)
sf = home_search_field()
typed = bool(sf) and type_text(sf, NOMATCH)
nodes = ui()
after = visible_titles(nodes, (A_TITLE, B_TITLE))
placeholder = find_contains(nodes, "No notes found") is not None
# value = the RESULT of the filter: zero cards + the specific empty text.
passed = ok and typed and (not after) and placeholder
record("computation_search_no_match", passed,
"" if passed else
f"behavior_wrong: gibberish query -> visible {sorted(after)} "
f"placeholder={placeholder}, expected 0 cards + 'No notes found.'",
depth=0, jump_kind="value",
expect="gibberish query -> 0 cards, 'No notes found.'")
# ══════════════════════════════════════════════════════════════════════════════
# WORD COUNT (Note Info modal, depth 3, jump_kind="value")
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("computation_word_count_three",))
def test_word_count_three():
restart_app()
wait_for_foreground()
reached = and_enter_note_info("Wc3", "Milk Eggs Bread")
got = read_row_number(ui(), "Words") if reached else None
passed = reached and got == "3"
record("computation_word_count_three", passed,
"" if passed else
(f"behavior_wrong: Words={got!r}, expected '3'" if reached
else "setup_failed: could not reach Note Info modal"),
depth=3, jump_kind="value", expect="Words=3 for 'Milk Eggs Bread'")
@and_test(expects=("computation_word_count_two",))
def test_word_count_two():
restart_app()
wait_for_foreground()
reached = and_enter_note_info("Wc2", "one two")
got = read_row_number(ui(), "Words") if reached else None
passed = reached and got == "2"
record("computation_word_count_two", passed,
"" if passed else
(f"behavior_wrong: Words={got!r}, expected '2'" if reached
else "setup_failed: could not reach Note Info modal"),
depth=3, jump_kind="value", expect="Words=2 for 'one two'")
@and_test(expects=("computation_word_count_one",))
def test_word_count_one():
restart_app()
wait_for_foreground()
reached = and_enter_note_info("Wc1", "a")
got = read_row_number(ui(), "Words") if reached else None
passed = reached and got == "1"
record("computation_word_count_one", passed,
"" if passed else
(f"behavior_wrong: Words={got!r}, expected '1'" if reached
else "setup_failed: could not reach Note Info modal"),
depth=3, jump_kind="value", expect="Words=1 for 'a'")
# ══════════════════════════════════════════════════════════════════════════════
# CHARACTER COUNT (Note Info modal, depth 3, jump_kind="value")
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("computation_char_count_fifteen",))
def test_char_count_fifteen():
restart_app()
wait_for_foreground()
reached = and_enter_note_info("Cc15", "Milk Eggs Bread")
got = read_row_number(ui(), "Characters") if reached else None
passed = reached and got == "15"
record("computation_char_count_fifteen", passed,
"" if passed else
(f"behavior_wrong: Characters={got!r}, expected '15'" if reached
else "setup_failed: could not reach Note Info modal"),
depth=3, jump_kind="value",
expect="Characters=15 for 'Milk Eggs Bread'")
@and_test(expects=("computation_char_count_seven",))
def test_char_count_seven():
restart_app()
wait_for_foreground()
reached = and_enter_note_info("Cc7", "one two")
got = read_row_number(ui(), "Characters") if reached else None
passed = reached and got == "7"
record("computation_char_count_seven", passed,
"" if passed else
(f"behavior_wrong: Characters={got!r}, expected '7'" if reached
else "setup_failed: could not reach Note Info modal"),
depth=3, jump_kind="value", expect="Characters=7 for 'one two'")
@and_test(expects=("computation_char_count_one",))
def test_char_count_one():
restart_app()
wait_for_foreground()
reached = and_enter_note_info("Cc1", "a")
got = read_row_number(ui(), "Characters") if reached else None
passed = reached and got == "1"
record("computation_char_count_one", passed,
"" if passed else
(f"behavior_wrong: Characters={got!r}, expected '1'" if reached
else "setup_failed: could not reach Note Info modal"),
depth=3, jump_kind="value", expect="Characters=1 for 'a'")
# ══════════════════════════════════════════════════════════════════════════════
# NOTE TOTAL (Tools screen, depth 2, jump_kind="value")
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("computation_note_total_three",))
def test_note_total_three():
clear_data()
restart_app()
wait_for_foreground()
made = create_note("Tot1") and create_note("Tot2") and create_note("Tot3")
reached = made and and_enter_tools()
got = read_number_below(ui(), "Notes") if reached else None
passed = reached and got == "3"
record("computation_note_total_three", passed,
"" if passed else
(f"behavior_wrong: Tools Notes count={got!r}, expected '3'" if reached
else "setup_failed: could not reach Tools screen"),
depth=2, jump_kind="value", expect="Tools Notes count = 3")
@and_test(expects=("computation_note_total_one",))
def test_note_total_one():
clear_data()
restart_app()
wait_for_foreground()
made = create_note("SoloTot")
reached = made and and_enter_tools()
got = read_number_below(ui(), "Notes") if reached else None
passed = reached and got == "1"
record("computation_note_total_one", passed,
"" if passed else
(f"behavior_wrong: Tools Notes count={got!r}, expected '1'" if reached
else "setup_failed: could not reach Tools screen"),
depth=2, jump_kind="value", expect="Tools Notes count = 1")
# ══════════════════════════════════════════════════════════════════════════════
# MARKDOWN INSERTION (Edit page, depth 1, jump_kind="value" — inserted string)
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("computation_markdown_checkbox_insert",))
def test_markdown_checkbox_insert():
restart_app()
wait_for_foreground()
desc = focus_description()
and_enter("editor")
before = description_value()
was_empty = before == ""
cb = find_node(ui(), content_desc="Checkbox")
tapped = bool(cb) and tap_node(cb)
settle("tap")
after = description_value()
# empty field -> exactly the checkbox token.
passed = bool(desc) and was_empty and tapped and after == "[ ] "
record("computation_markdown_checkbox_insert", passed,
"" if passed else
f"behavior_wrong: Description after Checkbox={after!r}, expected '[ ] ' "
f"(was_empty={was_empty}, tapped={tapped})",
depth=1, jump_kind="value",
expect="Checkbox inserts '[ ] ' into empty Description")
@and_test(expects=("computation_markdown_bold_insert",))
def test_markdown_bold_insert():
restart_app()
wait_for_foreground()
desc = focus_description()
and_enter("editor")
before = description_value()
was_empty = before == ""
arrow = toolbar_forward_arrow(ui()) # set 1 -> set 2 (Bold/Header/Italic)
advanced = bool(arrow) and tap_node(arrow)
settle("tap")
bold = find_node(ui(), content_desc="Bold")
tapped = bool(bold) and tap_node(bold)
settle("tap")
after = description_value()
passed = bool(desc) and was_empty and advanced and tapped and "****" in after
record("computation_markdown_bold_insert", passed,
"" if passed else
f"behavior_wrong: Description after Bold={after!r}, expected to contain "
f"'****' (advanced={advanced}, tapped={tapped})",
depth=1, jump_kind="value",
expect="Bold inserts '****' into Description")
@and_test(expects=("computation_markdown_header_insert",))
def test_markdown_header_insert():
restart_app()
wait_for_foreground()
desc = focus_description()
and_enter("editor")
before = description_value()
was_empty = before == ""
arrow = toolbar_forward_arrow(ui()) # set 1 -> set 2 (Header lives here)
advanced = bool(arrow) and tap_node(arrow)
settle("tap")
header = find_node(ui(), content_desc="Header")
tapped = bool(header) and tap_node(header)
settle("tap")
after = description_value()
passed = bool(desc) and was_empty and advanced and tapped and "# " in after
record("computation_markdown_header_insert", passed,
"" if passed else
f"behavior_wrong: Description after Header={after!r}, expected to "
f"contain '# ' (advanced={advanced}, tapped={tapped})",
depth=1, jump_kind="value",
expect="Header inserts '# ' into Description")
# ══════════════════════════════════════════════════════════════════════════════
# FONT SIZE DIALOG numeric readout (depth 3, jump_kind="value")
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("computation_font_size_value", "computation_font_size_value_vlm"))
def test_font_size_value():
restart_app()
wait_for_foreground()
reached = and_enter_font_size_dialog()
nodes = ui()
label = find_contains(nodes, "Font Size:") if reached else None
txt = _norm(label.get("text")) if label else ""
# parse the trailing integer and require it in the app's [12,18] band.
num = None
if txt:
digits = "".join(ch for ch in txt.split(":")[-1] if ch.isdigit())
num = int(digits) if digits else None
has_preview = find_contains(nodes, "Preview") is not None
passed = reached and num is not None and 12 <= num <= 18 and has_preview
record("computation_font_size_value", passed,
"" if passed else
(f"behavior_wrong: Font Size label={txt!r} parsed={num} "
f"preview={has_preview}, expected 'Font Size: N' with 12<=N<=18"
if reached else "setup_failed: could not reach Font Size dialog"),
depth=3, jump_kind="value",
expect="dialog shows 'Font Size: N' with 12<=N<=18")
# VLM: the preview SENTENCE is rendered at the chosen font size — a rendered
# sample that only the pixels carry (exact glyph size never in the tree).
vlm_assert("computation_font_size_value",
"In this Font Size dialog, is there a sample sentence of body text "
"rendered below a 'Preview' heading (a preview of how notes will "
"look at the selected size)?",
RESULTS_DIR, depth=3, jump_kind="value", tag="size")
# ══════════════════════════════════════════════════════════════════════════════
# MARKDOWN RENDER (Preview, depth 1) — markers stripped (rule) + bold (VLM)
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("computation_markdown_render_strips_markers",
"computation_markdown_render_strips_markers_vlm"))
def test_markdown_render_strips_markers():
restart_app()
wait_for_foreground()
reached = False
if open_editor():
and_enter("editor")
if type_note_fields("MdRender", "This is **bold** text"):
eye = eye_toggle(ui())
if eye and tap_node(eye):
settle("tap")
and_enter("preview")
reached = find_node(ui(), content_desc="Info") is not None
nodes = ui()
# The rendered body must show the words WITHOUT the ** markers.
rendered_clean = find_contains(nodes, "This is bold text") is not None
raw_markers = find_contains(nodes, "**bold**") is not None
passed = reached and rendered_clean and not raw_markers
record("computation_markdown_render_strips_markers", passed,
"" if passed else
(f"behavior_wrong: rendered_clean={rendered_clean} "
f"raw_markers_visible={raw_markers}, expected 'This is bold text' "
f"with no '**'" if reached
else "setup_failed: could not reach Preview"),
depth=1, jump_kind="value",
expect="body renders 'This is bold text' (no '**' markers)")
# VLM: the word 'bold' is rendered in a HEAVIER weight than its neighbours —
# a styling fact that never reaches the view tree.
vlm_assert("computation_markdown_render_strips_markers",
"In the note body 'This is bold text', is the single word 'bold' "
"rendered in a noticeably heavier/bolder font weight than the "
"surrounding words 'This is' and 'text'?",
RESULTS_DIR, depth=1, jump_kind="value", tag="color")
TESTS = [
test_search_filter_by_name,
test_search_filter_by_body,
test_search_clear_restores,
test_search_no_match,
test_word_count_three,
test_word_count_two,
test_word_count_one,
test_char_count_fifteen,
test_char_count_seven,
test_char_count_one,
test_note_total_three,
test_note_total_one,
test_markdown_checkbox_insert,
test_markdown_bold_insert,
test_markdown_header_insert,
test_font_size_value,
test_markdown_render_strips_markers,
]
if __name__ == "__main__":
run_suite(TESTS, "computation")
|