Designing Your Delphi Extensibility Code

This topic describes the objects and functions you need to develop to create support for your custom controls.

Overview

The Delphi unit that you develop for extensibility must include the following items:

  • One or more Agent Objects; one Agent Object for each type of control that you want to support. The Agent Objects interface between OpenText Functional Testing and the Delphi controls in the application being tested.

  • One factory function that creates the appropriate Agent Object for each control. When OpenText Functional Testing first interacts with a control, it calls the factory function to create the corresponding Agent Object.

For some custom controls, mapping the control to an existing Delphi test object class might provide sufficient support. In such cases, you do not have to design an Agent Object for the control.

Back to top

Creating Your Extensibility Code

To create the extensibility Delphi unit that you develop to support your custom controls, use the template unit provided with the Delphi Add-in: <OpenText Functional Testing installdir>\dat\Extensibility\Delphi\ExtensibilityImplementationTemplate.pas

In your extensibility code you must do the following:

  • Import and use the AgentExtensibilitySDK unit provided with the OpenText Functional Testing Delphi Add-in: <OpenText Functional Testing installdir>\dat\ Extensibility\Delphi\AgentExtensibilitySDK.pas

  • Design an Agent Object for each type of control that you want to support. The Agent Object must inherit from TMicAO or one of the other Agent Object base classes defined in the Delphi Add-in Extensibility SDK. In the Agent Objects, develop published properties that support the test object methods and identification properties required for your controls. For more information, see Working with Published Properties to Support Test Object Methods and Identification Properties.

  • Create a factory function that receives an object reference of a Delphi user interface control and returns a new Agent Object. The factory function must be able to recognize the custom controls for which you are creating support, and create the appropriate Agent Object.

  • In the initialization section of your extensibility unit, call the AddExtensibilityServer API function to register your factory function to the Delphi Add-in.

For more information, see <OpenText Functional Testing installdir>\dat\Extensibility\Delphi\AgentExtensibilitySDK.pas.

Before you can run the support that you develop, you must compile the Delphi application you are testing with the extensibility unit you designed and with the Delphi Add-in precompiled agent. For more information, see Deploying the Toolkit Support Set.

Back to top

Working with Published Properties to Support Test Object Methods and Identification Properties

OpenText Functional Testing interacts with the application's controls by setting and retrieving the published properties provided by the Agent Object and the control itself. OpenText Functional Testing first accesses the published properties of the Agent Object and then, if necessary, the published properties of the Delphi object.

When you develop your Agent Object, design published properties to support the identification properties and test object methods that you defined in the test object configuration file. For example, you can create published properties in your Agent Object to enable access to (public) unpublished member variables of the control.

The following reserved properties are used for the implementation of recording and running tests and components:

  • __QTPReplayMtd_

    Use this prefix for all Agent Object properties designed to implement running test object methods.

  • __CellRect, __CellData, and __TableContent

    These properties are used to implement support for grid objects. For more information, see Creating Support for Custom Grid Controls.

  • __QTPRecording

    This property is used to implement support for the OpenText Functional Testing recording capability. For more information, see Supporting the Recording Capability.

The implementation for recording and running tests and components is described in the following sections:

Supporting identification properties

For each identification property that you want to support, make sure there is a published property with the same name in the Delphi control or the Agent Object.

Note: OpenText Functional Testing uses only lowercase letters in identification property names. Therefore, the names of published properties that support identification properties must contain only lowercase letters (even if the identification property name in the test object configuration file contains uppercase letters).

An OpenText Functional Testing user can access the published properties of the Agent Object and the Delphi control using the GetROProperty and SetROProperty methods. In addition, these published properties can be verified using checkpoints in an OpenText Functional Testing test and viewed in the Object Spy.

If a property name begins with a double underscore ('__'), it is not displayed in the Object Spy and cannot be accessed by checkpoints or output values. Such hidden properties can be accessed by the GetROProperty and SetROProperty test object methods, and can be accessed directly in user defined functions created in OpenText Functional Testing.

Supporting Test Object Methods

For each test object method that you want to support, create a published property named __QTPReplayMtd_<Test Object Method Name> in the Agent Object. For example, a published property named __QTPReplayMtd_MyTOMethod provides the implementation for running the MyTOMethod test object method.

Supporting the Recording Capability

An Agent Object must implement the __QTPRecording published property to support the OpenText Functional Testing recording capability.

During a recording session, when an event occurs on a custom Delphi control, OpenText Functional Testing sends the Windows message to the Agent Object and queries the __QTPRecording property to retrieve the corresponding line to add to the test or component.

In most cases, you do not have to implement this property in your extensibility code. If you want to create an Agent Object that supports recording, have your Agent Object inherit from the TMicRecordableAO base class.

The TMicRecordableAO agent object base class implements __QTPRecording to perform the following:

  1. Process the parameters passed by OpenText Functional Testing.

  2. Call the ProcessMessage function to determine what step to record for the event that occurred (and the recording mode).

  3. Convert the recording information to the format required by OpenText Functional Testing.

    In the Agent Object that you develop, you need only implement the ProcessMessage function.

    When OpenText Functional Testing accesses the __QTPRecording property, it passes the window message parameters and window handle to the Agent Object, and expects in return, an array (of type safearray) that contains the recorded step information (the operation and its arguments) and the recording mode. For more information on recording modes, see <OpenText Functional Testing installdir>\dat\Extensibility\Delphi\AgentExtensibilitySDK.pas.

    Input parameters:

    Parameter Index

    Value Type

    Description

    0

    VT_I4

    Window handle

    1

    VT_I4

    Message

    2

    VT_I4

    IParam

    3

    VT_I4

    wParam

    Output safearray format:

    Parameter Index

    Value Type

    Description

    0

    VT_I4

    Recording mode

    1

    VT_BSTR

    Test object method to record

    2..end

     

    Test object method arguments

  4. Note: If you create a custom test object class to support the custom control, you can use the ExtObjRecFilter attribute in the toolkit configuration file to specify the level of events that trigger recording. For more information, see Mapping Test Object Classes to Inner Objects.

Back to top