Thank you very much guys.

I think We will be applying something similar to Lawrence’s approach for the moment as a workaround.

However, we are looking forward to seeing Matt’s implementation with FlexUnit under Flex 1.5.

 

Matt,

 

If you don’t mind, would you be able to give some information about your design?

 

 

Regards

 

 

 

Message: 11       

   Date: Fri, 11 Feb 2005 09:04:33 +0100

   From: "Dirk Eismann" <[EMAIL PROTECTED]>

Subject: RE: Asynchrony problem?

 

Hi Cumhur,

 

indees the problem is Flash Player's single threaded engine. If you setup a for or while loop after calling a remote method, the player "blocks" and is not able to process responses that comes in from the remote method.

 

To process the result of a async method invokation, you'll have to use the result/fault events of your service tag, i.e.

 

  public function testEndToEnd() {

    _root.logonWindow.username.text = "tcfeu";

    _root.logonWindow.password.text = "1";

    EventBroadcaster.getInstance().broadcastEvent("SomeCommand");

  }

 

after the event has been broadcasted and SomeCommand executed, some time later the defined onResult event handler will be invoked with the service results (if SomeCommand implements Responder then SomeCommand.onResult() will be invoked). If an error occured, the onFault method will be called.

 

Hope that helps,

Dirk.

 

 

Message: 1        

   Date: Fri, 11 Feb 2005 15:57:08 -0000

   From: "lm7e" <[EMAIL PROTECTED]>

Subject: Re: Asynchrony problem?

 

 

Cumhur,

 

I ran into this as well this week. After some tinkering, I came upon

a solution. I extendedthe FlexUnit TestCase class to make an

AsyncTestCase class from which my own test cases that make

asynchronous calls can inherit. In my case, I was testing my

services like this:

 

public function testSomeServiceOperation() {

var service : Object = Services.getInstance

().getService("someService");

var pendingCall = service.someOperation();

pendingCall.resultHandler = Delegate.create(this,

CheckResult);

pendingCall.faultHandler = Delegate.create(this,

ServiceFailed);

}

 

public function CheckResult(result : Object) {

            ...

            asyncAddFailure("", "The test failed.");

            ...

}

 

public function ServiceFailed(result : Object) {

            asyncAddFailure("", "The service threw a fault.");

}

 

From AsyncTestCase.as:

      public function asyncAddFailure(userMessage : String,

message : String) : Void {

            if (userMessage.length > 0) {

                  userMessage = userMessage + " - ";

            }

     

      mx.core.Application.application.testRunner.runner.treeDataPro

vider.addFailure(this,new Error(userMessage + message));

     

      mx.core.Application.application.testRunner.testsTree.dispatch

Event({type:"change"});

      }

 

Note that I gave my TestRunner the id of 'testRunner'.

 

This is probably not the best solution and I would love to see a

more elegant one. So if anyone has solved this more elegantly, I

would be interested aswell. Perhaps there can be a tighter

integration between Cairngorm and FlexUnit.

 

Hope this helps (for what it is),

Lawrence

 

 

Message: 8        

   Date: Fri, 11 Feb 2005 10:05:11 -0800

   From: Matt Chotin <[EMAIL PROTECTED]>

Subject: RE: Re: Asynchrony problem?

 

I have been working onthis problem for the last day or two since we need asynchronous support for our own testing.  Unfortunately I'm working on code that works with the next version of Flex and I therefore can't contribute it back quite yet.  If I have time in the next week or so I'll try to port it back into a version that will work with 1.5 and send it to Ali for his approval.  As you can imagine it really changes a lot of the underlying FlexUnit system to prevent the next test from running while waiting for an asynchronous result so it'snot a quick fix :-(

 

Matt

 

Message: 12       

   Date: Fri, 11 Feb 2005 18:38:32 -0000

   From: "lm7e" <[EMAIL PROTECTED]>

Subject: Re: Asynchrony problem?

 

 

Thanks, Matt! It's nice to know we weren't overlooking something

obvious. I will be anxiously awaiting your solution :)

 

Lawrence

 

 

Cumhur Guzel

Senior Programmer - Development

Infomedia Ltd.

Electronic Catalogues Division

Phone:   +61 (0) 2 9454 1500

Direct:    +61 (0) 2 9454 1709

Fax:       +61 (0) 2 9454 1888

Mobile:  +61  (0) 401 683 402

 

* This email transmission and any attachments may contain privileged and confidential information. If you are not the intended recipient you are not authorised to, read, distribute or reproduce any part of this transmission (including any attachments) without the prior written consent of the sender. If you have received this email in error, please notify the sender by email immediately.

* Opinions expressed in this email and any attachment are those of the senderand not necessarily the opinions of Infomedia.

* Please scan this email and any attachment for viruses. Infomedia takes all reasonable precautions to ensure no viruses are present in this email or accompanying attachments, but does not under any circumstance accept any responsibility for loss or damage caused by viruses.

 

Reply via email to