Payday Loans Online Payday Loans Online

Todd Rothe : UI/UX Developer

it's pronounced rowth-ee

By 2g1c2 girls 1 cup

Using UIImpersonator with FlexUnit 4

While testing Spark based custom components I discovered UIImpersonator in FlexUnit 4. Then I nearly strangled UIImpersonator. Here are the issues I ran into, my initial code, and how to resolve the issues.

Issues:
1. Error: Required skin part myRequiredSkinPart cannot be found.
2. Skin for FlexVisualTestEnvironment47.MyView38.MyViewSkin49.contentGroup.myStream._MyStreamSkin_MyRenderer1 cannot be found.

Initial Code:
[Before(async)]
public function setUp():void
{
_target = new MyView();
Async.proceedOnEvent( this, _target, FlexEvent.CREATION_COMPLETE );
UIImpersonator.addChild( _target );
}
[Test(async)]
public function getSetProp():void
{
var _prop:Prop = new Prop();
_target.prop = _prop;
assertThat( _target.prop, sameInstance( _prop ) );
}

Resolutions:
The first error I ran into was this :
1. Error: Required skin part myRequiredSkinPart cannot be found.

Issue : The power of UIImpersonator is that it instantiates your component in isolation, outside of the scope of your application. Therefore css based styles are NOT applied. In my case this meant that my component skin was not applied to my component. When testing using UIImpersonator you need to manually add the skin for your UIComponent.

Fix : Manually set the skinClass style on you component.
_targetSkin = new MyViewSkin();
_target.setStyle( “skinClass”, Class(MyViewSkin) );

The second error I hit was :
2. Error: Skin for FlexVisualTestEnvironment47.MyView38.MyViewSkin49.contentGroup.myStream._MyStreamSkin_MyRenderer1 cannot be found.

Issue : Same issue as before only now the skin that is missing is many components deep.

Fix : Don’t use IUImpersonator for complex composite custom components.

UIImpersonator ensures your test environment is completely separate from the FlexUnit application environment. While this can be useful at times it is often more trouble than it’s worth.

more posts at www.toddrothe.com/blog

 

No Responses to “Using UIImpersonator with FlexUnit 4” (post new)

 

Leave a Reply

You must be logged in to post a comment.