Testing an GUI

Ned Konz ned at squeakland.org
Sat Dec 6 16:40:10 UTC 2003


On Saturday 06 December 2003 1:15 am, Alexandre Bergel wrote:

> I would like to make some testsuite related to an GUI.
> My current idea is simply to instanciate my morph, and sending the
> mouseDown: selector with an appropriate instance of MouseButtonEvent as a
> message.
>
> Is there a better way? Something already built-in?

I started to do this at one point:

* make a new TestSuite or TestResource class for testing GUIs
* specialize a type of EventRecorder for use playing back events to the GUI 
under test
* to record test events, construct the GUI element under test and play with 
it. Recorded events are captured as a TestResource or as internal code in the 
test cases.
* during recording of test events and during testing, construct the GUI 
element(s) under test as children of a captive PasteUpMorph (rather than the 
World)
* play back recorded events during testing.

I could try to find it and give you a copy, but that's the idea.

I ended up spending too much time on EventRecorder strangeness. I think now 
that it would be easier to make a new EventRecorder for just this use.

Remember that the event dispatching in Morphic goes through the World (or more 
generally, owner -> submorphs). So if you make a PasteUpMorph to hold your 
GUI elements you can have it record the events as well, or you can do what 
the EventRecorder does and tell the hand addKeyboardListener: and 
addMouseListener: and then use #handleListenEvent: to do the actual 
recording.

You would offset the mouse positions by the offset of the test PasteUpMorph, 
of course, and since your tests would always create the GUI elements under 
test at exactly the same position within the PasteUpMorph, there would be no 
problems with offsets.




More information about the Squeak-dev mailing list