{"id":15722447,"url":"https://github.com/defold/extension-poco","last_synced_at":"2025-10-20T04:31:40.473Z","repository":{"id":55667223,"uuid":"293739890","full_name":"defold/extension-poco","owner":"defold","description":"Test automation from a computer to a test device using the Poco APO","archived":false,"fork":false,"pushed_at":"2023-01-10T22:46:03.000Z","size":441,"stargazers_count":16,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-30T15:25:04.651Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/defold.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-08T07:52:48.000Z","updated_at":"2024-10-14T16:59:01.000Z","dependencies_parsed_at":"2023-02-08T20:31:33.156Z","dependency_job_id":null,"html_url":"https://github.com/defold/extension-poco","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defold%2Fextension-poco","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defold%2Fextension-poco/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defold%2Fextension-poco/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defold%2Fextension-poco/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/defold","download_url":"https://codeload.github.com/defold/extension-poco/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237267971,"owners_count":19282320,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T22:07:43.036Z","updated_at":"2025-10-20T04:31:40.037Z","avatar_url":"https://github.com/defold.png","language":"Lua","funding_links":[],"categories":["Libraries"],"sub_categories":["Programming Language"],"readme":"# Poco test framework integration\n\n## About\n\n`extension-poco` is a native extension for [Defold](https://www.defold.com) to enable test automation from a computer to a test device (desktop or mobile).\n\nThis extension implements the [Poco](https://poco-chinese.readthedocs.io/en/latest/#) api, using the [Cocos2Dx-lua](https://poco-chinese.readthedocs.io/en/latest/source/doc/integration.html?highlight=cocos2d#cocos2dx-lua) Lua server, with some small customization on top (see `defold-poco.lua`)\n\n![](./examples/example.gif)\n\n## Installation\n\n### Defold\nTo use this library in your Defold project, add the following URL to your `game.project` dependencies:\n\nhttps://github.com/defold/extension-poco/archive/master.zip\n\nWe recommend using a link to a zip file of a [specific release](https://github.com/defold/extension-poco/releases).\n\n### Python\n\nThe Poco api is compatible with both Python 2.7 and Python 3.3-3.6.\n\n### Poco library\n\nInstall the Poco library (from [documentation](https://poco-chinese.readthedocs.io/en/latest/source/README.html#installation)):\n\n    pip install pocoui\n\n## Usage - Game side\n\n### Server\n\nSee [main.script](./main/main.script) for an example.\n\nNote that you can also use this in the `gui` script context as well.\n\nAdd a require to one of your Defold scripts\n\n    local poco = require('poco.lua.defold-poco')\n\nCreate a PocoManager instance at game startup:\n\n    function init(self)\n        poco:init_server(15004) -- default port for Poco\n    end\n\nUpdate the PocoManager instance continuously:\n\n    function update(self, dt)\n        poco:server_loop()\n    end\n\nYou also need to set the view projection matrices (e.g. on resize event).\nThe default values are the identity matrix.\n\n    poco:set_view_proj(get_view_proj()) -- view projection matrix from render script\n    poco:set_gui_view_proj(get_gui_view_proj()) -- view projection matrix from render script\n\nHere's an example using [rendercam](https://github.com/rgrams/rendercam):\n\n    local rendercam = require \"rendercam.rendercam\"\n\n    local function get_view_proj()\n        local view = rendercam.calculate_view()\n        local proj = rendercam.calculate_proj()\n        return proj * view\n    end\n\n    local function get_gui_view_proj()\n        local mat = vmath.matrix4_orthographic(0, rendercam.window.x, 0, rendercam.window.y, -1, 1)\n        return mat\n    end\n\n### Custom function\n\nYou can add a custom function that you can call from the client scripts:\n\nServer:\n\n    poco:set_dispatch_fn(\"TestNewFunction\", function(x, y, z)\n            print(\"INSIDE NEW CLIENT TEST FUNCTION!\", x, y, z)\n            return {message= \"\" .. (x + y + z)}\n        end)\n\nClient:\n\n    cbk = poco.agent.rpc.call(\"TestNewFunction\", 1, 2, 3)\n    cbk.wait()\n\n\n## Custom hook\n\nYou can also add a hook to an existing function, in order to manipulate the result before it's returned to the client.\n\n    poco:set_dispatch_callback_fn(\"Dump\", function(scene)\n        pprint(\"INSIDE NEW CALLBACK FUNCTION!\", scene)\n        return scene\n    end)\n\n\n## Usage - Client side (i.e. the Python test script)\n\n### Setup\n\nIf you're using a predefined ipaddress, you can use a `VirtualDevice`:\n\n    device = VirtualDevice(ipaddress)\n\nYou create a `StdPoco` instance using an `ip address` and a `port`:\n\n    poco = StdPoco(addr=(ipaddress, port), device=device, use_airtest_input=False)\n\nIf you are using Android, you don't know the ipaddress of the device, you can use a `device = None` and ipaddress 0 `0.0.0.0`.\n\nThe default port for the poco server in the extension is `15004`\n\nSee the [examples](https://github.com/defold/extension-poco/tree/master/examples) for practical examples of how to create a Poco instance.\n\n\n### Dump the scene graph\n\nYou can get the full scene graph:\n\n    ui = poco.agent.hierarchy.dump()\n\n### Click on an object\n\nTo click on an object named `button_node`:\n\n    poco(\"button_node\").click()\n\n### Send key text combination\n\nSpecial keys are of the format `{KEY_name}`.\nOther characters are treated as text. (NOTE: Currently no unicode support)\n\n    poco.agent.input.keyevent('test@mail.coo{KEY_BACKSPACE}m')\n\n\n### Examples\n[Examples](https://github.com/defold/extension-poco/tree/master/examples)\n\nThis extension also contains a test project, which we can test against.\n\nLaunch the test project on your device and then run one of the [test scripts](https://github.com/defold/extension-poco/tree/master/examples).\n\nHow to test against a local build on the host computer:\n\n    $ python2 ./examples/example_dump.py\n\nConnect to a certain ip (any device type):\n\n    $ python2 ./examples/example_dump.py -a \u003cip address\u003e\n\nConnect to an Android device via `adb` (if you don't know its ipaddress)\n\n    $ python2 ./examples/example_dump.py -p android\n\nFor list of all arguments:\n\n    $ python2 ./examples/example_dump.py -h\n\n\n\n### Poco Documentation\n\nThere are several resources on how to write a test script here:\n\n* [AirTestProject/Poco](https://github.com/AirtestProject/Poco/blob/master/README.rst)\n\n* [Poco - Examples and Tutorials](https://poco.readthedocs.io/en/latest/source/doc/poco-example/index.html#tutorial)\n\n\n### Caveats\n\nWhile the Defold scene graph inspection api strives to reconstruct the scene as it once was in the Defold Editor, it is not possible to accurately do so to 100%. Some of the data is not avaiable once in runtime format.\n\nEach component type also has to implement its own hooks into the inspection api, so if the component type you're looking for isn't seen in the output graph, this might be the reason.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefold%2Fextension-poco","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdefold%2Fextension-poco","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefold%2Fextension-poco/lists"}