Functional Tester cuenta con un conjunto de SubItems predefinido que el proxy puede usar durante la grabación. Durante la grabación, el proxy determina el SubItem en un punto y envía los detalles del SubItem junto con el método de acción de usuario para TestObject. Durante la reproducción, el proxy vuelve a determinar las coordenadas para el SubItem y la acción del usuario se reproduce.
listBox.click(atText("Item1"));
En este ejemplo, click es el suceso. El parámetro atText("Item1") es el subItem que el proxy encuentra en el punto. En el caso de .Net, la API GetActionArgs() devuelve uno o varios SubItems del control. La determinación del SubItem que se utilizará depende específicamente del control.
El siguiente ejemplo muestra la implementación de Java correspondiente a los métodos de grabación con SubItems:
{
.
.
Vector args = new Vector(20);
SubItem subItem = null;
IMouseEventInfo event0 = action.getEventInfo(0);
Point firstPoint = new Point ( event0.getX(), event0.getY() );
Point firstPointToList = new Point ( firstPoint.x, firstPoint.y );
int itemIndex = locationToIndex(firstPointToList);
String itemText = ((java.awt.List)theTestObject).getItem(itemIndex);
if (itemText!= null && ! itemText.equals("") )
subItem = new Text(item);
else
subItem = new Index(atIndex);
.
.
args.addElement(subItem);
.
.
}
El siguiente ejemplo muestra la implementación de .Net correspondiente a los métodos de grabación con SubItems:
protected override System.Collections.ArrayList GetActionArgs(System.Drawing.Point point)
{
System.Collections.ArrayList args = new System.Collections.ArrayList() ;
Subitem subitem = null ;
System.Drawing.Point clientPoint = ((Control)theTestObject).PointToClient(point) ;
int itemIndex = ((ListBox)theTestObject).IndexFromPoint(clientPoint) ;
string itemText = ((ListBox)theTestObject).GetItemText(item);
if (itemText == null || itemText.Length == 0)
{
// item has no text so generate an index
subitem = new Rational.Test.Ft.Script.Index(itemIndex) ;
}
if ( subitem != null )
{
args.Add(subitem) ;
}
return args ;
}
El siguiente ejemplo muestra la implementación de Java correspondiente a los métodos de reproducción con SubItems:
public void click(MouseModifiers modifiers, Subitem subitem)
{
.
.
Point pt = this.getScreenPoint(subitem);
new Screen().click( modifiers, pt);
.
.
}
public java.awt.Rectangle getScreenPoint (Subitem subitem)
{
int index = getItemIndex(subitem);
if ( index == -1 )
return null;
java.awt.Rectangle rectCell = getCellBounds(index);
java.awt.Rectangle rectScreen = this.getScreenRectangle();
return new java.awt.Rectangle
( rectScreen.x + rectCell.x, rectScreen.y + rectCell.y,
rectCell.width, rectCell.height );
}
El siguiente ejemplo muestra la implementación de .Net correspondiente a los métodos de reproducción con SubItems:
protected override System.Drawing.Rectangle GetSubitemRect(Rational.Test.Ft.Script.Subitem subitem)
{
int index = GetItemIndex(subitem) ;
return ((ListBox)theTestObject).GetItemRectangle(index) ;
}