为什么 FlexUnit 中的 asyncHandler 无法捕获 TIMERCOMPLETE 事件?
我正在使用 Flex 单元测试计时器事件。以下是我尝试过的代码, 它总是转到 cmdFailed 函数(超时函数)。我是弹性单元的新手。任何帮助将不胜感激。
[前]
public function setUp():void
{
timer = new Timer(12000);
}
[Test(async,order=1)]
public function teststorapidpresenter():void
{
timer.addEventListener(TimerEvent.TIMER_COMPLETE,Async.asyncHandler(this,cmdHandler,20000,null,cmdFailed));
timer.start();
}
private function cmdHandler(event:TimerEvent,passThroughData:Object):void
{
}
private function cmdFailed(event:Event):void
{
fail("Event not dispatched");
}
I am testing timerevent with flex unit. Follwing is the code which i tried ,
it always goes to cmdFailed function (Time out function).I am new to flex unit .any help would be greatly appreciated.
[Before]
public function setUp():void
{
timer = new Timer(12000);
}
[Test(async,order=1)]
public function teststorapidpresenter():void
{
timer.addEventListener(TimerEvent.TIMER_COMPLETE,Async.asyncHandler(this,cmdHandler,20000,null,cmdFailed));
timer.start();
}
private function cmdHandler(event:TimerEvent,passThroughData:Object):void
{
}
private function cmdFailed(event:Event):void
{
fail("Event not dispatched");
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这里是经典错误。
默认情况下,定时器的repeatCount属性为0。
这意味着时间永远不会停止,因此 TIMER_COMPLETE 永远不会被调度。
它应该有效
Yes, classic error here.
By default, repeatCount property of a timer is 0.
That means the time never stops so the TIMER_COMPLETE is never dispatched.
and it should work