1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
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__))+"/quadrant_" + 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.aurorasoftworks.quadrant.ui.standard-1.apk'
device.installPackage(srcfile)
#clean the enviroment
init()
device.startActivity(component='com.aurorasoftworks.quadrant.ui.standard/.QuadrantStandardLauncherActivity')
MonkeyRunner.sleep(2)
device.shell("am kill-all")
MonkeyRunner.sleep(2)
device.press("KEYCODE_DPAD_DOWN",MonkeyDevice.DOWN_AND_UP)
device.press("KEYCODE_DPAD_DOWN",MonkeyDevice.DOWN_AND_UP)
device.press("KEYCODE_DPAD_CENTER",MonkeyDevice.DOWN_AND_UP)
MonkeyRunner.sleep(5)
device.press("KEYCODE_DPAD_UP",MonkeyDevice.DOWN_AND_UP)
device.press("KEYCODE_DPAD_UP",MonkeyDevice.DOWN_AND_UP)
device.press("KEYCODE_DPAD_UP",MonkeyDevice.DOWN_AND_UP)
device.press("KEYCODE_DPAD_UP",MonkeyDevice.DOWN_AND_UP)
device.press("KEYCODE_DPAD_DOWN",MonkeyDevice.DOWN_AND_UP)
device.press("KEYCODE_DPAD_CENTER",MonkeyDevice.DOWN_AND_UP)
print "Running Quadrant"
MonkeyRunner.sleep(120)
device.press("KEYCODE_DPAD_DOWN",MonkeyDevice.DOWN_AND_UP)
device.press("KEYCODE_DPAD_RIGHT",MonkeyDevice.DOWN_AND_UP)
device.press("KEYCODE_DPAD_CENTER",MonkeyDevice.DOWN_AND_UP)
MonkeyRunner.sleep(30)
take_snapshot(device)
device.removePackage("com.aurorasoftworks.quadrant.ui.standard")
if __name__ == '__main__':
main()
|