1#!/bin/bash
2
3if ! which adb &> /dev/null; then
4  echo "adb is not in your path, did you run envsetup.sh?"
5  exit -1
6fi
7
8TMPFILE=$(tempfile)
9echo '<body><div>just some text</div></body>' > $TMPFILE
10adb push $TMPFILE /data/local/tmp/file.html
11rm $TMPFILE
12adb shell am start -n com.android.htmlviewer/.HTMLViewerActivity -d "file:///data/local/tmp/file.html" -a VIEW -t "text/html"
13
14sleep 3
15
16echo 'Running test, you should run `adb logcat | grep WebViewStartupTimeMillis=` in another shell to see results.'
17# Launch webview test shell 100 times
18for i in $(seq 1 100); do
19  if [[ $(($i % 10)) -eq 0 ]]; then
20    echo -n "..$i.."
21  fi
22  adb shell kill -9 `adb shell ps | grep com.android.webview.chromium.shell | tr -s " " " " | cut -d" " -f2`
23  adb shell am start -n com.android.webview.chromium.shell/.StartupTimeActivity -a VIEW > /dev/null
24  sleep 0.5
25done
26echo
27
28adb shell rm /data/local/tmp/file.html
29