• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

proceedOnEvent() timeout waiting for creationComplete

New Here ,
Feb 15, 2012 Feb 15, 2012

Copy link to clipboard

Copied

Hello,

I have a test case that will not run due to proceedOnEvent not seeing the desired event.  Here's the test code:

package com.mine.components.buttonBar

{

          import flexunit.framework.Assert;

 

          import mx.collections.ArrayList;

          import mx.core.FlexGlobals;

          import mx.events.FlexEvent;

 

          import org.flexunit.async.Async;

          import org.fluint.uiImpersonation.UIImpersonator;

          import org.hamcrest.assertThat;

          import org.hamcrest.collection.hasItems;

          import org.hamcrest.object.equalTo;

          import org.hamcrest.object.notNullValue;

 

          public class ButtonBarTest

          {

                    private var buttonBar: ButtonBar;

 

                    private var buttonData: Array = [{label: "one"  },{label: "two"},{label: "three"},{label: "four"},{label: "five"}];

 

 

                    [Before(async, ui)]

                    public function setUp():void

                    {

                              buttonBar = new ButtonBar();

                              buttonBar.dataProvider = new ArrayList( buttonData );

 

                              Async.proceedOnEvent( this, buttonBar, FlexEvent.CREATION_COMPLETE, 3000 );

                              UIImpersonator.addChild( buttonBar );

                    }

 

                    [After(async,ui)]

                    public function tearDown():void

                    {

                              UIImpersonator.removeChild( buttonBar );

                              buttonBar.dataProvider = null;

                              buttonBar = null;

                    }

 

                    [BeforeClass]

                    public static function setUpBeforeClass():void

                    {

                    }

 

                    [AfterClass]

                    public static function tearDownAfterClass():void

                    {

                    }

 

                    [Test(async, ui)]

                    public function testGet_selectedIndices():void

                    {

                              assertThat( buttonBar, notNullValue() );

                              var selectedIndices: Vector.<int> = buttonBar.selectedIndices;

                              assertThat( selectedIndices, notNullValue() );

                              assertThat( selectedIndices, equalTo( 0 ) );

                              buttonBar.selectedIndices = new Vector.<int>( 0, 2, 4 );

                              assertThat( buttonBar.selectedIndices, hasItems( 0, 2, 4 ) );

                    }

          }

}

I can run the test within flashbuilder or from ant using a test runner and I get the same result.

The button bar component is derived from spark.components.SkinnableDataContainer and has its own skin.  Buttons are added to a DataGroup, one button for each dataProvider element.  The buttons and data group are added by the skin classes associated with the button bar.

I am using flexunit-4.1.0-8-4.1.016076.

I'd really appreciate some help in getting this test case to work correctly.

Thanks,

Jeff

TOPICS
FlexUnit

Views

4.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 23, 2012 Feb 23, 2012

Copy link to clipboard

Copied

It's been a week so ... bump. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 12, 2013 Apr 12, 2013

Copy link to clipboard

Copied

Hi,

It's been over a year now. Were you able to find a solution to this? I am getting the exact same issue. If, instead of calling UIImpersonator.addChild()method, I call FlexGlobals.topLevelApplication.addElement(), the test passes.

Here's a simple test that uses UIImpersonator and fails (timeout):

[Test(async, ui)]

public function test():void

{

    var c:UIComponent = new UIComponent;

    Async.proceedOnEvent(this, c, FlexEvent.CREATION_COMPLETE);

    UIImpersonator.addChild(c);

}

However, the following test passes:

[Test(async, ui)]

public function test():void

{

    var c:UIComponent = new UIComponent;

    Async.proceedOnEvent(this, c, FlexEvent.CREATION_COMPLETE);

    FlexGlobals.topLevelApplication.addElement(c);

}

I have tried building with Flex versions 4.6.0, 4.9.0 and 4.9.1 ending up with the exact same output each time. I am using the latest version of FlexUnit.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 12, 2013 Apr 12, 2013

Copy link to clipboard

Copied

In the first example, your component is added to a container attached to the system root (so a peer to the application) in the second you are attaching it directly to the application. There isnt a good reason why one should work for you and one not. However, all of the verions of Flex you mention were released after the latest release of FlexUnit so there is the chance that something changed.

I will take a look at this for you, but I can't promise when that will happen so for the moment, if the topLevelApplication trick is working, I see little wrong with that. The only thing to be aware of is that your topLevelApplication may attempt to resize, etc. based on adding a child so it might affect test time.

It may be easier to add a fixed with container (canvas or similar) to the application and then specifically target that just to mitigate the response. Another possibility, if you wish to try, you can actually pass a visualDisplayRoot to the FlexUnitCore when you instantiate it. I believe I saw you doing so in your other post.

So, you can try saying

var core:FlexUnitCore = new FlexUnitCore();

core.visualDisplayRoot = this; //assuming this is running from the main app

-----

Some additional thoughts. If this is a Spark only project:

If flexunit is running an mx only or mx/spark environment it builds a Container for your tests. If it cannot find mx.core.Container at runtime, it builds a Group.

https://github.com/flexunit/flexunit/blob/master/FlexUnit4/src/org/fluint/uiImpersonation/flex/FlexE...

Group doesnt let you call addChild. It expects you to call addElement()

Mike


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 12, 2013 Apr 12, 2013

Copy link to clipboard

Copied

Thank you! I will try out your suggestions.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 12, 2013 Apr 12, 2013

Copy link to clipboard

Copied

Just an update: Flex 4.5.1 behaves the same way. Which version of the SDK do you guys use to test?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 12, 2013 Apr 12, 2013

Copy link to clipboard

Copied

Our build server is testing this against 3.2-3.4 and 4.0 and 4.1.

It hasnt been updated for releases after that.

It uses the CI listener and does pass all tests, including a bunch that are async. Did you try the addChild versus addElement thing. If you are using spark, it seems likely

Mike

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 12, 2013 Apr 12, 2013

Copy link to clipboard

Copied

With UIImpersonator.addElement(), I get this issue: http://stackoverflow.com/questions/7456760/flexunit-spark-component-test-issue-uiimpersonator. It's not a Spark-only project though.

I will probably just use topLevelApplication.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 12, 2013 Apr 12, 2013

Copy link to clipboard

Copied

LATEST

Use topLevelApplication for now and I will spend some time trying to resolve this in a better way. As the post mentiones FlexUnit is being moved to the Apache Flex project so we havent been actively developing but I can try to figure this out and release a patch.

Thanks for your time investigating and I will post back here when I have a resolution.

Mike

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines