Skip to content

Commit ae3aba1

Browse files
authored
Hooks: app_hook in every language, and its capture on MobiumApp (#8)
mobium hook raiseToast "Toast raised by test script" on an Android 15 emulator launched with --gray-box: the app's own toast, drawn at the top of the screen, says what the hook was sent.
1 parent a85410d commit ae3aba1

9 files changed

Lines changed: 51 additions & 0 deletions

File tree

‎data/runs.json‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,5 +732,15 @@
732732
"output": "tapped testid=busyRowB at (540, 1095)\ngray box: waited 307 ms for the app to go idle (busy: quiet)",
733733
"caption": "`mobium tap testid=busyRowB` on MobiumApp's Busy Demo, Android 15 emulator, launched with `--gray-box`: the tap waited for the quiet refresh to finish, and Row B is the new generation's",
734734
"after": "/img/shots/app_tap-3-after.jpg"
735+
},
736+
"app_hook[0]": {
737+
"tool": "app_hook",
738+
"index": 0,
739+
"command": "mobium hook raiseToast \"Toast raised by test script\"",
740+
"verbatim": true,
741+
"exit": 0,
742+
"output": "hook raiseToast answered: \"shown\"\ngray box: the app was idle",
743+
"caption": "`mobium hook raiseToast \"Toast raised by test script\"` on MobiumApp, Android 15 emulator, launched with `--gray-box`: the app's own toast says what the hook was sent",
744+
"after": "/img/shots/app_hook-0-after.jpg"
735745
}
736746
}

‎examples/canonical.json‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,5 +903,17 @@
903903
"name": "mobium-test"
904904
}
905905
}
906+
],
907+
"app_hook": [
908+
{
909+
"title": "Call a hook the app registered, and get back what it answered",
910+
"cli": "mobium hook raiseToast \"Toast raised by test script\"",
911+
"args": {
912+
"hook": "raiseToast",
913+
"args": [
914+
"Toast raised by test script"
915+
]
916+
}
917+
}
906918
]
907919
}

‎examples/dotnet.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,11 @@
459459
{
460460
"code": "device.Shutdown(\"mobium-test\");"
461461
}
462+
],
463+
"app_hook": [
464+
{
465+
"code": "device.LaunchWithGrayBox(\"dev.mobium.mobiumapp\");\nvar answer = device.Hook(\"raiseToast\", \"Toast raised by test script\"); // \"shown\""
466+
}
462467
]
463468
},
464469
"members": {

‎examples/go.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,11 @@
459459
{
460460
"code": "if err := dev.Shutdown(ctx, \"mobium-test\"); err != nil {\n\treturn err\n}"
461461
}
462+
],
463+
"app_hook": [
464+
{
465+
"code": "if err := dev.LaunchWithGrayBox(ctx, \"dev.mobium.mobiumapp\"); err != nil {\n\treturn err\n}\nanswer, err := dev.Hook(ctx, \"raiseToast\", \"Toast raised by test script\")\nif err != nil {\n\treturn err\n}\nfmt.Println(answer) // shown"
466+
}
462467
]
463468
},
464469
"members": {

‎examples/java.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,11 @@
459459
{
460460
"code": "device.shutdown(\"mobium-test\");"
461461
}
462+
],
463+
"app_hook": [
464+
{
465+
"code": "device.launchWithGrayBox(\"dev.mobium.mobiumapp\");\nObject answer = device.hook(\"raiseToast\", \"Toast raised by test script\"); // \"shown\""
466+
}
462467
]
463468
},
464469
"members": {

‎examples/javascript.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,11 @@
459459
{
460460
"code": "await device.shutdown('mobium-test')"
461461
}
462+
],
463+
"app_hook": [
464+
{
465+
"code": "await device.launch('dev.mobium.mobiumapp', { grayBox: true })\nconsole.log(await device.hook('raiseToast', 'Toast raised by test script')) // shown"
466+
}
462467
]
463468
},
464469
"members": {

‎examples/python.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,11 @@
459459
{
460460
"code": "device.shutdown(\"mobium-test\")"
461461
}
462+
],
463+
"app_hook": [
464+
{
465+
"code": "device.launch(\"dev.mobium.mobiumapp\", gray_box=True)\nprint(device.hook(\"raiseToast\", \"Toast raised by test script\")) # shown"
466+
}
462467
]
463468
},
464469
"members": {

‎scripts/capture.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ def app_screen(name):
6262
dict(tool="app_launch", i=0, setup=[f"terminate {SETTINGS}"], after=True),
6363
# MobiumApp links Mobium's gray-box library; the launch says the app answered.
6464
dict(tool="app_launch", i=1, setup=[f"terminate {APP}"]),
65+
# A gray-box hook: MobiumApp's raiseToast draws its message in a toast.
66+
dict(tool="app_hook", i=0, setup=[f"terminate {APP}", f"launch --gray-box {APP}"], after=True,
67+
caption="`mobium hook raiseToast \"Toast raised by test script\"` on MobiumApp, Android 15 emulator, "
68+
"launched with `--gray-box`: the app's own toast says what the hook was sent"),
6569
dict(tool="app_map", i=0, setup=settings_root(), after=True),
6670
dict(tool="app_text", i=0, setup=settings_root(), after=True),
6771
dict(tool="app_find", i=0, setup=settings_root(), after=True),
56.9 KB
Loading

0 commit comments

Comments
 (0)