您好,登錄后才能下訂單哦!
一.Monkey簡介
Monkey是Android中的一個命令行工具,可以運行在模擬器里或實際設備中。它向系統(tǒng)發(fā)送偽隨機的用戶事件流(如按鍵輸入、觸摸屏輸入、手勢輸入等),實現(xiàn)對正在開發(fā)的應用程序進行測試。Monkey測試是一種為了測試軟件的穩(wěn)定性、健壯性的快速有效的方法。
二、Monkey程序介紹
1) Monkey程序由Android系統(tǒng)自帶,使用Java語言寫成,在Android文件系統(tǒng)中的存放路徑是:/system/framework/monkey.jar;
2) Monkey.jar程序是由一個名為“monkey”的Shell腳本來啟動執(zhí)行,shell腳本在Android文件系統(tǒng)中的存放路徑是:/system/bin/monkey;
我們就可以通過在cmd窗口執(zhí)行adb shell monkey {+命令參數}來進行monkey測試了。
下邊就是monkey中的一些常用指令:
三、Monkey測試前的準備
1.準備一張sd卡(或者手機有內置sd卡),以便測試中存儲緩存或者圖片信息。
2.執(zhí)行monkey測試前,一定要確保屏幕處于解鎖狀態(tài)。
3.設置屏幕超時時間為最大時間(設置->顯示->休眠->30分鐘或者從不)。以防測試過程中手機鎖屏,影響monkey測試。
4.打開usb調試,確保adb可以連接。
5.抓取adb log,(如果出現(xiàn)anr,需要將/data/anr/下的anr log拿出來)。
四、Monkey測試命令
1. 測試命令:
adb shell monkey -p 包名 --ignore-timeouts --ignore-crashes--ignore-security-exceptions -v -v --throttle 200 1000000
例如我們的app進行測試,命令如下:
adb shell monkey -p com.test --ignore-timeouts --ignore-crashes--ignore-security-exceptions -v -v --throttle500 1000000
我們在測試過程中,建議不要忽略這些異常,盡可能的暴露出app中存在的問題,如果選擇忽略出現(xiàn)crash,anr等現(xiàn)象,手機中就不會有提示,不便于判斷測試是否正常。忽略異常是想要對此模塊執(zhí)行完成,盡可能多的發(fā)現(xiàn)更多問題,但是這個問題的判斷只能通過log去分析,不便于測試的判斷。所以我們測試建議使用下邊的命令:
adb shell monkey -p 包名 –v -v -v --throttle 500 1000000 >e:\monkeylog.txt
各個參數的意義如下:
-P
用于約束限制,用此參數指定一個或多個包(Package)。指定包之后,Monkey將只允許系統(tǒng)啟動指定的APP。如果不指定包,Monkey將允許系統(tǒng)啟動設備中的所有APP。
--ignore-crashes
用于指定當應用程序崩潰時(Force & Close錯誤),Monkey是否停止運行。如果使用此參數,即使應用程序崩潰,Monkey依然會發(fā)送事件,直到事件計數完成。
--ignore-timeouts
用于指定當應用程序發(fā)生ANR(Application No Responding)錯誤時,Monkey是否停止運行。如果使用此參數,即使應用程序發(fā)生ANR錯誤,Monkey依然會發(fā)送事件,直到事件計數完成。
--ignore-security-exceptions
用于指定當應用程序發(fā)生許可錯誤時(如證書許可,網絡許可等),Monkey是否停止運行。如果使用此參數,即使應用程序發(fā)生許可錯誤,Monkey依然會發(fā)送事件,直到事件計數完成。
-v
用于指定反饋信息級別(信息級別就是日志的詳細程度),總共分3個級別,分別對應的參數如下表所示:
日志級別 Level 0
示例:adb shell monkey -p com.android.contacts -v --throttle 200 1000000
缺省值,僅提供啟動提示、測試完成和最終結果等少量信息
日志級別Level 1
示例:adb shell monkey -p com.android.contacts–v -v --throttle 200 1000000
提供較為詳細的日志,包括每個發(fā)送到Activity的事件信息
日志級別Level 2
示例: adb shellmonkey -p com.android.contacts–v –v -v --throttle 200 1000000
提供最詳細的日志,包括了測試中選中/未選中的Activity信息
--throttle
在每兩次操作(即事件)間的時延,單位是毫秒,一般我們設置延時時間為500ms,比較接近人的手動操作,如果在測試中發(fā)生了anr,可以將間隔設置為500ms,進行測試驗證。
-s
S其實就seed,它是隨機數的事件序列定一個值,若出現(xiàn)問題下次可以重復同樣的序列進行排錯。
下面其實就是指定了一個seed為1080的隨機事件序列。
adb shell monkey -s 1080 -p com.android.contacts–v -v --throttle 200 1000000
2. Monkey測試中的黑名單和白名單
在測試中,因為手機中的一些其他操作可能影響測試結果(例如下拉通知欄),我們可以進行設置一個類似黑名單的東西去屏蔽它,具體命令如下:
adb shell monkey --pkg-blacklist-file /data/ blacklist.txt -v -v--throttle 200 1000000
具體的實現(xiàn)方式是,首先在電腦上建立一個blacklist.txt文件,在這個文件中將要屏蔽的包名一一寫進去,然后將這個文件push到手機的data目錄下: adbpush blacklist.txt /data/,這樣就會屏蔽掉這幾個包,不去執(zhí)行它。下面是我建的一個blacklist.txt文件。
和黑名單類似,我們也可以建立一個類似于白名單一樣的文件whitelist.txt,只去執(zhí)行在白名單列表中的包名(我們測試過程中可把我們自己app的包名加到這個文件中),詳細步驟和黑名單一樣,這里不在贅述。具體命令如下:
adb shell monkey --pkg-whitelist-file /data/whitelist.txt -v -v --throttle 5001000000
五、Monkey測試pass或者fail的判斷
1. monkey測試正常結束(pass)的判斷
如果正常完成monkey測試,會在最好的monke log中打印出:
Monkey finished的字樣。下面是setting模塊monkey測試pass的log。
// Allowing start of Intent {act=android.intent.action.MAIN cmp=com.android.settings/.SubSettings } inpackage com.android.settings
//activityResuming(com.android.settings)
:Sending Trackball (ACTION_MOVE):0:(-3.0,3.0)
:Sending Trackball (ACTION_MOVE): 0:(4.0,4.0)
:Sending Touch (ACTION_DOWN): 0:(642.0,499.0)
Events injected: 300000
:Sending rotation degree=0, persist=false
:Dropped: keys=0 pointers=0 trackballs=0flips=0 rotations=0
## Network stats: elapsed time=35892101ms(0ms mobile, 0ms wifi, 35892101ms not connected)
// Monkey finished
2. monkey測試非正常結束(fail)的判斷
(1)monkey測試中出現(xiàn)停止運行(crash)現(xiàn)象
下邊是以前測試瀏覽器出現(xiàn)的停止運行現(xiàn)象,monkey log如下:
在monkeylog的最后邊會有CRASH的關鍵字或者在我們的adblog中搜索fatal的關鍵字:
// CRASH: com.android.browser (pid 8766)
// Short Msg: java.lang.IllegalArgumentException
// Long Msg: java.lang.IllegalArgumentException: parameter must be a descendant
of this view
// Build Label:SR402/Q203/Q203_CCE:4.0.4/IMM76I/eng.pub1.20130703.094433:user/t
est-keys
// Build Changelist: eng.pub1.20130703.094433
// Build Time: 1372815912000
// java.lang.IllegalArgumentException: parameter must be a descendant of thisvi
ew
// at android.view.ViewGroup.offsetRectBetweenParentAndChild(ViewGroup.java
:4157)
// at android.view.ViewGroup.offsetRectIntoDescendantCoords(ViewGroup.java:
4100)
// at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:34
00)
// at android.view.ViewRootImpl.handleFinishedEvent(ViewRootImpl.java:3306)
// atandroid.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2466)
// at android.os.Handler.dispatchMessage(Handler.java:99)
// at android.os.Looper.loop(Looper.java:137)
// at android.app.ActivityThread.main(ActivityThread.java:4482)
// at java.lang.reflect.Method.invokeNative(Native Method)
// at java.lang.reflect.Method.invoke(Method.java:511)
// at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit
.java:787)
// at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
// at dalvik.system.NativeStart.main(Native Method)
//
app_crashcom.android.browser_2013-07-05_02_59_35.455_.txt:
// app_crashcom.android.browser_2013-07-05_02_59_35.455_.txt status was 0
Monkey aborted due to error.
Events injected: 74031
:Dropped: keys=73 pointers=1022 trackballs=0 flips=0
Network stats: elapsed time=1318105ms(859932ms mobile, 0ms wifi, 458173ms no
t connected)
System appears to have crashed at event 74031of 1000000 using seed 100
(2)monkey測試中出現(xiàn)無響應(anr)現(xiàn)象
下邊是以前測試phone出現(xiàn)的anr現(xiàn)象,monkey log如下:
在monkeylog的最后邊會有NOT RESPONDING的關鍵字:
Sleeping for 0 milliseconds
:Sending Touch (ACTION_DOWN): 0:(25.0,153.0)
// NOT RESPONDING: com.android.phone (pid 751)
act=ACTION_ENABLE_CHANNELS_GSMLoad: 12.93 / 13.27 / 12.31
CPU usage from 7183ms to 2144ms ago:
57%1235/com.android.contacts: 51% user + 5.9% kernel / faults: 1229 minor
32% 378/system_server:22% user + 9.5% kernel / faults: 228 minor
13% 128/surfaceflinger:8.5% user + 4.7% kernel / faults: 20 minor
9.9%734/com.android.inputmethod.latin: 8.3% user + 1.5% kernel / faults: 21 minor
8.3% 2616/com.android.commands.monkey:6.5% user + 1.7% kernel / faults: 87 minor
7.9% 2471/adbd: 2.3%user + 5.5% kernel
4.3% 131/mediaserver:2.7% user + 1.5% kernel
3.5%695/com.android.systemui: 3.3% user + 0.1% kernel / faults: 1082 minor
2.3% 132/dbus-daemon: 2.3%user + 0% kernel
1.3% 2650/logcat: 0.3%user + 0.9% kernel
1.1% 6183/kworker/0:0:0% user + 1.1% kernel
0.9% 1053/mpdecision: 0%user + 0.9% kernel
0.7% 7790/kworker/u:3:0% user + 0.7% kernel
0.5% 9141/kworker/1:1:0% user + 0.5% kernel
0.3% 22/kworker/u:1: 0%user + 0.3% kernel
0.3% 143/alljoyn-daemon:0.1% user + 0.1% kernel / faults: 27 minor
0.1% 1//init: 0% user +0.1% kernel / faults: 35 minor
0% 3/ksoftirqd/0: 0%user + 0% kernel
0.1% 5/kworker/u:0: 0%user + 0.1% kernel
+0% 9350/hciattach: 0%user + 0% kernel
+0% 9352/irq/301-msm_hs_:0% user + 0% kernel
+0% 9353/hci0: 0% user +0% kernel
+0% 9354/bluetoothd: 0%user + 0% kernel
+0% 9375/dun-server: 0%user + 0% kernel
+0% 9377/sapd: 0% user +0% kernel
+0% 9400/abtfilt: 0% user+ 0% kernel
81% TOTAL: 57% user + 19% kernel + 5% iowait + 0.1% softirq
CPU usage from 928ms to 1470ms later:
68%1235/com.android.contacts: 62% user + 5.5% kernel / faults: 84 minor
62%1235/ndroid.contacts: 57% user + 5.5% kernel
1.8% 5072/BinderThread #: 1.8% user + 0% kernel
1.8% 6217/BinderThread #: 1.8% user + 0% kernel
24% 378/system_server:14% user + 9.2% kernel / faults: 13 minor
5.5%401/ActivityManager: 3.7% user + 1.8% kernel
5.5% 460/InputDispatcher:1.8% user + 3.7% kernel
1.8%378/system_server: 1.8% user + 0% kernel
1.8%449/PowerManagerSer: 1.8% user + 0% kernel
1.8% 789/Binder Thread#: 1.8% user + 0% kernel
1.8% 810/Binder Thread#: 1.8% user + 0% kernel
1.8% 811/Binder Thread#: 0% user + 1.8% kernel
1.8% 814/Binder Thread#: 1.8% user + 0% kernel
1.8% 1341/BinderThread #: 1.8% user + 0% kernel
16%734/com.android.inputmethod.latin: 11% user + 5.5% kernel / faults: 5 minor
7.4% 734/putmethod.latin:5.5% user + 1.8% kernel
1.8% 747/Binder Thread#: 0% user + 1.8% kernel
1.8% 749/Binder Thread#: 0% user + 1.8% kernel
1.8% 2653/BinderThread #: 1.8% user + 0% kernel
7.4% 128/surfaceflinger:5.5% user + 1.8% kernel / faults: 1 minor
3.7%276/SurfaceFlinger: 3.7% user + 0% kernel
7.2%2616/com.android.commands.monkey: 5.4% user + 1.8% kernel / faults: 12 minor
7.2%2616/commands.monkey: 5.4% user + 1.8% kernel
5.4% 2471/adbd: 0% user+ 5.4% kernel
3.6% 2471/adbd: 0%user + 3.6% kernel
1.8% 2473/adbd: 0%user + 1.8% kernel
3.7% 131/mediaserver:1.8% user + 1.8% kernel
1.8%9268/TimedEventQueue: 1.8% user + 0% kernel
0.7% 5/kworker/u:0: 0%user + 0.7% kernel
0.9%695/com.android.systemui: 0.9% user + 0% kernel
1% 1053/mpdecision: 0%user + 1% kernel
1% 1063/mpdecision: 0%user + 1% kernel
1.2% 9141/kworker/1:1:0% user + 1.2% kernel
71% TOTAL: 50% user + 18% kernel + 1.8% iowait
procrank:
// Exception from procrank:
java.io.IOException: Error running exec(). Command: [procrank]Working Directory: null Environment: null
anr_com.android.phone_2013-07-05_04_02_24.737_.txt:
// Rejecting start ofIntent { cmp=com.android.stk/.StkDialogActivity } in package com.android.stk
// anr_com.android.phone_2013-07-05_04_02_24.737_.txt status was0
anr traces:
// anr traces status was 0
meminfo:
// meminfo status was 0
** Monkey aborted due to error.
Events injected: 94581
:Dropped: keys=57 pointers=906 trackballs=0 flips=0
## Network stats: elapsed time=1891513ms (807371ms mobile, 0mswifi, 1084142ms not connected)
** System appears to have crashed at event 94581 of 1000000using seed 100
(3)monkey測試中uncaught exception 停止。
11-01 08:53:27.113: ERROR/AndroidRuntime(1973):Uncaught handler: thread main exiting due to uncaught exception
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): java.lang.NullPointerException
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): atandroid.widget.TabHost.dispatchKeyEvent(TabHost.java:279)
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): atandroid.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:748)
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): atandroid.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:748)
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): atandroid.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:748)
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): atandroid.widget.TabHost.dispatchKeyEvent(TabHost.java:275)
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): atandroid.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:748)
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): atandroid.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:748)
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:748)
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): atcom.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1655)
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): atcom.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1102)
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): atandroid.app.Activity.dispatchKeyEvent(Activity.java:2038)
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): atcom.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1631)
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): atandroid.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2368)
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): atandroid.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2338)
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): atandroid.view.ViewRoot.handleMessage(ViewRoot.java:1641)
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): atandroid.os.Handler.dispatchMessage(Handler.java:99)
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): at android.os.Looper.loop(Looper.java:123)
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): atandroid.app.ActivityThread.main(ActivityThread.java:4363)
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): atjava.lang.reflect.Method.invokeNative(Native Method)
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): atjava.lang.reflect.Method.invoke(Method.java:521)
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): atcom.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): atcom.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
11-01 08:53:27.133: ERROR/AndroidRuntime(1973): at dalvik.system.NativeStart.main(NativeMethod)
11-01 08:53:27.163: INFO/Process(53): Sending signal. PID: 1973SIG: 3
11-01 08:53:27.173: INFO/dalvikvm(1973): threadid=7: reacting tosignal 3
11-01 08:53:27.173: ERROR/dalvikvm(1973): Unable to open stacktrace file '/data/anr/traces.txt': Permission denied
11-01 08:53:27.622: INFO/AndroidRuntime(2077): AndroidRuntimeonExit calling exit(190)
11-01 08:53:33.702: WARN/ActivityManager(53): Launch timeout hasexpired, giving up wake lock!
11-01 08:53:33.733: WARN/ActivityManager(53): Activity idletimeout for HistoryRecord{43d3ab48 wfh.LessonTable/.MainTable}
11-01 08:53:41.173: DEBUG/dalvikvm(1334): GC freed 62 objects /3120 bytes in 2419ms
11-01 08:53:43.742: WARN/ActivityManager(53): Activity destroytimeout for HistoryRecord{43dc5028 wfh.LessonTable/.AWeekLesson}
(4)monkey異常停止,但在monkey log中沒有有用log
對于這一類問題,我們首先要排查,手機的adb是否能連接上,是不是有人為的影響,手機是否處于開機狀態(tài),是否因為之前電量不足,而測試比較耗電的模塊導致了手機低電量關機等。
下面的monkelog是在測試計算器時出現(xiàn)了異常停止,但是monkeylog沒有直觀的log信息(對于此類問題,研發(fā)可以通過log搜索到最后一個calendar_time關鍵字,,也就是monkey最后執(zhí)行時間,并出現(xiàn)異常的時間在adblog中分析具體停止原因。)
//[calendar_time:2013-07-17 21:00:44.859 system_uptime:3960520]
// Sending event #34700
:Sending Touch (ACTION_DOWN): 0:(225.0,1247.0)
:Sending Touch (ACTION_UP): 0:(316.6447,1145.2222)
:Sending Trackball (ACTION_MOVE): 0:(-3.0,-5.0)
:Sending Touch (ACTION_DOWN): 0:(504.0,372.0)
:Sending Trackball (ACTION_MOVE): 0:(-1.0,-2.0)
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.calculator2/.Calculator;end
// Allowing start ofIntent { 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:(278.0,723.0)
:Sending Touch (ACTION_UP): 0:(209.08629,731.03766)
:Sending Touch (ACTION_DOWN): 0:(272.0,311.0)
:Sending Touch (ACTION_UP): 0:(269.88586,319.0354)
:Sending Trackball (ACTION_MOVE): 0:(4.0,1.0)
:Sending Touch (ACTION_DOWN): 0:(456.0,497.0)
//[calendar_time:2015-04-15 17:00:55.627system_uptime:3971287]
// Sending event #34800
:Sending Touch (ACTION_UP): 0:(89.99596,759.6784)
//activityResuming(com.android.launcher)
// Rejecting resume ofpackage com.android.launcher
:Sending Flip keyboardOpen=false
六、Monkey log的簡單分析
:Monkey: seed=0 count=800 因為沒有指定seed的,所以這一塊是隨機的,count就是我們設置的事件數
:AllowPackage:com.android.contacts 這就是允許訪問的package,也就是我們指定的
:IncludeCategory:android.intent.category.LAUNCHER:IncludeCategory:android.intent.category.MONKEY
// Selecting main activities fromcategory android.intent.category.LAUNCHER//
+ Using main activitycom.android.contacts.activities.DialtactsActivity (from packagecom.android.contacts)//
+ Using main activitycom.android.contacts.activities.PeopleActivity (from packagecom.android.contacts)//
Selecting main activities fromcategory android.intent.category.MONKEY
// Seeded: 0
// Event percentages:
// 0: 15.0% [--pct-touch PERCENT] 調整觸摸事件的百分比(觸摸事件是一個down-up事件,它發(fā)生在屏幕的某一位置)
// 1: 10.0% [--pct-motion PERCENT]調整動作事件的百分比
// 2: 15.0% [--pct-trackballPERCENT]調整軌跡事件的百分比(軌跡事件由一個或幾個隨機的移動組成,有時還伴隨有點擊)。
// 3: 25.0% [--pct-syskeys PERCENT]調整“系統(tǒng)”按鍵事件的百分比(如Home、Back、音量控制鍵等)。
// 4: 15.0% [--pct-nav PERCENT]調整“基本”導航事件的百分比(導航事件由來自方向輸入設備的up/down/left/right組成)。
// 5: 15.0% [--pct-majornav PERCENT]調整“主要”導航事件的百分比(這些導航事件通常引發(fā)圖形界面中的動作,如:回退按鍵、菜單按鍵)
// 6: 2.0% [--pct-appswitchPERCENT]調整啟動Activity的百分比。在隨機間隔里,Monkey將執(zhí)行一個startActivity()調用,作為最大程度覆蓋包中全部Activity的一種方法。
// 7: 2.0% [--pct-flip PERCENT] 調整翻轉事件百分比。
// 8: 1.0% [--pct-anyeventPERCENT]調整其它類型事件的百分比。它包羅了所有其它類型的事件,如:按鍵、其它不常用的設備按鈕等。
(下面表示表示跳轉到com.android.contacts 里面的PeopleActivity這一個Activity里)
:Switch:#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10000000;component=com.android.contacts/.activities.PeopleActivity;end
// Allowing start of Intent {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]cmp=com.android.contacts/.activities.PeopleActivity } in packagecom.android.contacts
Sleeping for 200 milliseconds(這個就是我們設置的200ms的每兩次事件的間隔)
(下面是發(fā)送的一些動作,如點擊按下,點擊放開,移動)
:Sending Key (ACTION_DOWN): 22 // KEYCODE_DPAD_RIGHT:Sending Key
(ACTION_UP): 22 // KEYCODE_DPAD_RIGHTSleeping
for 200 milliseconds:Sending Key(ACTION_DOWN)
: 23 // KEYCODE_DPAD_CENTER:Sending Key(ACTION_UP)
: 23 // KEYCODE_DPAD_CENTERSleeping for 200milliseconds:Sending Flip keyboardOpen=falseSleeping
for 200 milliseconds
:Sending Key (ACTION_DOWN): 20 // KEYCODE_DPAD_DOWN
:Sending Key (ACTION_UP): 20 // KEYCODE_DPAD_DOWN
Sleeping for 200 milliseconds
:Sending Touch (ACTION_DOWN):0:(313.0,367.0)
:Sending Touch (ACTION_UP):0:(313.19876,367.49512)
Sleeping for 200 milliseconds:SendingKey (ACTION_DOWN): 82
// KEYCODE_MENU:Sending Key(ACTION_UP): 82
// KEYCODE_MENUSleeping
for 200 milliseconds
:Sending Touch (ACTION_DOWN):0:(427.0,724.0)
:Sending Touch (ACTION_UP):0:(432.7109,722.9021)
Sleeping for 200 milliseconds
:Sending Trackball (ACTION_MOVE):0:(-1.0,-1.0)
:Sending Trackball (ACTION_MOVE): 0:(-5.0,0.0)
:Sending Trackball (ACTION_MOVE):0:(3.0,4.0)
:Sending Trackball (ACTION_MOVE):0:(0.0,4.0)
:Sending Trackball (ACTION_MOVE):0:(3.0,-5.0)
:Sending Trackball (ACTION_MOVE):0:(-2.0,0.0)
:Sending Trackball (ACTION_MOVE):0:(1.0,3.0)
:Sending Trackball (ACTION_MOVE):0:(-5.0,-3.0)
:Sending Trackball (ACTION_MOVE):0:(3.0,-3.0)
:Sending Trackball (ACTION_MOVE):0:(-2.0,1.0)
Sleeping for 200 milliseconds
(下面是拒絕此跳轉,因為它是跳轉到非它自己的包的Activity,本測試中只是測試它程序所在的包,此跳轉是跳出本程序,進入到settings的ManageAccountsSettingsActivity )
// Rejecting start of Intent {act=android.settings.SYNC_SETTINGScmp=com.android.settings/.Settings$ManageAccountsSettingsActivity } in packagecom.android.settings
:Sending Key (ACTION_DOWN): 21 // KEYCODE_DPAD_LEFT
:Sending Key (ACTION_UP): 21 // KEYCODE_DPAD_LEFTSleeping
for 200 milliseconds
:Sending Trackball (ACTION_MOVE):0:(1.0,-3.0)
:Sending Trackball (ACTION_MOVE):0:(-5.0,3.0)
:Sending Trackball (ACTION_MOVE):0:(-5.0,-1.0)
:Sending Trackball (ACTION_MOVE):0:(2.0,-5.0)
:Sending Trackball (ACTION_MOVE):0:(-2.0,2.0)
:Sending Trackball (ACTION_MOVE):0:(-1.0,2.0)
:SendingTrackball (ACTION_MOVE): 0:(-4.0,-5.0)
:Sending Trackball (ACTION_MOVE):0:(-3.0,-4.0)
:Sending Trackball (ACTION_MOVE):0:(-2.0,2.0)
:Sending Trackball (ACTION_MOVE):0:(1.0,3.0)
:Sending Key (ACTION_DOWN): 82 // KEYCODE_MENU
:Sending Key (ACTION_UP): 82 // KEYCODE_MENU
Sleeping for 200 milliseconds
:Sending Key (ACTION_DOWN): 130 // KEYCODE_MEDIA_RECORD
:Sending Key (ACTION_UP): 130 // KEYCODE_MEDIA_RECORDSleeping for 200milliseconds
(下面也是允許跳轉,也就是允許跳轉到測試包中的其他activity)
// Allowing start of Intent {cmp=com.android.contacts/.preference.ContactsPreferenceActivity } in packagecom.android.contacts
:Sending Key (ACTION_DOWN): 3 // KEYCODE_HOME
:Sending Key (ACTION_UP): 3 // KEYCODE_HOME
// Rejecting start of Intent {act=android.intent.action.MAIN cat=[android.intent.category.HOME]cmp=com.android.launcher/com.android.launcher2.Launcher } in packagecom.android.launcher
:Sending Touch (ACTION_UP):0:(69.70096,174.86081)
Sleeping for 200 milliseconds
:Sending Key (ACTION_DOWN): 22 // KEYCODE_DPAD_RIGHT
:Sending Key (ACTION_UP): 22 // KEYCODE_DPAD_RIGHT
Sleeping for 200 milliseconds:SendingKey (ACTION_DOWN): 20 //KEYCODE_DPAD_DOWN
:Sending Key (ACTION_UP): 20 // KEYCODE_DPAD_DOWN
Sleeping for 200 milliseconds
:Sending Key (ACTION_DOWN): 82 // KEYCODE_MENU
:Sending Key (ACTION_UP): 82 // KEYCODE_MENU
Sleeping for 200 milliseconds
:Sending Touch (ACTION_DOWN):0:(21.0,468.0)
:Sending Touch (ACTION_POINTER_DOWN1): 0:(27.638153,474.00204) 1:(346.0,657.0)
:Sending Touch (ACTION_MOVE):0:(37.267162,481.8316) 1:(326.71375,662.1464)
:Sending Touch (ACTION_MOVE):0:(38.95241,487.67917) 1:(313.75757,666.34375)
:Sending Touch (ACTION_MOVE):0:(42.695473,490.5754) 1:(298.60742,671.7384)
:Sending Touch (ACTION_MOVE):0:(60.71522,499.6811) 1:(278.45618,674.3698)
:Sending Touch (ACTION_MOVE):0:(61.872463,509.58676) 1:(257.19217,681.1843)
:Sending Touch (ACTION_MOVE): 0:(75.17328,518.97986)1:(239.4733,684.1668)
:Sending Touch (ACTION_MOVE):0:(89.66536,529.8832) 1:(231.6301,692.0084)
:Sending Touch (ACTION_MOVE):0:(92.55939,532.7987) 1:(230.73659,694.44574)
:Sending Touch (ACTION_MOVE):0:(94.616165,533.37885) 1:(228.23737,701.20294)
:Sending Touch (ACTION_POINTER_UP 1):0:(94.91951,537.33026) 1:(207.84836,704.19226)
:Sending Touch (ACTION_UP):0:(103.09425,540.7762)
Events injected: 800
(下面是丟棄的,鍵=0,指針=0,軌跡球=0,翻轉=0。 )
:Dropped: keys=0 pointers=8trackballs=0 flips=0
## Network stats: elapsedtime=47875ms (0ms mobile, 0ms wifi, 47875ms not connected)
網絡統(tǒng)計經過時間為47875ms,其中0ms是用于在手機數據的,0ms用于無線網絡上,沒有連接的時間為47875ms,意思就是一直沒有連接上網絡。
// Monkey finished (表明測試正常完成)
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。