-
Notifications
You must be signed in to change notification settings - Fork 25
Description
When creating mock objects from an interface, all of its super classes are included in the mock objects type hierarchy. But interfaces in ActionScript can extend only other interfaces, and since DisplayObject, Sprite and MovieClip don't implement one, we can't type cast our mock objects to any of these. Hence, we lose the ability to use these mock objects as an argument in calls to addChild () or removeChild() - which basically prevents the fully decoupled testing of UI elements.
If a subclass of DisplayObject implements a custom interface, it should be possible to create a mock object, which extends from DisplayObject or one of its descendants, instead of just plain Object.
I would imagine a syntax like this:
nice (IUISubClass).asSprite();
nice (IUISubClass).asMovieClip();
or via metadata:
[Mock (base="flash.display.Sprite")]
public var uiSubClass:IUISubClass;
The same approach could of course also be useful for any other classes that need to be used in type casts to classes that don't implement an interface.