SUnit testing for morphic

Ned Konz ned at squeakland.org
Tue Feb 10 20:59:05 UTC 2004


On Monday 09 February 2004 6:08 pm, Tom Koenig wrote:
> I'm working on creating some SUnit tests for Jerome Peace's Polygon fixes.
>
> Does anyone have any advice/examples of how I can pass events to messages
> programmatically?  I can unit test some messages that pass evt, because the
> event really isn't used in the method.  I guess I'm looking for a way to
> instantiate events?  (But that can't be right because there is no Event
> Class (just EventSensor).
>
> Pointers to any existing SUnit tests cases for Morphic would be useful.

I have started this before, using the EventRecorder/HandMorphForReplay.

Actually, there is an Event hierarchy. Look at the hierarchy rooted at 
MorphicEvent.

My idea was to make a modified event recorder and have it save events and play 
them back as part of the test. You'd instantiate your morph under test in a 
captive PasteUpMorph at a known position, then play back the tape (which 
would have its contents stored in the test case method as text). The events 
would have their coordinates offset by the origin of the PUM.

It was almost working, as I recall; if you're interested in picking this up, 
it may be amusing to look at (this is assuming I can find my work).

A possibly easier way to do this is to do one of:

* ignore the EventRecorder altogether and make a new recorder for this 
purpose. You can hook into the event stream as a mouse and/or keyboard 
listener.

* use the existing EventRecorder and just play back tapes from your test 
cases. I recommend instantiating your morphs in known places, of course.




More information about the Squeak-dev mailing list