Skip to main content
nikos101
Inspiring
Mar 16, 2011 5:07 PM UTC
Answered

Timeout Occurred before expected event for simple SequenceRunner

I'm having trouble with these tests. I'm always getting Timeout Occurred for my sequence in the test testOnLogout.

Any ideas?

Timeout Occurred before expected eventTimeout Occurred before expected event
Error: Timeout Occurred before expected event
    at org.flexunit.internals.runners.statements::ExpectAsync/handleAsyncTimeOut()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at org.flexunit.async::AsyncHandler/handleTimeout()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()

      package tests.view
{
   
   
    import flexunit.framework.Assert;
   
    import mx.events.FlexEvent;


    import org.flexunit.async.Async;
import org.fluint.sequence.SequenceRunner;
import org.fluint.sequence.SequenceSetter;
    import org.fluint.sequence.SequenceWaiter;
    import org.fluint.uiImpersonation.UIImpersonator;
   
    import views.LoginForm;
   
    public class TestLoginForm
    {       
       
        private var view:LoginForm;

        [Before(async,ui)]
        public function setUp() : void
        {
            view = new LoginForm;
            Async.proceedOnEvent( this, view, FlexEvent.CREATION_COMPLETE, 600 );
            UIImpersonator.addChild( view );
        }
       
       
        [After(async,ui)]
        public function tearDown():void
        {
            UIImpersonator.removeChild( view );           
            view = null;
        }

       
        [Test(async, ui)]
        public function testOnLogout():void {
            var passThroughData:Object = new Object();
           
            passThroughData.username = 'test';
            passThroughData.password = 'test';
            passThroughData.selectedIndex = 0;

            var sequence:SequenceRunner = new SequenceRunner( this     );
            sequence.addStep( new SequenceSetter( view.username, {text:passThroughData.username} ) );
            sequence.addStep( new SequenceWaiter(view.username, FlexEvent.VALUE_COMMIT, 400 ) );
           
            sequence.addStep( new SequenceSetter( view.password, {text:passThroughData.password} ) );
            sequence.addStep( new SequenceWaiter( view.password, FlexEvent.VALUE_COMMIT, 400 ) );
            sequence.addStep( new SequenceSetter( view.domain, {selectedIndex:passThroughData.selectedIndex} ) );
            sequence.addStep( new SequenceWaiter( view.domain, FlexEvent.VALUE_COMMIT, 400 ) );
           
            view.onLogout();
           
            sequence.addStep( new SequenceWaiter(view.username, FlexEvent.VALUE_COMMIT, 400 ) );
            sequence.addStep( new SequenceWaiter( view.password, FlexEvent.VALUE_COMMIT, 400 ) );
            sequence.addStep( new SequenceWaiter( view.domain, FlexEvent.VALUE_COMMIT, 400 ) );
           
           
           
            sequence.addAssertHandler( handleOnLogout, passThroughData );
           
            sequence.run();
        }

       
        protected function handleOnLogout( passThroughData:Object ):void {
            Assert.assertEquals(
                view.username.text,passThroughData.username,
                view.password.text,passThroughData.password,
                view.domain.selectedIndex,passThroughData.selectedIndex);
        }
       
       
       
    }
}

This topic is closed to new replies. Start a new post to keep the conversation going.
mlabriolaCorrect answer
Participating Frequently
Mar 16, 2011 5:36 PM UTC

So, I am taking a guess here that what you want is the onLogout() call to happen as part of the sequence. But this is not what your code does. Sequences are defined and then run when you call the run() method.

Here you are calling the onLogout method in the middle of defining the sequence.. then sometime later (likely after the logout is done) your sequence begins waiting for things to happen... and times out because nothing is happening.

I think what you want here is to use the SequenceCaller class to actually execute the onLogout as part of the sequence.

Mike

2 replies

mlabriolaCorrect answer
Participating Frequently
Mar 16, 2011 5:36 PM UTC

So, I am taking a guess here that what you want is the onLogout() call to happen as part of the sequence. But this is not what your code does. Sequences are defined and then run when you call the run() method.

Here you are calling the onLogout method in the middle of defining the sequence.. then sometime later (likely after the logout is done) your sequence begins waiting for things to happen... and times out because nothing is happening.

I think what you want here is to use the SequenceCaller class to actually execute the onLogout as part of the sequence.

Mike

Translate
nikos101
nikos101Author
Inspiring
Mar 17, 2011 12:15 PM UTC

thx mike, you mean like this: I'm still getting timeouts

    [Test(async, ui)]
    public function testOnLogout():void {
        var passThroughData:Object = new Object();

        passThroughData.username = 'test';
        passThroughData.password = 'test';
        passThroughData.selectedIndex = 0;

        var sequence:SequenceRunner = new SequenceRunner(this);
        sequence.addStep(new SequenceSetter(view.username, {text:passThroughData.username}));
        sequence.addStep(new SequenceWaiter(view.username, FlexEvent.VALUE_COMMIT, 400));
        sequence.addStep(new SequenceSetter(view.password, {text:passThroughData.password}));
        sequence.addStep(new SequenceWaiter(view.password, FlexEvent.VALUE_COMMIT, 400));
        sequence.addStep(new SequenceSetter(view.domain, {selectedIndex:passThroughData.selectedIndex}));
        sequence.addStep(new SequenceWaiter(view.domain, FlexEvent.VALUE_COMMIT, 400));

        sequence.addStep(new SequenceCaller(view,view.onLogout ));
      
        sequence.addStep(new SequenceWaiter(view.username, FlexEvent.VALUE_COMMIT, 400));
        sequence.addStep(new SequenceWaiter(view.password, FlexEvent.VALUE_COMMIT, 400));
        sequence.addStep(new SequenceWaiter(view.domain, FlexEvent.VALUE_COMMIT, 400));


        sequence.addAssertHandler(handleOnLogout, passThroughData);

        sequence.run();
    }

FYI

    public function onLogout():void
            {
                username.text = '';
                password.text = '';
                domain.selectedIndex = 0;
            }

Translate