Datasets:
File size: 25,754 Bytes
d292518 | 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 | #!/usr/bin/env python3
"""NAVIGATION lane — surface REACHABILITY + back-stack integrity for Vector Pinball.
This lane is the SOLE owner of jump_kind="reach" and of the depth>=2 chains. Every
jump is proven with and_reach(before, after, target, source): the TARGET surface's
discriminating element APPEARED *and* the SOURCE surface's element DISAPPEARED — a
screen that was in the dump all along was never reached. Back navigation is proven
the same way (the surface you left is gone, the one you returned to is back), and the
deep chains unwind hop-by-hop with and_back().
The playfield + score are canvas/GL views that never reach the view tree, so the five
VLM records assert canvas-only ARRIVAL end-states (gameplay field shown, paused overlay
atop field, the two AlertDialogs, a different table after next). Everything else is
tree-observable and stays a rule assertion.
"""
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from android_testgen_kit import * # noqa: F403,E402
RESULTS = RESULTS_DIR
# ══════════════════════════════════════════════════════════════════════════════
# Depth-family helpers (the and_reach_* / and_enter_* NAME is what the depth audit
# looks for; each returns the (before, after) surface snapshots it observed so the
# caller can build its own reach verdict, or already carries a proven reach).
# ══════════════════════════════════════════════════════════════════════════════
def and_reach_menu():
"""Fresh launch -> main menu (game NOT in progress). depth 0 entry point."""
restart_app()
wait_for_foreground(10)
return ui()
def and_reach_preferences():
"""Main menu -> Preferences activity. Returns (before, after) snapshots."""
before_nodes = and_reach_menu()
before = and_showing(before_nodes)
tap_node(node_by_id(before_nodes, "preferencesButton"))
settle("tap")
after_nodes = ui()
and_enter("Preferences")
return before, and_showing(after_nodes), after_nodes
def and_reach_about():
"""Main menu -> About activity. Returns (before, after) snapshots."""
before_nodes = and_reach_menu()
before = and_showing(before_nodes)
tap_node(node_by_id(before_nodes, "aboutButton"))
settle("tap")
after_nodes = ui()
and_enter("About")
return before, and_showing(after_nodes)
def and_reach_highscores():
"""Main menu -> High Scores panel (panel swap, same activity)."""
before_nodes = and_reach_menu()
before = and_showing(before_nodes)
tap_node(node_by_id(before_nodes, "highScoreButton"))
settle("tap")
after_nodes = ui()
and_enter("HighScores")
return before, and_showing(after_nodes), after_nodes
def and_reach_gameplay():
"""Main menu -> gameplay (buttonPanel gone, pauseIcon shown). depth 1."""
before_nodes = and_reach_menu()
before = and_showing(before_nodes)
tap_node(node_by_id(before_nodes, "startGameButton"))
settle("tap")
settle("tap")
after_nodes = ui()
ok = and_reach(before, and_showing(after_nodes), "pauseIcon", "buttonPanel")
if ok:
and_enter("Gameplay")
return ok, after_nodes
def and_reach_paused_via_icon():
"""menu -> gameplay -> paused (tap pauseIcon). depth 2. Returns (ok, nodes)."""
ok, game_nodes = and_reach_gameplay()
if not ok:
return False, game_nodes
before = and_showing(game_nodes)
tap_node(node_by_id(game_nodes, "pauseIcon"))
settle("tap")
paused_nodes = ui()
reached = and_reach(before, and_showing(paused_nodes), "RESUME GAME", "pauseIcon")
if reached:
and_enter("Paused")
return reached, paused_nodes
def and_reach_gamespeed_dialog():
"""menu -> prefs -> Game speed dialog. depth 2. Returns (ok, before, after)."""
_b, _prefs, prefs_nodes = and_reach_preferences()
row = find_node(prefs_nodes, text="Game speed")
if row is None:
return False, set(), set()
before = and_showing(prefs_nodes)
tap_node(row)
settle("tap")
after = and_showing()
ok = and_reach(before, after, "Fast", "Sound")
if ok:
and_enter("GameSpeedDialog")
return ok, before, after
def and_reach_linewidth_dialog():
"""menu -> prefs -> Line width dialog. depth 2. Returns (ok, before, after)."""
_b, _prefs, prefs_nodes = and_reach_preferences()
row = find_node(prefs_nodes, text="Line width") or scroll_into_view("Line width")
prefs_nodes = ui()
row = find_node(prefs_nodes, text="Line width")
if row is None:
return False, set(), set()
before = and_showing(prefs_nodes)
tap_node(row)
settle("tap")
after = and_showing()
ok = and_reach(before, after, "OK", "Sound")
if ok:
and_enter("LineWidthDialog")
return ok, before, after
# ══════════════════════════════════════════════════════════════════════════════
# (A) Top-level destinations — one hop each (depth 1, reach)
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("nav_reach_preferences",))
def test_reach_preferences():
if not device_online():
record("nav_reach_preferences", False,
"setup_failed: device offline", depth=1, jump_kind="reach",
expect="Preferences activity shown")
return
before, after, _n = and_reach_preferences()
ok = and_reach(before, after, "Sound", "START GAME")
record("nav_reach_preferences", ok,
"" if ok else "feature_missing: Preferences did not open (Sound row absent or menu still shown)",
depth=1, jump_kind="reach",
expect="Preferences: Sound row appeared; main-menu START GAME gone")
@and_test(expects=("nav_reach_about",))
def test_reach_about():
before, after = and_reach_about()
# aboutTextView's node_key is its long text; match a stable substring inside it.
ok = and_reach(before, after, "Brian Nenninger", "START GAME")
record("nav_reach_about", ok,
"" if ok else "feature_missing: About did not open (about text absent or menu still shown)",
depth=1, jump_kind="reach",
expect="About: aboutTextView (with 'Brian Nenninger') appeared; START GAME gone")
@and_test(expects=("nav_reach_highscores",))
def test_reach_highscores():
before, after, _n = and_reach_highscores()
ok = and_reach(before, after, "OK", "START GAME")
record("nav_reach_highscores", ok,
"" if ok else "feature_missing: High Scores panel did not open (OK button absent or menu still shown)",
depth=1, jump_kind="reach",
expect="High Scores: hideHighScoreButton (OK) appeared; START GAME gone")
@and_test(expects=("nav_reach_gameplay", "nav_reach_gameplay_vlm"))
def test_reach_gameplay():
ok, _n = and_reach_gameplay()
record("nav_reach_gameplay", ok,
"" if ok else "behavior_wrong: Start Game did not enter gameplay (pauseIcon absent or buttonPanel still present)",
depth=1, jump_kind="reach",
expect="Gameplay: pauseIcon appeared; menu buttonPanel gone")
vlm_assert("nav_reach_gameplay",
"Is the pinball playfield (a large vector line drawing with colored "
"circular bumpers) now fully visible with NO grey menu panel of buttons "
"overlaying its center?",
RESULTS, depth=1, jump_kind="reach", tag="layout")
# ══════════════════════════════════════════════════════════════════════════════
# (B) Back navigation from each destination (reach back, depth 1)
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("nav_highscores_ok_back",))
def test_highscores_ok_returns_to_menu():
_b, _panel, panel_nodes = and_reach_highscores()
ok_btn = node_by_id(panel_nodes, "hideHighScoreButton")
if ok_btn is None:
record("nav_highscores_ok_back", False,
"setup_failed: High Scores panel/OK button not reached", depth=1,
jump_kind="reach", expect="menu restored after tapping OK")
return
before = and_showing(panel_nodes)
tap_node(ok_btn)
settle("tap")
after = and_showing()
ok = and_reach(before, after, "START GAME", "OK")
record("nav_highscores_ok_back", ok,
"" if ok else "behavior_wrong: OK did not return to the main menu (START GAME absent or OK still shown)",
depth=1, jump_kind="reach",
expect="menu START GAME back; panel OK button gone")
@and_test(expects=("nav_highscores_key_back",))
def test_highscores_back_key_closes_panel():
_b, _panel, panel_nodes = and_reach_highscores()
if node_by_id(panel_nodes, "hideHighScoreButton") is None:
record("nav_highscores_key_back", False,
"setup_failed: High Scores panel not reached", depth=1,
jump_kind="reach", expect="menu restored after BACK; app foreground")
return
before = and_showing(panel_nodes)
and_back() # BACK pops the panel
after = and_showing()
fg = is_app_foreground()
ok = fg and and_reach(before, after, "START GAME", "OK")
record("nav_highscores_key_back", ok,
"" if ok else "behavior_wrong: BACK did not close High Scores back to menu (or app left foreground)",
depth=1, jump_kind="reach",
expect="menu START GAME back; panel OK gone; app still foreground")
@and_test(expects=("nav_preferences_back",))
def test_preferences_back_to_menu():
_b, prefs, _n = and_reach_preferences()
if not any("Sound" in k for k in prefs):
record("nav_preferences_back", False,
"setup_failed: Preferences not reached", depth=1, jump_kind="reach",
expect="menu restored after BACK from Preferences")
return
and_back() # BACK leaves the Preferences activity
after = and_showing()
fg = is_app_foreground()
ok = fg and and_reach(prefs, after, "START GAME", "Sound")
record("nav_preferences_back", ok,
"" if ok else "behavior_wrong: BACK from Preferences did not restore the main menu",
depth=1, jump_kind="reach",
expect="menu START GAME back; Preferences Sound row gone; app foreground")
@and_test(expects=("nav_about_back",))
def test_about_back_to_menu():
before, about = and_reach_about()
if not any("Brian Nenninger" in k for k in about):
record("nav_about_back", False,
"setup_failed: About not reached", depth=1, jump_kind="reach",
expect="menu restored after BACK from About")
return
and_back() # BACK leaves the About activity
after = and_showing()
fg = is_app_foreground()
ok = fg and and_reach(about, after, "START GAME", "Brian Nenninger")
record("nav_about_back", ok,
"" if ok else "behavior_wrong: BACK from About did not restore the main menu",
depth=1, jump_kind="reach",
expect="menu START GAME back; about text gone; app foreground")
# ══════════════════════════════════════════════════════════════════════════════
# (C) State-machine transitions treated as reach — depth 2 (gameplay is depth 1;
# the paused menu / resume / end are one hop deeper)
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("nav_pause_via_icon",))
def test_pause_via_icon():
ok, _n = and_reach_paused_via_icon()
record("nav_pause_via_icon", ok,
"" if ok else "behavior_wrong: tapping pauseIcon did not open the paused menu (RESUME GAME absent or pauseIcon still shown)",
depth=2, jump_kind="reach",
expect="Paused: RESUME GAME appeared; pauseIcon gone")
@and_test(expects=("nav_pause_via_score", "nav_pause_via_score_vlm"))
def test_pause_via_score_area():
ok_game, game_nodes = and_reach_gameplay()
if not ok_game:
record("nav_pause_via_score", False,
"setup_failed: gameplay not reached", depth=2, jump_kind="reach",
expect="Paused menu via score-area tap")
vlm_assert("nav_pause_via_score",
"Is a vertical menu of grey buttons (with RESUME GAME at the top) "
"shown overlaying the pinball playfield?",
RESULTS, depth=2, jump_kind="reach", tag="layout")
return
score = node_by_id(game_nodes, "scoreView")
before = and_showing(game_nodes)
tap_node(score)
settle("tap")
after = and_showing()
ok = and_reach(before, after, "RESUME GAME", "pauseIcon")
if ok:
and_enter("Paused")
record("nav_pause_via_score", ok,
"" if ok else "behavior_wrong: tapping the score area did not open the paused menu",
depth=2, jump_kind="reach",
expect="Paused: RESUME GAME appeared; pauseIcon gone")
vlm_assert("nav_pause_via_score",
"Is a vertical menu of grey buttons (with RESUME GAME at the top) "
"shown overlaying the pinball playfield?",
RESULTS, depth=2, jump_kind="reach", tag="layout")
@and_test(expects=("nav_resume_to_game",))
def test_resume_returns_to_game():
ok_p, paused_nodes = and_reach_paused_via_icon()
resume = node_by_id(paused_nodes, "resumeGameButton") if ok_p else None
if resume is None:
record("nav_resume_to_game", False,
"setup_failed: paused menu / resume button not reached", depth=2,
jump_kind="reach", expect="gameplay restored after Resume")
return
before = and_showing(paused_nodes)
tap_node(resume)
settle("tap")
after = and_showing()
ok = and_reach(before, after, "pauseIcon", "RESUME GAME")
record("nav_resume_to_game", ok,
"" if ok else "behavior_wrong: Resume did not return to gameplay (pauseIcon absent or RESUME GAME still shown)",
depth=2, jump_kind="reach",
expect="gameplay pauseIcon back; paused RESUME GAME gone")
@and_test(expects=("nav_endgame_to_menu",))
def test_endgame_returns_to_fresh_menu():
ok_p, paused_nodes = and_reach_paused_via_icon()
end = node_by_id(paused_nodes, "endGameButton") if ok_p else None
if end is None:
record("nav_endgame_to_menu", False,
"setup_failed: paused menu / End Game button not reached", depth=2,
jump_kind="reach", expect="fresh main menu after End Game")
return
before = and_showing(paused_nodes)
tap_node(end)
settle("tap")
settle("tap")
after_nodes = ui()
after = and_showing(after_nodes)
# Fresh menu is discriminated from the paused menu by START GAME + selectTableRow
# reappearing while RESUME GAME leaves.
ok = (and_reach(before, after, "START GAME", "RESUME GAME")
and node_by_id(after_nodes, "selectTableRow") is not None)
record("nav_endgame_to_menu", ok,
"" if ok else "behavior_wrong: End Game did not restore the fresh main menu (START GAME/selectTableRow absent or RESUME GAME still shown)",
depth=2, jump_kind="reach",
expect="fresh menu START GAME + selectTableRow back; paused RESUME GAME gone")
@and_test(expects=("nav_back_during_game",))
def test_back_during_game_pauses():
ok_game, game_nodes = and_reach_gameplay()
if not ok_game:
record("nav_back_during_game", False,
"setup_failed: gameplay not reached", depth=2, jump_kind="reach",
expect="paused menu after BACK during gameplay; app foreground")
return
before = and_showing(game_nodes)
and_back() # custom back: pauses instead of exiting
after = and_showing()
fg = is_app_foreground()
ok = fg and and_reach(before, after, "RESUME GAME", "pauseIcon")
record("nav_back_during_game", ok,
"" if ok else "behavior_wrong: BACK during gameplay did not pause (RESUME GAME absent, pauseIcon still shown, or app exited)",
depth=2, jump_kind="reach",
expect="paused RESUME GAME appeared; pauseIcon gone; app still foreground")
# ══════════════════════════════════════════════════════════════════════════════
# (D) DEEP CHAINS — menu -> prefs -> dialog (depth 2 reach) + hop-by-hop back-stack
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("nav_gamespeed_dialog", "nav_gamespeed_dialog_vlm"))
def test_gamespeed_dialog_opens():
ok, _before, _after = and_reach_gamespeed_dialog()
record("nav_gamespeed_dialog", ok,
"" if ok else "feature_missing: Game speed dialog did not open (Fast option absent or prefs list still shown)",
depth=2, jump_kind="reach",
expect="Game speed dialog: 'Fast' option appeared; prefs Sound row covered")
vlm_assert("nav_gamespeed_dialog",
"Is a dialog titled 'Game speed' shown with three radio-button rows "
"labelled Slow, Normal and Fast stacked vertically?",
RESULTS, depth=2, jump_kind="reach", tag="shape")
@and_test(expects=("nav_linewidth_dialog", "nav_linewidth_dialog_vlm"))
def test_linewidth_dialog_opens():
ok, _before, _after = and_reach_linewidth_dialog()
record("nav_linewidth_dialog", ok,
"" if ok else "feature_missing: Line width dialog did not open (OK/EditText absent or prefs list still shown)",
depth=2, jump_kind="reach",
expect="Line width dialog: OK button + EditText appeared; prefs Sound row covered")
vlm_assert("nav_linewidth_dialog",
"Is a dialog titled 'Line width' shown with a single-line text input "
"field above a CANCEL and an OK button at the bottom-right?",
RESULTS, depth=2, jump_kind="reach", tag="position")
@and_test(expects=("nav_backstack_prefs_dialog_unwind",))
def test_backstack_prefs_dialog_unwinds():
"""DEEP 2-hop back-stack: menu -> prefs -> Game speed dialog, then BACK unwinds
it hop by hop: BACK #1 -> prefs list restored; BACK #2 -> main menu restored."""
ok, _before, dialog = and_reach_gamespeed_dialog()
if not ok:
record("nav_backstack_prefs_dialog_unwind", False,
"setup_failed: could not reach the Game speed dialog to unwind",
depth=2, jump_kind="reach",
expect="dialog -> prefs -> menu unwound by two BACK presses")
return
# hop 1 back: dialog -> prefs list (Sound row returns, Fast option gone)
and_back()
prefs_again = and_showing()
hop1 = and_reach(dialog, prefs_again, "Sound", "Fast")
# hop 2 back: prefs -> main menu (START GAME returns, Sound row gone)
and_back()
menu_again = and_showing()
fg = is_app_foreground()
hop2 = and_reach(prefs_again, menu_again, "START GAME", "Sound")
ok_all = hop1 and hop2 and fg
record("nav_backstack_prefs_dialog_unwind", ok_all,
"" if ok_all else "behavior_wrong: BACK did not unwind dialog->prefs->menu one hop at a time",
depth=2, jump_kind="reach",
expect="BACK#1 restores prefs (Sound back, Fast gone); BACK#2 restores menu (START GAME back)")
@and_test(expects=("nav_backstack_game_pause_resume",))
def test_backstack_game_pause_resume():
"""DEEP chain: menu -> gameplay -> paused (BACK) -> gameplay (Resume). Proves the
in-game BACK pauses (one hop deeper) and Resume unwinds it back to the field."""
ok_game, game_nodes = and_reach_gameplay()
if not ok_game:
record("nav_backstack_game_pause_resume", False,
"setup_failed: gameplay not reached", depth=2, jump_kind="reach",
expect="game -> paused -> game round trip")
return
before_game = and_showing(game_nodes)
and_back() # gameplay -> paused
paused = and_showing()
into_paused = and_reach(before_game, paused, "RESUME GAME", "pauseIcon")
resume = node_by_id(ui(), "resumeGameButton")
if resume is None:
record("nav_backstack_game_pause_resume", False,
"behavior_wrong: BACK during gameplay did not surface RESUME GAME",
depth=2, jump_kind="reach",
expect="game -> paused -> game round trip")
return
before_resume = and_showing()
tap_node(resume) # paused -> gameplay
settle("tap")
back_in_game = and_showing()
into_game = and_reach(before_resume, back_in_game, "pauseIcon", "RESUME GAME")
ok = into_paused and into_game
record("nav_backstack_game_pause_resume", ok,
"" if ok else "behavior_wrong: game->paused->game round trip did not unwind correctly",
depth=2, jump_kind="reach",
expect="BACK yields paused (RESUME GAME); Resume returns the field (pauseIcon)")
# ══════════════════════════════════════════════════════════════════════════════
# (E) Table selector host — pick a different table, then reach gameplay on it
# ══════════════════════════════════════════════════════════════════════════════
@and_test(expects=("nav_table_next_then_play", "nav_table_next_then_play_vlm"))
def test_table_next_then_play():
"""The table picker changes only the canvas (tree unchanged), so the reach is
proven by entering gameplay on the newly-selected table; the VLM confirms the
arrived field is a pinball table layout drawn behind no menu."""
menu_nodes = and_reach_menu()
nxt = node_by_id(menu_nodes, "nextTableButton")
if nxt is None:
record("nav_table_next_then_play", False,
"feature_missing: nextTableButton not present on the menu", depth=1,
jump_kind="reach", expect="gameplay reached after selecting next table")
vlm_assert("nav_table_next_then_play",
"In the large central play area (below the thin top status strip), "
"is a pinball table drawn as a vector outline containing "
"several solid colored circular bumpers (yellow, red, blue, "
"green, magenta) and NOT a grey panel of labelled menu buttons?",
RESULTS, depth=1, jump_kind="reach", tag="content")
return
tap_node(nxt) # advance the table picker (still on the menu)
settle("tap")
menu2 = ui()
still_menu = node_by_id(menu2, "selectTableRow") is not None
before = and_showing(menu2)
tap_node(node_by_id(menu2, "startGameButton"))
settle("tap")
settle("tap")
after = and_showing()
ok = still_menu and and_reach(before, after, "pauseIcon", "buttonPanel")
if ok:
and_enter("Gameplay")
record("nav_table_next_then_play", ok,
"" if ok else "behavior_wrong: could not reach gameplay after selecting the next table",
depth=1, jump_kind="reach",
expect="picker stayed on menu; then Start Game reached gameplay (pauseIcon; buttonPanel gone)")
vlm_assert("nav_table_next_then_play",
"In the large central play area (below the thin top status strip), is a "
"pinball table drawn as a vector outline containing several "
"solid colored circular bumpers (yellow, red, blue, green, "
"magenta) and NOT a grey panel of labelled menu buttons?",
RESULTS, depth=1, jump_kind="reach", tag="content")
TESTS = [
test_reach_preferences,
test_reach_about,
test_reach_highscores,
test_reach_gameplay,
test_highscores_ok_returns_to_menu,
test_highscores_back_key_closes_panel,
test_preferences_back_to_menu,
test_about_back_to_menu,
test_pause_via_icon,
test_pause_via_score_area,
test_resume_returns_to_game,
test_endgame_returns_to_fresh_menu,
test_back_during_game_pauses,
test_gamespeed_dialog_opens,
test_linewidth_dialog_opens,
test_backstack_prefs_dialog_unwinds,
test_backstack_game_pause_resume,
test_table_next_then_play,
]
if __name__ == "__main__":
run_suite(TESTS, "navigation")
|