Monkey Test 2(脚本方式)
来源:互联网 发布:及时生成字幕软件 编辑:程序博客网 时间:2024/06/17 15:09
Android 的monkey test 工具提供了 -f scriptfile 参数,可以指定 test 脚本。在 monkey 的源码 MonkeySourceScript.java 中有一小段注释,里面给了一个不到 10 行例子:
- /**
- * monkey event queue. It takes a script to produce events
- *
- * sample script format:
- * type= raw events
- * count= 10
- * speed= 1.0
- * start data >>
- * captureDispatchPointer(5109520,5109520,0,230.75429,458.1814,0.20784314,
- * 0.06666667,0,0.0,0.0,65539,0)
- * captureDispatchKey(5113146,5113146,0,20,0,0,0,0)
- * captureDispatchFlip(true)
- * ...
- */
monkey中提供的函数如下:
- DispatchPointer(long downTime, long eventTime, int action, float x, float y, float pressure, float size, int metaState, float xPrecision, float yPrecision, int device, int edgeFlags)
- DispatchTrackball(long downTime, long eventTime, int action, float x, float y, float pressure, float size, int metaState, float xPrecision, float yPrecision, int device, int edgeFlags)
- DispatchKey(long downTime, long eventTime, int action, int code, int repeat, int metaState, int device, int scancode)
- DispatchFlip(boolean keyboardOpen)
- DispatchPress(int keyCode)
- LaunchActivity(String pkg_name, String cl_name)
- UserWait(long sleeptime)
- LongPress(int keyCode)
首先本地编写需要的测试的事件 命名为 monkey.script (文件格式无要求),将文件push到手机或模拟器的sdcard中
如: adb push lujing/monkey.script /sdcard/
然后执行脚本:
adb shell monkey -v -f /sdcard/monkey.script
附 Example:
type= user
count= 49
speed= 1.0
start data >>
LaunchActivity(com.example.android.notepad, com.example.android.notepad.NotesList)
DispatchPress(KEYCODE_DPAD_DOWN)
LongPress(KEYCODE_DOWN)
DispatchPress(KEYCODE_BACK)
其中 type值可以任意,源码中没有对该值做任何处理。
count值,在此无效,还是需要在命令行输入需要执行的次数。因为命令行的count值是必填项
另外,如何通过LaunchActivity启动带参数的activity,还需要继续研究。有收获的朋友一定要通知哦^_^
0 0
- Monkey Test 2(脚本方式)
- Android monkey test 脚本的编写
- Android monkey test 脚本的编写
- Android monkey test 脚本的编写
- Android monkey test 脚本的编写
- Android中的Monkey test 脚本学习
- Android monkey test 脚本的编写
- Monkey Test 1(默认运行方式)
- Monkey test
- Monkey Test
- monkey test
- monkey test
- monkey脚本
- monkey脚本
- Android Monkey test
- Android Monkey test
- Android Monkey test
- Monkey test 資料
- 【Linux学习】Linux文件系统2—linux常用目录结构、绝对路径、相对路径
- hdu1505 单调队列
- 《C++ primer 5》 chapter 1.4
- ParaView整体介绍
- sersync2完全安装配置说明(一) —-基本功能使用
- Monkey Test 2(脚本方式)
- 邻居,你好!
- leetcode: Gas Station
- <<Oracle Applications DBA 基础(第二期)>>Week 10 exercise
- 黑马程序员 手写山寨版的金山词霸
- OCP 1Z0 053 147
- 字符串比较问题
- 插入排序
- JDOM操作XML实例