CameraTest

 1 from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice,MonkeyImage
 2 
 3 #device = MonkeyRunner.waitForConnection()
 4 #device.startActivity(component="com.lenovo.scg/.camera.CameraLauncher")
 5 #MonkeyRunner.sleep(1)
 6 
 7 def take_picture(device):
 8     for i in range(1,5):
 9         MonkeyRunner.sleep(2)
10         device.touch(541,1761,'DOWN_AND_UP')
11     
12 def switch_camera(device):
13     MonkeyRunner.sleep(3)
14     device.touch(989,89,'DOWN_AND_UP')
15 
16 def enter_camera(device):
17     device.touch(413,1101,'DOWN_AND_UP')
18     MonkeyRunner.sleep(2)
19     
20 def exit_camera(device):
21     MonkeyRunner.sleep(2)
22     device.press('KEYCODE_HOME', MonkeyDevice.DOWN_AND_UP)
23     MonkeyRunner.sleep(3)
24     
25 def TEST_LOOP(device):
26     enter_camera(device)
27     take_picture(device)
28     switch_camera(device)
29     take_picture(device)
30     exit_camera(device)
31 
32 def main():
33     print "Start"
34     device = MonkeyRunner.waitForConnection()
35         
36     if not device:
37         print "Couldn't get connection"
38         sys.exit()
39     
40     print "Found device"
41     
42     for i in range(1,300):
43         TEST_LOOP(device)
44         print(i)
45         
46 if __name__ == '__main__':
47     main()
原文地址:https://www.cnblogs.com/eustoma/p/4347529.html