I’ve been out on the road visiting with folks using Eggplant from the East to the West coasts. Some of our friends are developing or have in market mobile devices in need of GUI testing.
One in particular is the Nokia N95 (http://www.nseries.com/index.html) running the S60 (http://www.s60.com/life) operating system. With mVNC installed to do VNC <-> bluetooth stack translations, this little device and operating system are prime candidates for device automation and testing.
To make it easy to test contact information, a simple script was created for our friends in Europe testing this configuration to reduce the tedium of typing characters from a standard telephone’s numeric pad. An example of how you may not want a script to look due to the difficult way it reads may be considered:
http://img186.imageshack.us/img186/8826/callchriskw2.th.png
As you can see, there quite a few sequences to just punch in a simple name. Why not allow Eggplant and its embedded scripting language Sensetalk along with some thought take the choir out of the task. A powerful idea like repeat looping gives the power take redundant tasks like testing and compress ideas into a series of values or in this case mappings of values. Embedding the keys, and how they are to be mapped to the keypad of a mobile phone is a simple process yet one that needs some thought.
-- Take a set of values and map to keys in a property list
set keypad to ( a:(2,1), b:(2,2), c:(2,3), \
d:(3,1), e:(3,2), f:(3,3), \
g:(4,1), h:(4,2), i:(4,3), \
j:(5,1), k:(5,2), l:(5,3), \
m:(6,1), n:(6,2), o:(6,3), \
p:(7,1), q:(7,2), r:(7,3), s:(7,4), \
t:(8,1), u:(8,2), v:(8,3), \
w:(9,1), x:(9,2), y:(9,3), z:(9,4), \
" ":("#", 1))
Each character of the alphabet and a few special keys are handled in this simple SenseTalk Property List. Allowing for simple lookup by character, we also have as the property value a list which is the phone pad numeric key to type and it’s count. For instance, to type on the remote mobile device the capital letter “A” the following SenseTalk script will output “01”.
repeat with each item aKey in keys
repeat with each char aChar in aKey
repeat item 2 of keypad.(aChar) times
if aChar is an uppercase then TypeText 0
TypeText item 1 of keypad.(aChar)
end repeat
end repeat
end repeat
So, simply each character in the variable keys is swept, we look up the value in the property list, we then use that key to get the count (item 2) and if the character is an upper case letter the “0” is punched so capitalization results. Please remember when reading SenseTalk script, parenthetical notation is used to reference the actual value in a variable rather than as an unquoted literal referencing a particular key as a string. This point is one of the biggest pitfalls with experienced and new users alike and one of the most likely places for errors to occur in scripts.
We also want to slow down the RemoteWorkInterval to make the characters seem as if someone was punching on the device with their thumbs. There is no need to set the RWI down to less than .25 as a human would be very hard pressed (no pun intended) to type more than 4 chars per second, or about 240 chars per min on a device regularly. If turned down to 0.1, a dual thumbed user would be typing 600 chars per minute, or about 100 words per minute without errors. This is based on the average english word length of approximately six characters including a space of separation. This is simply not possible by even highly trained people using QWERTY keyboards, common enough on DVORAK, and definitely nearly if not impossible on a two thumb device.
params n, keys...
if n is not a positive number then
insert n before keys
set n to .25 seconds
end if
set orwi to the RemoteWorkInterval
set the RemoteWorkInterval to n
Its good form/style and courtesy to Eggplant’s global values the way you found them if altering for speed and performance issues during script execution. Please find another posting describing the ins and outs of the StoreEggplantSettings and RestoreEggplantSettings scripts included in this project.
And finally, the result allows a more readable form to be used when typing text to a remote mobile device.
TypePhoneKey "Todd Nathan"
TypePhoneKey "Support Services Manager"
which will in this case instruct the mVNC server to output
0866633#06062844266
0707070788776667778#0707070733777
888444222337777#062662433777