-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA_PhotoSlide_.py
134 lines (118 loc) · 4.57 KB
/
A_PhotoSlide_.py
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/env python
# coding:utf-8
import datetime
import json
import threading
import subprocess
import sys
import time
import re
import traceback
import xlwt
import math
from uiautomator import device as d
from time import sleep
patternFps = re.compile(r'[\s]+[\d]+.[\d]+[\s]+[\d]+.[\d]+[\s]+[\d]+.[\d]+[\s\S]*')
patternProfileData = re.compile(r'[\d]+,[\d]+,[\d]+,[\s\S]*')
def BeforeTestCommon():
print("install start-up and screen-on")
d.screen.on()
print("unlock")
d(index="0").swipe.up(steps=10)
print("home")
d.press.home()
print("menu")
d.press.menu()
d(resourceId="com.android.systemui:id/clearButton").click()
print("click clearButton")
d.server.adb.cmd("shell", "am", "start", "-n", "com.miui.gallery/.activity.HomePageActivity")
print("am start gallery")
def prepare_A_PhotoSlide_():
try:
gridTop = ""
gridinfo = d(resourceId="com.miui.gallery:id/grid").info
gridjson = json.dumps(gridinfo)
gridjson = json.loads(gridjson)
for key in gridjson.keys():
boundsVal = gridjson[key]
if key == "bounds":
boundsVal = json.dumps(boundsVal)
boundsValJson = json.loads(boundsVal)
gridTop = boundsValJson["top"]
action_barBottomTop = ""
action_barBottominfo = d(resourceId="miui:id/action_bar").info
action_barBottominfo = json.dumps(action_barBottominfo)
action_barBottominfo = json.loads(action_barBottominfo)
for key in action_barBottominfo.keys():
boundsVal = action_barBottominfo[key]
if key == "bounds":
boundsVal = json.dumps(boundsVal)
boundsValJson = json.loads(boundsVal)
action_barBottomTop = boundsValJson["bottom"]
if gridTop != action_barBottomTop:
print(str(action_barBottomTop) + "Unequal" + str(gridTop))
d(resourceId="com.miui.gallery:id/grid").scroll.vert.forward(steps=10)
except:
traceback.print_exc()
def reset():
print("gfxinfo reset")
d.server.adb.cmd("shell", "dumpsys", "gfxinfo", "com.miui.gallery", "reset")
sleep(1)
print("sleep 1 second finished")
def swipePhotoPage():
print("begin swipePhotoPage:" + str(datetime.datetime.now()))
while True:
isend = d(resourceId="com.miui.gallery:id/grid").scroll.vert.forward(steps=10)
if isend == False:
break
def startTest():
BeforeTestCommon()
prepare_A_PhotoSlide_()
reset()
swipePhotoPage()
getSystemDropRate()
getFinalResult()
def getSystemDropRate():
print("collecting results")
intoGallery = "adb shell dumpsys gfxinfo com.miui.gallery framestats"
process = subprocess.Popen(intoGallery, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
profileText = open('./output/A_PhotoSlide_/txt/SystemDumpAll.txt', 'w')
while True:
nextline = process.stdout.readline()
nextlineDecode = nextline.decode()
if nextlineDecode == "" or nextlineDecode is None:
break
profileText.write(nextlineDecode)
print("collecting results end")
def getFinalResult():
print("generating results")
intoGallery = "adb shell dumpsys gfxinfo com.miui.gallery framestats"
process = subprocess.Popen(intoGallery, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
profileText = open('./output/A_PhotoSlide_/FinalResult.txt', 'w')
while True:
nextline = process.stdout.readline()
nextlineDecode = nextline.decode()
if nextlineDecode == "" or nextlineDecode is None:
break
if nextlineDecode.find("Graphics info") != -1:
profileText.write(nextlineDecode.strip())
profileText.write("\n")
for i in range(0,9):
nextline = process.stdout.readline()
nextlineDecode = nextline.decode()
profileText.write(nextlineDecode.strip())
profileText.write("\n")
print("generating results end")
return
if __name__ == '__main__':
startTest()
# d(text="相册").click()
#
# d(text="相机").click()
# while True:
# isb = d(resourceId="com.miui.gallery:id/grid").scroll.vert.forward(steps=10)
# if isb==False:
# break;
# uiselect = d(className="android.widget.ListView", resourceId="com.miui.gallery:id/album_list").child(className="android.widget.RelativeLayout")
# uiobj = d(className="android.widget.ListView", resourceId="com.miui.gallery:id/album_list").child(className="android.widget.RelativeLayout",instance=1)
# uiobj.click()