Datasets:
Download android/kin69-easynotes/tests/test_android_computation.py from Qwen/RecreationBench: direct link, hf CLI and curl.
- Browser
- Download file 30.2 kB
-
https://huggingface.co/datasets/Qwen/RecreationBench/resolve/main/android/kin69-easynotes/tests/test_android_computation.py
- Command line
-
hf download hf://datasets/Qwen/RecreationBench/android/kin69-easynotes/tests/test_android_computation.py
-
curl -L -o test_android_computation.py https://huggingface.co/datasets/Qwen/RecreationBench/resolve/main/android/kin69-easynotes/tests/test_android_computation.py
30.2 kB
| #!/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) | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| 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") | |
| 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") | |
| 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") | |
| 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") | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| 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'") | |
| 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'") | |
| 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") | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| 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'") | |
| 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'") | |
| 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") | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| 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") | |
| 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) | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| 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") | |
| 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") | |
| 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") | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| 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) | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| 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") | |