Hey Mark
Of course. Here you go (many thanks in advance):

        public class LoginViewTest
        {               
                
/*============================================================================*/
                /* Private Properties                                           
              */
                
/*============================================================================*/
                private var loginView:LoginView;
                
                
/*============================================================================*/
                /* Test Setup and Teardown                                      
              */
                
/*============================================================================*/
                [Before(async,ui)]
                public function setUp():void
                {
                        loginView = new LoginView();
                        Async.proceedOnEvent(this, loginView, 
FlexEvent.CREATION_COMPLETE, 1000);
                        UIImpersonator.addChild(loginView);
                }
                
                [After(async,ui)]
                public function tearDown():void
                {
                        UIImpersonator.removeAllChildren();
                        loginView = null;
                }
                
                [BeforeClass]
                public static function setUpBeforeClass():void
                {
                        if (!translationProxy)
                                translationProxy = new TranslationProxy();
                }
                
                [AfterClass]
                public static function tearDownAfterClass():void
                {
                }
                
                
/*============================================================================*/
                /* Tests                                                        
              */
                
/*============================================================================*/
        
                [Test(async, ui)]
                public function shouldAssert():void{
                        assertEquals(true, true);
                }


-----Ursprüngliche Nachricht-----
Von: Mark Line [mailto:[email protected]] 
Gesendet: Mittwoch, 30. April 2014 13:34
An: [email protected]
Betreff: RE: FlexUnit 4.2 UIImpersonator

I've not done any testing for a mobile project but can confirm its working 
correctly with spark components.

Do you have a whole class we can have a look at? (PS you can't use attachments 
here)

Here is a basic example:

    public class MyTest
    {
        private var _myForm:MyForm;

                [Before(async,ui)]
                public function setUp():void
                {
                        _ myForm = new MyForm ();
                        Async.proceedOnEvent(this, _ myForm,
FlexEvent.CREATION_COMPLETE, 50000);
                        UIImpersonator.addChild(_myForm);
                }
                [After(async,ui)]
                public function tearDown():void
                {
                        UIImpersonator.removeChild(_myForm);
                        _ myForm = null;
                }


                [Test(async,ui)]
                 public function checkSomethingTest():void
                        {
                        assertEquals(true,true)
                        }
}

-----Original Message-----
From: Daniel Tiefenauer [mailto:[email protected]]
Sent: 30 April 2014 12:21
To: [email protected]
Subject: FlexUnit 4.2 UIImpersonator

Hi there
I'm trying to perform UI-Tests for a Mobile Application created with Flex 
4.12.0. I'm following the tutorial under 
http://flex.apache.org/flexunit/tutorial/flexunit/Unit-14.html. However, I 
can't get this to work. When using UIImpersonator to add an UI component (even 
a Spark Button), the "creationComplete"-Event is never thrown. Hence I can't 
perform unit tests on the UI Components because the nested sub-elements are not 
present.

Here's what I did:
                    loginView = new LoginView();
                    Async.proceedOnEvent(this, loginView, 
StateChangeEvent.CURRENT_STATE_CHANGE);
                    UIImpersonator.addChild(loginView);

As said, I have tried this with a spark button, but it does not work. The 
tutorial mentioned above uses MX-Components. Can Spark components be tested at 
all?

Regards
Daniel

Reply via email to