Developing Custom Comparers for Bitmap Checkpoints

Relevant for: GUI tests and components

This chapter is intended for COM programmers who want to customize the algorithm used to compare bitmaps in bitmap checkpoints.

A custom comparer is a COM object that you develop to run the bitmap comparison in a bitmap checkpoint according to a specific algorithm. This enables you to create bitmap checkpoints that perform the comparison according to your needs.

By default, a bitmap checkpoint in UFT compares the actual and expected bitmaps pixel by pixel and fails if there are any differences. UFT provides various bitmap checkpoint configuration options that enable you to refine the bitmap comparison and make it more flexible. For example, you can define tolerance levels, or you can instruct UFT not to compare complete images, but rather compare selected areas within them, or to locate a specific image within an object in your application.

If you need to further customize the way bitmaps are compared in checkpoints, you can develop custom comparers and install and register them on the UFT computer. A UFT user can then choose to use a custom comparer to perform the comparison in a bitmap checkpoint (on a per checkpoint basis).

The COM object that you develop must implement interfaces that UFT provides in a type library, and register to the component category that UFT defines for bitmap comparers. The type library (BitmapComparer.tlb) and the category ID (defined in ComponentCategory.h) are available in <UFT installation folder>\dat\BitmapCPCustomization.

When a UFT user creates or edits a bitmap checkpoint, UFT displays any registered custom comparers in the advanced settings in the Bitmap Checkpoint Properties dialog box (in addition to the UFT default comparer). The user can then select a comparer according to the testing requirements of the specific application or bitmap being tested. For more details about using custom comparers in UFT, see Fine-tuning the bitmap comparison.

You can find an example of a situation where developing a custom comparer enhanced the use of bitmap checkpoints, in Custom comparer for images whose location changes - Use-case scenario.