重现 Android 猴子脚本

Reproduce Android Monkey Script

我 运行 Monkey 工具(对 Android 应用程序执行压力测试的工具)我得到了一些具有这种形式的脚本文件:

type= raw events
count= -1
speed= 1.0
start data >>
LaunchActivity(com.amaze.filemanager,com.amaze.filemanager.activities.MainActivity)
DispatchPointer(6934862,6934862,0,517.0,124.0,0.0,0.0,0,1.0,1.0,0,0)
DispatchPointer(6934862,6934867,1,520.041,127.07279,0.0,0.0,0,1.0,1.0,0,0)
GUIGen(3)
DispatchTrackball(-1,6945789,2,1.0,-3.0,0.0,0.0,0,1.0,1.0,0,0)
...

我想再次使用生成的脚本重新执行此类事件序列。 我该怎么做?

您将需要 adb 同样的。首先,您将在本地创建文件

monkey.script

type= raw events
count= -1
speed= 1.0
start data >>
LaunchActivity(com.amaze.filemanager,com.amaze.filemanager.activities.MainActivity)
DispatchPointer(6934862,6934862,0,517.0,124.0,0.0,0.0,0,1.0,1.0,0,0)
DispatchPointer(6934862,6934867,1,520.041,127.07279,0.0,0.0,0,1.0,1.0,0,0)
GUIGen(3)
DispatchTrackball(-1,6945789,2,1.0,-3.0,0.0,0.0,0,1.0,1.0,0,0)

然后你将它复制到你的phone

adb push ./monkey.script /sdcard/Download

然后你可以运行来自adb的脚本

$ adb shell monkey -f /sdcard/Download/monkey.script 1
Events injected: 4
## Network stats: elapsed time=10ms (0ms mobile, 0ms wifi, 10ms not connected)