当前位置: 首页 > 工具软件 > Monkey > 使用案例 >

monkey tool

颛孙庆
2023-12-01

monkey tool可以对模拟器或真实设备进行压力测试。

1 由于有多个devices,所以使用adb -s选择具体的设备。

adb devices

List of devices attached
emulator-5554   device
28a193fa        device

2 使用真实设备进行测试。

adb -s 28a193fa shell
shell@dior:/ $

进行了真实设备对应的shell命令行。

3 通过pm list package罗列出所有的package

package:com.qualcomm.fastdormancy
package:com.miui.gallery
package:com.qualcomm.timeservice
package:com.android.defcontainer
package:com.tencent.mm
package:com.jesson.meishi
package:com.android.quicksearchbox
package:com.carrot.iceworld
package:com.android.contacts
package:com.lenovocw.zhuhaizxt
package:com.android.phone
package:com.android.calculator2
package:com.miui.player
package:com.android.htmlviewer
package:com.xiaomi.mitunes
package:com.miui.guardprovider
package:com.alpha.lagouapk
package:com.android.cellbroadcastreceive
package:com.android.bluetooth
package:com.android.providers.calendar
package:com.nitrodesk.droid20.nitroid
......

4 选择其中的com.android.calculator2作为monkey测试package对象。

monkey -p com.android.calculator2 -v 100
console输出信息如下:

:Monkey: seed=1441754953280 count=100
:AllowPackage: com.android.calculator2
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
// Event percentages:
//   0: 15.0%
//   1: 10.0%
//   2: 2.0%
//   3: 15.0%
//   4: -0.0%
//   5: 25.0%
//   6: 15.0%
//   7: 2.0%
//   8: 2.0%
//   9: 1.0%
//   10: 13.0%
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.calculator2/.Calculator;end
// Allowing start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.android.calculator2/.Calculator } in package com
.android.calculator2
:Sending Touch (ACTION_DOWN): 0:(394.0,1063.0)
:Sending Touch (ACTION_UP): 0:(401.95813,1072.433)
:Sending Trackball (ACTION_MOVE): 0:(3.0,-5.0)
:Sending Trackball (ACTION_MOVE): 0:(2.0,4.0)
:Sending Trackball (ACTION_MOVE): 0:(4.0,4.0)
:Sending Trackball (ACTION_MOVE): 0:(-4.0,-3.0)
:Sending Touch (ACTION_DOWN): 0:(508.0,38.0)
:Sending Touch (ACTION_UP): 0:(520.8902,60.032974)
:Sending Touch (ACTION_DOWN): 0:(467.0,1067.0)
:Sending Touch (ACTION_UP): 0:(513.4296,1093.532)
:Sending Touch (ACTION_DOWN): 0:(349.0,495.0)
:Sending Touch (ACTION_UP): 0:(381.82608,496.23416)
:Sending Trackball (ACTION_MOVE): 0:(-5.0,0.0)
Events injected: 100
:Sending rotation degree=0, persist=false
:Dropped: keys=0 pointers=0 trackballs=0 flips=0 rotations=0
\#\# Network stats: elapsed time=1004ms (0ms mobile, 0ms wifi, 1004ms not connected)
// Monkey finished

同时可以看到手机里面的计算器进行了对应的操作。
当app崩溃或者发生无法处理的异常,或者发生无法响应的错误,Monkey就停止并生产error信息。

5 Others

Shell是进入了设备的根目录。
通过storage folder可以看到里面包括了sdcard0(对应系统自带的存储)和sdcard1(对应增加外部sd卡)。
/storage/sdcard0和/sdcard 目录都 软连接 到/storage/emulated/legacy 目录。
通过本人小米手机的文件管理app看到的文件是sdcard0和sdcard1中的文件信息。

Reference:

http://developer.android.com/tools/help/monkey.html

 类似资料:

相关阅读

相关文章

相关问答