Document directory
- Silktest support of Delphi applications
- Notes
- Using debug info agent with Delphi applications
Qtp test Delphi application
After installing the qtp Delphi plug-in, you must configure the program to be tested for normal use.
The method is as follows:
You must perform the following steps for each application that you want to test.
To link to the micdelphiagent. Pas module:
1. add the <quicktest professional installation folder> \ dat \ extensibility \ Delphi folder to your Delphi project search path or copy the contents of the <quicktest professional installation folder> \ dat \ extensibility \ Delphi folder to your project folder.
2. Add micdelphiagent to the uses section of your application's project file (project. DPR) as shown in the example below:
Program flight;
Uses
Micdelphiagent,
Forms,
Windows;
($ R *. Res)
Begin
Application. initialize
Application. Title: = 'flight reservation ';
Application. Run;
End.
3. compile your Delphi project.
NOTE: If your application has des the twwdbgrid from infopower, you must add support for this grid as described in login ing support for twwdbgrid.
Applying ing support for twwdbgrid
If your application implements des the twwdbgrid from infopower, follow the following instructions to enable support for this grid.
1. Add micwwsupport to the uses section of your application's project file (project. DPR) after micdelphiagent, as shown in the example below:
Program flight;
Uses
Micdelphiagent,
Micwwsupport,
Forms,
Windows;
($ R *. Res)
Begin
Application. initialize
Application. Title: = 'flight reservation ';
Application. Run;
End.
2. recompile your application.
You are now ready to create and run tests on Delphi applications.
Silktest test Delphi application silktest support of Delphi applications
While silktest does not support Delphi controls "out of the box", always all of the Delphi objects can be class mapped to standard silktest controls. For instance:
[Classmap]
Dialogbox, 0x50000044,0x50000044 = ignore
Tbitbtn = Pushbutton
Tbutton = Pushbutton
Tcheckbox = checkbox
Tcombobox = ComboBox
Tdbcheckbox = checkbox
Tdbcombobox = ComboBox
Tdbedit = textfield
Tdblistbox = ListBox
Tdblookupcombobox = ComboBox
Tdblookuplistbox = ListBox
Tdbmemo = textfield
Tdbradiogroup = ignore
Tedit = textfield
Tflyingpanel = Toolbar
Tgroupbox = statictext
Tgroupbutton = radiobutton
Tlistbox = ListBox
Tlistview = listview
Tmaskedit = textfield
Tmemo = textfield
Tpagecontrol = pagelist
Tpanel = ignore
Tradiobutton = radiobutton
Tradiogroup = ignore
Trichedit = textfield
Tricheredit = textfield
Tscrollbar = scrollbar
Tstatusbar = statusbar
Ttabcontrol = pagelist
Ttreeview = Treeview
Tupdown = updown
There are a few controm controls that don't respond to class mapping (such as treeviews, grids, and statictext). However, typekeys and mouse events can be used on them.
Getcontents () seems to return nothing for treeviews.
Notes
Silktest can work with Delphi objects in a variety of ways. the amount of functionality you achieve depends on how deep you want to get involved. you can even create an extension (external) for Delphi objects. delphi supports DLL calling, and you can use DLL's created in C/C ++ in your Delphi application. class mapping will work in specified instances, but not with every object.
If class mapping doesn' t work, you can try any of the following workarounds:
- Using sendmessage with the clipboard
- Delphi is built with VCL. the Borland VCL (visual component library) is similar to MFC in that all of the classes of objects that Delphi can create are in this library. instead of C ++ it is written in Object Pascal. borland ships the VCL source code with the product. in the VCL source, you can go to the definition of the object class that you want to support for and add message handlers (Windows API messages) for varous messages that you define.
- For example, add a message handler that says that if any object of this class has es a message called "qap_getvalue", get the contents of The ListBox, send a message back to the process that sent the message, and send it the value. on the silktest side of things you define a new class to support the object and add a method that sends/has es the message to the supported object.
- For example, here is sample code of a message handler on the Delphi side:
Procedure qap_getvalue (var msg: tmessagerecord );
VaR
Valuetoreturn: string;
Begin
Copytoclipboard;
MSG. Result: = true;
End;
- Here is sample code for the window class on the 4 test side:
Winclass delphobj: Control
List of string getcontents ()
If (sendmessage (this. hwnd, qap_getlistcontents, null, null ))
Return clipboard. gettext ()
Else
Raiseerror (1, "couldn't get the contents of {This },
Sendmessageevent not processed correctly ")
- Using the extension kit, create a DLL that does the same thing as above, using t passing values directly from application to application rather than relying on the clipboard. this method is preferred over the above because of speed and Data Type stability.
- Use low level 4 Test Events relying on coordinates to create methods. silktest low-level recording shoshould only be used when you want to use recording rather than hand scripting.
Testcomplete test Delphi application
With testcomplete you can test almost any windows application including those created with Borland Delphi ver. 3 and later.
- Borland Delphi v. 3.0-7.0.
- Borland Delphi 2005 and 2006 for win32.
- Codegear Delphi 2007 and 2009 for win32.
- Embarcadero Delphi 2010 for win32.
Using debug info agent with Delphi applications
Debug info agent exposesPublic,Published,ProtectedAndPrivateMembers of objects in Delphi open applications as soon as the application is compiled with debug information. this topic explains how to include debug information into Applications created with Borland Delphi v. 3-7 or Borland Delphi 2005 for win32. to learn how to prepare applications created with other Delphi versions, see implementing debug info agent support in applications.
The Delphi compiler generates debug information in the td32 format, which is compiled into the application's binary modules. however, it is possible to extract debug information into separate. TDS files using testcomplete's striptds utility.
Debug info agent can work with both formats. however, we recommend that you create external. TDS files for release builds of your products. this will decrease the overall size of your application. the td32 format of debug information can be used for intermediate or special builds.
Below are detailed instructions on changing the project options to use the desired format of debug information.
External debug information (TDS files)
The. TDS files are created based on executables and DLLs compiled with td32 debug information encoded. to remove debug information from modules and store them in separate. TDS files, you can use the striptds utility that is shipped with testcomplete.
So, to create. TDS files, you shoshould first compile the tested Delphi application with debug information and then process the compiled modules with the striptds utility. Below are detailed steps:
- Change the project settings to compile the application with td32 debug information:
- Open your project in Borland Delphi.
- Select project | options from Delphi's main menu. This will open the Project Options dialog.
- Switch to the compiler tabbed page and check the debug information and local symbols options in the debugging group:
Note: |
It is possible to keep the local symbols disabled, but in this case the names of some method parameters will not be displayed in the Object Browser panel. |
-
- Switch to the linker tab and enable the include td32 debug info option in the EXE and DLL Options Group:
-
- Press OK to save the changes and close the Project Options dialog.
- Re-build the application.
- Apply the striptds utility to each compiled executable and DLL. For example, to process all EXE and DLL files in the C: \ MyApp folder and Its subfolders, you can use the following command line:
Striptds.exe-r-WC: \ MyApp \ *. EXE; C: \ MyApp \ *. dll
The utility will remove debug information from the executable files and save it to separate. TDS files. the utility only works with those sections in the binary file that contain debug information. it does not change the code and data sections, so your module will work as it was designed. for more information about the modifications and command-line arguments of the striptds utility, see about striptds.
Some notes concerning this approach:
- The. TDS files containing debug information must reside in the same folders that the appropriate modules of the tested application.
- Even if the application is compiled with the local symbols option enabled, the names of some method parameters may not be displayed in the Object Browser. if viewing parameter names is important to you (for instance, if you are developing new tests), compile the tested Delphi application with internal td32 debug information (see below ).
- There is no need to distribute the generated. TDS files with your application.
Internal debug information (td32)
To compile your Delphi application with embedded td32 debug information, follow these steps:
- Choose project | options from the main menu.
- In the ensuing Project Options dialog, switch to the compiler tabbed page. Enable the debug information option in the debugging group to include debug information:
- To see the names of method parameters in the Object Browser panel, turn off the optimization option and enable the local symbols option. When using Delphi 5.0 or later, also enable the use DEBUG dcus option:
- Switch to the linker tab and enable the include td32 debug info option in the EXE and DLL Options Group:
- It is recommended that you turn off the build with runtime packages option on the packages tabbed page:
The reason for unchecking this option is as follows: in order for debug info agent to have access to VCL objects, methods and properties provided by Delphi packages, the latter must be compiled with debug information. however, runtime packages are compiled without debug information by default. when the build with runtime packages option is turned on, the compiler does not include the packages 'vcl code into the executable, so the methods and Properties of VCL objects provided by the packages will be unavailable to testcomplete. by unchecking this option, you force the compiler to include the packages 'Code into the executable and thus generate debug information for that code as well.
- Once you have completed the above steps, press OK to save the changes and close the Project Options dialog.
- Re-compile the application.
Remember to recompile the release version of your application without td32 debug information in order to reduce the application size.