I SubItem sono parti definite di un controllo Functional Tester sottoposte a test. In alcuni casi si ottengono risultati ottimali mediante la registrazione dell'interazione utente con dettagli SubItem anziché eseguendo la registrazione con le informazioni delle coordinate. Lo svantaggio dell'uso delle informazioni delle coordinate consiste nel fatto che quando vengono riordinate o modificate le dimensioni di parti di un controllo, la riproduzione delle azioni utente potrebbe non restituire gli stessi risultati.
Functional Tester dispone di una serie di SubItem predefiniti che possono essere utilizzati dai proxy durante la registrazione. Durante la registrazione, il proxy determina il SubItem in un punto e invia i dettagli del SubItem insieme al metodo dell'azione utente per il TestObject. In fase di riproduzione, il proxy determina nuovamente le coordinate per il SubItem e l'azione utente viene riprodotta.
| Java | .Net |
|---|---|
| System.Collections.ArrayList GetActionArgs(System.Drawing.Point point) | void (IMouseActionInfo action) |
| System.Drawing.Rectangle GetSubitemRect(Rational.Test.Ft.Script.Subitem subitem) | java.awt.Rectangle getScreenPoint (Subitem subitem) |
Mentre si registra un evento, viene richiamato il metodo ProcessMouseEvent. Quindi il proxy determina i SubItem appropriati in determinati punti e tali SubItems vengono registrati come parte dell'evento.
listBox.click(atText("Item1"));
In questo esempio, click corrisponde all'evento. Il parametro atText("Item1") è il SubItem che il proxy individua nel punto. In caso di .Net, l'API GetActionArgs() restituisce uno o più SubItem del controllo. La determinazione del SubItem da utilizzare è specifica del controllo.
L'esempio seguente mostra l'implementazione Java dei metodi di registrazione con SubItem:
{
.
.
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);
.
.
}
L'esempio seguente mostra l'implementazione .Net dei metodi di registrazione con SubItem:
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 ;
}
Durante la riproduzione il proxy deve trovare la coordinata dello schermo di un SubItem per riprodurre l'azione utente.
L'esempio seguente mostra l'implementazione Java dei metodi di riproduzione con SubItem:
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 );
}
L'esempio seguente mostra l'implementazione .Net dei metodi di riproduzione con SubItem:
protected override System.Drawing.Rectangle GetSubitemRect(Rational.Test.Ft.Script.Subitem subitem)
{
int index = GetItemIndex(subitem) ;
return ((ListBox)theTestObject).GetItemRectangle(index) ;
}