0 Replies Latest reply on Mar 3, 2011 10:36 PM by s@jiv

    How to dispatch the result from test cases to the function that loads

    s@jiv

      Hi ,

           I am currently working on writing a test case and i ant to execute the test case and the result of the test cases needs to be returned to function that loads the swf file using loader.

       

      Below is the structure

      1) Project A

               Has a action script file that has a loader which inturn loads the swf file.

       

      public function testRunner():void {

                  loader = new Loader();

                  loaderDispatcher = loader.contentLoaderInfo;         

                  sharedEvents = loaderDispatcher.sharedEvents;

                  parentURL = loaderDispatcher.loaderURL;

                  parentDomain = URLUtil.getServerNameWithPort(parentURL);

                  parentScheme = URLUtil.getProtocol(parentURL);

                  load("http://localhost:8000/abc.swf");

          var callback:Function = addAsync(onMessage, 30000, {}, handleTimeout);

          sharedEvents.addEventListener("message", callback);

          /*Listener added to receive message event*/

          sharedEvents.addEventListener(MessageEvent.MESSAGE, onMessageEvent);

      }

       

              private function load(location:String):void {

                  // create SWF loader

                  loaderDispatcher.addEventListener(Event.OPEN, onOpenEvent);

                  loaderDispatcher.addEventListener(Event.INIT, onINIT);

                  loaderDispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, onStatus);

                  loaderDispatcher.addEventListener(Event.COMPLETE, onComplete);

                  loaderDispatcher.addEventListener(IOErrorEvent.IO_ERROR, onError);

                  loaderDispatcher.addEventListener(Event.UNLOAD, onUnload);

                  loaderDispatcher.addEventListener(Event.CLOSE, onClose);

                  var request:URLRequest = new URLRequest(location);

          //request.idleTimeout = 8000;

          try{

      loader.load(request);

      _subMovie.addChild(loader);

             }

             catch (error:Error)

                     {

                       trace("Unable to load URL: " + error);

                     }

                  // listen for DISPATCH events

                  sharedEvents = loader.contentLoaderInfo.sharedEvents;

          sharedEvents.addEventListener(DISPATCH_EVENT_TYPE, handleDispatch);

              }

       

       

      2) Project B

            Project B has the test cases written and teh swf file for this project is abc.swf.

       

      test.mxml

       

      public function go():void {

      var core:FlexUnitCore = new FlexUnitCore();

      core.addListener(new TestCaseListener());

      core.run(ABCTest);

      var messageEvent:MessageEvent = new MessageEvent("message","action test","action testing");

      //loaderInfo.sharedEvents.dispatchEvent(messageEvent);

      }

       

       

      When I load abc.swf file this inturn call the mxml file which runs the testcases by using the FlexUnitCore .

       

       

      What I am looking for is dispatching the result that is available in TestcaseListener to the call of loader ie; in Project A

       

       

      public class TestCaseListener extends RunListener  {

      public override function testRunFinished(result:Result):void {

      trace("testRunFinished invoked 1 ::");

      trace("failureCount::"+result.failureCount);

      trace("failures::"+result.failures);

      trace("successful::"+result.successful);

      }

       

       

       

      Is there any way in which i can dispatch the result from testcaselistener to the call where this swf file is loaded .