Flexunit von Griff Kundenveranstaltung und Async.asyncHandler ()
-
28-09-2019 - |
Frage
Jeder weiß, wie
Lösung HelloCompo.as Async.asyncHandler()
funktioniert und wenn Async.processOnEvent()
nur in verwendet wird, kann [Vor] Verfahren. (Jeder weiß, ein paar hilfreiches Dokument neben
package flexUnitTests
{
import flash.events.Event;
import org.flexunit.asserts.assertTrue;
import org.flexunit.asserts.fail;
import org.flexunit.async.Async;
public class HelloTest
{
private var helloCompo:HelloCompo;
[Before]
public function setUp():void
{
helloCompo = new HelloCompo();
}
[After]
public function tearDown():void
{
helloCompo = null;
}
[Test(async)]
public function testHello():void
{
var handler:Function = Async.asyncHandler(this, helloHandler, 300, null, helloFailed);
helloCompo.addEventListener("hello", handler);
helloCompo.hello();
}
private function helloHandler(event:Event, passThroughObject:Object):void
{
//assert somthing
}
private function helloFailed(event:Event, passThroughObject:Object):void
{
fail("hello not dispatched");
}
}
}
package
{
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.IEventDispatcher;
public class HelloCompo extends EventDispatcher
{
public function HelloCompo(target:IEventDispatcher=null)
{
super(target);
}
public function hello():void
{
dispatchEvent(new Event("hello"));
}
}
}
Andere Tipps
Ich glaube, Sie brauchen Ihre Event-Listener hinzufügen, bevor hallo () aufrufen eigentlich