Script to create 6k worth of history…

Originally I had this:#!/bin/bash
# website history generator v 0.01
#
# Usage webhistgen <n> <appname>
# n: number of websites to visit
# appname: application name such as org.mozilla.fennec

n=$1;
appname=$2;

cmdline=”adb shell am start -a android.intent.action.VIEW -n “$appname”/.App -d http://www.randomwebsite.com/cgi-bin/random.pl&#8221;;
closeApp=”adb shell ps| grep “$appname” | awk ‘{print $2}’ | xargs adb shell kill”

tPause=2;
tLaunch=30;
tShutdown=30;

cAppInt=8;

for ((a=1; a <= n ; a++))
do

echo $(date) $($cmdline);

#if it’s the first time launching a tab, wait longer, else wait a short time to open a new tab
if [ `expr $a % $cAppInt` == 1 ]
then
sleep $tLaunch;
else
sleep $tPause;
fi

#close the app every cAppInt tab open
if [ `expr $a % $cAppInt` == 0 ]
then
echo $(date) $($closeApp);
sleep $tShutdown;
fi
done

The problem is that:

1) the intent opens a new tab with the link

2) the quit command isn’t working unless the phone is rooted

Fennec doesn’t like 40 tabs being opened much less 6k worth of tabs open.

So… my only hope is probably Monkeyrunner…  Looking into that right now.

Update: So I caved into rooting; fixed my script … I’ll look at monkey runner later, need to finish verifying bugs.  You can find a copy of the bash script here : ( http://people.mozilla.com/~nhirata/Scripts/webhistgen.sh )

#!/bin/bash
# website history generator v 0.02
#
# Usage webhistgen <n> <appname>
# n: number of websites to visit
# appname: application name such as org.mozilla.fennec
#

n=$1;
appname=$2;

cmdLine=”adb shell am start -a android.intent.action.VIEW -n “$appname”/.App -d http://www.randomwebsite.com/cgi-bin/random.pl&#8221;;
listApps=”adb shell ps|grep “$appname” | cut -c11-15″;

tPause=2;
tLaunch=10;
tShutdown=10;
cAppInt=8;

for ((a=1; a <= n ; a++))
do
echo $(date) $($cmdLine);

#if it’s the first time launching a tab, wait longer, else wait a short time to open a new tab
if [ `expr $a % $cAppInt` == 1 ]
then
sleep $tLaunch;
else
sleep $tPause;
fi

#close the app every cAppInt tab open; kill each process for fennec
if [ `expr $a % $cAppInt` == 0 ]
then
for i in `$listApps`
do
echo $(date) “adb shell su -c kill -9 $i”;
echo `adb shell su -c “kill -9 “$i`;
done
sleep $tShutdown;
fi
done

Advertisements

About shizen008

Breaking things and getting in trouble for it since '74. Disclaimer: I am not responsible if I make your head explode reading this blog! The writings here are my own expression and not of any companies. I currently work on being a QA for B2G aka Firefox OS
This entry was posted in mobifx, mobile, QA, QMO. Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s