-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscreen_mode_test.py
More file actions
42 lines (34 loc) · 1.21 KB
/
screen_mode_test.py
File metadata and controls
42 lines (34 loc) · 1.21 KB
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
#! /usr/bin/env monkeyrunner
# Filename: screen_mode_test
# Description: This file is used to auto-test.
import sys, os, time
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice,MonkeyImage
# define some useful path
adb_path = r"D:\Android4.0\Android4.0\Android\android-sdk\platform-tools\adb.exe"
filename = "screen_mode_test"
# connect to the device, returning a MonkeyDevice
device = MonkeyRunner.waitForConnection()
if not device:
print >> sys.stderr, "Couldn't get connection"
sys.exit(1)
# Take snapshot
def takeSnapShot(index):
MonkeyRunner.sleep(1.0)
result = device.takeSnapshot()
tmp = time.strftime("%m.%d_%H.%M")
result.writeToFile(filename + '_' + str(index) + '_' + tmp + '.png', 'png')
### begine to test
if __name__=='__main__':
# start activity
device.startActivity(component='com.android.camera/.Camera')
# Test takeSnapShot
for i in range(1, 11):
takeSnapShot(i)
MonkeyRunner.sleep(3.0)
device.press('DPAD_CENTER', MonkeyDevice.DOWN_AND_UP)
MonkeyRunner.sleep(3.0)
#Exit Activity
device.press('KEYCODE_BACK', 'DOWN_AND_UP')
MonkeyRunner.sleep(0.5)
cmd = adb_path + " pull sdcard/DCIM/100ANDRO"
os.system(cmd)