我正在通過Ant運行FlexUnit測試。測試test1
失敗,消息「超時發生在預期事件」之前,但test2
通過。兩種測試之間的唯一區別是一個使用UIImpersonator.addChild()
而另一個使用FlexGlobals.topLevelApplication.addElement()
。UIImpersonator.addChild()不派遣正確的事件
test1
失敗,即使我聽"addedToStage"
事件。聽"added"
事件,但是,使test1
通過。
[Test(async, ui, description="Fails")]
public function test1():void
{
var c:UIComponent = new UIComponent;
Async.proceedOnEvent(this, c, FlexEvent.CREATION_COMPLETE);
UIImpersonator.addChild(c);
}
[Test(async, ui, description="Passes")]
public function test2():void
{
var c:UIComponent = new UIComponent;
Async.proceedOnEvent(this, c, FlexEvent.CREATION_COMPLETE);
FlexGlobals.topLevelApplication.addElement(c);
}
什麼是UIImpersonator?它是否擴展了Flex應用程序?或者它是Flex應用程序的孩子?如果不;那麼你的'c'將永遠不會通過它的Flex LifeCycle流程;並且creation_Complete永遠不會被解僱。 – JeffryHouser
http://docs.flexunit.org/index.php?title=UIImpersonator我認爲UIImpersonator可能與新的Flex版本不兼容。 – Ohas
聲音像UIImpersonator應該工作瓦特/組件:http://forums.adobe.com/thread/905337 – JeffryHouser