Interface Inspectable — This interface needs to be implemented for custom Java support in Squish.
public interface com.froglogic.squish.extension.Inspectable {
// Public Methodspublic boolean findObjects(ObjectQuery query,
int n,
java.util.AbstractList matches);public boolean findObjects(ObjectQuery query,
Object obj,
java.util.AbstractList matches);public Object getChildAt(Point pos);public Object[] getChildren();public Rect getGlobalBounds();public String getName();public Object getObject();public Object getParent();public Object getPropertyValue(String prop);public boolean isObjectReady();public Point mapFromGlobal(Point pos);public Point mapToGlobal(Point pos);
}
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, in order to let Squish know the wrapped custom Java classes better, it is encouraged to let Squish know the new wrapped classes better through the .ini file. See Wrapping custom Java classes in the user 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"
public boolean findObjects(ObjectQuery query,
int n,
java.util.AbstractList matches);Parameters
query
ObjectQuery object
n
no more then n objects need to be found
matches
list that matches the query in order of found
true 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.
public boolean findObjects(ObjectQuery query,
Object obj,
java.util.AbstractList matches);Parameters
query
ObjectQuery object
obj
stop searching up until obj is found
matches
objects that matches the query in order of found
true 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.
public Object getChildAt(Point pos);Parameters
pos
the point to use for hit-testing
the 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.
public Object[] getChildren();Parameters
array of all children
Return all children of the wrapped object.
public Rect getGlobalBounds();Parameters
the 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.
public Object getObject();Parameters
the object
Return the object that this Inspectable inspects.
public Object getPropertyValue(String prop);Parameters
prop
property name
value 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.
public 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.