Searching for GEF objects
Rational® Functional Tester recognizes the GEF EditParts and Palettes. Some Figures may not have an association with an EditPart. You can use Rational® Functional Tester APIs to find such Figures as shown in the below examples.
Example 1: The following example shows how to use getFigure()
API to retrieve a Figure that has the text "label" and is not associated with
EditPart
//Get the figure for an EditPart
GuiTestObject figureTO = EntityEditPart().getFigure();
//Find for a figure that has the text in it.
TestObject foundTO[] = figureTO.find(atDescendant("text", "label"));
if(foundTO != null)
{
int numFound = foundTO.length;
for(int index = 0; index < numFound ; index ++)
{
if(foundTO[index] != null && foundTO[index] instanceof GuiTestObject)
{
//To check for specific property on the figure
Object figWidth = foundTO[index].getProperty("width");
if(figWidth != null)
((GuiTestObject)foundTO[index]).click();
}
}
}
Example 2: The following example shows how to use getConnectors()
API to perform click operation on the connector that has the label "Association"
//List the connectors from the node's parent
TestObject parent = EntityEditPart().getParent();
if(parent != null && parent instanceof GefEditPartTestObject)
{
TestObject connectors[] = ((GefEditPartTestObject)parent).getConnectors();
if(connectors != null)
{
int numConnector = connectors.length;
for(int conIndex = 0; conIndex < numConnector; conIndex ++)
{
if(connectors[conIndex] != null && connectors[conIndex] instanceof GefEditPartTestObject)
{
GuiTestObject figConnector = ((GefEditPartTestObject)connectors[conIndex]).getFigure();
//Find for a figure that has some text in it.
TestObject foundConn[] = figConnector.find(atDescendant("text", "association"));
if(foundConn != null && foundConn.length > 0)
{
//If there is only one label with the text "Association"
if(foundConn[0] != null && foundConn[0] instanceof GuiTestObject)
{
((GuiTestObject)foundConn[0]).click();
}
}
}
}
}
}
Example 3: The following example populates a list with connectors that are descendants to the selected EditPart using the isConnector () API
//Assuming you have "RootEditPart" in the ObjectMap.
ArrayList connList = new ArrayList();
enumerateAllConnectors(RootEditPart(),connList);
}
private static void enumerateAllConnectors(TestObject editPart,ArrayList connList)
{
if(editPart != null )
{
if(editPart instanceof GefEditPartTestObject)
{
boolean isConnector = ((GefEditPartTestObject)editPart).isConnector();
if(isConnector)
connList.add(editPart);
}
TestObject []children = editPart.getChildren();
if(children != null)
{
int numChild = children.length;
for(int i=0; i < numChild ; i++)
{
enumerateAllConnectors(children[i], connList);
}
}
}
}