Use the bitmap checkpoint custom comparer samples

Relevant for: GUI tests and components

This task describes how to generate the sample custom comparer, and then register it and work with it.

  1. Prerequisites

    Decide whether you want to use the sample C++ project or the Visual Basic one.

    The samples are located under <UFT One installation folder>\samples\BitmapCPSample.

  2. Generate the sample comparer

    1. To open the sample project, do one of the following:

      • To open the C++ project, use Microsoft Visual Studio 2005 or later.

      • To open the Visual Basic project, use Microsoft Visual Studio 6.0.

    2. Compile the custom comparer, to build the .dll.

      Note: If you are using Microsoft Visual Studio 2010 to compile the C++ project, make the following modification before compiling: Open the stdafx.h file in <UFT One installation folder>\samples\BitmapCPSample\CPPCustomComparer, locate the line #define _WIN32_WINNT 0x0400 and change it to #define _WIN32_WINNT 0x0501.

    Back to top

  3. Install the custom comparer on a UFT One computer

    Run the custom comparer using the regsvr32.exe program to install it on the computer.

    Back to top

  4. Register the custom comparer to the component category

    If you are using the C++ sample project

    The C++ sample sources implement registering the custom comparer to UFT One in the DllRegisterServer and DllUnregisterServer methods.

    Therefore, if you used the C++ project to create the .dll, running the .dll (in the previous step) will also register the custom comparer.

    Note: The name displayed for the Visual Basic custom comparer in UFT One will be its ProgId—VBCustomComparer.BitmapComparer. For details on modifying this name, see Set the Custom Comparer Name - Optional.

    If you are using the Visual Basic sample project

    The Visual Basic sample project does not implement this registration.

    Therefore, the Visual Basic sample also includes an additional tool that you must run after installing the custom comparer, to register the custom comparer to the component category for UFT One bitmap comparers.

    For more details, see Install your custom comparer and register it to UFT One.

    You can run the Visual Basic Comparer Registration Tool from <UFT One installation folder>\samples\BitmapCPSample\VBCustomComparer\RegisterCategory.exe.

    In the dialog box that opens, enter the ProgID of the custom comparer and click Register.

    Note: The name displayed for the Visual Basic custom comparer in UFT One will be its ProgId—VBCustomComparer.BitmapComparer. For details on modifying this name, see Set the Custom Comparer Name - Optional.

    Back to top

  5. Study the custom comparer functionality

    Create bitmap checkpoint steps in a test or component in UFT One. In the advanced settings in the Bitmap Checkpoint Properties dialog box, you can select the sample custom comparer and use it to perform bitmap checkpoints.

    1. Note the customized information that is displayed in the dialog box when you select the custom comparer.

      • The default configuration string that the sample comparer returns (and UFT One displays in the Bitmap Checkpoint Properties dialog box) is MaxSurfAreaDiff=140000.

      • The documentation provided with this sample comparer (and opened from the Bitmap Checkpoint Properties dialog box) is the SampleComparerDetails.txt text file located in <UFT One installation folder>\samples\BitmapCPSample\CPPCustomComparer.

    2. Run bitmap checkpoints to test the behavior of the sample comparer. For example, you can run checkpoints on the Windows Calculator application, alternately setting the Calculator view to Standard or Scientific, to obtain different size bitmaps for the same object.

      The sample custom comparer does not compare the content of the actual and expected bitmaps. It compares the total number of pixels they contain. For configuration input, this comparer expects a string that defines the MaxSurfAreaDiff parameter. The comparer fails the checkpoint if the difference in total number of pixels is greater than the number defined for MaxSurfAreaDiff.

    3. View the results of your checkpoint in the run results.

      This sample bitmap custom comparer returns the actual bitmap as the difference bitmap. In addition, it provides a text string that specifies the difference in total number of pixels. UFT One displays this string in the run results.

    Back to top