summaryrefslogtreecommitdiff
path: root/testautomation/global/tools/includes/required/t_tools3.inc
diff options
context:
space:
mode:
Diffstat (limited to 'testautomation/global/tools/includes/required/t_tools3.inc')
-rwxr-xr-x[-rw-r--r--]testautomation/global/tools/includes/required/t_tools3.inc289
1 files changed, 285 insertions, 4 deletions
diff --git a/testautomation/global/tools/includes/required/t_tools3.inc b/testautomation/global/tools/includes/required/t_tools3.inc
index b55546edd8d6..27ac128437ee 100644..100755
--- a/testautomation/global/tools/includes/required/t_tools3.inc
+++ b/testautomation/global/tools/includes/required/t_tools3.inc
@@ -29,8 +29,7 @@
'*
'* short description : Global Tools III
'*
-'\*************************************************************************************
-
+'\******************************************************************************
sub hToolbarSelect( sType as string, sOpen as boolean, optional SetToDefault as boolean )
Dim sDefault as integer, sKontext as string, sPosition as integer
@@ -916,6 +915,7 @@ sub hCloseAllToolbars
endif
end sub
+'*******************************************************************************
function hIsAccessbridgeInstalled() as boolean
'/// created by HDE
@@ -942,7 +942,7 @@ function hIsAccessbridgeInstalled() as boolean
sAccessBridgeFolder = "Java Access Bridge"
sCompareString = sProgramFiles & "\" & sAccessBridgeFolder & "\AccessBridgeTester.class"
sAccessibilityCompare = "with accessibility support"
- if hFileExists(sCompareString) = True then
+ if ( FileExists( sCompareString ) ) then
AccessbridgeIsInstalled = True
else
ToolsOptions
@@ -965,7 +965,7 @@ function hIsAccessbridgeInstalled() as boolean
endif
endif
Kontext "OptionenDlg"
- OptionenDlg.Cancel
+ hCloseDialog( OptionenDlg, "Cancel" )
endif
end select
endif
@@ -973,3 +973,284 @@ function hIsAccessbridgeInstalled() as boolean
hIsAccessbridgeInstalled = AccessbridgeIsInstalled
end function
+
+'*******************************************************************************
+
+function hUseAsyncSlot( cSlot as string ) as integer
+
+ ' These are a selection of slots that take time to get enabled after
+ ' actions have been performed on a document. Although they might appear
+ ' to be ready in the UI we still need to probe them.
+
+ dim iRetries as integer : iRetries = 0
+ dim iTime as integer : iTime = 0
+
+ dim slot as string : slot = lcase( cSlot )
+
+ const MAX_RETRIES = 100 ' Number of time we try to call the slot
+ const DELAY = 100 ' 100ms delay to wait between retries
+ const RC_TIMEOUT = -1 ' Returnvalue if slot is not available
+ const CFN = "global::tools::includes::required::hUseAsyncSlot(): "
+
+ if ( GVERBOSE ) then printlog( CFN & "Execute <" & cSlot & ">" )
+ WaitSlot()
+
+ for iRetries = 1 to MAX_RETRIES
+ try
+ select case ( slot )
+ case "fileclose" : FileClose
+ case "filesave" : FileSave
+ case "filesaveas" : FileSaveAs( "SynchronMode", TRUE )
+ case "filesaveall" : FileSaveAll( "SynchronMode", TRUE )
+ case "fileexport" : FileExport
+ case "filereload" : FileReload( "SynchronMode", TRUE )
+ case "fileopen" : FileOpen
+ case "fileprint" : FilePrint
+ case "fileprintersettings" : FilePrintersettings
+ case "fileproperties" : FileProperties
+
+ case "editdoc" : EditDoc
+ case "editcopy" : EditCopy
+ case "editchangesrecord" : EditChangesRecord
+ case "editchangesshow" : EditChangesShow
+ case "editchangesprotecttrace" : EditChangesProtectTrace
+ case "editchangescomment" : EditChangesComment
+
+ case "editpaste" : EditPaste
+ case "editcut" : EditCut
+ case "editselectall" : EditSelectAll
+ case "editselectallmath" : EditSelectAllMath
+ case "editselectionmodeblock" : EditSelectionModeBlock
+ case "editselectionmodestandard" : EditSelectionModeStandard
+ case "editdeletecontents" : EditDeleteContents
+ case "editundo" : EditUndo
+ case "editredo" : EditRedo
+ case "editrepeat" : EditRepeat
+ case "editpastespecial" : EditPasteSpecial
+ case "editpastespecialwriter" : EditPasteSpecialWriter
+ case "editsearchandreplace" : EditSearchAndReplace
+ case "editduplicate" : EditDuplicate
+ case "editgluepoints" : EditGluePoints
+ case "editdeleteslide" : EditDeleteSlide
+ case "editobjectproperties" : EditObjectProperties
+ case "editobjectedit" : EditObjectEdit
+ case "editobjectsavecopyas" : EditObjectSaveCopyAs
+ case "edithyperlink" : EditHyperlink
+ case "editlinkswriter" : EditLinksWriter
+ case "editfields" : EditFields
+
+ case "formatframe" : FormatFrame
+ case "formatcharttype" : FormatChartType
+ case "formatcontrol" : FormatControl
+ case "formateditpoints" : FormatEditPoints
+ case "formatsections" : FormatSections
+ case "formatchangecaseupper" : FormatChangeCaseUpper
+ case "formatchangecaselower" : FormatChangeCaseLower
+ case "formatarea" : FormatArea
+ case "formatarrangebringtofrontcalc" : FormatArrangeBringToFrontCalc
+ case "formatflipvertically" : FormatFlipVertically
+ case "formatfliphorizontally" : FormatFlipHorizontally
+ case "formatline" : FormatLine
+ case "formatpositionandsize" : FormatPositionAndSize
+ case "formatfontwork" : FormatFontwork
+ case "formatpagewriter" : FormatPageWriter
+ case "formatparagraph" : FormatParagraph
+ case "formatruby" : FormatRuby
+ case "formatstylebold" : FormatStyleBold
+ case "formatungroupdraw" : FormatUngroupDraw
+ case "formatexitgroupdraw" : FormatExitGroupDraw
+ case "formatgroupgroup" : FormatGroupGroup
+ case "formatgroupeditgroupcalc" : FormatGroupEditGroupCalc
+ case "formatalignmentlefttext" : FormatAlignmentLeftText
+ case "formatgraphics" : FormatGraphics
+ case "formatanchortopage" : FormatAnchorToPage
+ case "formatwrapcontour" : FormatWrapContour
+ case "formatwrapeditcontour" : FormatWrapEditContour
+ case "formatpagewriter" : FormatPageWriter
+ case "formatautoformatapply" : FormatAutoformatApply
+
+ case "insertslide" : InsertSlide
+ case "insertfieldsother" : InsertFieldsOther
+ case "insertgraphicsfromfile" : InsertGraphicsFromFile
+ case "insertindexesbibliographyentry" : InsertIndexesBibliographyEntry
+
+ case "contextpositionandsize" : ContextPositionAndSize
+ case "contextproperties" : ContextProperties
+
+ case "toolslanguagehyphenate" : ToolsLanguageHyphenate
+ case "toolsupdateallindexes" : ToolsUpdateAllIndexes
+ case "toolsupdatefields" : ToolsUpdateFields
+ case "toolsupdatelinks" : ToolsUpdateLinks
+ case "toolslanguagehangulhanjaconversion" : ToolsLanguageHangulHanjaConversion
+
+ case "viewslide" : ViewSlide
+ case "viewdrawing" : ViewDrawing
+ case "viewnotes" : ViewNotes
+ case "viewhandout" : ViewHandout
+ case "viewzoom" : ViewZoom
+ case "viewnormal" : ViewNormal
+ case "viewworkspacedrawingview" : ViewWorkspaceDrawingView
+ case "viewworkspaceoutlineview" : ViewWorkspaceOutlineView
+ case "viewworkspaceslideview" : ViewWorkspaceSlidesView
+ case "viewworkspacenotesview" : ViewWorkspaceNotesView
+ case "viewworkspacehandoutview" : ViewWorkspaceHandoutView
+
+ case else : warnlog( "Unknown slot called: " & cSlot )
+ end select
+
+ exit for ' This is only executed if the slot was called successfully
+ catch
+ wait( DELAY )
+ endcatch
+ next iRetries
+
+ ' Total time used
+ iTime = iRetries * DELAY
+
+ ' Timeout is -1
+ if ( iRetries = MAX_RETRIES ) then iTime = RC_TIMEOUT
+
+ if ( GVERBOSE ) then printlog( CFN & "Exit with rc=" & iTime )
+ hUseAsyncSlot() = iTime
+
+end function
+
+'*******************************************************************************
+
+function hClickButton( oButton as object ) as integer
+
+ dim iRetries as integer : iRetries = 0
+ dim iTime as integer : iTime = 0
+
+ const MAX_RETRIES = 50 ' Try to click the button max 50 times
+ const DELAY = 100 ' 100ms wait between retries
+ const RC_TIMEOUT = -1 ' Return -1 if the button is not available
+ const CFN = "global::tools::includes::required::hClickButton(): "
+
+ if ( GVERBOSE ) then printlog( "Click <" & oButton.name() & ">" )
+ WaitSlot()
+
+ for iRetries = 1 to MAX_RETRIES
+ try
+ oButton.click()
+ exit for
+ catch
+ wait( DELAY )
+ endcatch
+ next iRetries
+
+ ' Total time used
+ iTime = iRetries * DELAY
+
+ if ( iRetries = MAX_RETRIES ) then iTime = RC_TIMEOUT
+
+ if ( GVERBOSE ) then printlog( CFN & "Exit with rc=" & iTime )
+ hClickButton() = iTime
+
+end function
+
+'*******************************************************************************
+
+function hCloseDialog( oDialog as object, sUserFlags as string ) as boolean
+
+ ' this function closes a dialog providing three different methods while
+ ' removing the need for static sleep statements
+
+ const CFN = "global::tools::includes::required::t_tools3.inc::hCloseDialog(): "
+ const METHOD_CLOSE = 1
+ const METHOD_CANCEL = 2
+ const METHOD_OK = 3
+ const METHOD_202 = 4
+ const METHOD_YES = 5
+ const METHOD_NO = 6
+ const TIMEOUT = 2 ' Maximum time to wait for a dialog to close
+
+ dim sFlags as string : sFlags = lcase( sUserFlags )
+ dim iClosingMethod as integer
+ dim bDialogMustExist as boolean : bDialogMustExist = TRUE
+
+ hCloseDialog() = FALSE ' Set default returnvalue, assume failure
+
+ ' Find out which closing method was provided, "close" ist the default
+ if ( instr( sFlags, "cancel" ) ) then
+ iClosingMethod = METHOD_CANCEL
+ elseif ( instr( sFlags, "202" ) ) then
+ iClosingMethod = METHOD_202
+ elseif ( instr( sFlags, "yes" ) ) then
+ iClosingMethod = METHOD_YES
+ elseif ( instr( sFlags, "ok" ) ) then
+ iClosingMethod = METHOD_OK
+ elseif ( instr( sFlags, "no" ) ) then
+ iClosingMethod = METHOD_NO
+ else
+ iClosingMethod = METHOD_CLOSE
+ endif
+
+ ' Find out whether the dialog must exist (default) or is just closed as a precaution ("optional")
+ if ( instr( sFlags, "optional") ) then bDialogMustExist = FALSE
+
+ if ( GVERBOSE ) then
+ printlog( "Closing dialog <" & oDialog.name() & "> using the flags <" & sFlags & ">.")
+ endif
+
+ if ( oDialog.exists() ) then
+ try
+ select case( iClosingMethod )
+ case METHOD_CLOSE : oDialog.close()
+ case METHOD_CANCEL : oDialog.cancel()
+ case METHOD_202 : oDialog.click( 202 )
+ case METHOD_YES : oDialog.yes()
+ case METHOD_NO : oDialog.no()
+ case METHOD_OK : oDialog.ok()
+ case else :
+ warnlog( CFN & " Script error: Allowed closing methods are cancel, close, ok, yes, no and 202" )
+ end select
+ catch
+ warnlog( CFN & "This dialog does not provide the requested closing method" )
+ hCloseDialog() = FALSE
+ exit function
+ endcatch
+ else
+ if ( bDialogMustExist ) then
+ warnlog( CFN & "The requested dialog is not available, no action taken" )
+ hCloseDialog() = FALSE
+ exit function
+ endif
+ endif
+
+ ' Any other outcome until now returned FALSE. If we get here, we have a success.
+ if ( oDialog.notExists( TIMEOUT ) ) then hCloseDialog() = TRUE
+
+end function
+
+'*******************************************************************************
+
+function hWaitForObject( oControl as object, iTime as integer ) as integer
+
+ const CFN = "global::tools::includes::required::t_tools3.inc::hWaitForObject(): "
+ const RC_TIMEOUT = -1
+
+ dim iWait as integer
+
+ if ( GVERBOSE ) then printlog( CFN & "Entering function for control: " & oControl.name() )
+
+ WaitSlot( 2000 )
+
+ for iWait = 0 to iTime
+ try
+ if ( oControl.isEnabled() ) then
+ printlog( CFN & "Control is enabled: " & oControl.name() )
+ hWaitForObject() = iWait
+ exit function
+ else
+ if ( GVERBOSE ) then printlog( "Waiting..." )
+ endif
+ catch
+ wait( 1 )
+ endcatch
+ next iWait
+
+ printlog( CFN & "Control not found or not enabled, timeout reached" )
+ hWaitForObject() = RC_TIMEOUT
+
+end function