Adobe Flex 3 Help

Use run-time loading

You use the run-time testing files rather than building your applications with testing libraries. This lets you test SWF files that are compiled without automated testing support. To do this, you use a SWF file that does include the automated testing libraries. In that SWF file, the SWFLoader class loads your application's SWF file which does not include the testing libraries. The result is that you can test the target SWF file in a testing tool such as QTP, even though the application SWF file was not compiled with automated testing support.

Flex Builder includes a wrapper SWF file and an HTML template that supports run-time loading. The source MXML file for the wrapper SWF file is also included. The following files are located in the flex_builder_install_dir/sdks/3.0.0/templates/automation-runtimeloading-files directory:

  • RunTimeLoading.html -- The HTML template that loads the run-time loader SWF file. This template includes code that converts the automationswfurl query string parameter to a flashVars variable that it passes to the application. You use this query string parameter to specify the name of the application you want to test.
  • runtimeloading.mxml -- The source code for the runtimeloading.swf file that you compile. The SWF file acts as a wrapper for your application. This SWF file includes the testing libraries so that you do not have to compile them into your application SWF file.
  1. Compile the runtimeloading.swf file. You can use the batch file in the flex_builder_install_dir/sdks/3.0.0/templates/automation-runtimeloading-files directory. Execute this batch file from the sdks/3.0.0/frameworks directory. This batch file ensures that your runtimeloading.swf file includes the automation.swc, automation_agent.swc, automation_dmv.swc, automation_flashflexkit.swc, and qtp.swc libraries.
  2. Deploy the runtimeloading.swf, RunTimeLoading.html, and your application's SWF file to a web server. Request the RunTimeLoading.html file and pass the name of your SWF file as the value to the automationswfurl query string parameter. For example:
    http://localhost/RunTimeLoading.html?automationswfurl=MyApp.swf
    
    

If you want to recompile the runtimeloading.swf file without the batch file, be sure to include automated testing support by adding the appropriate automation SWC files with the include-libraries compiler option.

The batch file for compiling the runtimeloading.swf file is Windows only. To compile the SWF file on Mac OS or Linux, you must write your own batch file.

Testing applications that load external libraries

Applications that load other SWF file libraries require a special setting for automated testing to function properly. A library that is loaded at run time (including run-time shared libraries (RSLs)) must be loaded into the ApplicationDomain of the loading application. If the SWF file used in the application is loaded in a different application domain, automated testing record and playback will not function properly.

The following example shows a library that is loaded into the same ApplicationDomain:

import flash.display.*;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;
 
var ldr:Loader = new Loader();
 
var urlReq:URLRequest = new URLRequest("RuntimeClasses.swf");
var context:LoaderContext = new LoaderContext();
context.applicationDomain = ApplicationDomain.currentDomain;
loader.load(request, context);