Using QuickTest Professional 10.00 you can develop custom comparers for bitmap checkpoints. A custom comparer is a COM object that performs the bitmap comparison for the checkpoint according to your testing requirements. For example, you could define a custom comparer that allows a bitmap checkpoint to pass even if the image in the application shifts by an amount specified when the checkpoint is defined.
After you install and register a custom comparer on the QuickTest computer, your comparer is available for selection in the Bitmap Checkpoint Properties dialog box. The dialog box provides space for specifying additional configuration preferences expected by your comparer.
When QuickTest performs a bitmap checkpoint that uses a custom comparer, it supplies the expected and actual bitmaps to the custom comparer object. It then receives and reports the results that the custom comparer returns.
To develop a custom comparer, you -create a COM object that implements the QuickTest bitmap checkpoint comparer interfaces to perform the following tasks:
– Accept input from QuickTest and perform the bitmap comparison.
– Provide comparison results to QuickTest.
– Provide information that QuickTest can display in the Bitmap Checkpoint Properties dialog box when a user creates or edits a bitmap checkpoint.
Creating a custom comparer in C++ using Microsoft Visual Studio:
1. In Microsoft Visual Studio, select New > Project. The New Project dialog box opens.
2. Select the ATL Project template, enter SampleCPPCustomComparer in the Name box for the project, and click OK. The New ATL Project wizard opens.
3. In Application Settings, make sure that the Attributed option is not selected, and click Finish.
4. In the class view, select the SampleCPPCustomComparer project, right-click, and select Add > Class. The Add Class dialog box opens.
5. Select ATL Simple Object and click Add. The ATL Simple Object Wizard opens.
6. In the Short name box, enter BitmapComparer. The wizard uses this name to create the names of the class, the interface, and the files that it creates.
7. In the Type box, enter Sample Custom Comparer. This is the custom comparer name that QuickTest will display in the Bitmap Checkpoint Properties dialog box and in the test results.
8. Click Finish. The wizard creates the necessary files for the class that you added, including .cpp and .h files with implementation of CBitmapComparer class.
9. In the class view, select CBitmapComparer, right-click, and select Add > Implement Interface. The Implement Interface wizard opens.
10. In the Implement interface from option, select File. Browse to or enter the location of the QuickTest bitmap checkpoint comparer type library. The type library is located in: \dat\BitmapCPCustomization\BitmapComparer.tlb.
The wizard displays the interfaces available in the selected type library, IBitmapCompareConfiguration and IVerifyBitmap.
11. Add both interfaces to the list of interfaces to implement, and click Finish.
In the BitmapComparer.h file, the wizard adds the declarations, classes, and method stubs that are necessary to implement the interfaces. In subsequent steps you will need to add implementation to these method stubs.
Please note that in Microsoft Visual Studio 2005, the wizard generates the signature for the CompareBitmaps method in the IVerifyBitmap interface incorrectly. To enable your project to compile correctly, manually change the type of the last argument (pbMatch) from BOOL* to VARIANT_BOOL*.
12. Open the BitmapComparer.h and BitmapComparer.cpp files.
13. In BitmapComparer.h, create declarations for the bitmap checkpoint comparer interface methods (based on the function bodies that the wizard created): CompareBitmaps, GetDefaultConfigurationString, and GetHelpFilename.
14. Move the function bodies that the wizard created for the bitmap checkpoint comparer interface methods from the BitmapComparer.h file to the BitmapComparer.cpp file.
15. For QuickTest to recognize the COM object that you create as a custom comparer, you must register it to the component category for QuickTest bitmap comparers. The component category ID is defined in \dat\BitmapCPCustomization\ComponentCategory.h.
You can implement this registration in the DllRegisterServer and DllUnregisterServer methods in the SampleCPPCustomComparer.cpp file that the wizard created as part of your project. These methods are called when you run a DLL using the regsvr32.exe program.
– Add the \dat\BitmapCPCustomization folder to your project’s include path.
– Open the SampleCPPCustomComparer.cpp file and add the following line: #include “ComponentCategory.h”
– In the SampleCPPCustomComparer.cpp file, modify the DllRegisterServer and DllUnregisterServer methods created by the wizard.
Your custom comparer can now be used in QuickTest for bitmap checkpoints by using the following steps:
a. Open QuickTest and create a bitmap checkpoint on the Windows Calculator application (Standard view).The Bitmap Checkpoint Properties dialog box includes the Comparer option, in which you can select the QuickTest default comparer or your sample custom comparer.
b. Change the Calculator view to Scientific. The size of the calculator object is now larger. Run the checkpoint using the default QuickTest comparer. The checkpoint fails.
c. Edit the checkpoint and select Sample Custom Comparer in the Comparer box.