Creating Support for Custom Grid Controls

To create support for a custom grid control you need to map the control to an appropriate test object class, develop an Agent Object that implements the support, and (optionally) instruct UFT One to treat the control as a table.

Mapping a Custom Grid Control to a Test Object Class

You can map the custom grid control to the DelphiTable test object class, or to a custom grid test object class that you define in the test object configuration file.

If you map the custom grid control to the DelphiTable test object class, you do not have to create any of the definitions described in Instructing UFT One to Treat Your Custom Grid Control as a Table .

Back to top

Developing an Agent Object to Support a Custom Grid Control

The Agent Object must provide support for all of the test object methods and identification properties defined in the test object class mapped to the grid control. These include grid operations such as SetCellData and GetCellData, and any other methods and properties that you define in the test object class.

The UFT One Delphi Add-in provides a test object extension (Mercury.DelphiTableSrv) that implements much of the design required to support grid controls.

This extension implements basic grid operations like SetCellData, GetCellData, and SelectCell. The extension delegates these test object methods to the Agent Object using the __CellRect, __CellData, __TableContent, RowCount, and ColCount published properties.

To create support for a custom grid control, you must design an Agent Object that inherits from TMicGridAOBase or TCustomGridAOBase and implements these published properties. (For more information about the TMicGridAOBase or TCustomGridAOBase base classes, see <UFT One installation folder>\dat\Extensibility\Delphi\AgentExtensibilitySDK.pas.)

In addition, you must instruct UFT One to use the grid test object extension to support your custom grid.

Note: If you map the custom control to a custom test object class, design the Agent Object to support any additional test object methods and identification properties defined in the test object class.

Implementing the Published Properties for Supporting a Grid

The support that you develop for a custom grid control is based on the Delphi Add-in grid test object extension. Therefore, you must implement the following published properties in your Agent Object:

  • __CellRect must return the rectangle at which the cell is located, in the format: x;y;width;height;; where x and y are the coordinates of the top left corner of the rectangle.

  • __CellData is used to set and retrieve the value contained in a cell (in String format). The TMicGridAOBase agent object base class implements this property to call the abstract functions GetCellDataEx and SetCellDataEx. Implement these functions in the derived class that you design for your Agent Object.

  • __TableContent is used to write the content (data) of the whole table to the specified file and return true or false indicating success or failure. The file is specified in the parameter passed to the Agent Object from UFT One. Write the table content to the file in string format, with tabs separating cell data and new-line characters separating rows.

  • The grid test object extension uses this property to support table checkpoints. The TMicGridAOBase agent object base class implements this property to call the abstract CaptureTableEx function. Implement this function in the derived class that you design for your Agent Object.

    Back to top

    Instructing UFT One to Treat Your Custom Grid Control as a Table

    Note: For custom grid controls mapped to the DelphiTable test object class, you do not have to create any of the definitions described in this section.

    In the toolkit configuration XML file, define the following:

    • Instruct UFT One to use the Delphi Add-in grid test object extension to support your custom grid control (or all controls mapped to a specific custom grid test object class).

    • If you defined a custom grid test object class (in the test object configuration file), instruct UFT One to treat this type of test object as a table test object when creating checkpoints and output values.

    To instruct UFT One to use the grid test object extension for this type of control:

    Add the following definitions to your toolkit configuration XML file (bold text represents the lines you need to add):

    <MicTest>
      <Key Name="Packages">
        <Key Name="DelphiPackage">
          <Key Name="CustomServers">
            <Key Name="TCustomGridNativeClass"> 
              <Value Name="CustReplayProgID" 
                          Type="BSTR"> Mercury.DelphiTableSrv 
              </Value>
            </Key>
          </Key>
        </Key>
      </Key>
    ...
    </MicTest> 
    • Replace TCustomGridNativeClass with the window class name of the grid control for which you are developing support.

    • Within the Key element where Name="CustomServers", create a separate Key value for each custom grid class that you want to support.

    Alternatively, you could create a single Key element to instruct UFT One to use the grid test object extension for all custom controls mapped to a certain custom test object class. To do this, replace TCustomGridNativeClass in the section above with the name of the custom grid test object class, prefixed with the string MC2CSMapping_ (for example, MC2CSMapping_DelphiCustomTable).

    To instruct UFT One to treat this type of test object as a table test object when creating checkpoints and output values:

    Add the following definitions to your toolkit configuration file in the section that you create to map your custom test object class to an inner objects (bold text represents the lines you need to add):

    <MicTest>
    ...
      <Key Name="Test Objects">
        <Key Name="TheDelphiCustomTestObject you are mapping">
    ...
          <!-- enables table checkpoint and output value -->
          <Key Name="CustomStepCfg"> 
            <Value Name="Checkpoint" Type="BSTR">Mercury.MultiVerUI</Value>
            <Value Name="Output Value" Type="BSTR">Mercury.MultiVerUI</Value>
          </Key>
          <!-- Enables use of the Define/Modify Row Range dialog box -->
          <Key Name="CustomStepCfgDlg"> 
            <Value Name="Checkpoint" Type="BSTR">
                         Mercury.TableTOConcigUI
            </Value>
            <Value Name="Output Value" Type="BSTR">
                         Mercury.TableTOConcigUI
            </Value>
          </Key>
        </Key>
      </Key>
    </MicTest> 

    If you define more than one custom Delphi grid test object class, add these definitions within the Key element that you define for each of the relevant test object classes.

    This instructs UFT One to use the Table Checkpoint Properties and Table Output Value Properties dialog boxes for this type of test object.

    For information on the structure and syntax of the toolkit configuration XML, see Understanding the Toolkit Configuration XML File Structure.

    Back to top

    View a sample

    A sample toolkit support set, which provides support for a custom grid control (TStringDrawGrid), is located in the <UFT One installation folder>\samples\DelphiGridExtSample folder. After reading this section, you can use the sample to gain a better understanding of how to create support for custom grid controls. For more information, see Delphi Add-in Extensibility Samples.

    Back to top