Ben Armstrong: Tuxpaint GUI testing with xautomation
#!/bin/bash
testname="tuxpaint"
root_geometry= xprop -root _NET_DESKTOP_GEOMETRY cut -d= -f2
root_x= echo $root_geometry cut -d, -f1
root_y= echo $root_geometry cut -d, -f2
xc=$((root_x/2-1))
yc=$((root_y/2-1))
capture_tuxpaint ()
tuxpaint --startblank --nolockfile --lang $1 --640x480 --windowed --nosound &
sleep 1
xte "mousemove $xc $yc"
xte "mouseclick 1"
sleep 1
xte "key Escape"
sleep 2
import -silent -window "Tux Paint" $testname-$1.png
xte "mousermove -120 -40"
xte "mouseclick 1"
for lang in tuxpaint --lang help awk '$1~/^[[:lower:]]/ print $1 ' ; do
capture_tuxpaint $lang
done
I’m not entirely happy with it, but it’s at least a starting point. Ideally, I’d make .pat files to use with visgrep to find coordinates for the button images instead of hardwiring the approximate button positions. Also, the script needs a companion script to configure the system for testing (i.e. perform the locales configuration and install all fonts).
Here are the resulting screenshots which show up a few problems with the translations. It looks like the quit dialog strings have been updated since they were first translated, so now we need retranslation for several languages. Also, there are some languages, like Swahili and Klingon, for which there are no locales in glibc in Debian. I’ll have to talk to the glibc maintainers about that. And for that matter, I don’t even know if a DFSG-free Klingon font exists.
In any event, I’m delighted with the results, and look forward to using xautomation more for GUI testing.
1 For one thing, several languages require special fonts. For another, there is no way to get tuxpaint to tell you what locales it supports. Granted, there is --lang help, but this is a crude approximation, as the mapping between language and locale is arbitrarily hardwired (which hmh on #debian-devel irc pointed out to me is just plain wrong). It doesn’t help me at all in the arduous task of configuring glibc locales so I can test them. For that, I need to look at i18n.c.
2 I tried using xmacro at first, but xmacrorec just made my pointer jiggle back and forth. It seemed like it was updating the position for a short distance, and then X was resetting it back to the former position of the pointer. Some strange interaction with my window manager, perhaps? But ultimately I am happier with the xautomation approach anyway.
Dear Dirk Eddelbuettel,
And you don&apost really use these big containers unless you&aposre shipping something faaar away. If your job is in that box, man, you can just kiss it good-bye, because baby it&aposs gone.
Maybe the best way to ship out one of these jobs containers would be to have a big bulldozer that comes through the middle of town, crushing the community infrastructure under its treads, and then picks up the big shipping container full of tech jobs and carries it off to a big ship in the harbour (rolling over some more schools and houses and small businesses) and then sends it off to somewhere crazy and foreign where they keep monkeys as pets as a matter of course.
In any case: good job, Sun. I hope this works out great for you.
tags: 
