Change screen orientations during monkey run

半城伤御伤魂 提交于 2019-12-08 19:28:48

问题


I'm using monkey command to do some stress testing on my app. But i want to test it more with respect to screen orientations to detect and capture some heapupdates while changing orientations. I searched all over android official site about monkey commands/arguments which will do screen orientations while running on any app/activity. But no luck and thought of asking professionals like you.

If idea on this, please let me know.


回答1:


Monkey has a number of undocumented options, including --pct-rotation. Add that switch to your command and watch your screen rotate like it's possessed by demons:

Up to (including) adb version 1.0.31:

adb shell monkey -p com.example.app -v --pct-rotation=70 500

Since adb version 1.0.32:

adb shell monkey -p com.example.app -v --pct-rotation 70 500

Look in the processOptions() method of the monkey command to see all of the supported options: https://android.googlesource.com/platform/development.git/+/master/cmds/monkey/src/com/android/commands/monkey/Monkey.java

Look at the constructor for the MonkeySourceRandom class to see the default percentages for all of the event types. These are the current values in the master branch at the time of this post. Note that the default for rotation is 0:

    // default values for random distributions
    // note, these are straight percentages, to match user input (cmd line args)
    // but they will be converted to 0..1 values before the main loop runs.
    mFactors[FACTOR_TOUCH] = 15.0f;
    mFactors[FACTOR_MOTION] = 10.0f;
    mFactors[FACTOR_TRACKBALL] = 15.0f;
    // Adjust the values if we want to enable rotation by default.
    mFactors[FACTOR_ROTATION] = 0.0f;
    mFactors[FACTOR_NAV] = 25.0f;
    mFactors[FACTOR_MAJORNAV] = 15.0f;
    mFactors[FACTOR_SYSOPS] = 2.0f;
    mFactors[FACTOR_APPSWITCH] = 2.0f;
    mFactors[FACTOR_FLIP] = 1.0f;
    mFactors[FACTOR_ANYTHING] = 13.0f;
    mFactors[FACTOR_PINCHZOOM] = 2.0f;

https://android.googlesource.com/platform/development.git/+/master/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java




回答2:


The Test Monkey uses random input. It will change the screen orientation, but there is no guarantee that it will do so on any given test run.




回答3:


Although there is no guarantee that Monkey will change orientation during a given run, you can reach your desired outcome by figuring out a SEED that will cause monkey to change orientation and re-using that SEED in future runs.

# monkey -h
usage: monkey [-p ALLOWED_PACKAGE [-p ALLOWED_PACKAGE] ...]
              ...
              [-s SEED] [-v [-v] ...]
              ...


来源:https://stackoverflow.com/questions/12872917/change-screen-orientations-during-monkey-run

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!