Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Async test support for as3-signals
ActionScript
tree: cbf2d6d83d

Merge pull request #5 from chriswaugh/master

Updated to signals 0.9 BETA
latest commit cbf2d6d83d
eidiot authored
Failed to load latest commit information.
libs
src/org/osflash/signals/utils Added a pom for building with maven. Moved all instances of Signal to…
tests
.gitignore
MIT-LICENSE.txt Add MIT license file
README.textile Add .textile to README
build.properties Updated to signals 0.9 BETA
build.xml
pom.xml

README.textile

Utility classes for unit test signals.

This library is a utility for Robert Penner ’s as3-signals with some delegate methods to test them with FlexUnit4:

  • proceedOnSignal
  • handleSignal
  • failOnSignal
  • registerFailureSignal

proceedOnSignal

Use this method to ensure that some signal is dispatched during an asynchronous test.

[Test(async)]
public function test_proceedOnSignal():void 
{
    var model:IModel = new SomeModel();
    proceedOnSignal(this, model.changedSignal);
    model.doSomethingChange();
}

handleSignal

Use this method to ensure that some signal is dispatched and do more assertions in the handler. The handler method must have two arguments. The first one is a SignalAsyncEvent, you can get all arguments passed by the signal’s dispatch() method by event.args. The second Object typed argument is the data passed by the passThroughData argument in the handleSignal method.

[Test(async)] 
public function change_user():void 
{
    var model:IModel = new SomeModel();
    handleSignal(this, model.changedSignal, verify_user, 500, {name:"Tom", age:20});
    model.changeUser("Tom", 20);
}
private function verify_user(event:SignalAsyncEvent, data:Object):void 
{
    assertEquals(event.args[ 0 ], data.name);
    assertEquals(event.args[ 1 ], data.age);
}

failOnSignal

Use this method to ensure that some signal is not dispatched during an asynchronous test in a time period.

[Test(async)] 
public function not_changed():void 
{
    var model:IModel = new SomeModel();
    failOnSignal(model.changedSignal);
    model.doSomethingNotChange();
}

registerFailureSignal

Use this method to fail a test when a signal is dispatched. Think you are waiting for a success signal of a service, you will want to fail the test when the service’s error signal is dispatched instead of waiting until timeout.

[Test(async)] 
public function call_service():void 
{
    var service:IService = new SomeService();
    registerFailureSignal(this, service.failedSignal);
    proceedOnSignal(this, service.successSignal);
    service.call();
}
Something went wrong with that request. Please try again.