Develop 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 One compares the actual and expected bitmaps pixel by pixel and fails if there are any differences. UFT One 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 One computer. A UFT One 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 One provides in a type library, and register to the component category that UFT One defines for bitmap comparers. The type library (BitmapComparer.tlb) and the category ID (defined in ComponentCategory.h) are available in <UFT_One_installdir>\dat\BitmapCPCustomization.
When a UFT One user creates or edits a bitmap checkpoint, UFT One displays any registered custom comparers in the advanced settings in the Bitmap Checkpoint Properties dialog box (in addition to the UFT One 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 One, 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.