1 Reply Latest reply on Jan 5, 2011 7:33 AM by nikos101

    Best way to test ProgressEvent.PROGRESS?

    Tim Robles

      I have a custom loader that's dispatching a ProgressEvent. I want to be able to test that the last ProgressEvent.PROGRESS event fired has a progress property of 1.0. Typically I'd add an Async.asyncHandler() but this only fires once per listener, and won't listen indefinitely for all the ProgressEvents. Any ideas on the best way to test an event that fires continually?

        • 1. Re: Best way to test ProgressEvent.PROGRESS?
          nikos101 Level 2

          use a timer and increment every time the event fires:


                  public function testButtonClick():void {
                      var timer:Timer = new Timer( 2000,1 );
                      Async.handleEvent( this, timer, TimerEvent.TIMER_COMPLETE, checkCount,1800 );
                      this.addEventListener( ProgressEvent.PROGRESS', function( e:Event ):void { clickCount++ } );
                      view.addCommentBtn.dispatchEvent( new MouseEvent( MouseEvent.CLICK, true, false ) );
                  private function checkCount( e:Event, passThroughData:Object ):void {
                      Assert.assertEquals( 1, clickCount );