1# Script to automate the following sequence:
2# - Open Feedly
3# - Open an article
4# - Scroll to bottome
5# - Open the same article in Chrome
6# - Scroll the article
7# - Back to Feely (should still be in memory)
8# - Home screen
9# ---- repeat ----
10#
11# Currently works on volantis only (verticle orientation)
12#
13
14CMDDIR=$(dirname $0 2>/dev/null)
15CMDDIR=${CMDDIR:=.}
16. $CMDDIR/defs.sh
17
18case "$DEVICE" in
19(volantis)
20	echo volantis...
21	feedlyArticle="500 700"
22	feedlyOptions="1480 100"
23	feedlyBrowserSelect="1350 650"
24	feedlyArticleSwipeUp="700 700 700 50 50"
25	feedlyArticleSwipeDown="700 200 700 700 50"
26	chromeSwipe="700 700 700 50 50"
27	;;
28(shamu|*)
29	echo shamu...
30	feedlyArticle="676 500"
31	feedlyOptions="1327 207"
32	feedlyBrowserSelect="1278 1191"
33	feedlyArticleSwipeUp="700 1847 700 400 50"
34	feedlyArticleSwipeDown="700 400 700 1847 50"
35	chromeSwipe="700 1847 700 400 50"
36	;;
37(hammerhead|*)
38	echo "Error: No feedly screen geometry information available for $DEVICE"
39	exit 1;;
40esac
41
42feedlySwitchToTime=600
43
44# start feedly, if not installed, error out
45t=$(forceStartActivity feedly)
46checkIsRunning feedly "initial start of feedly"
47echo Feedly start time = ${t}ms
48
49# start chrome, if not installed, error out
50t=$(forceStartActivity chrome)
51checkIsRunning chrome "initial start of chrome"
52echo Chrome start time = ${t}ms
53sleep 1
54
55feedlyStartTimes=0
56
57cur=1
58while [ $cur -le $iterations ]
59do
60	echo =======================================
61	echo Iteration $cur of $iterations
62	echo =======================================
63	startInstramentation
64	t=$(startActivity feedly)
65	if [ $(checkStartTime "$t" $feedlySwitchToTime) != true ]; then
66		handleError Feedly took too long to start: $t v $feedlySwitchToTime: $?
67		# for now, not fatal
68		# exit 1
69	fi
70	sleep 2
71	((feedlyStartTimes=feedlyStartTimes+t))
72	echo feedly started in ${t}ms
73	checkIsRunning chrome "switch back to feedly"
74	checkIsRunning googlequicksearchbox "switch back to feedly"
75
76	# click on first article
77	doTap $feedlyArticle
78	sleep 2
79
80	# scroll through article
81	doSwipe $feedlyArticleSwipeUp
82	sleep 5
83	checkIsRunning chrome "feedly swipe"
84	checkIsRunning googlequicksearchbox "feedly swipe"
85
86	# scroll back to top
87	doSwipe $feedlyArticleSwipeDown
88	sleep 2
89
90	# switch to chrome
91	# 1. click on menu bar
92	doTap $feedlyOptions
93	sleep 1
94	# 2. click on browser
95	doTap $feedlyBrowserSelect
96	sleep 10
97
98	checkIsRunning feedly "switch to chrome"
99	checkIsRunning googlequicksearchbox "switch to chrome"
100
101	# Now we're back in chrome, swipe to bottom of article
102	doSwipe $chromeSwipe
103	sleep 2
104	checkIsRunning feedly "swiped chrome"
105	stopInstramentation
106	((cur=cur+1))
107done
108((feedlyAve=feedlyStartTimes/iterations))
109echo Avg start times: feedly: ${feedlyAve}ms
110
111doKeyevent HOME
112