RSS
 

Archive for August, 2010

#19: Test expandable ListView in Windows Applications

31 Aug

In post#11, post#12, and post#14, we talked about how to test TreeView in Windows Applications. In this post, we will discuss how to test ListView in a Windows Application.

What is the difference between Windows ListView and Windows TreeView? To see the definitions and illustrations of Windows ListView and Windows TreeView, please click the link.

Compare the TreeView mentioned in post#14, and the ListView displayed in this post: the ListView can be considered as a table which contains multiple rows and columns, while the TreeView is a list which has only one column but many rows. In the ListView, there are Study rows, Series rows and Image rows. Expand the Study, then you will see the Series; Expand the Series, then you will see the images. The Study names are the Package names, and the Series names are the Protocol names. Each Study/Package name is unique, and so does the Series/Protocol names. By default, the Images do not have names, that is why the “Name” column for images is empty, but the “Mode” column for each image has a unique Mode name withing one Series (not unique across multiple Series). On the other hand, the “Mode” column is empty for Study and Series rows. It looks like there are 3 levels within the ListView, i.e., Study – Series – Image. However, after you do a simple recording on this ListView, you will find out that Study, Series and Image are treated equally in the script (i.e., no path). This is different than the TreeView, which support nodes from multiple levels in the script, such as path = parent node/current node/child node.

The script below will load images one by one from the Study Browser (see the Workstation pic above) as the order mentioned in the ModeCategoryUnit sheet from the Measurement.xlsx (see Excel pic above) .

'$TPinclude "Declaration_GlobalConstants"

Sub Main()

'Import data from Measurement.xlsx's ModeCategoryUnit sheet to array SheetData()
Dim RowCount As Integer
Dim ColumnCount As Integer
Dim SheetData() As String 'Dynamic array

RowCount = Function_ExcelSheetRowCount.ExcelSheetRowCount(ExcelFilePath_Measurement, "ModeCategoryUnit")
ColumnCount = Function_ExcelSheetColumnCount.ExcelSheetColumnCount(ExcelFilePath_Measurement, "ModeCategoryUnit")

ReDim SheetData(RowCount, ColumnCount) As String    'Array is sized dynamically

SheetData() = Function_GetExcelSheetData.GetExcelSheetData(ExcelFilePath_Measurement, "ModeCategoryUnit")

'From Study Browser, open Images from different Study and Series
Dim Study_Package As String 'Study names are the Package names
Dim Series_Protocol As String    'Series names are the Protocol names
Dim Image_Mode As String    'Image names are the Mode names
Dim j As Integer
Dim Count As Integer

'Open the workstation
    ProgramManagerWindow("Application=EXPLORER.EXE Caption='Program Manager'").Attach
        ListView("Index=1").Select "the workstation", tpMouseDoubleClick

'Attach to the workstation
    Window("the workstation").Attach
        For j = 1 To ColumnCount Step 3

            'Inside Study Browser, load the Image_Mode from the correct Study and Series
            Study_Package = SheetData(1, j)
            Series_Protocol = SheetData(2, j)
            Image_Mode = SheetData(3, j)

            'If can not find the Series_Protocol, then the Study_Package needs to be expanded
            If ListView("Parent.Caption='Study Browser'").FindItem(Series_Protocol) = 0 Then
                ListView("Parent.Caption='Study Browser'").Select (Study_Package)
            End If

            'If the mode column (i.e., the 6th column) of the row after Series_Protocol is empty
            'then the row is either a Series or a Study
            'the Series_Protocol needs to be expanded to see all the Image_Modes
            Count = ListView("Parent.Caption='Study Browser'").FindItem(Series_Protocol)
            If ListView("Parent.Caption='Study Browser'").GetItem(Count + 1, 6) = "" Then
                ListView("Parent.Caption='Study Browser'").Select (Series_Protocol), tpMouseDoubleClick
            End If

            'Search to load the Image_Mode in between the Series_Protocol and next Series/Study
            Do While ListView("Parent.Caption='Study Browser'").GetItem(Count + 1, 6) <> ""
                If ListView("Parent.Caption='Study Browser'").GetItem(Count + 1, 6) = Image_Mode Then
                    ListView("Parent.Caption='Study Browser'").SelectIndex (Count + 1), tpMouseDoubleClick
                    Exit Do
                Else
                    Count = Count + 1
                End If
            Loop

            'Switch back to Study Browser
            Button("Caption=B").Click
        Next

End Sub

In the above script you saw the following TListView methods (“TListView” means “TestPartner ListView”. The methods for “TListView” are based on Windows standard ListView methods but not exactly the same. Please check TestPartner Help for more details):
1, ListView.FindItem
Locates an item in a control such a list box or a combo box, and returns its location.
variable = object.FindItem( SearchItem As String ) As Long
(Item must be in the first column (i.e., “Name” column). If Item can NOT be found, returns zero.)

2, ListView.Select
Selects an item in the control exposed by the object.
variable = object.Select( Item As String, [Flags As tpMouseFlags = tpMouseSingleClick], [X As Long = -32767], [Y As Long = -32767] ) As Boolean
(Item must be in the first column (i.e., “Name” column). If the identification column is NOT the first column or the first column is empty, then use ListView.SelectIndex to select, see #4 below)

3, ListView.GetItem
Returns the text of an item in a control based on its position in the table or menu in which the item appears.
variable = object.GetItem( Row As Long, [Column As Long=1] ) As String
(Item can be anywhere inside the ListView, identified by its row and column number)

4, ListView.SelectIndex
Selects an item in a control using its index (position) e.g. list boxes, combo boxes.
variable = object.SelectIndex( ItemIndex As Long, [Flags As tpMouseFlags = tpMouseSingleClick], [X As Long = -32767], [Y As Long = -32767] ) As Boolean
(If the identification column is NOT the first column of the ListView or the first column is empty, then use ListView.SelectIndex to select. Otherwise, use ListView.Select to select, see #2 above. For example, in the above Workstation pic, the highlighted B-Mode has an index number 10.)

 
No Comments

Posted by Jia Qi in TestPartner (TP)

 

#18: TestPartner is not compatible with the currently installed VBA

25 Aug

Sometimes, when you try to launch TestPartner, you may get a pop up message saying “TestPartner is not compatible with the currently installed version of VBA (6.5.****)”.

This is because when you updated your windows, your VBA got updated too, and the new VBA version is no longer compatible with your TestPartner version.

There are 2 solutions for you: upgrade your TestPartner, or downgrade your VBA.

To upgrade your TestPartner, please contact Micro Focus/Compuware. This will cost you money.

To downgrade your VBA, please find the correct VBA version for your TestPartner (e.g., TP 6.3 supports VBA 6.5.1040), then find the DLL file for this VBA version (e.g., VBE6.DLL for VBA 6.5.1040), then replace the DLL file at C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6.

Here is the VBE6.DLL for VBA 6.5.1040 for you to download

 
No Comments

Posted by Jia Qi in TestPartner (TP)