Understanding the New Custom Support
This topic explains the files and classes included in your newly created custom toolkit support set.
Toolkit Support Set content
Your new UFT One Java Add-in Extensibility custom toolkit support set is composed of:
One toolkit support class: ImageControlsSupport, which is created by the wizard when the ImageControlsSupport project is created, and not changed.
One toolkit configuration file: ImageControls.xml. This file is created by the wizard when the ImageControlsSupport project is created. It is updated with each support class you add for this toolkit.
The ImageControls.xml file is now updated to map the com.demo.ImageButton custom control, to its support class, com.mercury.ftjadin.qtsupport.imagecontrols.cs.ImageButtonCS.
One test object configuration file: ImageControlsTestObjects.xml. Since you did not add any identification properties or test object methods to this the JavaButton test object class, this file does not currently contain any significant information.
For a complete understanding of the structure of this file, see the UFT One Test Object Schema Help.
Custom support classes, one per custom class. In this case, you created one custom support class: ImageButtonCS.
The following sections explain the elements that the wizard creates in the ImageButtonCS class.
Understanding the Basics of the ImageButtonCS Class
The UFT One Java Add-in Extensibility wizard creates the custom support class based on the specifications you entered, and registers it in the toolkit support configuration file.
The two most basic characteristics of a support class are:
The support class it extends
The test object class mapped to the custom control
Open ImageButtonCS.java to review the support class that the wizard created for ImageButton.
The first declaration reflects your selection in the wizard to extend the CanvasCS class:
public class ImageButtonCS extends CanvasCS implements ActionListener { private static final String DEBUG_IMAGEBUTTONCS = "DEBUG_IMAGEBUTTONCS"; ... }
Note: DEBUG_IMAGEBUTTONCS is defined to control printing log messages. For more information, see Logging and Debugging the Custom Support Class.
The to_class property, implemented by the to_class_attr method, defines the test object class selected to represent this custom control. UFT One decides the set of identification properties and test object methods for the test object based on this mapping.
public String to_class_attr(Object obj) { return "JavaButton"; }
This implementation is sufficient to provide initial recognition of the custom control in UFT One.
Understanding Identification Property and Test Object Method Support
Each identification property that can be learned for a particular custom control is represented in the support class, by a method called <property name>_attr. Each test object method that can be supported for the control is represented by a method called <test object method name>_replayMethod.
When the wizard creates the support class, it inserts stubs for the required methods, according to the identification properties and test object methods that you selected to implement.
The following method stub was added because you selected to override the label identification property, inherited from CanvasCS, in Creating a New UFT One Custom Support Class:
public String label_attr(Object arg0) { return super.label_attr(arg0); }
The following method stub was added because you selected to implement the Click(Object obj) test object method, in Creating a New UFT One Custom Support Class:
public Retval Click_replayMethod(Object obj, String button) { return Retval.NOT_IMPLEMENTED; }
Understanding Event Recording Support
In the ImageButtonCS class, the following elements provide the basis for event recording:
Low-level recording override (enables recording of higher-level events):
protected Object mouseRecordTarget(MouseEvent e) { return null; }
This method is added because you selected the Override low-level mouse event recording check box in Creating a New UFT One Custom Support Class.
Listing ActionListener for registration on the ImageButton control:
public ImageButtonCS() { addSimpleListener("ActionListener", "addActionListener", "removeActionListener"); }
This constructor method is added because in Creating a New UFT One Custom Support Class, you added the ActionListener to the list of listeners you want to implement.
The constructor calls the addSimpleListener method to add the ActionListener to the list of listeners that need to be registered on the custom control.
Action event handler implementation:
public void actionPerformed(ActionEvent arg0) { try { if (!isInRecord()) return; // TODO: Uncomment and edit the call to MicAPI.record // MicAPI.record(arg0.getSource(), <Operation>, new // String[]{<Parameters>}); } catch (Throwable th) { } }
The wizard creates this method stub without any actual implementation. You implement it when you get to the step for Implementing Event Handler Methods to Support Recording. The method stub contains the try ... catch block and the isInRecord check, providing a recommendation for this method's structure. For more information, see Supporting the Record Option.
Next steps: