Datasets:
Download android/urikdev-urik/tests/test_android_computation.py from Qwen/RecreationBench: direct link, hf CLI and curl.
- Browser
- Download file 27.8 kB
-
https://huggingface.co/datasets/Qwen/RecreationBench/resolve/main/android/urikdev-urik/tests/test_android_computation.py
- Command line
-
hf download hf://datasets/Qwen/RecreationBench/android/urikdev-urik/tests/test_android_computation.py
-
curl -L -o test_android_computation.py https://huggingface.co/datasets/Qwen/RecreationBench/resolve/main/android/urikdev-urik/tests/test_android_computation.py
27.8 kB
| #!/usr/bin/env python3 | |
| """COMPUTATION lane — Urik Keyboard (com.urik.keyboard). | |
| This app is a soft-keyboard + settings app: there is NO calculator. Its | |
| deterministic input -> output surfaces are: | |
| 1. ListPreference dialogs: pick an option -> the row's `summary` becomes EXACTLY | |
| that option's label (Suggestion Count, Key Size, Key Label Size, Cursor Speed, | |
| Space Bar Size, Keyboard Layout, Long Press Punctuation, Long Press Duration). | |
| 2. Vibration Strength SeekBar: tap a position on the bar -> the `seekbar_value` | |
| label shows the corresponding number (observed deterministic: far-left -> "6", | |
| far-right -> "250", centre -> "128"). | |
| 3. test_field EditText: type a string -> the field's `text` equals exactly that. | |
| Every expected value below was REPRODUCED LIVE on the original app (see _explore*). | |
| All tests are jump_kind="value" with a specific `expect`, depth=2 (Settings -> | |
| fragment -> [dialog]), and restore any mutated preference to keep the baseline clean. | |
| """ | |
| import os, sys | |
| sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) | |
| from android_testgen_kit import * # noqa: F403 | |
| # ── local helpers (READ-ONLY kit; these only orchestrate kit calls) ───────────── | |
| def summary_for(nodes, title_text): | |
| """The `summary` TextView that sits directly under the row whose title == title_text. | |
| Preference rows are (title TextView / summary TextView) pairs; we pick the | |
| summary whose center-y is closest to (and not far above) the located title. | |
| Returns (title_node, summary_node) — either may be None. | |
| """ | |
| tn = find_node(nodes, text=title_text) | |
| if not tn or "_center" not in tn: | |
| return None, None | |
| ty = tn["_center"][1] | |
| cands = [n for n in nodes | |
| if n.get("resource-id", "").endswith("summary") and "_center" in n] | |
| below = [n for n in cands if n["_center"][1] >= ty - 5] | |
| if not below: | |
| return tn, None | |
| best = min(below, key=lambda n: abs(n["_center"][1] - ty)) | |
| return tn, best | |
| def summary_text(nodes, title_text): | |
| _tn, sm = summary_for(nodes, title_text) | |
| return (sm.get("text", "").strip() if sm else "") | |
| def open_settings(): | |
| """restart_app() -> tap 'Open Settings' -> return the settings-list nodes.""" | |
| restart_app() | |
| wait_for_foreground() | |
| tap_text(ui(), "Open Settings") | |
| def and_enter_fragment(row_text): | |
| """Open a settings fragment by its row title (exact text, then ci fallback). | |
| Names in the and_enter_* family, so it backs the depth>=1 declaration. | |
| Returns (ok, note). | |
| """ | |
| nodes = ui() | |
| n = find_node(nodes, text=row_text) or find_node_ci(nodes, row_text) | |
| if not n: | |
| return False, f"setup_failed: settings row {row_text!r} not found" | |
| if not tap_node(n): | |
| return False, f"setup_failed: settings row {row_text!r} not tappable" | |
| and_enter(row_text) | |
| return True, "" | |
| def and_enter_layout_fragment(): | |
| """Open the 'Layout & Input' fragment. Its row text is the LITERAL | |
| 'Layout & Input' (uiautomator does not unescape &); fall back to the | |
| unique summary 'Number row, space bar size'.""" | |
| nodes = ui() | |
| row = (find_node(nodes, text="Layout & Input") | |
| or find_node(nodes, text="Number row, space bar size")) | |
| if not row: | |
| return False, "setup_failed: 'Layout & Input' row not found" | |
| if not tap_node(row): | |
| return False, "setup_failed: 'Layout & Input' row not tappable" | |
| and_enter("Layout & Input") | |
| return True, "" | |
| def and_enter_dialog(pref_title, scroll=False): | |
| """Scroll (optional) to a ListPreference row, tap it to open its dialog. | |
| Counts as one more surface (the dialog). Returns (ok, note). | |
| """ | |
| if scroll and not find_node(ui(), text=pref_title): | |
| scroll_into_view(pref_title) | |
| pn = find_node(ui(), text=pref_title) | |
| if not pn: | |
| return False, f"setup_failed: preference {pref_title!r} not found" | |
| before = and_showing() | |
| if not tap_node(pn): | |
| return False, f"setup_failed: preference {pref_title!r} not tappable" | |
| after = and_showing() | |
| if not surface_changed(before, after): | |
| return False, f"behavior_wrong: no dialog appeared for {pref_title!r}" | |
| and_enter(f"{pref_title} dialog") | |
| return True, "" | |
| def pick_option(pick): | |
| """Tap a dialog option (CheckedTextView) by its exact label.""" | |
| return tap_text(ui(), pick) | |
| def restore_listpref(pref_title, restore_label, scroll=False): | |
| """Best-effort restore of a ListPreference to its original label. Never fails | |
| the test — restoration is cleanup, not the assertion.""" | |
| try: | |
| if scroll and not find_node(ui(), text=pref_title): | |
| scroll_into_view(pref_title) | |
| pn = find_node(ui(), text=pref_title) | |
| if pn and tap_node(pn): | |
| tap_text(ui(), restore_label) | |
| except Exception: | |
| pass | |
| def seek_value(nodes): | |
| n = node_by_id(nodes, "seekbar_value") | |
| return (n.get("text", "").strip() if n else "") | |
| def tap_seekbar_fraction(frac): | |
| """Tap the Vibration Strength SeekBar at a horizontal fraction of its width. | |
| Coordinate is DERIVED from the seekbar node's own bounds (never a literal). | |
| Returns the new seekbar_value text, or "" if the bar was not found. | |
| """ | |
| bar = node_by_id(ui(), "seekbar") | |
| if not bar or "_bounds" not in bar: | |
| return "", False | |
| x1, y1, x2, y2 = bar["_bounds"] | |
| tx = int(x1 + (x2 - x1) * frac) | |
| ty = (y1 + y2) // 2 | |
| tap(tx, ty) | |
| return seek_value(ui()), True | |
| def test_field(nodes): | |
| """The fragment's bottom 'Test changes' EditText (id test_field).""" | |
| n = node_by_id(nodes, "test_field") | |
| if n: | |
| return n | |
| ets = find_by_class(nodes, "EditText") | |
| return ets[-1] if ets else None | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| # (1) ListPreference: pick option -> summary becomes EXACTLY that label | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| def test_suggestion_count_2(): | |
| """Suggestion Count: pick '2' in the dialog -> row summary becomes '2' | |
| (observed). Positive/negative: '2' is ABSENT as the summary before, PRESENT | |
| after. VLM: the dialog is a rendered radio list. Restore to '3' at the end.""" | |
| name = "computation_suggestion_count_2" | |
| exp = "2" | |
| open_settings() | |
| ok, note = and_enter_fragment("Auto-Correct Settings") | |
| if not ok: | |
| record(name, False, note, depth=1, jump_kind="value", expect="summary '2'") | |
| return | |
| before = summary_text(ui(), "Suggestion Count") # observed "3" | |
| okd, noted = and_enter_dialog("Suggestion Count") | |
| if not okd: | |
| record(name, False, noted, depth=2, jump_kind="value", expect="summary '2'") | |
| return | |
| # VLM while the dialog is up: a rendered radio/checkmark option list. | |
| vlm_assert("computation_suggestion_count_dialog", | |
| "Is a dialog shown containing a vertical list of selectable options " | |
| "each preceded by a round radio-button circle (one filled/selected)?", | |
| RESULTS_DIR, tag="shape") | |
| pick_option("2") | |
| got = summary_text(ui(), "Suggestion Count") | |
| ok = (got == exp) and (before != exp) | |
| record(name, ok, | |
| "" if ok else f"behavior_wrong: summary {got!r} after picking '2' " | |
| f"(before {before!r}), expected '2'", | |
| depth=2, jump_kind="value", expect="Suggestion Count summary == '2'") | |
| restore_listpref("Suggestion Count", "3") | |
| def test_suggestion_count_1(): | |
| """Suggestion Count: pick '1' -> summary becomes '1' (observed). Restore '3'.""" | |
| name = "computation_suggestion_count_1" | |
| open_settings() | |
| ok, note = and_enter_fragment("Auto-Correct Settings") | |
| if not ok: | |
| record(name, False, note, depth=1, jump_kind="value", expect="summary '1'") | |
| return | |
| before = summary_text(ui(), "Suggestion Count") | |
| okd, noted = and_enter_dialog("Suggestion Count") | |
| if not okd: | |
| record(name, False, noted, depth=2, jump_kind="value", expect="summary '1'") | |
| return | |
| pick_option("1") | |
| got = summary_text(ui(), "Suggestion Count") | |
| ok = (got == "1") and (before != "1") | |
| record(name, ok, | |
| "" if ok else f"behavior_wrong: summary {got!r} after picking '1' " | |
| f"(before {before!r}), expected '1'", | |
| depth=2, jump_kind="value", expect="Suggestion Count summary == '1'") | |
| restore_listpref("Suggestion Count", "3") | |
| def test_key_size_large(): | |
| """Key Size: options Small/Medium/Large/Extra Large (Medium selected). Pick | |
| 'Large' -> summary becomes 'Large' (observed). Restore 'Medium'.""" | |
| name = "computation_key_size_large" | |
| open_settings() | |
| ok, note = and_enter_fragment("Appearance") | |
| if not ok: | |
| record(name, False, note, depth=1, jump_kind="value", expect="summary 'Large'") | |
| return | |
| before = summary_text(ui(), "Key Size") # observed "Medium" | |
| okd, noted = and_enter_dialog("Key Size") | |
| if not okd: | |
| record(name, False, noted, depth=2, jump_kind="value", expect="summary 'Large'") | |
| return | |
| pick_option("Large") | |
| got = summary_text(ui(), "Key Size") | |
| ok = (got == "Large") and (before != "Large") | |
| record(name, ok, | |
| "" if ok else f"behavior_wrong: Key Size summary {got!r} after picking " | |
| f"'Large' (before {before!r}), expected 'Large'", | |
| depth=2, jump_kind="value", expect="Key Size summary == 'Large'") | |
| restore_listpref("Key Size", "Medium") | |
| def test_key_label_size_large(): | |
| """Key Label Size: options Small/Medium/Large (Medium selected). Pick 'Large' | |
| -> summary becomes 'Large' (observed). Restore 'Medium'.""" | |
| name = "computation_key_label_size_large" | |
| open_settings() | |
| ok, note = and_enter_fragment("Appearance") | |
| if not ok: | |
| record(name, False, note, depth=1, jump_kind="value", expect="summary 'Large'") | |
| return | |
| before = summary_text(ui(), "Key Label Size") | |
| okd, noted = and_enter_dialog("Key Label Size") | |
| if not okd: | |
| record(name, False, noted, depth=2, jump_kind="value", expect="summary 'Large'") | |
| return | |
| pick_option("Large") | |
| got = summary_text(ui(), "Key Label Size") | |
| ok = (got == "Large") and (before != "Large") | |
| record(name, ok, | |
| "" if ok else f"behavior_wrong: Key Label Size summary {got!r} after " | |
| f"picking 'Large' (before {before!r}), expected 'Large'", | |
| depth=2, jump_kind="value", expect="Key Label Size summary == 'Large'") | |
| restore_listpref("Key Label Size", "Medium") | |
| def test_cursor_speed_fast(): | |
| """Cursor Speed: options Slow/Medium/Fast/Very Fast (Medium selected). Pick | |
| 'Fast' -> summary becomes 'Fast' (observed). Row needs scrolling. Restore 'Medium'.""" | |
| name = "computation_cursor_speed_fast" | |
| open_settings() | |
| ok, note = and_enter_fragment("Typing Behavior Settings") | |
| if not ok: | |
| record(name, False, note, depth=1, jump_kind="value", expect="summary 'Fast'") | |
| return | |
| scroll_into_view("Cursor Speed") | |
| before = summary_text(ui(), "Cursor Speed") | |
| okd, noted = and_enter_dialog("Cursor Speed", scroll=True) | |
| if not okd: | |
| record(name, False, noted, depth=2, jump_kind="value", expect="summary 'Fast'") | |
| return | |
| pick_option("Fast") | |
| got = summary_text(ui(), "Cursor Speed") | |
| ok = (got == "Fast") and (before != "Fast") | |
| record(name, ok, | |
| "" if ok else f"behavior_wrong: Cursor Speed summary {got!r} after " | |
| f"picking 'Fast' (before {before!r}), expected 'Fast'", | |
| depth=2, jump_kind="value", expect="Cursor Speed summary == 'Fast'") | |
| restore_listpref("Cursor Speed", "Medium", scroll=True) | |
| def test_long_press_punctuation_spacebar(): | |
| """Long Press Punctuation: options Off/Spacebar/Period Key (Period Key selected). | |
| Pick 'Spacebar' -> summary becomes 'Spacebar' (observed). Restore 'Period Key'.""" | |
| name = "computation_long_press_punctuation_spacebar" | |
| open_settings() | |
| ok, note = and_enter_fragment("Typing Behavior Settings") | |
| if not ok: | |
| record(name, False, note, depth=1, jump_kind="value", expect="summary 'Spacebar'") | |
| return | |
| scroll_into_view("Long Press Punctuation") | |
| before = summary_text(ui(), "Long Press Punctuation") # observed "Period Key" | |
| okd, noted = and_enter_dialog("Long Press Punctuation", scroll=True) | |
| if not okd: | |
| record(name, False, noted, depth=2, jump_kind="value", expect="summary 'Spacebar'") | |
| return | |
| pick_option("Spacebar") | |
| got = summary_text(ui(), "Long Press Punctuation") | |
| ok = (got == "Spacebar") and (before != "Spacebar") | |
| record(name, ok, | |
| "" if ok else f"behavior_wrong: Long Press Punctuation summary {got!r} " | |
| f"after picking 'Spacebar' (before {before!r}), expected 'Spacebar'", | |
| depth=2, jump_kind="value", expect="Long Press Punctuation summary == 'Spacebar'") | |
| restore_listpref("Long Press Punctuation", "Period Key", scroll=True) | |
| def test_long_press_duration_long(): | |
| """Long Press Duration: options Short/Medium/Long (Medium selected). Pick | |
| 'Long' -> summary becomes 'Long' (observed). Restore 'Medium'.""" | |
| name = "computation_long_press_duration_long" | |
| open_settings() | |
| ok, note = and_enter_fragment("Typing Behavior Settings") | |
| if not ok: | |
| record(name, False, note, depth=1, jump_kind="value", expect="summary 'Long'") | |
| return | |
| scroll_into_view("Long Press Duration") | |
| before = summary_text(ui(), "Long Press Duration") | |
| okd, noted = and_enter_dialog("Long Press Duration", scroll=True) | |
| if not okd: | |
| record(name, False, noted, depth=2, jump_kind="value", expect="summary 'Long'") | |
| return | |
| pick_option("Long") | |
| got = summary_text(ui(), "Long Press Duration") | |
| ok = (got == "Long") and (before != "Long") | |
| record(name, ok, | |
| "" if ok else f"behavior_wrong: Long Press Duration summary {got!r} after " | |
| f"picking 'Long' (before {before!r}), expected 'Long'", | |
| depth=2, jump_kind="value", expect="Long Press Duration summary == 'Long'") | |
| restore_listpref("Long Press Duration", "Medium", scroll=True) | |
| def test_space_bar_size_wide(): | |
| """Space Bar Size (Layout & Input): options Compact/Standard/Wide (Standard | |
| selected). Pick 'Wide' -> summary becomes 'Wide' (observed). Restore 'Standard'.""" | |
| name = "computation_space_bar_size_wide" | |
| open_settings() | |
| ok, note = and_enter_layout_fragment() | |
| if not ok: | |
| record(name, False, note, depth=1, jump_kind="value", expect="summary 'Wide'") | |
| return | |
| if not find_node(ui(), text="Space Bar Size"): | |
| scroll_into_view("Space Bar Size") | |
| before = summary_text(ui(), "Space Bar Size") # observed "Standard" | |
| okd, noted = and_enter_dialog("Space Bar Size", scroll=True) | |
| if not okd: | |
| record(name, False, noted, depth=2, jump_kind="value", expect="summary 'Wide'") | |
| return | |
| pick_option("Wide") | |
| got = summary_text(ui(), "Space Bar Size") | |
| ok = (got == "Wide") and (before != "Wide") | |
| record(name, ok, | |
| "" if ok else f"behavior_wrong: Space Bar Size summary {got!r} after " | |
| f"picking 'Wide' (before {before!r}), expected 'Wide'", | |
| depth=2, jump_kind="value", expect="Space Bar Size summary == 'Wide'") | |
| restore_listpref("Space Bar Size", "Standard", scroll=True) | |
| def test_keyboard_layout_qwertz(): | |
| """Keyboard Layout (Layout & Input): default summary 'Default (Language Layout)'. | |
| Options include QWERTY/AZERTY/QWERTZ/Dvorak/... Pick 'QWERTZ' -> summary becomes | |
| EXACTLY 'QWERTZ' (observed verbatim). VLM: the dialog is a rendered option list. | |
| Restore to 'Default (Language Layout)'.""" | |
| name = "computation_keyboard_layout_qwertz" | |
| open_settings() | |
| ok, note = and_enter_layout_fragment() | |
| if not ok: | |
| record(name, False, note, depth=1, jump_kind="value", expect="summary 'QWERTZ'") | |
| return | |
| before = summary_text(ui(), "Keyboard Layout") # observed "Default (Language Layout)" | |
| okd, noted = and_enter_dialog("Keyboard Layout") | |
| if not okd: | |
| record(name, False, noted, depth=2, jump_kind="value", expect="summary 'QWERTZ'") | |
| return | |
| vlm_assert("computation_keyboard_layout_dialog", | |
| "Is a dialog shown listing multiple keyboard-layout choices (such as " | |
| "QWERTY / QWERTZ / AZERTY) as a vertical list of selectable rows?", | |
| RESULTS_DIR, tag="shape") | |
| pick_option("QWERTZ") | |
| got = summary_text(ui(), "Keyboard Layout") | |
| ok = (got == "QWERTZ") and (before != "QWERTZ") | |
| record(name, ok, | |
| "" if ok else f"behavior_wrong: Keyboard Layout summary {got!r} after " | |
| f"picking 'QWERTZ' (before {before!r}), expected 'QWERTZ'", | |
| depth=2, jump_kind="value", expect="Keyboard Layout summary == 'QWERTZ'") | |
| restore_listpref("Keyboard Layout", "Default (Language Layout)") | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| # (2) Vibration Strength SeekBar: tap a position -> numeric label (deterministic) | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| def test_vibration_seekbar_min(): | |
| """Vibration Strength SeekBar (min 1, max 255, starts at 128). Tapping the far | |
| LEFT (2% of the bar width) deterministically sets seekbar_value to '6' | |
| (reproduced 3x). Positive/negative: value is '128' before, '6' after. VLM: the | |
| thumb visibly sits at the left end. Restore toward 128 (centre tap -> 128).""" | |
| name = "computation_vibration_seekbar_min" | |
| open_settings() | |
| ok, note = and_enter_fragment("Typing Behavior Settings") | |
| if not ok: | |
| record(name, False, note, depth=1, jump_kind="value", expect="seekbar_value '6'") | |
| return | |
| if not scroll_into_view("Vibration Strength"): | |
| record(name, False, "setup_failed: 'Vibration Strength' not reached", | |
| depth=2, jump_kind="value", expect="seekbar_value '6'") | |
| return | |
| and_enter("Vibration Strength seekbar") | |
| before = seek_value(ui()) # observed "128" | |
| got, found = tap_seekbar_fraction(0.02) | |
| if not found: | |
| record(name, False, "setup_failed: seekbar node not found", | |
| depth=2, jump_kind="value", expect="seekbar_value '6'") | |
| return | |
| # VLM: thumb pushed to the far-left after the tap. | |
| vlm_assert("computation_vibration_seekbar_min", | |
| "Is the slider (SeekBar) thumb positioned at the far-LEFT end of the " | |
| "Vibration Strength track, near the start of the bar?", | |
| RESULTS_DIR, tag="position") | |
| ok = (got == "6") and (before == "128") | |
| record(name, ok, | |
| "" if ok else f"behavior_wrong: seekbar_value {got!r} after far-left tap " | |
| f"(before {before!r}), expected '6'", | |
| depth=2, jump_kind="value", expect="seekbar_value == '6' (far-left tap)") | |
| tap_seekbar_fraction(0.5) # restore toward centre (-> 128) | |
| def test_vibration_seekbar_max(): | |
| """Tapping the far RIGHT (98% of the bar width) deterministically sets | |
| seekbar_value to '250' (reproduced 3x). Positive/negative: '250' absent before, | |
| present after. VLM: the thumb visibly sits at the right end. Restore toward 128.""" | |
| name = "computation_vibration_seekbar_max" | |
| open_settings() | |
| ok, note = and_enter_fragment("Typing Behavior Settings") | |
| if not ok: | |
| record(name, False, note, depth=1, jump_kind="value", expect="seekbar_value '250'") | |
| return | |
| if not scroll_into_view("Vibration Strength"): | |
| record(name, False, "setup_failed: 'Vibration Strength' not reached", | |
| depth=2, jump_kind="value", expect="seekbar_value '250'") | |
| return | |
| and_enter("Vibration Strength seekbar") | |
| before = seek_value(ui()) | |
| got, found = tap_seekbar_fraction(0.98) | |
| if not found: | |
| record(name, False, "setup_failed: seekbar node not found", | |
| depth=2, jump_kind="value", expect="seekbar_value '250'") | |
| return | |
| vlm_assert("computation_vibration_seekbar_max", | |
| "Is the slider (SeekBar) thumb positioned at the far-RIGHT end of the " | |
| "Vibration Strength track, near the end of the bar?", | |
| RESULTS_DIR, tag="position") | |
| ok = (got == "250") and (before != "250") | |
| record(name, ok, | |
| "" if ok else f"behavior_wrong: seekbar_value {got!r} after far-right tap " | |
| f"(before {before!r}), expected '250'", | |
| depth=2, jump_kind="value", expect="seekbar_value == '250' (far-right tap)") | |
| tap_seekbar_fraction(0.5) # restore toward centre (-> 128) | |
| def test_vibration_seekbar_center(): | |
| """Tapping the CENTRE (50% of the bar width) deterministically sets | |
| seekbar_value to '128' (reproduced 3x; also the default). Verify by first | |
| driving it to the far-left ('6') then a centre tap returns it to '128' — | |
| so the assertion is a specific set->read, not merely 'unchanged'.""" | |
| name = "computation_vibration_seekbar_center" | |
| open_settings() | |
| ok, note = and_enter_fragment("Typing Behavior Settings") | |
| if not ok: | |
| record(name, False, note, depth=1, jump_kind="value", expect="seekbar_value '128'") | |
| return | |
| if not scroll_into_view("Vibration Strength"): | |
| record(name, False, "setup_failed: 'Vibration Strength' not reached", | |
| depth=2, jump_kind="value", expect="seekbar_value '128'") | |
| return | |
| and_enter("Vibration Strength seekbar") | |
| low, found = tap_seekbar_fraction(0.02) # drive down to '6' first | |
| if not found: | |
| record(name, False, "setup_failed: seekbar node not found", | |
| depth=2, jump_kind="value", expect="seekbar_value '128'") | |
| return | |
| got, _ = tap_seekbar_fraction(0.5) # centre -> back to '128' | |
| ok = (low == "6") and (got == "128") | |
| record(name, ok, | |
| "" if ok else f"behavior_wrong: centre tap gave {got!r} (from {low!r}), " | |
| f"expected '128'", | |
| depth=2, jump_kind="value", expect="seekbar_value == '128' (centre tap)") | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| # (3) test_field EditText echo: type a string -> field text equals it exactly | |
| # (different fragments from the interaction lane; distinct markers) | |
| # ══════════════════════════════════════════════════════════════════════════════ | |
| def test_test_field_echo_typing(): | |
| """Typing Behavior fragment's bottom test_field: type 'kbdcompute7' -> the | |
| field's text equals exactly 'kbdcompute7' (observed). VLM: the typed text is | |
| rendered in the field.""" | |
| name = "computation_test_field_echo_typing" | |
| marker = "kbdcompute7" | |
| open_settings() | |
| ok, note = and_enter_fragment("Typing Behavior Settings") | |
| if not ok: | |
| record(name, False, note, depth=1, jump_kind="value", expect=f"field == {marker!r}") | |
| return | |
| tf = test_field(ui()) | |
| if not tf: | |
| record(name, False, "feature_missing: no test_field EditText", | |
| depth=2, jump_kind="value", expect=f"field == {marker!r}") | |
| return | |
| if not type_text(tf, marker): | |
| record(name, False, "setup_failed: could not type into test_field", | |
| depth=2, jump_kind="value", expect=f"field == {marker!r}") | |
| return | |
| got = (node_by_id(ui(), "test_field") or {}).get("text", "") | |
| ok = got.strip() == marker | |
| # VLM: the field visibly renders the typed characters. | |
| vlm_assert("computation_test_field_echo_typing", | |
| f"Does the 'Test changes' input field at the bottom visibly display " | |
| f"the typed text '{marker}'?", | |
| RESULTS_DIR, tag="content") | |
| record(name, ok, | |
| "" if ok else f"behavior_wrong: test_field held {got!r}, expected {marker!r}", | |
| depth=2, jump_kind="value", expect=f"test_field text == {marker!r}") | |
| def test_test_field_echo_layout(): | |
| """Layout & Input fragment's bottom test_field: type 'kbdlayout9' -> the | |
| field's text equals exactly 'kbdlayout9' (observed).""" | |
| name = "computation_test_field_echo_layout" | |
| marker = "kbdlayout9" | |
| open_settings() | |
| ok, note = and_enter_layout_fragment() | |
| if not ok: | |
| record(name, False, note, depth=1, jump_kind="value", expect=f"field == {marker!r}") | |
| return | |
| tf = test_field(ui()) | |
| if not tf: | |
| record(name, False, "feature_missing: no test_field EditText", | |
| depth=2, jump_kind="value", expect=f"field == {marker!r}") | |
| return | |
| if not type_text(tf, marker): | |
| record(name, False, "setup_failed: could not type into test_field", | |
| depth=2, jump_kind="value", expect=f"field == {marker!r}") | |
| return | |
| got = (node_by_id(ui(), "test_field") or {}).get("text", "") | |
| ok = got.strip() == marker | |
| record(name, ok, | |
| "" if ok else f"behavior_wrong: test_field held {got!r}, expected {marker!r}", | |
| depth=2, jump_kind="value", expect=f"test_field text == {marker!r}") | |
| TESTS = [ | |
| # ListPreference pick -> summary | |
| test_suggestion_count_2, | |
| test_suggestion_count_1, | |
| test_key_size_large, | |
| test_key_label_size_large, | |
| test_cursor_speed_fast, | |
| test_long_press_punctuation_spacebar, | |
| test_long_press_duration_long, | |
| test_space_bar_size_wide, | |
| test_keyboard_layout_qwertz, | |
| # SeekBar set -> value | |
| test_vibration_seekbar_min, | |
| test_vibration_seekbar_max, | |
| test_vibration_seekbar_center, | |
| # test_field echo | |
| test_test_field_echo_typing, | |
| test_test_field_echo_layout, | |
| ] | |
| if __name__ == "__main__": | |
| run_suite(TESTS, "computation") | |