Skip to content

Commit

Permalink
merging changes from destroytoday
Browse files Browse the repository at this point in the history
  • Loading branch information
Simeon Bateman committed Mar 1, 2011
2 parents b669c13 + 176f243 commit 30b2718
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 6 deletions.
31 changes: 27 additions & 4 deletions FlexUnit4/src/org/flexunit/async/Async.as
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
package org.flexunit.async
{
import flash.events.IEventDispatcher;
import flash.events.TimerEvent;
import flash.net.Responder;

import mx.rpc.IResponder;
import flash.utils.Timer;

import org.flexunit.internals.runners.statements.IAsyncHandlingStatement;

Expand Down Expand Up @@ -188,13 +188,15 @@ package org.flexunit.async
* available to both the responder and the <code>timeoutHandler</code>.
* @param timeoutHandler: The function that will be executed if the <code>timeout</code> period is reached.
*/
CONFIG::useFlexClasses
CONFIG::useFlexClasses {
import mx.rpc.IResponder;

public static function asyncResponder( testCase:Object, responder:*, timeout:int, passThroughData:Object = null, timeoutHandler:Function = null ):IResponder {
var asyncHandlingStatement:IAsyncHandlingStatement = AsyncLocator.getCallableForTest( testCase );

return asyncHandlingStatement.asyncResponder( responder, timeout, passThroughData, timeoutHandler );
}

}
/**
* This method works in a similar fashion to handleEvent, however, it is intended to work with AsyncTokens and Responders as opposed to events.
*
Expand All @@ -212,5 +214,26 @@ package org.flexunit.async

return asyncHandlingStatement.asyncNativeResponder( resultHandler, faultHandler, timeout, passThroughData, timeoutHandler );
}

/**
* Calls a method after a given delay.
* @param testCase The current asynchronous test case.
* @param callback The function that will be executed if the <code>delay</delay> has been reached.
* @param delay The length of time, in milliseconds, before calling the <code>callback</code>.
*/
public static function delayCall(testCase:Object, callback:Function, delay:Number):void
{
var asyncHandlingStatement:IAsyncHandlingStatement = AsyncLocator.getCallableForTest( testCase );
var timer:Timer = new Timer(delay, 1);
var handler:Function;

handler = asyncHandlingStatement.asyncHandler( function(event:TimerEvent, object:Object):void
{
callback();
}, delay + 100.0);

timer.addEventListener( TimerEvent.TIMER_COMPLETE, handler, false, 0, true );
timer.start();
}
}
}
6 changes: 5 additions & 1 deletion FlexUnit4Test/.actionScriptProperties
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<<<<<<< HEAD
<actionScriptProperties analytics="false" mainApplicationPath="UIRunner.mxml" projectUUID="c0791c78-cb1b-4837-9e08-e5a4373e5714" version="6">
=======
<actionScriptProperties analytics="false" mainApplicationPath="UIRunner.mxml" projectUUID="c0791c78-cb1b-4837-9e08-e5a4373e5714" version="7">
>>>>>>> 176f2432292cb449acd4d71c51e40eb77d757fff
<compiler additionalCompilerArguments="-locale en_US -define=CONFIG::useFlexClasses,true" autoRSLOrdering="false" copyDependentFiles="true" fteInMXComponents="false" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="true" htmlHistoryManagement="true" htmlPlayerVersionCheck="true" includeNetmonSwc="false" outputFolderPath="bin-debug" sourceFolderPath="src" strict="true" targetPlayerVersion="0.0.0" useApolloConfig="false" useDebugRSLSwfs="true" verifyDigests="true" warn="true">
<compilerSourcePath/>
<libraryPath defaultLinkType="1">
<libraryPathEntry kind="4" path=""/>
<libraryPathEntry kind="1" linkType="1" path="libs"/>
<libraryPathEntry kind="3" linkType="1" path="/FlexUnit4/bin/FlexUnit4.swc" useDefaultLinkType="false"/>
<libraryPathEntry kind="3" linkType="1" path="/FlexUnit4CIListener/bin/FlexUnit4CIListener.swc" useDefaultLinkType="false"/>
<libraryPathEntry kind="3" linkType="1" path="/FlexUnit4UIListener/bin/FlexUnit4UIListener.swc" useDefaultLinkType="false"/>
<libraryPathEntry kind="3" linkType="1" path="/FlexUnit4FluintExtensions/bin/FlexUnit4FluintExtensions.swc" useDefaultLinkType="false"/>
</libraryPath>
Expand All @@ -18,4 +21,5 @@
</applications>
<modules/>
<buildCSSFiles/>
<flashCatalyst validateFlashCatalystCompatibility="false"/>
</actionScriptProperties>
7 changes: 7 additions & 0 deletions FlexUnit4Test/src/org/flexunit/async/cases/AsyncASCase.as
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,12 @@ package org.flexunit.async.cases
//Verify expectations were met
asyncHandlingStatementMock.mock.verify();
}

// In all honesty, I'm not sure how I should test this...
[Ignore]
[Test(description="Ensure the delayCall function is correctly called")]
public function delayCallTest():void {

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ package org.flexunit.async.cases

//Set expectations
asyncHandlingStatementMock.mock.method("asyncResponder").withArgs(responder, timeout, passThroughData, timeoutHandler).once.returns(responderMock);

Async.asyncResponder(testCase, responder, timeout, passThroughData, timeoutHandler);

//Verify expectations were met
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ package org.flexunit.runner.notification.cases

//TODO: There needs to be a second tests created for when Capabilities.isDebugger returns a value of false, how would this
//be properly implemented
[Ignore]
[Test(description="Ensure that the statck trace value is correctly obtained when the system is a debugging version")]
public function getStackTraceDebuggerTest():void {
Assert.assertEquals(exception.getStackTrace(), failure.stackTrace);
Expand Down

0 comments on commit 30b2718

Please sign in to comment.