Note that there are some explanatory texts on larger screens.

plurals
  1. POSequenceWaiter doesn't recognize my event
    primarykey
    data
    text
    <p>I'm using this <a href="http://blog.darrenbishop.com/2011/04/darren-on-flex-flexunit4-testing-with_19.html" rel="nofollow">AsyncHelper</a>. I would like to create basic test case where I would like to dispatch event from the test method (by Parsley MessageDispatcher), catch this event in any other method and dispatch it back (by flex EventDispatcher).</p> <p>This is my test case: <code> package flexUnitTests { import flash.events.ErrorEvent; import flash.events.Event; import flash.events.EventDispatcher;</p> <pre><code>import flexUnitTests.events.TestEvent; import flexUnitTests.helpers.AsyncHelper; import mx.logging.Log; import mx.logging.LogEventLevel; import mx.logging.targets.TraceTarget; import org.flexunit.assertThat; import org.hamcrest.object.equalTo; import org.spicefactory.parsley.core.context.Context; import org.spicefactory.parsley.core.messaging.MessageProcessor; import org.spicefactory.parsley.dsl.context.ContextBuilder; import org.spicefactory.parsley.flex.FlexConfig; import org.spicefactory.parsley.flex.FlexContextBuilder; public class HelloTest extends AsyncHelper { [MessageDispatcher] public var dispatcher:Function; [Inject] public var context:Context; public var eventDispatcher:EventDispatcher; [Before] public function initializeContext():void { // Use ContextBuilder to build context var context:Context = ContextBuilder.newSetup() .newBuilder() .config(FlexConfig.forClass(ParsleyConfig)) .build(); // Add this test case to context context.addDynamicObject(this); eventDispatcher = new EventDispatcher(); } [After] public function destroyContext():void { eventDispatcher = null; } [MessageHandler(selector='TestEvent.ok')] public function passItOn(event:TestEvent):void { eventDispatcher.dispatchEvent(event); } [Test(async)] public function tryIt():void { dispatcher(new TestEvent(TestEvent.OK)); waitFor(eventDispatcher, TestEvent.OK, 2000); thenAssert(function(event:TestEvent, data:*):void { assertThat(event.type, equalTo('TestEvent.ok')); }); } } </code></pre> <p>} </code></p> <p>And my Event looks like this: <code> package flexUnitTests.events { import flash.events.Event;</p> <pre><code>public class TestEvent extends Event { static public const OK :String = "TestEvent.ok"; public function TestEvent(type:String) { super(type); } } </code></pre> <p>} </code></p> <p>I don't know where is a problem. If I made traces at code, I can see that Parsley dispatch my event into passItOn method. And flex EventDispatcher dispatch event back. But I don't know why SequenceWaiter doesn't recognize my event.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload