-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_single_battery_test.py
77 lines (66 loc) · 2.3 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
import argparse
import time
import random
import helper.adb as adb
available_apps = [
{
"name": "firefox",
"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"
}
]
apps = []
parser = argparse.ArgumentParser(description='Alternative Android Battery Test')
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="7777")
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_connected_device(args.ip, args.port)
count = args.count
start = args.start
# 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, "firefox", interaction[0], n))