blob: ee3db849761d60f7658f00cdd00a934c97e2ecd7 [file] [log] [blame]
import os,sys,time
from subprocess import call
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
COUNT = 0;
def gen_png_no():
global COUNT
COUNT = COUNT + 1
return str(COUNT)
def take_snapshot(device):
result = device.takeSnapshot()
result.writeToFile(os.path.realpath(os.path.dirname(__file__))+"/vellamo_" + gen_png_no() +".png","png")
def init():
os.system("rm" + os.path.realpath(os.path.dirname(__file__)) + "/*.png 2> /dev/null")
def main():
if len(sys.argv) < 2:
print "please input the device id"
sys.exit(0)
#connect the device
timeout_val = 5
for dev_id in sys.argv[1:]:
device = MonkeyRunner.waitForConnection( timeout = timeout_val,deviceId = dev_id )
if not device:
print "connect to the device timeout"
sys.exit(0)
else:
print "connect to the device: " + dev_id
device.shell("echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor")
device.shell("echo performance > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor")
srcfile = os.path.realpath(os.path.dirname(__file__))+'/com.quicinc.vellamo-1.apk'
device.installPackage(srcfile)
#clean the enviroment
init()
device.startActivity(component='com.quicinc.vellamo/.Vellamo')
MonkeyRunner.sleep(2)
device.shell("am kill-all")
MonkeyRunner.sleep(1)
device.press("KEYCODE_DPAD_DOWN",MonkeyDevice.DOWN_AND_UP)
MonkeyRunner.sleep(1)
device.press("KEYCODE_DPAD_DOWN",MonkeyDevice.DOWN_AND_UP)
MonkeyRunner.sleep(1)
device.press("KEYCODE_DPAD_DOWN",MonkeyDevice.DOWN_AND_UP)
MonkeyRunner.sleep(1)
device.press("KEYCODE_DPAD_DOWN",MonkeyDevice.DOWN_AND_UP)
MonkeyRunner.sleep(1)
device.press("KEYCODE_DPAD_DOWN",MonkeyDevice.DOWN_AND_UP)
MonkeyRunner.sleep(1)
device.press("KEYCODE_DPAD_DOWN",MonkeyDevice.DOWN_AND_UP)
MonkeyRunner.sleep(1)
device.press("KEYCODE_DPAD_CENTER",MonkeyDevice.DOWN_AND_UP)
MonkeyRunner.sleep(1)
device.press("KEYCODE_DPAD_RIGHT",MonkeyDevice.DOWN_AND_UP)
MonkeyRunner.sleep(1)
device.press("KEYCODE_ENTER",MonkeyDevice.DOWN_AND_UP)
MonkeyRunner.sleep(1)
device.press("KEYCODE_ENTER",MonkeyDevice.DOWN_AND_UP)
MonkeyRunner.sleep(2)
device.press("KEYCODE_DPAD_RIGHT",MonkeyDevice.DOWN_AND_UP)
MonkeyRunner.sleep(1)
device.press("KEYCODE_DPAD_CENTER",MonkeyDevice.DOWN_AND_UP)
MonkeyRunner.sleep(1)
print "Running Andeebench"
MonkeyRunner.sleep(600)
take_snapshot(device)
device.removePackage("com.quicinc.vellamo")
if __name__ == '__main__':
main()