-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_single_battery_test.py
96 lines (85 loc) · 2.79 KB
/
start_single_battery_test.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
import argparse
import time
import random
import helper.adb as adb
available_apps = [
{
"name": "firefox",
"implicit": True,
"data": "https://contactapp.stefanhuber.at"
},
{
"name": "chrome",
"implicit": True,
"data": "https://contactapp.stefanhuber.at"
},
{
"name": "native",
"implicit": False,
"pkg": "at.stefanhuber.contactappnative",
"activity": "MainActivity"
},
{
"name": "react",
"implicit": False,
"pkg": "com.contactappreactnative",
"activity": "MainActivity"
},
{
"name": "capacitor",
"implicit": False,
"pkg": "at.stefanhuber.contactappcapacitor",
"activity": "MainActivity"
},
{
"name": "flutter",
"implicit": False,
"pkg": "com.thomasdorfer.contactappflutter",
"activity": "MainActivity"
},
{
"name": "gecko-wrapper",
"implicit": False,
"pkg": "at.stefanhuber.geckowrapper",
"activity": "MainActivity"
},
{
"name": "webview-wrapper",
"implicit": False,
"pkg": "at.stefanhuber.webviewwrapper",
"activity": "MainActivity"
},
]
apps = []
parser = argparse.ArgumentParser(description='Alternative Android Battery Test')
parser.add_argument('-a', '--app', type=str, help='Name of app', default="chrome")
#parser.add_argument('-i', '--ip', type=str, help='IP-Address of adb-connected Android device', default="")
#parser.add_argument('-p', '--port', type=str, help='Port of adb-connected Android device', default="")
parser.add_argument('-n', '--count', type=int, help='Number of executions of a test per app', default=1)
parser.add_argument('-s', '--start', type=int, help='Start index of test', default=1)
args = parser.parse_args()
device = adb.get_device_model()
count = args.count
start = args.start
app = args.app
# interaction: interaction class name, energy metering True/False
interactions = [
["OpenCloseDrawerInteractionTest", True],
["ScrollDownListInteractionTest", True],
["ScrollUpListInteractionTest", True],
["SwitchScreensInteractionTest", True],
["TopRightMenuInteractionTest", False],
["EnterFormDataInteractionTest", True],
["BackMenuInteractionTest", False],
]
for n in range(start, start + count):
print("start run: {} of {}".format(n, (start + count - 1)))
time.sleep(5)
for interaction in interactions:
if interaction[1]:
adb.clear_batterystats()
adb.start_instrumentation("at.stefanhuber.instrumentation", interaction[0])
if interaction[1]:
adb.dump_batterystats()
adb.pull_data("/data/local/tmp/battery.txt",
"./data/battery_{}_{}_{}_{}.txt".format(device, app, interaction[0], n))