예를 들어, TextBox 제어에는 지원되는 데이터 유형으로 텍스트 및 선택된 텍스트가 있을 수 있습니다. 이러한 각각의 유형은 프록시가 정의하는 문자열 이름 및 설명과 연관됩니다. 이 이름은 제어 데이터를 가져오기 위해 getTestData(String) API에 전달됩니다. getTestData(String) API 구현 시 적합한 사전 정의 데이터 유형을 사용해야 하며 데이터 유형을 제어 데이터로 채우고 이에 따라 적절히 리턴해야 합니다.
다음 클래스 다이어그램은 Functional Tester에서 사용 가능한 사전 정의된 데이터 유형을 표시합니다.
다음 사전 정의된 데이터 유형은 getTestData() 프록시 API 구현 시 사용할 수 있는 데이터 유형의 일부입니다.
TestDataText
TestDataText 유형은 문자열 값을 나타냅니다.
다음 예제 코드는 Java™에서 TestDataText 데이터 유형을 구현하는 방법을 보여줍니다.
import com.rational.test.ft.vp.ITestData; import com.rational.test.ft.vp.impl.TestDataText; ITestData testData = null; testData = new TestDataText( getSelectedText()); return testData ;
다음 예제 코드는 .Net에서 TestDataText 데이터 유형을 구현하는 방법을 보여줍니다.
Rational.Test.Ft.Vp.ITestData testData = null ; object item = ((ComboBox)theTestObject).SelectedItem ; testData = new Rational.Test.Ft.Vp.Impl.TestDataText(((ComboBox)theTestObject).GetItemText(item)); return testData;
TestDataList
TestDataList 유형은 ListBox의 항목 및 표의 단일 열과 같은 항목의 목록을 나타냅니다.
다음 예제 코드는 Java에서 TestDataList 데이터 유형을 구현하는 방법을 보여줍니다.
import com.rational.test.ft.vp.ITestData; import com.rational.test.ft.vp.impl.TestDataElementList; import com.rational.test.ft.vp.impl.TestDataList; Object[] items = getListItemObjects(); TestDataElementList testData = new TestDataElementList(); for ( int i = 0; i < items.length; i ++ ) { if ( items[i] != null ) { testData.add(new TestDataElement(items[i], false)); nonNullValueExist = true; } else testData.add(null); } return (new TestDataList(testData));
다음 예제 코드는 .Net에서 TestDataList 데이터 유형을 구현하는 방법을 보여줍니다.
Rational.Test.Ft.Vp.ITestData testData = null ; string[] itemList = new string[((ComboBox)theTestObject).Items.Count] ; for(int i=0; i < ((ComboBox)theTestObject).Items.Count; i++) { object item = ((ComboBox)theTestObject).Items[i] ; if (item is string) itemList[i] = (string) item ; else itemList[i] = ((ComboBox)theTestObject).GetItemText(item) ; } testData = new Rational.Test.Ft.Vp.Impl.TestDataList(new Rational.Test.Ft.Vp.Impl.TestDataElementList(itemList)) ; return testData;
TestDataTable
TestDataTable 유형은 표 또는 눈금과 같이 제어에 들어 있는 2차원 데이터를 나타냅니다.
다음 예제 코드는 Java에서 TestDataTable 데이터 유형을 구현하는 방법을 보여줍니다.
import com.rational.test.ft.vp.ITestData; import com.rational.test.ft.vp.ITestDataTable; import com.rational.test.ft.vp.impl.TestDataTable; import com.rational.test.ft.vp.impl.TestDataTableRegion; . . int rowCount = getRowCount(); int colCount = getColumnCount(); object[] rowElements; rowElements = new object[colCount]; for (int row = 0; row < rowCount; ++row) { for (int col = 0; col < colCount; ++col) { object item = this.getItemText(row, col); if (item != null) rowElements[col] = item.ToString(); } testData.add(rowElements); } for (int col = 0; col < colCount; ++col) { object item = this.getColumnName(col); if (item != null) data.setColumnHeader(col, header); } testData.addComparisonRegion(TestDataTableRegion.allCells()); testData.setCompareBothByLeftRegions(true); return testData;
다음 예제 코드는 .Net에서 TestDataTable 데이터 유형을 구현하는 방법을 보여줍니다.
Rational.Test.Ft.Vp.ITestData testData = null; System.Data.DataTable dataTable = GetControlData(); int colCount = dataTable.Columns.Count; int rowCount = dataTable.Rows.Count; object[] rowElements; rowElements = new object[colCount]; for (int row = 0; row < rowCount; ++row) { for (int col = 0; col < colCount; ++col) { object item = null; item = dataTable.Rows[row][col]; if (item != null) item = item.ToString(); rowElements[col] = item; } testData.Add(rowElements); } for (int col = 0; col < colCount; ++col) { string columnName = dataTable.Columns[col].ColumnName; if (columnName != null && !columnName.Equals(string.Empty)) testData.SetColumnHeader(col, columnName); } testData.AddComparisonRegion(TestDataTableRegion.AllCells()); testData.SetCompareBothByLeftRegions(true); return testData;
TestDataTree
TestDataTree 유형은 트리 데이터 구조를 나타냅니다.
다음 예제 코드는 .Net에서 TestDataTree 데이터 유형을 구현하는 방법을 보여줍니다.
public override Rational.Test.Ft.Vp.ITestData GetTestData(string testDataType) { . . Rational.Test.Ft.Vp.ITestData testData = new TestDataTree(GetRootNodes()); return testData; . . } private ITestDataTreeNodes GetRootNodes() { System.Collections.ArrayList nodeCache = new System.Collections.ArrayList(80); System.Windows.Forms.TreeNodeCollection rootNodes = ((TreeView)this.theTestObject).Nodes; if ( rootNodes != null && rootNodes.Count > 0 ) { for ( int i = 0; i < children.Length; ++i ) { nodeCache.Add(GetNode(children[i], null)); } } ITestDataTreeNode[] nodes = new TestDataTreeNode[nodeCache.Count]; System.Array array = nodeCache.ToArray(); for ( int i = 0; i < array.Length; ++i ) { nodes[i] = (ITestDataTreeNode)array.GetValue(i); } TestDataTreeNodes testNodes = new TestDataTreeNodes(nodes); return testNodes; } // Gets called by GetRootNodes() private ITestDataTreeNode GetNode(System.Object item, ITestDataTreeNode parent) { String text = ((TreeNode)item).Text; ITestDataTreeAttributes attr = new TestDataTreeAttributes(text); ITestDataTreeNode node = new TestDataTreeNode(parent, text, null, false); System.Collections.ArrayList nodeCache = new System.Collections.ArrayList(20); System.Windows.Forms.TreeNodeCollection childrenNodes = ((TreeNode)item).Nodes; if ( childrenNodes != null && childrenNodes.Count > 0 ) { int length = childrenNodes.Count; if ( length > 0 ) { for ( int i = 0; i < length; ++i ) { nodeCache.Add(GetNode(children[i], node)); } int size = nodeCache.Count; if ( size > 0 ) { ITestDataTreeNode[] childNodes = new ITestDataTreeNode[size]; System.Array array = nodeCache.ToArray(); for ( int i = 0;i < size; i ++ ) childNodes[i] = (ITestDataTreeNode)array.GetValue(i); node.SetChildren(childNodes); } } } return node; }