|
去年为小组的兄弟们写了个Monkey的测试脚本 ,今天又翻看到此脚本 ,为此特分享给51的网友.
def command():
log_lev = log_leve2.GetValue()
run_times = setting_run_times.GetValue()
seed = setting_seed.GetValue()
throttle = setting_throttle.GetValue()
pct_touch = setting_pct_touch.GetValue()
pct_motion = setting_pct_motion.GetValue()
pct_trackball = setting_pct_trackball.GetValue()
pct_nav = setting_pct_nav.GetValue()
pct_majornav = setting_pct_majornav.GetValue()
pct_syskeys = setting_pct_syskeys.GetValue()
pct_appswitch = setting_pct_appswitch.GetValue()
pct_anyevent = setting_pct_anyevent.GetValue()
p_allowed_package_name = setting_p_allowed_package_name.GetValue()
ignore_crashes_ = ignore_crashes.GetValue()
ignore_timeouts_ = ignore_timeouts.GetValue()
ignore_security_exceptions_ = ignore_security_exceptions.GetValue()
adb_command =''
if p_allowed_package_name=="":
pass
else:
adb_command=adb_command + p_allowed_package_name +" "
if seed=="":
pass
else:
adb_command= adb_command + '-s '+seed+" "
if pct_touch=="":
pass
else:
adb_command= adb_command + '--pct-touch '+pct_touch+" "
if pct_motion=="":
pass
else:
adb_command= adb_command + '--pct-motion '+pct_motion+" "
if pct_trackball=="":
pass
else:
adb_command= adb_command + '--pct-trackball '+pct_trackball+" "
if pct_nav=="":
pass
else:
adb_command= adb_command + '--pct-nav '+pct_nav+" "
if pct_majornav=="":
pass
else:
adb_command= adb_command + '--pct-majornav '+pct_majornav+" "
if pct_syskeys=="":
pass
else:
adb_command= adb_command + '--pct-syskeys '+pct_syskeys+" "
if pct_appswitch=="":
pass
else:
adb_command= adb_command + '--pct-appswitch '+pct_appswitch+" "
if pct_anyevent=="":
pass
else:
adb_command= adb_command + '--pct-anyevent '+pct_anyevent+" "
if throttle=="":
pass
else:
adb_command= adb_command + '--throttle '+ throttle +" "
if ignore_crashes_ is True:
adb_command= adb_command + '--ignore-crashes'+" "
else:
pass
if ignore_timeouts_ is True:
adb_command= adb_command + '--ignore-timeouts'+" "
else:
pass
if ignore_security_exceptions_ is True:
adb_command= adb_command + '--ignore-security-exceptions'+" "
else:
pass
if log_lev is 3:
adb_command= adb_command + '-v -v -v '
elif log_lev is 2:
adb_command= adb_command + '-v -v '
else:
adb_command= adb_command + "-v "
run_monkey = "adb shell monkey %s%s " %(adb_command,run_times)
return run_monkey |
|