Question
problems with wrong listeners called with async tests
I have the following test which does two async tests (this is over a socket connection):
-------------
public function testConnection():void
{
gs.addEventListener(IOErrorEvent.IO_ERROR,
addAsync(onConnectError, 1000));
gs.addEventListener(GErrorEvent.REGISTRATION_ERROR,
addAsync(onConnectRegisterError, 1000));
gs.connect();
}
private function onConnectError(e:IOErrorEvent):void
{
fail("Connection to Growl failed : " + e.text);
}
private function onConnectRegisterError(e:GErrorEvent):void
{
fail("Registration failed : " + "[" + e.code + "] " + e.message);
}
--------------
However, when I run this, i get the following error:
--
Error #1034: Type Coercion failed: cannot convert flash.events::IOErrorEvent@1c3f5e41 to com.adobe.growl.events.GrowlErrorEvent.
--
Digging down on this, it looks like FlexUnit is getting confused and somehow calling the wrong listener for the wrong event.
i.e.
it is calling
onConnectRegisterError(e:GErrorEvent) for the IOErrorEvent.IO_ERROR event
I can confirm this, because If I change to signature of onConnectRegisterError to take an IOErrorEvent
onConnectRegisterError(e:IOErrorEvent):void
the error does not occur.
Has anyone run into anything like this? or had problems with multiple async events in one test?
mike
-------------
public function testConnection():void
{
gs.addEventListener(IOErrorEvent.IO_ERROR,
addAsync(onConnectError, 1000));
gs.addEventListener(GErrorEvent.REGISTRATION_ERROR,
addAsync(onConnectRegisterError, 1000));
gs.connect();
}
private function onConnectError(e:IOErrorEvent):void
{
fail("Connection to Growl failed : " + e.text);
}
private function onConnectRegisterError(e:GErrorEvent):void
{
fail("Registration failed : " + "[" + e.code + "] " + e.message);
}
--------------
However, when I run this, i get the following error:
--
Error #1034: Type Coercion failed: cannot convert flash.events::IOErrorEvent@1c3f5e41 to com.adobe.growl.events.GrowlErrorEvent.
--
Digging down on this, it looks like FlexUnit is getting confused and somehow calling the wrong listener for the wrong event.
i.e.
it is calling
onConnectRegisterError(e:GErrorEvent) for the IOErrorEvent.IO_ERROR event
I can confirm this, because If I change to signature of onConnectRegisterError to take an IOErrorEvent
onConnectRegisterError(e:IOErrorEvent):void
the error does not occur.
Has anyone run into anything like this? or had problems with multiple async events in one test?
mike
