Functional Tester has set of predefined SubItems and proxy can use them during recording. During recording, proxy determines the SubItem at a point and sends the SubItem details along with the user action method for the TestObject. At playback time, the proxy again determines the coordinate for the SubItem and the user action is played back.
listBox.click(atText("Item1"));
In this example, click is the event. The atText("Item1") parameter is the subItem that the proxy finds at the point. In case of .Net, the GetActionArgs() API returns one or more SubItems of the control. Determining which SubItem to use is specific to the control.
The following example shows the Java implementation of recording methods with 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); . . }
The following example shows the .Net implementation of recording methods with 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 ; }
The following example shows the Java implementation of playing back methods with 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 ); }
The following example shows the .Net implementation of playing back methods with SubItems:
protected override System.Drawing.Rectangle GetSubitemRect(Rational.Test.Ft.Script.Subitem subitem) { int index = GetItemIndex(subitem) ; return ((ListBox)theTestObject).GetItemRectangle(index) ; }