generated from Android-TPL-energy-consumption/CrashReportingTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scenario.sh
32 lines (20 loc) · 832 Bytes
/
scenario.sh
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
#!/bin/bash
PACKAGE="tpl.crashreporting.crashlytics"
ACTIVITY="tpl.crashreporting.crashlytics.MainActivity"
# Launch app
adb shell am start -n $PACKAGE/$ACTIVITY
# Wait few seconds to simulate user waiting
sleep 3
# Press button to crash the app (https://stackoverflow.com/a/50027374/11243782)
## Dump layout file
adb pull $(adb shell uiautomator dump | grep -oP '[^ ]+.xml') view.xml
## Retrieve button coordinates
coords=$(perl -ne 'printf "%d %d\n", ($1+$3)/2, ($2+$4)/2 if /text="CLICK ME!"[^>]*bounds="\[(\d+),(\d+)\]\[(\d+),(\d+)\]"/' view.xml)
## Click button
adb shell input tap $coords
# Sleep some time (expecting that information is sent to the server)
sleep 3
# Close Android message about the crash by clicking outside it
adb shell input tap 500 500
# Wait few seconds to wait until report is sent
sleep 12