Inspectable

com.froglogic.squish.extension.Inspectable

Interface Inspectable — This interface needs to be implemented for custom Java support in Squish.

Synopsis

public interface com.froglogic.squish.extension.Inspectable {

// Public Methods
  public abstract boolean findObjects(com.froglogic.squish.extension.ObjectQuery query,
                                      int n,
                                      java.util.AbstractList matches);
  public abstract boolean findObjects(com.froglogic.squish.extension.ObjectQuery query,
                                      java.lang.Object obj,
                                      java.util.AbstractList matches);
  public abstract java.lang.Object getChildAt(com.froglogic.squish.extension.Point pos);
  public abstract java.lang.Object[] getChildren();
  public abstract com.froglogic.squish.extension.Rect getGlobalBounds();
  public abstract java.lang.String getName();
  public abstract java.lang.Object getObject();
  public abstract java.lang.Object getParent();
  public abstract java.lang.Object getPropertyValue(java.lang.String prop);
  public abstract boolean isObjectReady();
  public abstract com.froglogic.squish.extension.Point mapFromGlobal(com.froglogic.squish.extension.Point pos);
  public abstract com.froglogic.squish.extension.Point mapToGlobal(com.froglogic.squish.extension.Point pos);
}

Description

This interface needs to be implemented for custom Java support in Squish. When fully implemented it ensures that the custom classes/widgets are shown correctly in the spy, will show a correct highlight rectangle when picking, and can be used to record/playback events on. An Inspectable interface will have to be implemented for each custom class that needs to be known to Squish. These classes can either be stored in the AUT jar or in an external jar. The classes can look like this for an imaginary canvas example:

class MyCanvasItemExtension extends InspectableAdapter
 {
   MyCanvasItem itm;
   public Rect getGlobalBounds()
   {
    ....
 }
 class MyCanvasExtension extends InspectableAdapter
 {
   MyCanvas can;
   public Rect getGlobalBounds()
   {
    ....
 }

After defining such classes for every custom Object that needs to be exposed, these need to be registered into Squish. The way to do it is to create a factory that returns the right Inspectable for the given object:

class MyCanvasFactory implements InspectableFactory
 {
     public Inspectable query( Object object )
     {
         if ( object instanceof MyCanvas ) {
             return new MyCanvasExtension( object );
         } else {
      ....
     }

Now we have the factory we need an init hook which registers the factory into the registry:

public static void init( InspectableRegistry registry )
      {
          registry.register( new MyCanvasFactory() );
      }
  }

Also, in the manifest file for the jar where the above extensions are stored, there needs to be an extra entry so that Squish can find the init method:

Extension: MyCanvasFactory

Finally, we let Squish know about the new wrapped classes through the .ini file. See Wrapping custom Java classes in the reference guide. The same .ini file should be used to let Squish know the location of the extension jar file generated above. An entry can look like this: JavaExtensionDir="/home/squish/extensions/", "/home/squish/mycanvas"

See Also: com.froglogic.squish.extension.InspectableAdapter, com.froglogic.squish.extension.InspectableFactory, com.froglogic.squish.extension.InspectableRegistry

Methods

findObjects(ObjectQuery, int, AbstractList)

public abstract boolean findObjects(com.froglogic.squish.extension.ObjectQuery query, int n, java.util.AbstractList matches);

Parameters
queryObjectQuery object
nno more then n objects need to be found
matcheslist that matches the query in order of found
returntrue if n objects are in the list

Find and add objects that matches query in a list. The search should end if list contains n objects. This function is used for finding the n-th reoccurrence of an object.

Important: This function is subject to change at any time. Use the InspectableAdapter default implementation, unless there are good reasons not to.

findObjects(ObjectQuery, Object, AbstractList)

public abstract boolean findObjects(com.froglogic.squish.extension.ObjectQuery query, java.lang.Object obj, java.util.AbstractList matches);

Parameters
queryObjectQuery object
objstop searching up until obj is found
matchesobjects that matches the query in order of found
returntrue if obj is in the list

Find and add objects that matches query in a list. The search should end after obj is found. This function is used for finding the occurrence property of an object.

Important: This function is subject to change at any time. Use the InspectableAdapter default implementation, unless there are good reasons not to.

getChildAt(Point)

public abstract java.lang.Object getChildAt(com.froglogic.squish.extension.Point pos);

Parameters
posthe point to use for hit-testing
returnthe object that is hit

Return the child hit at position pos. Containers should return the exact child that is hit if it supports recording at that level of detail (for instance canvasses). The hit child can also be an indirect child, for instance a child of a child of the container. The coordinates are relative to the wrapped object. In case no child is at pos, null should be returned.

getChildren()

public abstract java.lang.Object[] getChildren();

Parameters
returnarray of all children

Return all children of the wrapped object. In case of zero children, an empty array should be returned (not 'null' but 'new Object[]{}')

getGlobalBounds()

public abstract com.froglogic.squish.extension.Rect getGlobalBounds();

Parameters
returnthe bounds as a Rect

Gets the bounds of this component in the form of a Rect object. The bounds specify this component's width, height, and location relative to its container, all in the container's coordinate system.

getName()

public abstract java.lang.String getName();

Parameters
returnthe name

Return the name of this object.

getObject()

public abstract java.lang.Object getObject();

Parameters
returnthe object

Return the object that this Inspectable inspects.

getParent()

public abstract java.lang.Object getParent();

Parameters
returnthe parent

Return the parent of this object.

getPropertyValue(String)

public abstract java.lang.Object getPropertyValue(java.lang.String prop);

Parameters
propproperty name
returnvalue of this property or null

Return the value of a string property. This function is used for creating an object name for the object map. In the descriptors xml file, any property name "abc" from getter functions "getAbc()" may be added if the object class is known to Squish. For object classes not known to Squish, or if there is not a getter function, this function should return the value instead. Properties marked in the descriptor xml as object, must have a matching Inspectable.

isObjectReady()

public abstract boolean isObjectReady();

Returns true when the wrapped object is ready to receive user input like text for a text field, or button clicks for a button, false otherwise.

mapFromGlobal(Point)

public abstract com.froglogic.squish.extension.Point mapFromGlobal(com.froglogic.squish.extension.Point pos);

Parameters
posthe global coordinate
returnthe converted point

Converts the global/screen coordinates x,y into coordinates local to the wrapped object and returns the result as a Point.

mapToGlobal(Point)

public abstract com.froglogic.squish.extension.Point mapToGlobal(com.froglogic.squish.extension.Point pos);

Parameters
posthe local coordinate
returnthe converted point

Converts the local coordinates x,y into absolute screen coordinates and returns the result as a Point.

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.
The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

Search Results