You probably need to do some setup or customization to run that
UIImpersonator...  probably it's docs tell you what to do.

FWIW, flexmojos unit test support is meant for unit test. Not for
UI/Integration tests.  For that scenarios most likely flexmojos need
changes.

Sent from DROID

Em 23/04/2010 08:35, "Peter Bierman" <[email protected]>escreveu:

Hi,

I’m having a problem with a unit test that uses the flexunit 4
UIImpersonator class and the buttonbar class when running it with
flex-mojos.
I’m posting it here because when I run the same test with the default
runner from eclipse the test passes every time.
Only when executing it with maven and the flexmojos I get this problem.
The unit test is pretty straightforward:

            [Before(async,ui)]
            public function setUp():void {
                  mainView = new MainView();
                  Async.proceedOnEvent(this, mainView,
FlexEvent.CREATION_COMPLETE, 2000);
                  UIImpersonator.addChild(mainView);
                  appModel = new AppModel();
                  mainView.appModel = appModel;
            }

            [Test(async,timeout="2000")]
            public function testCloseProject():void {
                  Async.handleEvent(this, mainView,
UserEvent.HOME_USER_EVENT, closeProjectHandler);
                  var lastButtonIndex:int =
(mainView.topMenu.dataProvider as ArrayCollection).length - 1;
                  var closeButton:Button =
mainView.topMenu.getChildAt(lastButtonIndex) as Button;
                  closeButton.dispatchEvent(new
MouseEvent(MouseEvent.CLICK));
            }

            public function closeProjectHandler(event:UserEvent,
param2:*):void {
                  mainView.topMenu.validateNow();
                  Assert.assertEquals(0, mainView.topMenu.selectedIndex);
            }

The mainview has a topmenu property that’s a buttonbar.

      <!-- top menu -->
      <mx:ToggleButtonBar id="topMenu" styleName="topMenu"
dataProvider="{appModel.topMenuItems}"
                  itemClick="buttonBarClick(event)"/>

And the model that fills it is declared as follows:
      public var topMenuItems:Array = ["General", "Close Project"];

Running the test through the flexunit 4 runner
(org.flexunit.flexui.TestRunnerBase) makes the test pass every time.

But running it with maven and the flexmojos I get the following error:
TypeError: Error #1009: Cannot access a property or method of a null
object reference
                at
mx.controls::ButtonBar/
http://www.adobe.com/2006/flex/mx/internal::drawButtonFocus()[C
:\autobuild\3.5.0\frameworks\projects\framework\src\mx\controls\ButtonBar.as:930]
                at
mx.controls::ButtonBar/clickHandler()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\controls\ButtonBar.as:1053]
                at
mx.controls::ToggleButtonBar/clickHandler()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\controls\ToggleButtonBar.as:625]
                at flash.events::EventDispatcher/dispatchEventFunction()
                at flash.events::EventDispatcher/dispatchEvent()
                at
mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9440]
                at
nl.prismait.icco.monitoringsprotocol.views::MainViewTest/testCloseProject()[C:\workspaces\icco-monitoringsprotocol\IccoMonitoringsProtocolAir\src\test\air\nl\prismait\icco\monitoringsprotocol\views\MainViewTest.as:44]
                at Function/http://adobe.com/AS3/2006/builtin::apply()
                at
flex.lang.reflect::Method/apply()[C:\Users\mlabriola\Documents\workspaces\net\digitalprimates\opensource\flexunit\FlexUnit4\src\flex\lang\reflect\Method.as:124]
                at
ReflectiveCallable/run()[C:\Users\mlabriola\Documents\workspaces\net\digitalprimates\opensource\flexunit\FlexUnit4\src\org\flexunit\runners\model\FrameworkMethod.as:214]
                at
org.flexunit.runners.model::FrameworkMethod/applyExplosivelyAsync()[C:\Users\mlabriola\Documents\workspaces\net\digitalprimates\opensource\flexunit\FlexUnit4\src\org\flexunit\runners\model\FrameworkMethod.as:121]
                at
org.flexunit.runners.model::FrameworkMethod/invokeExplosivelyAsync()[C:\Users\mlabriola\Documents\workspaces\net\digitalprimates\opensource\flexunit\FlexUnit4\src\org\flexunit\runners\model\FrameworkMethod.as:132]
                at
org.flexunit.internals.runners.statements::InvokeMethod/evaluate()[C:\Users\mlabriola\Documents\workspaces\net\digitalprimates\opensource\flexunit\FlexUnit4\src\org\flexunit\internals\runners\statements\InvokeMethod.as:52]
                at
org.flexunit.internals.runners.statements::ExpectAsync/evaluate()[C:\Users\mlabriola\Documents\workspaces\net\digitalprimates\opensource\flexunit\FlexUnit4\src\org\flexunit\internals\runners\statements\ExpectAsync.as:335]
                at
org.flexunit.internals.runners.statements::FailOnTimeout/evaluate()[C:\Users\mlabriola\Documents\workspaces\net\digitalprimates\opensource\flexunit\FlexUnit4\src\org\flexunit\internals\runners\statements\FailOnTimeout.as:68]
                at
org.flexunit.internals.runners.statements::StackAndFrameManagement/handleTimerComplete()[C:\Users\mlabriola\Documents\workspaces\net\digitalprimates\opensource\flexunit\FlexUnit4\src\org\flexunit\internals\runners\statements\StackAndFrameManagement.as:100]
                at flash.events::EventDispatcher/dispatchEventFunction()
                at flash.events::EventDispatcher/dispatchEvent()
                at flash.utils::Timer/tick()

I have a feeling that the problem lies within the UIImpersonator class
that sets the object on the stage, but I was wondering if someone had
a clue where to start looking because I’ve been trying for a day now
and I can’t find any leads.

I’ll paste my pom.xml for reference but I don’t suspect that’s the problem.
<project xmlns="http://maven.apache.org/POM/4.0.0";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd";>

  <modelVersion>4.0.0</modelVersion>
  <groupId>icco</groupId>
  <artifactId>monitoringsProtocol</artifactId>
  <version>0.1</version>
  <packaging>swf</packaging>
  <name>monitoringsProtocol Project</name>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <build>
    <sourceDirectory>src/main/air</sourceDirectory>
    <testSourceDirectory>src/test/air</testSourceDirectory>
    <plugins>
      <plugin>
        <groupId>org.sonatype.flexmojos</groupId>
        <artifactId>flexmojos-maven-plugin</artifactId>
        <version>3.6.1</version>
        <extensions>true</extensions>
            <configuration>
                  <targetPlayer>10.0.0</targetPlayer>
                  <sourceFile>MonitoringsProtocol.mxml</sourceFile>
            </configuration>
            <dependencies>
          <dependency>
            <groupId>com.adobe.flex</groupId>
            <artifactId>compiler</artifactId>
            <version>3.5.0.12683</version>
            <type>pom</type>
          </dependency>
        </dependencies>
    </plugins>
  </build>
  <dependencies>
      <dependency>
            <groupId>com.adobe.flex.framework</groupId>
            <artifactId>air-framework</artifactId>
            <version>3.5.0.12683</version>
            <type>pom</type>
      </dependency>
    <dependency>
      <groupId>com.adobe.flexunit</groupId>
      <artifactId>flexunit</artifactId>
      <version>4.0-beta-2</version>
      <type>swc</type>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

Peter

--
You received this message because you are subscribed to the Google
Groups "Flex Mojos" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]<flex-mojos%[email protected]>
For more options, visit this group at
http://groups.google.com/group/flex-mojos

http://flexmojos.sonatype.org/

-- 
You received this message because you are subscribed to the Google
Groups "Flex Mojos" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/flex-mojos

http://flexmojos.sonatype.org/

Reply via email to