Yesterday I tacked a quick gui harness prototype onto my copy of JBehave (seemed like an appropriate place to put it). I used a thing called a QueuedMiniMap – a cut-down map which, when you get an item by key, will wait until that item is added before returning. It can also throw a timeout exception. I added a listener to window open and close events on the AWT thread which puts or removes the windows to or from the map. I’m keying the window on title (for JFrames and Dialogs), then name, then class string, depending on which one is non-null first.
I now have a mechanism for grabbing hold of AWT / Swing windows as they open – easily adapted to grab anything asynchronously. Cute. Abbot does actually do something similar – it keeps track of all the open windows in the same way – but the method which tries to get the windows from its list just keeps looping, requesting repeatedly until it gets the window or times out (the ‘child in the back seat’ method). All I’ve done is find a way to make the child go to sleep until we arrive.
I’m sure that when I go to click the buttons on the window I’ll find out that I’ve missed something (most of Abbot’s vast functionality, for a start) – but it’s fast. Very fast. Very small.
@todo next: button clicking, text entry, window visibility, focus, make sure it works in Linux too.
(Also wondering about better ways to key the windows in the map – suggestions welcome.)
(Anyone got any tips for making Eclipse work under Debian-based Linux? It says it can’t find the blatantly present startup.jar … and where do you normally keep things like Eclipse in the filesystem? I think I could use a pointer to a suitable newbie site and a good book!)