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, SelectCell, and so on. 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.