加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

Monkey日志信息的11种Event percentages

(2015-01-11 15:47:38)
标签:

monkey

分类: 自动化测试

我们查看官方文档,表里只给出了8种事件(可以看我上篇的翻译文档)。但我们运行Monkey后,却发现有11种事件!最坑爹的是,在每种事件的百分比后面,他还不给注明是什么事件!

原来不同的Android SDK中的Event percentages种类数和顺序是不一样的!

http://img.blog.csdn.net/20150110231346488?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc29uZ3poZW5odWEyMDAw/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEastpercentages" />


我们可以查看android-4.2.2_r1.2中的MonkeySourceRandom.java中定义的这些值:

 

  1. public static final int FACTOR_TOUCH        0 
  2. public static final int FACTOR_MOTION       1 
  3. public static final int FACTOR_PINCHZOOM    2 
  4. public static final int FACTOR_TRACKBALL    3 
  5. public static final int FACTOR_ROTATION     4 
  6. public static final int FACTOR_NAV          5 
  7. public static final int FACTOR_MAJORNAV     6 
  8. public static final int FACTOR_SYSOPS       7 
  9. public static final int FACTOR_APPSWITCH    8 
  10. public static final int FACTOR_FLIP         9 
  11. public static final int FACTOR_ANYTHING     10 
  12. public static final int FACTORZ_COUNT       11   // should be last+1  
  13.   
  14. private static final int GESTURE_TAP 0 
  15. private static final int GESTURE_DRAG 1 
  16. private static final int GESTURE_PINCH_OR_ZOOM 2 

然后再来看Monkey.java源码中的processOptions()方法

 

 

  1.    
  2. private boolean processOptions()  
  3.     // quick (throwaway) check for unadorned command  
  4.     if (mArgs.length 1 
  5.         showUsage();  
  6.         return false 
  7.      
  8.   
  9.     try  
  10.         String opt;  
  11.         while ((opt nextOption()) != null 
  12.             if (opt.equals("-s"))  
  13.                 mSeed nextOptionLong("Seed");  
  14.             else if (opt.equals("-p"))  
  15.                 mValidPackages.add(nextOptionData());  
  16.             else if (opt.equals("-c"))  
  17.                 mMainCategories.add(nextOptionData());  
  18.             else if (opt.equals("-v"))  
  19.                 mVerbose += 1 
  20.             else if (opt.equals("--ignore-crashes"))  
  21.                 mIgnoreCrashes true 
  22.             else if (opt.equals("--ignore-timeouts"))  
  23.                 mIgnoreTimeouts true 
  24.             else if (opt.equals("--ignore-security-exceptions"))  
  25.                 mIgnoreSecurityExceptiontrue 
  26.             else if (opt.equals("--monitor-native-crashes"))  
  27.                 mMonitorNativeCrashes true 
  28.             else if (opt.equals("--ignore-native-crashes"))  
  29.                 mIgnoreNativeCrashes true 
  30.             else if (opt.equals("--kill-process-after-error"))  
  31.                 mKillProcessAfterError true 
  32.             else if (opt.equals("--hprof"))  
  33.                 mGenerateHprof true 
  34.             else if (opt.equals("--pct-touch"))  
  35.                 int MonkeySourceRandom.FACTOR_TOUCH;  
  36.                 mFactors[i] -nextOptionLong("touch events percentage");  
  37.             else if (opt.equals("--pct-motion"))  
  38.                 int MonkeySourceRandom.FACTOR_MOTION;  
  39.                 mFactors[i] -nextOptionLong("motion events percentage");  
  40.             else if (opt.equals("--pct-trackball"))  
  41.                 int MonkeySourceRandom.FACTOR_TRACKBALL;  
  42.                 mFactors[i] -nextOptionLong("trackball events percentage");  
  43.             else if (opt.equals("--pct-rotation"))  
  44.                 int MonkeySourceRandom.FACTOR_ROTATION;  
  45.                 mFactors[i] -nextOptionLong("screen rotation events percentage");  
  46.             else if (opt.equals("--pct-syskeys"))  
  47.                 int MonkeySourceRandom.FACTOR_SYSOPS;  
  48.                 mFactors[i] -nextOptionLong("system (key) operations percentage");  
  49.             else if (opt.equals("--pct-nav"))  
  50.                 int MonkeySourceRandom.FACTOR_NAV;  
  51.                 mFactors[i] -nextOptionLong("nav events percentage");  
  52.             else if (opt.equals("--pct-majornav"))  
  53.                 int MonkeySourceRandom.FACTOR_MAJORNAV;  
  54.                 mFactors[i] -nextOptionLong("major nav events percentage");  
  55.             else if (opt.equals("--pct-appswitch"))  
  56.                 int MonkeySourceRandom.FACTOR_APPSWITCH;  
  57.                 mFactors[i] -nextOptionLong("app switch events percentage");  
  58.             else if (opt.equals("--pct-flip"))  
  59.                 int MonkeySourceRandom.FACTOR_FLIP;  
  60.                 mFactors[i] -nextOptionLong("keyboard flip percentage");  
  61.             else if (opt.equals("--pct-anyevent"))  
  62.                 int MonkeySourceRandom.FACTOR_ANYTHING;  
  63.                 mFactors[i] -nextOptionLong("any events percentage");  
  64.             else if (opt.equals("--pct-pinchzoom"))  
  65.                 int MonkeySourceRandom.FACTOR_PINCHZOOM;  
  66.                 mFactors[i] -nextOptionLong("pinch zoom events percentage");  
  67.             else if (opt.equals("--pkg-blacklist-file"))  
  68.                 mPkgBlacklistFile nextOptionData();  
  69.             else if (opt.equals("--pkg-whitelist-file"))  
  70.                 mPkgWhitelistFile nextOptionData();  
  71.             else if (opt.equals("--throttle"))  
  72.                 mThrottle nextOptionLong("delay (in milliseconds) to wait between events");  
  73.             else if (opt.equals("--randomize-throttle"))  
  74.                 mRandomizeThrottle true 
  75.             else if (opt.equals("--wait-dbg"))  
  76.                 // do nothing it's caught at the very start of run()  
  77.             else if (opt.equals("--dbg-no-events"))  
  78.                 mSendNoEvents true 
  79.             else if (opt.equals("--port"))  
  80.                 mServerPort (intnextOptionLong("Server port to listen on for commands");  
  81.             else if (opt.equals("--setup"))  
  82.                 mSetupFileName nextOptionData();  
  83.             else if (opt.equals("-f"))  
  84.                 mScriptFileNames.add(nextOptionData());  
  85.             else if (opt.equals("--profile-wait"))  
  86.                 mProfileWaitTime nextOptionLong("Profile delay"  
  87.                             (in milliseconds) to wait between user action");  
  88.             else if (opt.equals("--device-sleep-time"))  
  89.                 mDeviceSleepTime nextOptionLong("Device sleep time"  
  90.                                                   "(in milliseconds)");  
  91.             else if (opt.equals("--randomize-script"))  
  92.                 mRandomizeScript true 
  93.             else if (opt.equals("--script-log"))  
  94.                 mScriptLog true 
  95.             else if (opt.equals("--bugreport"))  
  96.                 mRequestBugreport true 
  97.             else if (opt.equals("--periodic-bugreport")){  
  98.                 mGetPeriodicBugreport true 
  99.                 mBugreportFrequency nextOptionLong("Number of iterations");  
  100.             else if (opt.equals("-h"))  
  101.                 showUsage();  
  102.                 return false 
  103.             else  
  104.                 System.err.println("** Error: Unknown option: " opt);  
  105.                 showUsage();  
  106.                 return false 
  107.              
  108.          
  109.     catch (RuntimeException ex)  
  110.         System.err.println("** Error: " ex.toString());  
  111.         showUsage();  
  112.         return false 
  113.      
  114.   
  115.     // If server port hasn't been specified, we need to specify  
  116.     // count  
  117.     if (mServerPort == -1 
  118.         String countStr nextArg();  
  119.         if (countStr == null 
  120.             System.err.println("** Error: Count not specified");  
  121.             showUsage();  
  122.             return false 
  123.          
  124.   
  125.         try  
  126.             mCount Integer.parseInt(countStr);  
  127.         catch (NumberFormatException e)  
  128.             System.err.println("** Error: Count is not number");  
  129.             showUsage();  
  130.             return false 
  131.          
  132.      
  133.   
  134.     return true 
  135.  

所以,Monkey运行结果中对应的就应该是:

 

0:--pct-touch//touch events percentage触摸事件百分比(触摸事件是一个在屏幕单一位置的按下-抬起事件)

1:--pct-motion//motion events percentage手势事件百分比(手势事件是由一个在屏幕某处的按下事件、一系列的伪随机移动、一个抬起事件组成)即一个滑动操作,但是是直线的,不能拐弯

2:--pct-pinchzoom//pinch zoom events percentage二指缩放百分比,即智能机上的放大缩小手势操作

3:--pct-trackball//trackball events percentage轨迹球事件百分比(轨迹球事件包括一个或多个随机移动,有时还伴有点击。轨迹球现在智能手机上已经没有了,就是类似手柄的方向键一样)

4:--pct-rotation//screen rotation events percentage屏幕旋转百分比,横屏竖屏

5:--pct-nav//nav events percentage基本导航事件百分比(导航事件包括上下左右,如方向输入设备的输入)老手机的上下左右键,智能机上没有

6:--pct-majornav//major nav events percentage主要导航事件百分比(这些导航事件通常会引发UI的事件,例如5-way pad的中间键、回退键、菜单键)

7:--pct-syskeys//system(key) operations percentage系统按钮事件百分比(这些按钮一般专供系统使用,如Home, Back, Start Call, End Call,音量控制)

8:--pct-appswitch//app switch events percentage启动activity事件百分比。在随机的间隔里,Monkey会执行一个startActivity()调用,作为最大程度覆盖包中全部Activity的一种方法

9:--pct-flip//keyboard flip percentage键盘轻弹百分比,如点击输入框,键盘弹起,点击输入框以外区域,键盘收回

10:--pct-anyevent//anyevents percentage其他类型事件百分比。包括了其他所有的类型事件,如按键、其他不常用的设备上的按钮等等。

 

参考:

http://blog.csdn.net/jlminghui/article/details/42261307

http://blog.csdn.net/jlminghui/article/details/42268187
源码:

https://code.google.com/p/android-source-browsing/source/browse/cmds/monkey/src/com/android/commands/monkey/Monkey.java?repo=platform--development&name=android-4.2.2_r1.2

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有