summaryrefslogtreecommitdiff
path: root/testautomation/global/tools/includes/optional/t_treelist_tools.inc
diff options
context:
space:
mode:
Diffstat (limited to 'testautomation/global/tools/includes/optional/t_treelist_tools.inc')
-rwxr-xr-xtestautomation/global/tools/includes/optional/t_treelist_tools.inc153
1 files changed, 58 insertions, 95 deletions
diff --git a/testautomation/global/tools/includes/optional/t_treelist_tools.inc b/testautomation/global/tools/includes/optional/t_treelist_tools.inc
index 36cfe7370901..5477022dc160 100755
--- a/testautomation/global/tools/includes/optional/t_treelist_tools.inc
+++ b/testautomation/global/tools/includes/optional/t_treelist_tools.inc
@@ -25,14 +25,12 @@
'
'/************************************************************************
'*
-'* owner : joerg.skottke@sun.com
+'* owner : joerg.skottke@oracle.com
'*
'* short description : Helpers for accessing treelists
'*
'\******************************************************************************
-private const DEBUG_ENABLE = false
-
function hGetNodeCount( oControl as object ) as integer
'///<h3>Retrieve the number of visible (open) nodes from a treelist</h3>
@@ -56,6 +54,7 @@ function hGetNodeCount( oControl as object ) as integer
const CFN = "hGetNodeCount::"
+ const RETVAL_FAILURE = 0
dim iCount as integer
'///+<li>Verify that the control exists</li>
@@ -64,15 +63,13 @@ function hGetNodeCount( oControl as object ) as integer
'///+<li>Verify that the control is enabled</li>
if ( oControl.isEnabled() ) then
- if ( DEBUG_ENABLE ) then
- printlog( CFN & "Regular access, control available and enabled" )
- endif
+ if ( GVERBOSE ) then printlog( CFN & "Regular access, control available and enabled" )
'///+<li>get the number of items from the control</li>
iCount = oControl.getItemCount()
else
printlog( CFN & "Failure: Control claims to be disabled." )
- iCount = 0
+ iCount = RETVAL_FAILURE
endif
else
try
@@ -80,12 +77,12 @@ function hGetNodeCount( oControl as object ) as integer
iCount = oControl.getItemCount()
catch
printlog( CFN & "Failure: Control not available." )
- iCount = 0
+ iCount = RETVAL_FAILURE
endcatch
endif
- if ( DEBUG_ENABLE ) then
- printlog( CFN & "Exit with nodecount = " & iCount )
- endif
+
+ if ( GVERBOSE ) then printlog( CFN & "Exit with nodecount = " & iCount )
+
hGetNodeCount = iCount
'///</ul>
@@ -111,9 +108,7 @@ function hSelectTopNode( oControl as object ) as boolean
hSelectTopNode() = false
endcatch
- if ( DEBUG_ENABLE ) then
- printlog( CFN & "Selected Node: " & oControl.getText() )
- endif
+ if ( GVERBOSE ) then printlog( CFN & "Selected Node: " & oControl.getText() )
end function
@@ -137,13 +132,9 @@ function hSelectNextNode( oControl as object ) as integer
iPosAfter = oControl.getSelIndex()
- if ( iPosAfter = iPosBefore ) then
- hSelectNextNode() = 0
- endif
+ if ( iPosAfter = iPosBefore ) then hSelectNextNode() = 0
- if ( iPosAfter = ( iPosBefore + 1 ) ) then
- hSelectnextNode() = iPosAfter
- endif
+ if ( iPosAfter = ( iPosBefore + 1 ) ) then hSelectNextNode() = iPosAfter
printlog( CFN & "Selected node: " & oControl.getText() )
@@ -179,19 +170,19 @@ function hExpandNode( oControl as object, iNode as integer ) as integer
'///<ul>
'///+<li>Returns new nodecount or 0 on error</li>
'///</ul>
-
+ const RC_FAILURE = 0
const CFN = "hExpandNode::"
dim iOldNodeCount as integer
- if ( DEBUG_ENABLE ) then
+ if ( GVERBOSE ) then
printlog( CFN & "Enter with option (Control): " & oControl.name() )
printlog( CFN & "Enter with option (iNode): " & iNode )
endif
iOldNodeCount = hGetNodeCount( oControl )
if ( iNode <= iOldNodeCount ) then
- if ( iNode > 0 ) then
+ if ( iNode > RC_FAILURE ) then
oControl.select( iNode )
endif
try
@@ -199,10 +190,10 @@ function hExpandNode( oControl as object, iNode as integer ) as integer
hExpandNode() = hGetNodeCount( oControl )
catch
warnlog( "#i84194# Treelist access failed (Keyboard navigation)" )
- hExpandNode() = 0
+ hExpandNode() = RC_FAILURE
endcatch
else
- hExpandNode() = 0
+ hExpandNode() = RC_FAILURE
endif
end function
@@ -229,7 +220,7 @@ function hExpandAllNodes( oControl as object ) as integer
iNodeRefCount = -1
iIteration = 0
- if ( DEBUG_ENABLE ) then
+ if ( GVERBOSE ) then
printlog( CFN & "Initial iNodeCurCount: " & iNodeCurCount )
printlog( CFN & "Initial iNodeRefCount: " & iNodeRefCount )
endif
@@ -245,7 +236,7 @@ function hExpandAllNodes( oControl as object ) as integer
iNodeCurCount = hGetNodeCount( oControl )
- if ( DEBUG_ENABLE ) then
+ if ( GVERBOSE ) then
printlog( "" )
printlog( CFN & "Exit iteration....: " & iIteration )
printlog( CFN & "Exit iNodeCurCount: " & iNodeCurCount )
@@ -254,7 +245,7 @@ function hExpandAllNodes( oControl as object ) as integer
loop
- if ( DEBUG_ENABLE ) then
+ if ( GVERBOSE ) then
printlog( CFN & "Exit with " & iNodeCurCount & _
" items after " & iIteration & " iterations" )
endif
@@ -282,7 +273,7 @@ function hGetVisibleNodeNames( oControl as object , lsList() as string ) as inte
dim iNodeCount as integer
dim iThisNode as integer
- printlog( CFN & "Enter" )
+ if ( GVERBOSE ) then printlog( CFN & "Enter" )
iNodeCount = hGetNodeCount( oControl )
@@ -298,7 +289,7 @@ function hGetVisibleNodeNames( oControl as object , lsList() as string ) as inte
endif
hGetVisibleNodeNames() = listcount( lsList() )
- printlog( CFN & "Exit" )
+ if ( GVERBOSE ) then printlog( CFN & "Exit" )
end function
@@ -327,6 +318,7 @@ function hSelectNodeByName( oControl as object , _name as string ) as integer
'///</ul>
const CFN = "hSelectNodeByName::"
+ const RETVAL_FAILURE = 0
dim iThisNode as integer
dim iCurrentNode as integer
@@ -334,9 +326,9 @@ function hSelectNodeByName( oControl as object , _name as string ) as integer
dim cNodeName as string
- printlog( CFN & "Enter with option (NodeName): " & _name )
+ if ( GVERBOSE ) then printlog( CFN & "Enter with option (NodeName): " & _name )
- iThisNode = 0
+ iThisNode = RETVAL_FAILURE
' First we try to jump to the node directly, if this fails we use the
' slower but safer method (expand all nodes and step through)
@@ -369,10 +361,10 @@ function hSelectNodeByName( oControl as object , _name as string ) as integer
next iCurrentNode
endcatch
- if ( iThisNode = 0 ) then
+ if ( iThisNode = RETVAL_FAILURE ) then
printlog( CFN & "Exit: Node not found." )
else
- printlog( CFN & "Exit: Node selected at pos: " & iThisNode )
+ if ( GVERBOSE ) then printlog( CFN & "Exit: Node selected at pos: " & iThisNode )
endif
hSelectNodeByName() = iThisNode
@@ -393,23 +385,17 @@ function hSelectTheLastNode( oControl as object ) as integer
const CFN = "hSelectTheLastNode::"
dim iCurrentNodeCount as integer
- printlog( CFN & "Enter with option (control): " & oControl.name() )
-
- iCurrentNodeCount = -1
-
- do while( iCurrentNodeCount < hGetNodeCount( oControl ) )
-
- iCurrentNodeCount = hGetNodeCount( oControl )
- hExpandNode( oControl, iCurrentNodeCount )
-
- if ( DEBUG_ENABLE ) then
+ iCurrentNodeCount = hExpandAllNodes( oControl )
+ if ( iCurrentNodeCount > 0 ) then
+ oControl.select( iCurrentNodeCount )
+ if ( GVERBOSE ) then
printlog( CFN & "Nodename.....: " & oControl.getText() )
printlog( CFN & "Node position: " & iCurrentNodeCount )
endif
-
- loop
+ else
+ iCurrentNodeCount = -1
+ endif
- printlog( CFN & "Exit with result: " & iCurrentNodeCount )
hSelectTheLastNode() = iCurrentNodeCount
end function
@@ -428,51 +414,6 @@ function hVerifyNodeName( oControl as object , cName as string ) as boolean
end function
-'*******************************************************************************
-
-function hWaitForTreelist( oTreeList as object, cContext as string, iItemCount as integer ) as boolean
-
- '///<h3>Wait for a treelist to get populated (java related delay)</h3>
- '///<b>IMPORTANT: Do not use unless absolutely necessary</b>
- '///+<p>Retrieve the number of items from the treelist until a specified
- '///+ number has been reached.</p>
-
- const CFN = "hWaitForTreelist::"
- dim iTry as integer
- dim iObjects as integer
- dim brc as boolean
-
- brc = false
- iTry = 0
-
- kontext cContext
-
- qaerrorlog( CFN & "Stupid function, do not use" )
-
- iObjects = 0
- do while ( iObjects < iItemCount )
-
- iTry = iTry + 1
- iObjects = hGetNodeCount( oTreeList )
-
- if ( iObjects >= iItemCount ) then
- brc = true
- exit do
- endif
-
- ' Failsafe mechanism
- if ( iTry = 10 ) then
- qaerrorlog( CFN & "Requested number of items never reached" )
- brc = false
- exit do
- endif
-
- loop
-
- hWaitForTreelist() = brc
-
-end function
-
'******************************************************************************
function hGetListItems( oControl as object, aList() as string ) as integer
@@ -484,8 +425,9 @@ function hGetListItems( oControl as object, aList() as string ) as integer
'///</ul>
const CFN = "hGetListItems::"
+ const RETVAL_FAILURE = 0
- printlog( CFN & "Enter with option (control): " & oControl.name() )
+ if ( GVERBOSE ) then printlog( CFN & "Enter with option (control): " & oControl.name() )
dim iItemCount as integer
dim iCurrentItem as integer
@@ -494,7 +436,7 @@ function hGetListItems( oControl as object, aList() as string ) as integer
iItemCount = oControl.getItemCount()
if ( iItemCount > ubound( aList() ) ) then
printlog( CFN & "Array too small, needed: " & iItemCount )
- hGetListItems() = 0
+ hGetListItems() = RETVAL_FAILURE
exit function
endif
@@ -506,8 +448,29 @@ function hGetListItems( oControl as object, aList() as string ) as integer
next iCurrentItem
- printlog( CFN & "Exit with number of items: " & iItemCount )
+ if ( GVERBOSE ) then printlog( CFN & "Exit with number of items: " & iItemCount )
hGetListItems() = iItemCount
end function
+'*******************************************************************************
+
+function hFindInList( oControl as object, cObject as string ) as integer
+
+ const RETVAL_FAILURE = 0
+ dim iCurrentObject as integer
+
+ for iCurrentObject = 1 to oControl.getItemCount()
+
+ oControl.select( iCurrentObject )
+
+ if ( oControl.getSelText() = cObject ) then
+ hFindInList() = iCurrentObject
+ exit function
+ endif
+
+ next iCurrentObject
+
+ hFindInList() = RETVAL_FAILURE
+
+end function \ No newline at end of file