comparison bindings/as3/ext/asunit/framework/AsynchronousHTTPServiceTestCase.as @ 732:3a0b9700b3d2

* Initial AS3 commit
author mas01mj
date Tue, 14 Sep 2010 16:47:10 +0000
parents
children
comparison
equal deleted inserted replaced
731:65134dd772fc 732:3a0b9700b3d2
1 package asunit.framework {
2 import asunit.errors.AbstractError;
3
4 import flash.errors.IllegalOperationError;
5 import flash.events.*;
6 import flash.net.URLLoader;
7 import flash.utils.getTimer;
8
9 import mx.rpc.AsyncToken;
10 import mx.rpc.Responder;
11 import mx.rpc.events.FaultEvent;
12
13 /**
14 * Extend this class if you have a TestCase that requires the
15 * asynchronous load of external data.
16 */
17 public class AsynchronousHTTPServiceTestCase extends AsynchronousTestCase implements Test {
18
19 public function AsynchronousHTTPServiceTestCase(testMethod:String = null) {
20 super(testMethod);
21 }
22
23 // use this method in overriding run() if you are using an HTTPService:
24 protected function configureResponder(token:AsyncToken):void {
25 token.addResponder(new Responder(resultFunc, faultFunc));
26 }
27
28 protected function resultFunc(event:Object):void {
29 completeHandler(event as Event);
30 }
31
32 protected function faultFunc(event:Object):void {
33 var faultEvent:FaultEvent = event as FaultEvent;
34 if (faultEvent == null) {
35 return;
36 }
37 var cause:Object = faultEvent.fault.rootCause;
38 var ioErrorEvent:IOErrorEvent = cause as IOErrorEvent;
39 if (ioErrorEvent) {
40 ioErrorHandler(ioErrorEvent);
41 return;
42 }
43 var securityErrorEvent:SecurityErrorEvent = cause as SecurityErrorEvent;
44 if (securityErrorEvent) {
45 securityErrorHandler(securityErrorEvent);
46 }
47 }
48
49 }
50
51 }