Planning Support for the ImageButton Control

In this section, you analyze the current UFT support of the ImageButton control, determine the answers to the questions in the Understanding the Custom Class Support Planning Checklist, and fill in the Custom Class Support Planning Checklist , accordingly.

The best way to do this is to run the application containing the custom control, and analyze it from a UFT perspective using the Object Spy, Keyword View, and Record option.

  1. Run the SampleApp application and open UFT.

    1. In the Eclipse Package Explorer tab, right-click SampleApp. Select Run As > Java Application. The SampleApp application opens.

    2. Open UFT and load the Java Add-in.

  2. Use the Object Spy to view the ImageButton properties.

    1. In UFT, open a GUI test and select Tools > Object Spy or click the Object Spy toolbar button to open the Object Spy dialog box. Click the Properties tab.

    2. In the Object Spy dialog box, click the pointing hand , then click the button in the SampleApp application.

      The ImageButton control is based on a custom class that UFT does not recognize. Therefore, it recognizes the button as a generic JavaObject named ImageButton, and the icon shown is the standard JavaObject class icon.

    3. Close the Object Spy.

  3. Record an operation on the ImageButton control.

    1. In UFT select Record > Record and Run Settings to open the Record and Run Settings dialog box. In the Java tab, select Record and run test on any open Java application. If the Web Add-in is also loaded, click the Web tab and select Record and run test on any open browser. Click OK.

    2. Click the Record button or select Record > Record. Click the button in the SampleApp application. The counter value in the edit box increases by one.

      A new step is added to the test.

    3. Click the Stop button or select Record > Stop to end the recording session.

      The Click operation recorded on the ImageButton JavaObject is a generic click, with arguments indicating the low-level recording details (x and y coordinates and the mouse button that performed the click).

  4. Determine the custom toolkit to which the ImageButton control belongs.

    When you extend UFT support for a control you always do so in the context of a toolkit. For the purpose of this tutorial, three classes that share the same ancestor, java.awt.Canvas, are grouped to form the custom toolkit named ImageControls: ImageButton, ImageLabel, and their superclass ImageControl.

    In this lesson you create support for the ImageControls toolkit, initially supporting only the ImageButton class.

  5. Complete the custom class support planning checklist.

    You want UFT to treat the ImageButton as a special kind of button and you want it to support the operation it performs. Therefore it makes sense to create Extensibility support for this control.

    The custom class ImageButton extends another custom class, ImageControl, for which UFT also does not provide support. At this point, there does not seem to be any functionality requiring special UFT support, which ImageButton shares with other classes that extend ImageControl. Therefore it is sufficient to extend support directly to the ImageButton class.

    When fully supported, UFT should recognize the ImageButton control as a JavaButton test object. You want JavaButton test objects representing controls of this type to be named according to the name of the image file that the control displays.

    The custom support should also include support for the simple Click-on-the-button operation. (Note that in UFT, the simple JavaButton Click operation has an optional argument that specifies which mouse button performed the click.) The ImageButton custom class listens for low-level mouse events and substitutes them with events that are more relevant to button behavior, in this case an Action event. Therefore, to record mouse clicks, the support class must listen for Action events.

    You can see the checklist, completed based on the information above.