Oh, and I tried changing to use the 3.5 and 4.1 compilers as well in case
that was the issue.  Same behavior with all three SDKs.

-Marty

On Tue, Mar 1, 2011 at 3:29 PM, Marty Blood <[email protected]> wrote:

> Hi Folks,
>
> I've been beating my head against a problem and I'm hoping someone out
> there can help.  I'm writing some test cases for our Flex application using
> Flex Unit 4 (RC 2) and we are currently building with the Flex 3.2 SDK in
> Flash Builder 4.
>
> The problem I'm seeing is when I add UI elements to the UIImpersonator they
> never finish setting up (i.e. their creation complete event is never
> triggered, never initialized, etc.).
>
> Per the directions at
> http://docs.flexunit.org/index.php?title=UIImpersonator I've set up my
> test case instantiating the component in the [Before], added the Async
> listener on the creation complete, etc.  In fact, just to make sure I didn't
> have a typo I took their complete example and pasted it in as a test case.
>  No dice.
>
> Source code I'm using below the description here.
>
> In every instance I get a 'Timeout occurred before expected event' error.
>
> Just to troubleshoot I tried adding the UI element as a child to the
> Application instead of the UIImpersonator (sorry to make your spine shiver,
> Douglas.  It's just for troubleshooting, honest!).  That worked fine so I
> know the Async proceedOnEvent is working fine.
>
> I also tried just removing the Async.proceedOnEvent but in that case the
> text input box is never initialized.
>
> Searching online some folks said that the problem may be with the
> VisualTestEnvironmentBuilder (which apparently UIImpersonator uses) but I
> haven't found anyone discussing how to _fix_ it.
>
> Any suggestions or help are appreciated.  Thanks for the help.
>
> -Marty
>
> TestApp.mxml:
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
>  xmlns:adobe="http://www.adobe.com/2009/flexUnitUIRunner";
> xmlns:listeners="org.flexunit.listeners.*"
>  creationComplete="runTests()" >
> <mx:Script>
>  import org.flexunit.runner.FlexUnitCore;
> import BasicSuite;
>  public function runTests():void
> {
> var core:FlexUnitCore = new FlexUnitCore();
>  core.addListener(runner);
> core.run(BasicSuite);
> }
>  </mx:Script>
> <adobe:TestRunnerBase id="runner" />
> </mx:Application>
>
> BasicSuite.as
> {
> [Suite]
> [RunWith("org.flexunit.runners.Suite")]
>  public class BasicSuite
> {
> //declare (but don't instantiate) a variable for each unit test class to
> run in this suite
>  public var test1:tests.ExpandingTextInputTest;
> }
> }
>
> tests.ExpandingTextInputTest:
> package tests
> {
> import mx.controls.Alert;
> import mx.controls.TextInput;
>  import mx.core.Application;
> import mx.events.FlexEvent;
>  import org.flexunit.Assert;
> import org.flexunit.async.Async;
> import org.fluint.uiImpersonation.UIImpersonator;
>
> public class ExpandingTextInputTest
> {
>  private var ti:TextInput;
>  /**
>  * initialize the text input and add it to the UIImpersonator
>  */
> [Before(async, ui)]
>  public function setUp():void
> {
> ti = new TextInput();
>  Async.proceedOnEvent(this, ti, FlexEvent.CREATION_COMPLETE, 1000);
> UIImpersonator.addChild(ti);
>  }
>  /**
>  * remove the input from the layout and null out the reference to ensure
> the object is destroyed.
>  */
>  [After(async, ui)]
> public function tearDown():void
> {
>  UIImpersonator.removeChild(ti);
> ti = null;
> }
>  /**
>  * test adding only a couple of characters.
>  */
> [Test(async,ui)]
> public function testAddingShortText():void
>  {
> Alert.show("In testAddingShortText.  Is TI initialized? " +
> ti.initialized);
>
> }
>      }
> }
>

Reply via email to