| name | agent-test |
| description | Use when running PoLang automated tests via JSON commands sent through AgentTestBroadcastReceiver, including test suites, single test cases, camera/agent feature verification, or performance/log collection |
Agent Test
定位:PC 端主导的 JSON 数据驱动自动化测试执行与诊断。
触发时机:用户提及运行测试、验证功能、发送测试命令、Accessibility UI 状态检查、性能采集时启用。
触发条件
- 运行测试套件:
scripts/agent-tester suite camera
- 发送单个 JSON 命令:
scripts/agent-tester cmd '{"method":"flip_camera"}'
- 运行单个 JSON 用例:
scripts/agent-tester case scripts/tests/camera/xxx.json
- 截屏验证、性能采集、报告生成
- 调试测试命令不生效的问题
核心原则
- PC 端主导:测试编排、截屏、报告全部由 PC 端完成,应用端只接收命令
- JSON 透传:PC 端不解析参数,直接把
{"method":"...","params":{...}} 传给应用端
- 显式广播:Android 12+ 必须用
-n 指定组件:com.mamba.picme/.testing.agent.bridge.AgentTestBroadcastReceiver
- 单引号包裹 JSON:防止 adb shell 把
{} 解释为 brace expansion
- 复用 AgentCommandParser:应用端用与 LLM 命令相同的解析路径处理测试命令
快速参考
发送 JSON 命令(最常用)
scripts/agent-tester cmd '{"method":"navigate_to","params":{"destination":"camera"}}'
scripts/agent-tester cmd '{"method":"switch_ratio","params":{"ratio":"16_9"}}'
scripts/agent-tester cmd '{"method":"switch_filter","params":{"filter":"leica_classic"}}'
scripts/agent-tester cmd '{"method":"capture","params":{}}'
scripts/agent-tester cmd '{"method":"flip_camera","params":{}}'
运行测试套件
scripts/agent-tester suite camera
scripts/agent-tester suite settings
运行单个用例
scripts/agent-tester case scripts/tests/camera/tc-camera-02-flip.json
诊断流程
Step 1: 确认设备连接
adb devices | grep "device$"
Step 2: 确认应用状态
adb shell pidof com.mamba.picme
adb shell am start -n com.mamba.picme/.MainActivity
Step 3: 发送命令并观察
adb logcat -c
scripts/agent-tester cmd '{"method":"navigate_to","params":{"destination":"camera"}}'
adb logcat -d | grep -iE "AgentTestReceiver|NavigationCapability|CapabilityRegistry|CameraCapability|scene"
Step 4: UI 状态验证
首选:Accessibility UI dump(结构化文本,更准更省 token)
python3 scripts/ui_driver.py dump > /tmp/ui_dump.json
python3 scripts/ui_driver.py find --content-description "快门"
次选:截屏(仅用于最终视觉验证)
adb shell screencap -p /sdcard/test.png
adb pull /sdcard/test.png /tmp/test.png
常见陷阱
| 陷阱 | 症状 | 修复 |
|---|
| 隐式广播被拦截 | 广播发送成功但无响应 | 使用 -n 显式组件 |
| JSON 被 brace expansion 截断 | json=method:switch_ratio | 用单引号包裹 JSON:--es json '{...}' |
| 场景不匹配命令排队 | 命令执行但 UI 无变化 | 先发送 navigate_to 切换到目标页面 |
| Capability delegate 未绑定 | CAPABILITY_UNAVAILABLE 错误 | 确保目标页面已显示并绑定 delegate |
| 日志过滤不到 | grep 无输出 | 检查 PID 是否正确,或直接用 adb logcat -d 全量查看 |
命令格式规范
JSON 命令结构
{"method":"<命令名>","params":{"<参数名>":"<值>"}}
支持的命令
| 命令 | 参数示例 | 说明 |
|---|
navigate_to | {"destination":"camera"} | 导航到指定页面 |
capture | - | 拍照 |
flip_camera | - | 切换前后摄像头 |
toggle_recording | - | 开始/停止录像 |
switch_ratio | {"ratio":"16_9"} | 切换画幅比例 |
switch_filter | {"filter":"leica_classic"} | 切换滤镜 |
switch_style | {"style":"toon"} | 切换风格 |
adjust_beauty | {"smoothing":80,"whitening":60} | 调整美颜 |
adjust_exposure | {"exposure":2} | 调整曝光 |
adjust_zoom | {"zoom":2.0} | 调整变焦 |
switch_mode | {"mode":"video"} | 切换拍摄模式 |
相关文件
版本历史
| 版本 | 日期 | 变更 |
|---|
| 2.1.0 | 2026-07-02 | 重命名目录和 skill 名从 agent-test-expert 到 agent-test |
| 2.0.0 | 2026-07-02 | 统一标题为 Agent Test;UI 验证优先使用 accessibility dump |
| 1.0.0 | 2026-06-06 | 初始版本,基于 Agent Test V2 JSON 驱动架构 |