我正在通过 Ant 运行 FlexUnit 测试。测试test1失败并显示消息“在预期事件之前发生超时”,但test2通过了。这两个测试之间的唯一区别是一个使用UIImpersonator.addChild()而另一个使用FlexGlobals.topLevelApplication.addElement().
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);
}