Monkey詳細(イベント型命令編)


(七)イベント型命令イベント型命令は4つの主要な機能を実現することができる.
(1)ランダムイベントの再現
モンキーの最大の特徴は擬似ランダムです.「偽」の字を付けたのは、ランダムなイベントが再現できるからだ.ランダムイベントのセットを実行するたびに、seedと呼ばれるランダムIDがシステムに与えられます.たとえば
C:\Users\XXXX>adb shell monkey -p com.breakloop.butterknifedemo -v 100
:Monkey: seed=1503779100077 count=100
:AllowPackage: com.breakloop.butterknifedemo
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
// Event percentages:
....
## Network stats: elapsed time=83ms (0ms mobile, 0ms wifi, 83ms not connected)
// Monkey finished

C:\Users\XXXX>

このグループのランダムイベントをもう一度実行するには、-s+seed+countを使用します.
C:\Users\yisong>adb shell monkey -v -s 1503779100077 100
:Monkey: seed=1503779100077 count=100
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
// Event percentages:
...
## Network stats: elapsed time=588ms (0ms mobile, 0ms wifi, 588ms not connected)

// Monkey finished

C:\Users\yisong>

実行イベント以外は、以前と同じです.
では、問題が来ました(a)seed後のcountが、前と違って実行結果はどうなりますか?countが小さくなると、行き先からcount個のイベントが実行されます.countが大きくなると、実行が完了すると、差分ランダムイベントが追加されます.(b)seedはいつ期限が切れますか.デバイスの再接続、kill-server&start-server、携帯電話の再起動はseedに影響しません.
(2)イベント間隔の指定
隣接する2つのランダムなイベントの間には、デフォルトではイベント間隔はありません.したがって,ランダムイベントの注入に失敗することがある.
:Sending Touch (ACTION_DOWN): 0:(736.0,455.0)
    // Injection Failed
:Sending Touch (ACTION_UP): 0:(736.2039,467.69113)
    // Injection Failed
:Sending Flip keyboardOpen=false
Got IOException performing flipjava.io.IOException: write failed: EINVAL (Invali
d argument)
    // Injection Failed
:Sending Touch (ACTION_DOWN): 0:(352.0,1698.0)
    // Injection Failed
:Sending Touch (ACTION_UP): 0:(349.23996,1686.784)
    // Injection Failed
:Sending Trackball (ACTION_MOVE): 0:(-5.0,-4.0)
:Sending Trackball (ACTION_UP): 0:(0.0,0.0)
:Sending Touch (ACTION_DOWN): 0:(788.0,1048.0)
    // Injection Failed
:Sending Touch (ACTION_UP): 0:(780.9308,1044.052)
    // Injection Failed
:Sending Trackball (ACTION_MOVE): 0:(0.0,-2.0)

このような状況を回避するには、イベント間に「待機」を追加する必要があります.パラメータ-throttle+間隔を使用します.スロットル?ブレーキと名付けるべきでしょう.(a)パラメータの前に2つの「-」!(b)時間単位はミリ秒
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.categ
ory.LAUNCHER;launchFlags=0x10200000;component=com.vmall.client/.activity.VmallWa
pActivity;end
    // Allowing start of Intent { act=android.intent.action.MAIN cat=[android.in
tent.category.LAUNCHER] cmp=com.vmall.client/.activity.VmallWapActivity } in pac
kage com.vmall.client
Sleeping for 1000 milliseconds
:Sending Trackball (ACTION_MOVE): 0:(-5.0,-5.0)
:Sending Trackball (ACTION_MOVE): 0:(0.0,1.0)
:Sending Trackball (ACTION_MOVE): 0:(2.0,-5.0)
:Sending Trackball (ACTION_MOVE): 0:(-5.0,-4.0)
:Sending Trackball (ACTION_MOVE): 0:(2.0,-1.0)
:Sending Trackball (ACTION_MOVE): 0:(-3.0,1.0)
:Sending Trackball (ACTION_MOVE): 0:(4.0,4.0)
:Sending Trackball (ACTION_MOVE): 0:(-4.0,4.0)
:Sending Trackball (ACTION_MOVE): 0:(4.0,-2.0)
:Sending Trackball (ACTION_MOVE): 0:(3.0,-3.0)
:Sending Trackball (ACTION_DOWN): 0:(0.0,0.0)
:Sending Trackball (ACTION_UP): 0:(0.0,0.0)
Sleeping for 1000 milliseconds
    // Allowing start of Intent { cmp=com.vmall.client/.activity.PolicyWebActivi
ty } in package com.vmall.client
:Sending Key (ACTION_DOWN): 82    // KEYCODE_MENU
:Sending Key (ACTION_UP): 82    // KEYCODE_MENU
Sleeping for 1000 milliseconds
:Sending Touch (ACTION_DOWN): 0:(139.0,398.0)
:Sending Touch (ACTION_MOVE): 0:(157.42459,406.12418)
:Sending Touch (ACTION_MOVE): 0:(175.66505,407.0996)
:Sending Touch (ACTION_MOVE): 0:(185.49532,419.4165)
:Sending Touch (ACTION_MOVE): 0:(199.77296,435.93414)
:Sending Touch (ACTION_MOVE): 0:(215.76842,453.50436)
:Sending Touch (ACTION_MOVE): 0:(232.69334,470.774)
:Sending Touch (ACTION_MOVE): 0:(254.05827,476.62515)
:Sending Touch (ACTION_MOVE): 0:(262.36322,481.53244)
:Sending Touch (ACTION_UP): 0:(281.79745,489.0132)
Sleeping for 1000 milliseconds
:Sending Key (ACTION_DOWN): 82    // KEYCODE_MENU

注意:logから見ると、すべてのイベントの後に「待機」があるわけではありません.個人的な感覚は、事件が最初の時間に応答できないときに、待つことだ.
(3)ある種類のイベントの割合を指定する
では、私たちにはどんな事件がありますか.各イベントはどのような操作を表しますか?イベントスケールを設定しない場合、デフォルトのスケールはありますか?一つ一つ説明しましょう.
まずランダムイベントLOGのセットを見てみましょう.
C:\Users\XXXX>adb shell monkey --throttle 1000 -v 10
:Monkey: seed=1503647257950 count=10
: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: -0.0%
//   6: 25.0%
//   7: 15.0%
//   8: 2.0%
//   9: 2.0%
//   10: 1.0%
//   11: 13.0%
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.categ
ory.LAUNCHER;launchFlags=0x10200000;component=com.huawei.android.findmyphone/.ui
.FindMyPhoneActivity;end
    // Allowing start of Intent { act=android.intent.action.MAIN cat=[android.in
tent.category.LAUNCHER] cmp=com.huawei.android.findmyphone/.ui.FindMyPhoneActivi
ty } in package com.huawei.android.findmyphone
:Sending Touch (ACTION_DOWN): 0:(236.0,163.0)
:Sending Touch (ACTION_UP): 0:(247.74335,163.03857)
:Sending Touch (ACTION_DOWN): 0:(819.0,1411.0)
:Sending Touch (ACTION_UP): 0:(825.0237,1402.9965)
:Sending Touch (ACTION_DOWN): 0:(745.0,1572.0)
Events injected: 10
:Sending rotation degree=0, persist=false
:Dropped: keys=0 pointers=0 trackballs=0 flips=0 rotations=0
## Network stats: elapsed time=5113ms (0ms mobile, 0ms wifi, 5113ms not connecte
d)
// Monkey finished

その中にEvent percentagesがあります.–pct-XXXX命令を使用しない場合は、デフォルトのスケールでランダムイベントがトリガーされます.ただ、インデックス対応のイベントが何なのかはわかりません.
パラメータによって、8種類に分けることができます.(a)–pct-touch:タッチイベント.すなわち、ある位置にあるDown-Up(指の立ち下がりと立ち上げ)イベントである.Down(ACTION_DOWN)とUp(ACTION_UP)の座標が近いが、同じではない.
C:\Users\XXXX>adb shell monkey --throttle 1000 -v --pct-touch 100 10
:Monkey: seed=1503671202592 count=10
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
// Event percentages:
//   0: 100.0%
//   1: 0.0%
//   2: 0.0%
//   3: 0.0%
//   4: -0.0%
//   5: -0.0%
//   6: 0.0%
//   7: 0.0%
//   8: 0.0%
//   9: 0.0%
//   10: 0.0%
//   11: 0.0%
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.categ
ory.LAUNCHER;launchFlags=0x10200000;component=com.gemalto.qrcodelib/.MainActivit
y;end
    // Allowing start of Intent { act=android.intent.action.MAIN cat=[android.in
tent.category.LAUNCHER] cmp=com.gemalto.qrcodelib/.MainActivity } in package com
.gemalto.qrcodelib
:Sending Touch (ACTION_DOWN): 0:(186.0,781.0)
:Sending Touch (ACTION_UP): 0:(181.72902,780.3934)
:Sending Touch (ACTION_DOWN): 0:(600.0,384.0)
:Sending Touch (ACTION_UP): 0:(609.29193,385.8893)
:Sending Touch (ACTION_DOWN): 0:(786.0,1742.0)
:Sending Touch (ACTION_UP): 0:(782.567,1737.6458)
:Sending Touch (ACTION_DOWN): 0:(733.0,1538.0)
:Sending Touch (ACTION_UP): 0:(742.7612,1545.8889)
:Sending Touch (ACTION_DOWN): 0:(176.0,1538.0)
Events injected: 10
:Sending rotation degree=0, persist=false
:Dropped: keys=0 pointers=0 trackballs=0 flips=0 rotations=0
## Network stats: elapsed time=5093ms (0ms mobile, 0ms wifi, 5093ms not connecte
d)
// Monkey finished

(b)–pct-motion:アクションイベント.Down(ACTION_DOWN)で始まり、Up(ACTION_UP)で終わり、真ん中に少なくとも1回Move(ACTION_MOVE)があります.
C:\Users\XXXX>adb shell monkey --throttle 1000 -v -v --pct-motion 100 10
:Monkey: seed=1503775969786 count=10
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
// Seeded: 1503775969786
// Event percentages:
//   0: 0.0%
//   1: 100.0%
//   2: 0.0%
//   3: 0.0%
//   4: -0.0%
//   5: -0.0%
//   6: 0.0%
//   7: 0.0%
//   8: 0.0%
//   9: 0.0%
//   10: 0.0%
//   11: 0.0%
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.categ
ory.LAUNCHER;launchFlags=0x10200000;component=com.huawei.android.remotecontrolle
r/.StartActivity;end
    // Allowing start of Intent { act=android.intent.action.MAIN cat=[android.in
tent.category.LAUNCHER] cmp=com.huawei.android.remotecontroller/.StartActivity }
 in package com.huawei.android.remotecontroller
Sleeping for 1000 milliseconds
    // Allowing start of Intent { cmp=com.huawei.android.remotecontroller/.app.W
elcomeActivity } in package com.huawei.android.remotecontroller
    // activityResuming(com.huawei.android.remotecontroller)
:Sending Touch (ACTION_DOWN): 0:(241.0,1334.0)
:Sending Touch (ACTION_MOVE): 0:(245.10721,1333.8828)
:Sending Touch (ACTION_MOVE): 0:(246.83798,1331.2542)
:Sending Touch (ACTION_MOVE): 0:(248.75221,1324.734)
:Sending Touch (ACTION_MOVE): 0:(249.26602,1323.9482)
:Sending Touch (ACTION_MOVE): 0:(251.57216,1317.7059)
:Sending Touch (ACTION_MOVE): 0:(255.50874,1314.2244)
:Sending Touch (ACTION_UP): 0:(259.62653,1307.603)
Sleeping for 1000 milliseconds
:Sending Touch (ACTION_DOWN): 0:(1031.0,1108.0)
Events injected: 10
:Sending rotation degree=0, persist=false
:Dropped: keys=0 pointers=0 trackballs=0 flips=0 rotations=0
## Network stats: elapsed time=2060ms (0ms mobile, 0ms wifi, 2060ms not connecte
d)
// Monkey finished

(c)-pct-trackball:トラックボールイベント.すなわち、単純なMove(ACTION_MOVE)である.
C:\Users\XXXX>adb shell monkey --throttle 1000 -v -v --pct-trackball 100 10
:Monkey: seed=1503665474331 count=10
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
// Seeded: 1503665474331
// Event percentages:
//   0: 0.0%
//   1: 0.0%
//   2: 0.0%
//   3: 100.0%
//   4: -0.0%
//   5: -0.0%
//   6: 0.0%
//   7: 0.0%
//   8: 0.0%
//   9: 0.0%
//   10: 0.0%
//   11: 0.0%
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.categ
ory.LAUNCHER;launchFlags=0x10200000;component=com.yunos.cloudkit.demo/.MainActiv
ity;end
    // Allowing start of Intent { act=android.intent.action.MAIN cat=[android.in
tent.category.LAUNCHER] cmp=com.yunos.cloudkit.demo/.MainActivity } in package c
om.yunos.cloudkit.demo
Sleeping for 1000 milliseconds
:Sending Trackball (ACTION_MOVE): 0:(-5.0,-3.0)
:Sending Trackball (ACTION_MOVE): 0:(4.0,1.0)
:Sending Trackball (ACTION_MOVE): 0:(-1.0,3.0)
:Sending Trackball (ACTION_MOVE): 0:(2.0,-1.0)
:Sending Trackball (ACTION_MOVE): 0:(-4.0,3.0)
:Sending Trackball (ACTION_MOVE): 0:(4.0,-3.0)
:Sending Trackball (ACTION_MOVE): 0:(4.0,-4.0)
:Sending Trackball (ACTION_MOVE): 0:(-4.0,-3.0)
:Sending Trackball (ACTION_MOVE): 0:(-2.0,-3.0)
Events injected: 10
:Sending rotation degree=0, persist=false
:Dropped: keys=0 pointers=0 trackballs=0 flips=0 rotations=0
## Network stats: elapsed time=1045ms (0ms mobile, 0ms wifi, 1045ms not connecte
d)
// Monkey finished

(d)–pct-nav:基本ナビゲーションイベント.すなわち、方向入力装置からの上下左右操作である.
C:\Users\XXXX>adb shell monkey --throttle 1000 -v -v --pct-nav 100 10
:Monkey: seed=1503699935813 count=10
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
// Seeded: 1503699935813
// Event percentages:
//   0: 0.0%
//   1: 0.0%
//   2: 0.0%
//   3: 0.0%
//   4: -0.0%
//   5: -0.0%
//   6: 100.0%
//   7: 0.0%
//   8: 0.0%
//   9: 0.0%
//   10: 0.0%
//   11: 0.0%
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.categ
ory.LAUNCHER;launchFlags=0x10200000;component=com.gto.paltesttoolui/com.gto.tsm.
instrumentation.EmmaInstrumentation%24InstrumentedActivity;end
    // Allowing start of Intent { act=android.intent.action.MAIN cat=[android.in
tent.category.LAUNCHER] cmp=com.gto.paltesttoolui/com.gto.tsm.instrumentation.Em
maInstrumentation$InstrumentedActivity } in package com.gto.paltesttoolui
Sleeping for 1000 milliseconds
:Sending Key (ACTION_DOWN): 22    // KEYCODE_DPAD_RIGHT
:Sending Key (ACTION_UP): 22    // KEYCODE_DPAD_RIGHT
Sleeping for 1000 milliseconds
:Sending Key (ACTION_DOWN): 22    // KEYCODE_DPAD_RIGHT
:Sending Key (ACTION_UP): 22    // KEYCODE_DPAD_RIGHT
Sleeping for 1000 milliseconds
:Sending Key (ACTION_DOWN): 20    // KEYCODE_DPAD_DOWN
:Sending Key (ACTION_UP): 20    // KEYCODE_DPAD_DOWN
Sleeping for 1000 milliseconds
:Sending Key (ACTION_DOWN): 21    // KEYCODE_DPAD_LEFT
:Sending Key (ACTION_UP): 21    // KEYCODE_DPAD_LEFT
Sleeping for 1000 milliseconds
:Sending Key (ACTION_DOWN): 21    // KEYCODE_DPAD_LEFT
Events injected: 10
:Sending rotation degree=0, persist=false
:Dropped: keys=0 pointers=0 trackballs=0 flips=0 rotations=0
## Network stats: elapsed time=5116ms (0ms mobile, 0ms wifi, 5116ms not connecte
d)
// Monkey finished

(e)-pct-majornav:メインナビゲーションイベント.すなわちNavigation Barの確認,メニュー,戻りキーなどである.
C:\Users\XXXX>adb shell monkey --throttle 1000 -v -v --pct-majornav 100 10
:Monkey: seed=1503700822988 count=10
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
// Seeded: 1503700822988
// Event percentages:
//   0: 0.0%
//   1: 0.0%
//   2: 0.0%
//   3: 0.0%
//   4: -0.0%
//   5: -0.0%
//   6: 0.0%
//   7: 100.0%
//   8: 0.0%
//   9: 0.0%
//   10: 0.0%
//   11: 0.0%
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.categ
ory.LAUNCHER;launchFlags=0x10200000;component=com.android.settings/.HWSettings;e
nd
    // Allowing start of Intent { act=android.intent.action.MAIN cat=[android.in
tent.category.LAUNCHER] cmp=com.android.settings/.HWSettings } in package com.an
droid.settings
Sleeping for 1000 milliseconds
:Sending Key (ACTION_DOWN): 82    // KEYCODE_MENU
:Sending Key (ACTION_UP): 82    // KEYCODE_MENU
Sleeping for 1000 milliseconds
:Sending Key (ACTION_DOWN): 82    // KEYCODE_MENU
:Sending Key (ACTION_UP): 82    // KEYCODE_MENU
Sleeping for 1000 milliseconds
:Sending Key (ACTION_DOWN): 23    // KEYCODE_DPAD_CENTER
:Sending Key (ACTION_UP): 23    // KEYCODE_DPAD_CENTER
Sleeping for 1000 milliseconds
:Sending Key (ACTION_DOWN): 82    // KEYCODE_MENU
:Sending Key (ACTION_UP): 82    // KEYCODE_MENU
Sleeping for 1000 milliseconds
:Sending Key (ACTION_DOWN): 23    // KEYCODE_DPAD_CENTER
Events injected: 10
:Sending rotation degree=0, persist=false
:Dropped: keys=0 pointers=0 trackballs=0 flips=0 rotations=0
## Network stats: elapsed time=5100ms (0ms mobile, 0ms wifi, 5100ms not connecte
d)
// Monkey finished

(f)-pct-syskeys:システムキーイベント.すなわち、HOMEキー、BACKキー、ダイヤルキー、切断キー、ボリュームキーなどのシステム保持キーである.
C:\Users\XXXX>adb shell monkey -v -v --pct-syskeys 100 10
:Monkey: seed=1503762438503 count=10
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
// Seeded: 1503762438503
// Event percentages:
//   0: 0.0%
//   1: 0.0%
//   2: 0.0%
//   3: 0.0%
//   4: -0.0%
//   5: -0.0%
//   6: 0.0%
//   7: 0.0%
//   8: 100.0%
//   9: 0.0%
//   10: 0.0%
//   11: 0.0%
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.categ
ory.LAUNCHER;launchFlags=0x10200000;component=com.huawei.phoneservice/.ui.HelpCe
nterActivity;end
    // Allowing start of Intent { act=android.intent.action.MAIN cat=[android.in
tent.category.LAUNCHER] cmp=com.huawei.phoneservice/.ui.HelpCenterActivity } in
package com.huawei.phoneservice
Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 24    // KEYCODE_VOLUME_UP
    // Allowing start of Intent { cmp=com.huawei.phoneservice/com.huawei.phonese
rviceuni.start.UserAgreementActivity } in package com.huawei.phoneservice
:Sending Key (ACTION_UP): 24    // KEYCODE_VOLUME_UP
Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 25    // KEYCODE_VOLUME_DOWN
:Sending Key (ACTION_UP): 25    // KEYCODE_VOLUME_DOWN
Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 25    // KEYCODE_VOLUME_DOWN
:Sending Key (ACTION_UP): 25    // KEYCODE_VOLUME_DOWN
Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 24    // KEYCODE_VOLUME_UP
:Sending Key (ACTION_UP): 24    // KEYCODE_VOLUME_UP
Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 24    // KEYCODE_VOLUME_UP
Events injected: 10
:Sending rotation degree=0, persist=false
:Dropped: keys=0 pointers=0 trackballs=0 flips=0 rotations=0
## Network stats: elapsed time=765ms (0ms mobile, 0ms wifi, 765ms not connected)

// Monkey finished

(g)-pct-appswitch:起動イベントの適用
C:\Users\XXXX>adb shell monkey -v --pct-appswitch 100 3
:Monkey: seed=1503724767031 count=3
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
// Event percentages:
//   0: 0.0%
//   1: 0.0%
//   2: 0.0%
//   3: 0.0%
//   4: -0.0%
//   5: -0.0%
//   6: 0.0%
//   7: 0.0%
//   8: 0.0%
//   9: 100.0%
//   10: 0.0%
//   11: 0.0%
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.cate
ory.LAUNCHER;launchFlags=0x10200000;component=com.huawei.fans/.activity.MainAct
vity;end
    // Allowing start of Intent { act=android.intent.action.MAIN cat=[android.i
tent.category.LAUNCHER] cmp=com.huawei.fans/.activity.MainActivity } in package
com.huawei.fans
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.cate
ory.LAUNCHER;launchFlags=0x10200000;component=com.huawei.appmarket/.MainActivit
;end
    // Allowing start of Intent { act=android.intent.action.MAIN cat=[android.i
tent.category.LAUNCHER] cmp=com.huawei.appmarket/.MainActivity } in package com
huawei.appmarket
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.cate
ory.LAUNCHER;launchFlags=0x10200000;component=com.android.soundrecorder/.SoundR
corder;end
    // Allowing start of Intent { act=android.intent.action.MAIN cat=[android.i
tent.category.LAUNCHER] cmp=com.android.soundrecorder/.SoundRecorder } in packa
e com.android.soundrecorder
Events injected: 3
:Sending rotation degree=0, persist=false
:Dropped: keys=0 pointers=0 trackballs=0 flips=0 rotations=0
## Network stats: elapsed time=75ms (0ms mobile, 0ms wifi, 75ms not connected)
// Monkey finished

(h)–pct-anyevent:その他の未言及イベント.このイベントには、上記の他のイベントが含まれる場合があります.
C:\Users\XXXX>adb shell monkey -v -v --pct-anyevent 100 10
:Monkey: seed=1503761055148 count=10
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
// Seeded: 1503761055148
// Event percentages:
//   0: 0.0%
//   1: 0.0%
//   2: 0.0%
//   3: 0.0%
//   4: -0.0%
//   5: -0.0%
//   6: 0.0%
//   7: 0.0%
//   8: 0.0%
//   9: 0.0%
//   10: 0.0%
//   11: 100.0%
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.categ
ory.LAUNCHER;launchFlags=0x10200000;component=com.huawei.health/.MainActivity;en
d
    // Allowing start of Intent { act=android.intent.action.MAIN cat=[android.in
tent.category.LAUNCHER] cmp=com.huawei.health/.MainActivity } in package com.hua
wei.health
Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 549    // 549
:Sending Key (ACTION_UP): 549    // 549
Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 507    // 507
:Sending Key (ACTION_UP): 507    // 507
Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 362    // 362
:Sending Key (ACTION_UP): 362    // 362
Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 673    // 673
:Sending Key (ACTION_UP): 673    // 673
Sleeping for 0 milliseconds
:Sending Key (ACTION_DOWN): 25    // KEYCODE_VOLUME_DOWN
Events injected: 10
:Sending rotation degree=0, persist=false
:Dropped: keys=0 pointers=0 trackballs=0 flips=0 rotations=0
## Network stats: elapsed time=691ms (0ms mobile, 0ms wifi, 691ms not connected)

// Monkey finished

各イベントのログをよく観察すると,(I)すべてのランダムイベント,count>0の場合,最初のイベントは永遠にappswitchであることが分かった.操作対象としてactivityが必要です!!(II)あるイベントが占める割合を100にすると,イベントインデックス対応関係が得られる.0–> –pct-touch 1–> –pct-motion 3–> –pct-trackball 6–> –pct-nav 7–> –pct-majornav 8–> –pct-syskeys 9–> –pct-appswitch 11–> –pct-anyevent
(III)一つ-vを使用するとACTION_MOVEイベントまたはKEYCODE_DPAD_XXXXはLOGに表示されません.
(4)実行スクリプト
パラメータ-fを使用してスクリプトpathを指定します.
adb shell monkey -f c:\d\test 100

ファイルは接尾辞なしで使用できます.注意:count=100とは、スクリプトを100回実行することです.
シナリオの作成については、個別の紙面で説明します.