|
From: <luk...@us...> - 2006-10-05 20:23:30
|
Revision: 121
http://svn.sourceforge.net/asunit/?rev=121&view=rev
Author: lukebayes
Date: 2006-10-05 13:17:40 -0700 (Thu, 05 Oct 2006)
Log Message:
-----------
updated example
Modified Paths:
--------------
trunk/framework/as3/asunit/framework/TestCaseExample.as
Modified: trunk/framework/as3/asunit/framework/TestCaseExample.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCaseExample.as 2006-10-05 19:07:54 UTC (rev 120)
+++ trunk/framework/as3/asunit/framework/TestCaseExample.as 2006-10-05 20:17:40 UTC (rev 121)
@@ -20,17 +20,17 @@
}
// This method will be called before every test method
- protected override function setUp():void {
+ override protected function setUp():void {
date = new Date();
// sprite = new Sprite();
// addChild(sprite);
}
-
+
// This method will be called after every test method
// but only if we're executing the entire TestCase,
- // the tearDown method won't be called if we're
+ // the tearDown method won't be called if we're
// calling start(MyTestCase, "someMethod");
- protected override function tearDown():void {
+ override protected function tearDown():void {
// removeChild(sprite);
// sprite = null;
date = null;
@@ -48,29 +48,26 @@
date.month = 1;
assertEquals(1, date.month);
}
-
- // This is an asynchronous test method
- public function testAsyncFeature():void {
- // create a new object that dispatches events...
- var dispatcher:IEventDispatcher = new EventDispatcher();
- // get a TestCase async event handler reference
- var handler:Function = addAsync(changeHandler);
- // subscribe to your event dispatcher using the returned handler
- dispatcher.addEventListener(Event.CHANGE, handler);
- // cause the event to be dispatched.
-// dispatcher.dispatchEvent(new Event(Event.CHANGE));
- setTimeout(dispatcher.dispatchEvent, 200, new Event(Event.CHANGE));
- }
-
- protected function changeHandler(event:Event):void {
- assertEquals(Event.CHANGE, event.type);
- }
-
- public function testAsyncFeatureTimeout():void {
- var dispatcher:IEventDispatcher = new EventDispatcher();
- var handler:Function = addAsync(changeHandler, 100);
- dispatcher.addEventListener(Event.CHANGE, handler);
- dispatcher.dispatchEvent(new Event(Event.CHANGE));
- }
- }
+
+ // This is an asynchronous test method
+ public function testAsyncFeature():void {
+ // create a new object that dispatches events...
+ var dispatcher:IEventDispatcher = new EventDispatcher();
+ // get a TestCase async event handler reference
+ // the 2nd arg is an optional timeout in ms. (default=1000ms )
+ var handler:Function = addAsync(changeHandler, 2000);
+ // subscribe to your event dispatcher using the returned handler
+ dispatcher.addEventListener(Event.CHANGE, handler);
+ // cause the event to be dispatched.
+ // either immediately:
+ //dispatcher.dispatchEvent(new Event(Event.CHANGE));
+ // or in the future < your assigned timeout
+ setTimeout( dispatcher.dispatchEvent, 200, new Event(Event.CHANGE));
+ }
+
+ protected function changeHandler(event:Event):void {
+ // perform assertions in your handler
+ assertEquals(Event.CHANGE, event.type);
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|