diff --git a/data/runs.json b/data/runs.json index 7ba127f..97be9c8 100644 --- a/data/runs.json +++ b/data/runs.json @@ -732,5 +732,15 @@ "output": "tapped testid=busyRowB at (540, 1095)\ngray box: waited 307 ms for the app to go idle (busy: quiet)", "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", "after": "/img/shots/app_tap-3-after.jpg" + }, + "app_hook[0]": { + "tool": "app_hook", + "index": 0, + "command": "mobium hook raiseToast \"Toast raised by test script\"", + "verbatim": true, + "exit": 0, + "output": "hook raiseToast answered: \"shown\"\ngray box: the app was idle", + "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", + "after": "/img/shots/app_hook-0-after.jpg" } } diff --git a/examples/canonical.json b/examples/canonical.json index b8aaae7..042486b 100644 --- a/examples/canonical.json +++ b/examples/canonical.json @@ -903,5 +903,17 @@ "name": "mobium-test" } } + ], + "app_hook": [ + { + "title": "Call a hook the app registered, and get back what it answered", + "cli": "mobium hook raiseToast \"Toast raised by test script\"", + "args": { + "hook": "raiseToast", + "args": [ + "Toast raised by test script" + ] + } + } ] } diff --git a/examples/dotnet.json b/examples/dotnet.json index 2460f48..9e94b30 100644 --- a/examples/dotnet.json +++ b/examples/dotnet.json @@ -459,6 +459,11 @@ { "code": "device.Shutdown(\"mobium-test\");" } + ], + "app_hook": [ + { + "code": "device.LaunchWithGrayBox(\"dev.mobium.mobiumapp\");\nvar answer = device.Hook(\"raiseToast\", \"Toast raised by test script\"); // \"shown\"" + } ] }, "members": { diff --git a/examples/go.json b/examples/go.json index 0d83a69..cac0fec 100644 --- a/examples/go.json +++ b/examples/go.json @@ -459,6 +459,11 @@ { "code": "if err := dev.Shutdown(ctx, \"mobium-test\"); err != nil {\n\treturn err\n}" } + ], + "app_hook": [ + { + "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" + } ] }, "members": { diff --git a/examples/java.json b/examples/java.json index 1533ce8..33ca858 100644 --- a/examples/java.json +++ b/examples/java.json @@ -459,6 +459,11 @@ { "code": "device.shutdown(\"mobium-test\");" } + ], + "app_hook": [ + { + "code": "device.launchWithGrayBox(\"dev.mobium.mobiumapp\");\nObject answer = device.hook(\"raiseToast\", \"Toast raised by test script\"); // \"shown\"" + } ] }, "members": { diff --git a/examples/javascript.json b/examples/javascript.json index cadfac0..f326e85 100644 --- a/examples/javascript.json +++ b/examples/javascript.json @@ -459,6 +459,11 @@ { "code": "await device.shutdown('mobium-test')" } + ], + "app_hook": [ + { + "code": "await device.launch('dev.mobium.mobiumapp', { grayBox: true })\nconsole.log(await device.hook('raiseToast', 'Toast raised by test script')) // shown" + } ] }, "members": { diff --git a/examples/python.json b/examples/python.json index 06964f2..5445334 100644 --- a/examples/python.json +++ b/examples/python.json @@ -459,6 +459,11 @@ { "code": "device.shutdown(\"mobium-test\")" } + ], + "app_hook": [ + { + "code": "device.launch(\"dev.mobium.mobiumapp\", gray_box=True)\nprint(device.hook(\"raiseToast\", \"Toast raised by test script\")) # shown" + } ] }, "members": { diff --git a/scripts/capture.py b/scripts/capture.py index 7198028..ab69f74 100644 --- a/scripts/capture.py +++ b/scripts/capture.py @@ -62,6 +62,10 @@ def app_screen(name): dict(tool="app_launch", i=0, setup=[f"terminate {SETTINGS}"], after=True), # MobiumApp links Mobium's gray-box library; the launch says the app answered. dict(tool="app_launch", i=1, setup=[f"terminate {APP}"]), + # A gray-box hook: MobiumApp's raiseToast draws its message in a toast. + dict(tool="app_hook", i=0, setup=[f"terminate {APP}", f"launch --gray-box {APP}"], after=True, + 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"), dict(tool="app_map", i=0, setup=settings_root(), after=True), dict(tool="app_text", i=0, setup=settings_root(), after=True), dict(tool="app_find", i=0, setup=settings_root(), after=True), diff --git a/static/img/shots/app_hook-0-after.jpg b/static/img/shots/app_hook-0-after.jpg new file mode 100644 index 0000000..7c54f9a Binary files /dev/null and b/static/img/shots/app_hook-0-after.jpg differ