| Package | org.flexunit.internals.runners.statements |
| Class | public class ExpectAsync |
| Inheritance | ExpectAsync AsyncStatementBase Object |
| Implements | IAsyncStatement, IAsyncHandlingStatement |
ExpectAsync is a decorator that is responsible for determing
whether a specific test method is expecting an asynchronous response. As this
infrastructure carries overhead, we only create it when the user specifics a
given test is asynchronous. The class implements IAsyncHandlingStatement
and works with the Async class.
In order to expect an asynchronous response, a test method must include metadata indicating
it is expecting asynchronous functionality.
[Test(async)]
public function asyncTest():void {
//Test with asynchronous functionality
}
See also
| Property | Defined By | ||
|---|---|---|---|
| bodyExecuting : Boolean [read-only]
Returns a Boolean value indicating whether the test method is current executing. | ExpectAsync | ||
| hasPendingAsync : Boolean [read-only]
Returns a Boolean value indicating whether there are still any pending asynchronous calls. | ExpectAsync | ||
| Method | Defined By | ||
|---|---|---|---|
ExpectAsync(objectUnderTest:Object, statement:IAsyncStatement)
Constructor. | ExpectAsync | ||
asyncErrorConditionHandler(eventHandler:Function):Function | ExpectAsync | ||
asyncHandler(eventHandler:Function, timeout:int, passThroughData:Object = null, timeoutHandler:Function = null):Function
Creates an AsyncHandler that pend and either call the eventHandler or the
timeoutHandler, passing the passThroughData, depending on whether the
timeout period has been reached. | ExpectAsync | ||
asyncNativeResponder(resultHandler:Function, faultHandler:Function, timeout:int, passThroughData:Object = null, timeoutHandler:Function = null):Responder
Creates an IAsyncTestResponder that pend and either call the eventHandler or the
timeoutHandler, passing the passThroughData, depending on whether the
timeout period has been reached. | ExpectAsync | ||
asyncResponder(responder:*, timeout:int, passThroughData:Object = null, timeoutHandler:Function = null):IResponder
Creates an IAsyncTestResponder that pend and either call the eventHandler or the
timeoutHandler, passing the passThroughData, depending on whether the
timeout period has been reached. | ExpectAsync | ||
evaluate(parentToken:AsyncTestToken):void
Registers the ExpectAsync statment for the current object being tested and evaluates the object that
implements the IAsyncStatement that was provided to the ExpectAsync class. | ExpectAsync | ||
failOnComplete(event:Event, passThroughData:Object):void
A handler method that is called in order to fail for a given asynchronous event once an it
has been dispatched. | ExpectAsync | ||
handleBindableNextSequence(event:Event, sequenceRunner:SequenceRunner):void | ExpectAsync | ||
handleNextExecuteComplete(result:ChildResult):void
Determines if there are any more pending asynchronous calls; if there are, keep running the calls if there are
no errors. | ExpectAsync | ||
handleNextSequence(event:Event, sequenceRunner:SequenceRunner):void
Handles the next steps in a SequenceRunner. | ExpectAsync | ||
hasAsync(method:FrameworkMethod, type:String):Boolean [static]
Determine if the method is asynchronous for a test method that is of the expected
metadata type. | ExpectAsync | ||
pendUntilComplete(event:Event, passThroughData:Object = null):void
A handler method that is called in order to wait once an asynchronous event has been dispatched. | ExpectAsync | ||
| Method | Defined By | ||
|---|---|---|---|
handleAsyncNativeTestResponderEvent(event:AsyncResponseEvent, passThroughData:Object = null):void
Handles the AsyncResponseEvent that is thrown by the asyncResponder. | ExpectAsync | ||
handleAsyncTestResponderEvent(event:AsyncResponseEvent, passThroughData:Object = null):void
Handles the AsyncResponseEvent that is thrown by the asyncResponder. | ExpectAsync | ||
protect(method:Function, ... rest):void
Attempts to call the provided method with the provided rest parameters. | ExpectAsync | ||
sendComplete(error:Error = null):void [override]
If the test has not yet been marked as complete, mark the ExpectAsync statement as having finished
and notify the parent token. | ExpectAsync | ||
| bodyExecuting | property |
bodyExecuting:Boolean [read-only] Returns a Boolean value indicating whether the test method is current executing.
public function get bodyExecuting():Boolean| hasPendingAsync | property |
hasPendingAsync:Boolean [read-only] Returns a Boolean value indicating whether there are still any pending asynchronous calls.
public function get hasPendingAsync():Boolean| ExpectAsync | () | Constructor |
public function ExpectAsync(objectUnderTest:Object, statement:IAsyncStatement)Constructor.
ParametersobjectUnderTest:Object — The current object that is being tested.
| |
statement:IAsyncStatement — The current IAsyncStatement that will be decorated with the
the ExpectAsync class.
|
| asyncErrorConditionHandler | () | method |
public function asyncErrorConditionHandler(eventHandler:Function):Function
Parameters
eventHandler:Function |
Function —
|
Error — Test Completed, but additional async event added
|
| asyncHandler | () | method |
public function asyncHandler(eventHandler:Function, timeout:int, passThroughData:Object = null, timeoutHandler:Function = null):Function
Creates an AsyncHandler that pend and either call the eventHandler or the
timeoutHandler, passing the passThroughData, depending on whether the
timeout period has been reached.
Parameters
eventHandler:Function — The Function that will be executed if the handler is called before
the timeout has expired.
| |
timeout:int — The length of time, in milliseconds, before the timeoutHandler will be executed.
| |
passThroughData:Object (default = null) — An Object that can be given information about the current test; this information will
be available for both the eventHandler and the timeoutHandler.
| |
timeoutHandler:Function (default = null) — The Function that will be executed if the timeout time is reached prior to
the expected event being dispatched.
|
Function — an event handler Function that will determine whether the timeout has been reached.
|
| asyncNativeResponder | () | method |
public function asyncNativeResponder(resultHandler:Function, faultHandler:Function, timeout:int, passThroughData:Object = null, timeoutHandler:Function = null):Responder
Creates an IAsyncTestResponder that pend and either call the eventHandler or the
timeoutHandler, passing the passThroughData, depending on whether the
timeout period has been reached.
Parameters
resultHandler:Function — The result Function that will be executed if the Responder is called on its result before
the timeout has expired.
| |
faultHandler:Function — The fault Function that will be executed if the Responder is called on its fault before
the timeout has expired.
| |
timeout:int — The length of time, in milliseconds, before the timeoutHandler will be executed.
| |
passThroughData:Object (default = null) — An Object that can be given information about the current test; this information will
be available for both the eventHandler and the timeoutHandler.
| |
timeoutHandler:Function (default = null) — The Function that will be executed if the timeout time is reached prior to
the expected event being dispatched.
|
Responder — an IResponder that will determine whether the timeout has been reached.
|
| asyncResponder | () | method |
public function asyncResponder(responder:*, timeout:int, passThroughData:Object = null, timeoutHandler:Function = null):IResponder
Creates an IAsyncTestResponder that pend and either call the eventHandler or the
timeoutHandler, passing the passThroughData, depending on whether the
timeout period has been reached.
Parameters
responder:* — The responder that will be executed if the IResponder is called before
the timeout has expired.
| |
timeout:int — The length of time, in milliseconds, before the timeoutHandler will be executed.
| |
passThroughData:Object (default = null) — An Object that can be given information about the current test; this information will
be available for both the eventHandler and the timeoutHandler.
| |
timeoutHandler:Function (default = null) — The Function that will be executed if the timeout time is reached prior to
the expected event being dispatched.
|
IResponder — an IResponder that will determine whether the timeout has been reached.
|
| evaluate | () | method |
public function evaluate(parentToken:AsyncTestToken):void
Registers the ExpectAsync statment for the current object being tested and evaluates the object that
implements the IAsyncStatement that was provided to the ExpectAsync class.
Parameters
parentToken:AsyncTestToken — The token to be notified when the potential asynchronous call have finished.
|
| failOnComplete | () | method |
public function failOnComplete(event:Event, passThroughData:Object):voidA handler method that is called in order to fail for a given asynchronous event once an it has been dispatched.
Parameters
event:Event — The event that was received.
| |
passThroughData:Object — An Object that contains information to pass to the handler.
|
| handleAsyncNativeTestResponderEvent | () | method |
protected function handleAsyncNativeTestResponderEvent(event:AsyncResponseEvent, passThroughData:Object = null):voidHandles the AsyncResponseEvent that is thrown by the asyncResponder. It sends data to the original responder based on if it is a result or fault status.
Parameters
event:AsyncResponseEvent | |
passThroughData:Object (default = null) |
| handleAsyncTestResponderEvent | () | method |
protected function handleAsyncTestResponderEvent(event:AsyncResponseEvent, passThroughData:Object = null):voidHandles the AsyncResponseEvent that is thrown by the asyncResponder. It sends data to the original responder based on if it is a result or fault status. If the original responder is of type ITestResponder, then the passThroughData is passed to it.
Parameters
event:AsyncResponseEvent | |
passThroughData:Object (default = null) |
| handleBindableNextSequence | () | method |
public function handleBindableNextSequence(event:Event, sequenceRunner:SequenceRunner):void
Parameters
event:Event | |
sequenceRunner:SequenceRunner |
| handleNextExecuteComplete | () | method |
public function handleNextExecuteComplete(result:ChildResult):void
Determines if there are any more pending asynchronous calls; if there are, keep running the calls if there are
no errors. If all calls have finished or an error was encountered in the result, report the error
to the parent token and stop tracking the asynchronous events.
Parameters
result:ChildResult — The ChildResult to check to see if there is an error.
|
| handleNextSequence | () | method |
public function handleNextSequence(event:Event, sequenceRunner:SequenceRunner):void
Handles the next steps in a SequenceRunner.
Parameters
event:Event — The event boradcast by the last step in the sequence.
| |
sequenceRunner:SequenceRunner — The runner responsible for running the steps in the sequence.
|
| hasAsync | () | method |
public static function hasAsync(method:FrameworkMethod, type:String):Boolean
Determine if the method is asynchronous for a test method that is of the expected
metadata type.
Parameters
method:FrameworkMethod — The FrameworkMethod that is potentially asynchronous.
| |
type:String (default = NaN) — The expected metadata type of the test method (ex: "Test", "Before", "After").
|
Boolean — a Boolean value indicating whether the provided method is asynchronous.
|
| pendUntilComplete | () | method |
public function pendUntilComplete(event:Event, passThroughData:Object = null):voidA handler method that is called in order to wait once an asynchronous event has been dispatched.
Parameters
event:Event — The event that was received.
| |
passThroughData:Object (default = null) — An Object that contains information to pass to the handler.
|
| protect | () | method |
protected function protect(method:Function, ... rest):void
Attempts to call the provided method with the provided rest parameters.
Parameters
method:Function — The Function to call with the provided rest parameters.
| |
... rest — The parameters supplied to the method.
|
| sendComplete | () | method |
override protected function sendComplete(error:Error = null):void
If the test has not yet been marked as complete, mark the ExpectAsync statement as having finished
and notify the parent token.
Parameters
error:Error (default = null) — The potential error to send to the parent token.
|