【Android】Monkey之命令详解

2017-02-24  骆海燕 

一  monkey事件类命令

1、运行脚本
adb shell monkey -f  <scriptfile> <event-count>
-f : 后接测试脚本名,表示要使用 monkey 支行指定的 monkey脚本,如:adb shell monkey -f  /mnt/sdcard/test 1(1为循环次数而不是事件数)


2、重复执行刚才的随机操作
adb shell monkey -s  <seed> <event-count>
-s : 后接随机数生成器的seed值 ,生成相同的事件序列


3、执行每一个指令的间隔时间
adb shell monkey --throttle  <milliseconds>
--throttle :单位是ms,表示事件之间固定的延迟


4、触摸事件百分比
adb shell monkey --ptc-touch <percent>
--ptc-touch:泛指在某一位置的一个down-up事件


5、动作事件百分比
adb shell monkey --ptc-motion <percent>
--ptc-touch:泛指在某一位置的一个down-up事件
动作事件不单单指手势操作,它指从某一位置按下(down事件)后经过一系列的伪随机事件后弹起(up事件)


6、轨迹球事件百分比
adb shell monkey --ptc-trackball <percent>
--ptc-trackball
轨迹球事件包括一系列的随机移动,以及偶尔跟随在移动后面的点击事件


7、调整基本导航事件百分比
adb shell monkey --ptc-nav <percent>
--ptc-nav
基本导航事件主要来自方向输入设备的上、下、左、右事件(up,down,left,right事件)


8、调整主要导航事件百分比
adb shell monkey --ptc-majornav <percent>
--ptc-majornav
主要导航事件主要指 引发图形界面的一些动作,如 5-way键盘中间按键、返回按键、菜单按键等


9、调整应用启动事件百分比
adb shell monkey --ptc-appswtich <percent>
--ptc-appswtich
应用启动事件(activity launches )俗称 打开应用,通过调用 startActivity()方法最大限度地开启该 package下的所有应用


10、调整系统按键事件百分比
adb shell monkey --ptc-syskeys <percent>
--ptc-syskeys
系统按键事件指:仅供系统使用的保留按键,如:home键,back键,拨号键,挂断键,音量键等


590°/5908 人阅读/0 条评论 发表评论

登录 后发表评论