diff options
Diffstat (limited to 'testautomation/global/tools/includes/required')
-rw-r--r--[-rwxr-xr-x] | testautomation/global/tools/includes/required/t_dir.inc | 51 | ||||
-rwxr-xr-x | testautomation/global/tools/includes/required/t_doc1.inc | 19 | ||||
-rw-r--r--[-rwxr-xr-x] | testautomation/global/tools/includes/required/t_doc2.inc | 129 | ||||
-rw-r--r--[-rwxr-xr-x] | testautomation/global/tools/includes/required/t_files.inc | 165 | ||||
-rw-r--r--[-rwxr-xr-x] | testautomation/global/tools/includes/required/t_filters.inc | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | testautomation/global/tools/includes/required/t_lists.inc | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | testautomation/global/tools/includes/required/t_menu.inc | 6 | ||||
-rw-r--r--[-rwxr-xr-x] | testautomation/global/tools/includes/required/t_option.inc | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | testautomation/global/tools/includes/required/t_tools1.inc | 2 | ||||
-rw-r--r-- | testautomation/global/tools/includes/required/t_tools2.inc | 26 | ||||
-rw-r--r--[-rwxr-xr-x] | testautomation/global/tools/includes/required/t_tools3.inc | 0 |
11 files changed, 232 insertions, 168 deletions
diff --git a/testautomation/global/tools/includes/required/t_dir.inc b/testautomation/global/tools/includes/required/t_dir.inc index ee673e6b1c47..f5aa59e2d78b 100755..100644 --- a/testautomation/global/tools/includes/required/t_dir.inc +++ b/testautomation/global/tools/includes/required/t_dir.inc @@ -288,4 +288,55 @@ function GetExtention ( Datei as String ) as string next i% GetExtention = Datei end function +' +'------------------------------------------------------------------------------- +' +function hSplitString( sString as string, sSeparator as string, iIndex as integer ) as string + + ' This function wraps around the "split" command and returns one single + ' item by index. Index = 0 means the *LAST* item is returned as this is + ' probably the most commonly used item. If the index is invalid (out of + ' bounds) we print a warning and return an error string. + + const CFN = "global::tools::includes::required::t_dir.inc:hSplitString(): " + const ERROR_MESSAGE = "Array out of bounds for the requested index in string " + const ARRAY_INDEX_CORRECTION = 1 ' The array lower boundary is zero but + ' function starts to count with one. + + ' Split the string into its fragments into an array with dynamic boundaries + dim sArray() as string + dim sReturnString as string : sReturnString = "" + + if ( GVERBOSE ) then + printlog( CFN & "Separator is: " & sSeparator ) + printlog( CFN & "Original string is: " & sString ) + endif + + sArray() = split( sString, sSeparator ) + + if ( GVERBOSE ) then + printlog( CFN & "Number of items found: " & ubound( sArray() ) ) + endif + + ' Special case: Index out of bounds + if ( iIndex > ( ubound( sArray() ) + ARRAY_INDEX_CORRECTION ) or iIndex < 0 ) then + warnlog( CFN & ERROR_MESSAGE & sString ) + hSplitString() = ERROR_MESSAGE & sString + exit function + endif + + ' Special case: Last item requested (this usually is the filename from a path) + if ( iIndex = 0 ) then + sReturnString = sArray( ubound( sArray() ) + if ( GVERBOSE ) then printlog( CFN & sReturnString ) + hSplitString() = sReturnString + exit function + endif + + ' Default is to return the requested item. + sReturnString = sArray( iIndex - ARRAY_INDEX_CORRECTION ) + if ( GVERBOSE ) then printlog( CFN & sReturnString ) + hSplitString() = sReturnString + +end function diff --git a/testautomation/global/tools/includes/required/t_doc1.inc b/testautomation/global/tools/includes/required/t_doc1.inc index ff07554bca35..0ee504c5432e 100755 --- a/testautomation/global/tools/includes/required/t_doc1.inc +++ b/testautomation/global/tools/includes/required/t_doc1.inc @@ -243,20 +243,17 @@ end function ' function hCloseDocument() - '/// Trigger FileClose slot' hUseAsyncSlot( "FileClose") - '/// Accept to lose changes' Kontext "Active" if ( Active.Exists( 2 ) ) then try Active.No catch - Active.Click( 202 ) + Active.click( 202 ) endcatch end if - '/// Wait for FileClose to complete' WaitSlot( 2000 ) end function @@ -357,6 +354,8 @@ end sub ' sub hTypeKeys ( OutputText , optional _iLoop as Integer ) + const CFN = "global::tools::includes::required::t_doc1.inc::hTypeKeys(): " + dim iRepeat as integer dim iLoop as integer dim oDocument as object @@ -371,10 +370,14 @@ sub hTypeKeys ( OutputText , optional _iLoop as Integer ) hSetDocumentContext() ' set kontext to current document type oDocument = hSetDocumentObject() ' Get the document object we want to write to - for iRepeat = 1 to iLoop - oDocument.TypeKeys( OutputText ) - wait( 200 ) - next iRepeat + try + for iRepeat = 1 to iLoop + oDocument.TypeKeys( OutputText ) + wait( 200 ) + next iRepeat + catch + warnlog( CFN & "Failed to send keystroke to given context" ) + endcatch end sub diff --git a/testautomation/global/tools/includes/required/t_doc2.inc b/testautomation/global/tools/includes/required/t_doc2.inc index 4192563b0eba..0e9af93f287c 100755..100644 --- a/testautomation/global/tools/includes/required/t_doc2.inc +++ b/testautomation/global/tools/includes/required/t_doc2.inc @@ -113,135 +113,6 @@ end sub ' '------------------------------------------------------------------------------- ' -function hEnableDocumentEditMode() as boolean - - hEnableDocumentEditMode() = false - - dim iTry as integer - - printlog( "Try to switch document to edit mode" ) - for iTry = 1 to 20 - try - kontext "Standardbar" - if ( Bearbeiten.getState( 2 ) <> 1 ) then - Bearbeiten.click() - - kontext "Active" - if ( Active.exists( 1 ) ) then - printlog( "Handle <Use copy message>" ) - hCloseDialog( Active, "yes" ) - wait( 2000 ) - printlog( "Successfully switched to edit mode" ) - hEnableDocumentEditMode() = true - exit for - endif - endif - catch - wait( 200 ) - endcatch - next iTry - -end function - -'******************************************************************************* - -function sMakeReadOnlyDocumentEditable() as boolean - - sMakeReadOnlyDocumentEditable() = hEnableDocumentEditMode() - exit function - - ' Function returns TRUE if document has been made editable and FALSE if - ' no action was required (that is: Document was not read-only) - - dim iTry as integer - dim iWait as integer - dim rc as integer - const CFN = "sMakeReadOnlyDocumentEditable::" - - if ( GVERBOSE ) then printlog( CFN & "Making document editable (create a copy) if it is readonly" ) - - ' We still run into synchronization problems with the "Make document editable" feature - ' because we do not know when this button becomes available and ready for use: The - ' document has to be loaded, then we have to wait for the toolbar to get populated. - ' One thing appears to work though: Try to execute the slot using hUseAsyncSlot. - ' This is a little bit tricky because the state of the document is altered but if - ' the slot has been executed once we know for sure that the button on the toolbar is - ' available and can check its state and - if need be - chenge the document state back. - - ' ========== Workaround begin ========== - hUseAsyncSlot( "EditDoc" ) - kontext "Active" - if ( Active.exists() ) then - if ( GVERBOSE ) then printlog( "Handling create copy message" ) - Active.yes() - wait( 1000 ) - endif - ' ========== Workaround end ========== - Kontext "Standardbar" - iWait = 0 - Do - if ( Bearbeiten.IsEnabled() ) then - try - if Bearbeiten.getState( 2 ) = 0 then - exit do - endif - catch - if ( GVERBOSE ) then printlog "Attempt " & iWait & " to make document readable failed" - iWait = iWait + 1 - wait ( 1000 ) - endcatch - else - if ( GVERBOSE ) then printlog "Attempt " & iWait & " to make document readable failed" - iWait = iWait + 1 - wait ( 1000 ) - end if - if iWait >= 5 then exit do - Loop - - if ( Bearbeiten.IsEnabled() ) then - - if ( Bearbeiten.getState( 2 ) = 0 ) then - - rc = hUseAsyncSlot("editdoc") - - if ( rc >= 0 ) then - for iTry = 1 to 2 - - - Kontext "Active" - if ( Active.exists( 5 ) ) then - - printlog( CFN & "Messagebox: " & Active.getText() ) - - try - if ( GVERBOSE ) then printlog( CFN & "Document was read-only. A copy will be used." ) - Active.Yes() - if ( GVERBOSE ) then printlog( CFN & "Closed 'use copy' message" ) - catch - if ( GVERBOSE ) then printlog( CFN & "Probing for unexpected messagebox..." ) - active.ok() - qaerrorlog( "#i100701 - Object not found message" ) - endcatch - else - printlog( CFN & "No messagebox informing about a copy being used" ) - endif - sMakeReadOnlyDocumentEditable() = TRUE - next iTry - else - printlog( CFN & "Document appears to be editable" ) - endif - else - if ( GVERBOSE ) then printlog( CFN & "Button <Bearbeiten> is pressed, document is editable" ) - sMakeReadOnlyDocumentEditable() = FALSE - endif - else - if ( GVERBOSE ) then printlog( CFN & "Control <Bearbeiten> is not enabled" ) - endif - -end function -' -'------------------------------------------------------------------------------- -' function fSelectFirstOLE() as integer 'Select first visible OLE object using Navigator 'Returns error-code: diff --git a/testautomation/global/tools/includes/required/t_files.inc b/testautomation/global/tools/includes/required/t_files.inc index 4b0ddd09318b..d734cd3f05a7 100755..100644 --- a/testautomation/global/tools/includes/required/t_files.inc +++ b/testautomation/global/tools/includes/required/t_files.inc @@ -34,7 +34,6 @@ function hGrafikEinfuegen( cFile as string ) as Boolean hGrafikEinfuegen() = hInsertGraphic( cFile, "Static" ) - exit function end function @@ -43,7 +42,6 @@ end function function hGrafikVerknuepftEinfuegen( cFile as string ) as Boolean hGrafikVerknuepftEinfuegen() = hInsertGraphic( cFile, "Linked" ) - exit function end function @@ -103,7 +101,7 @@ end function function hIsNamedDocLoaded( cFileName as string ) as boolean ' Retrieve the current filename from the document properties - which in - ' comparision to the old approach to retrive the name from the file save + ' comparision to the old approach to retrieve the name from the file save ' dialog - gives us the file including its extension. So we only need ' to compare the last characters from a full path to be relatively ' certain that we work with the correct file. There is some small margin of @@ -501,6 +499,167 @@ end function ' '------------------------------------------------------------------------------- ' +function hGetWorkFile( cFileName as string ) as string + hGetWorkFile() = hGetWorkPath() & cFileName +end function +' +'------------------------------------------------------------------------------- +' +function hGetWorkPath() as string + + ' Retrieve the user's work directory using the API (or fallback) + + dim sPath as string : sPath = "" + dim oOfficeConnect as object + dim oOfficeConfig as object + dim bPathIsFromAPI as boolean + + const CFN = "global::tools::includes::required::t_files.inc:hGetWorkPath(): " + + ' Create an UNO service and ask it for the location of Work + try + oOfficeConnect = hGetUnoService( true ) + oOfficeConfig = oOfficeConnect.createInstance( "com.sun.star.util.PathSettings" ) + sPath = convertFromURL( oOfficeConfig.Work ) + bPathIsFromAPI = true + catch + printlog( CFN & "Could not access service, connection broken?" ) + sPath = convertpath( gOfficePath & "user/work" ) + bPathIsFromAPI = false + endcatch + + if ( GVERBOSE ) then + + printlog( CFN & "Path is: " & sPath ) + + ' Check path existence + if ( FileExists( sPath ) ) then + printlog( CFN & "Path exists." ) + else + warnlog( CFN & "Path does not exist." ) + endif + + ' Inform about the location from where the path was taken + if ( bPathIsFromAPI ) then + printlog( CFN & "Path was taken from API" ) + else + warnlog( CFN & "Path was taken from (hardcoded) fallback" ) + endif + + endif + + hGetWorkPath() = sPath & getPathSeparator + +end function +' +'------------------------------------------------------------------------------- +' +function hFileGetLocalPath( sSourcePath as string ) as string + + ' Isolate filename from path, prepend local work directory and return new file path + hFileGetLocalPath() = hGetWorkFile( hSplitString( sSourcePath, getPathSeparator, 0 ) ) + +end function +' +'------------------------------------------------------------------------------- +' +function hFileListCopyLocal( lsSourceList() as string ) as boolean + + ' Copy a list of files from testautomation to the local work directory + + const CFN = "global::tools::includes::required::t_files.inc:hFileListCopyLocal(): " + dim iCurrentPath as integer + dim cTargetPath as string + dim cSourcePath as string + + hFileListCopyLocal() = true + + for iCurrentPath = 1 to listcount( lsSourceList() ) + + cSourcePath = lsSourceList( iCurrentPath ) + cTargetPath = hFileGetLocalPath( cSourcePath ) + + FileCopy( cSourcePath, cTargetPath ) + + ' If any one copy operation fails we + if ( not FileExists( cTargetPath ) ) then + hFileListCopyLocal() = false + warnlog( CFN & "File was not copied: " & cSourcePath ) + endif + + next iCurrentPath + +end function +' +'------------------------------------------------------------------------------- +' +function hFileOpenLocally( byVal sSourcePath as string ) as boolean + + ' Issue #i112208# - implement a function that copies a file from testautomation + ' into the local work directory and opens it from there to avoid that the + ' document gets opened in read-only mode. See details of the implementation + ' in the issue description. + + ' Parameters + ' 1) Path as string, URLs are untested. + ' 2) Separator, usually "getPathSeparator" + ' 3) Item number, 0 = last item which usually is the file name from a path. + ' Begin counting with 1, while the function internally accesses item 0 + ' from the array. + + const CFN = "global::tools::includes::required::t_files.inc:hFileOpenLocally(): " + + dim sTargetPath as string + + sSourcePath = convertpath( sSourcePath ) + + ' If the source file does not exist we quit + if ( not FileExists( sSourcePath ) ) then + warnlog( CFN & "Source path/file does not exist: " & sSourcePath ) + hFileOpenLocally() = false + exit function + endif + + ' Find out what the name of the target file is going to be + sTargetPath = hFileGetLocalPath( sSourcePath ) ' The path + file + + ' For debugging purposes set global variable gVerbose to TRUE + if ( gVerbose ) then + printlog( CFN & "Copying file" ) + printlog( CFN & "From: " & sSourcePath ) + printlog( CFN & "To..: " & sTargetPath ) + endif + + ' Copy the file from anywhere to the local user directory if it does not + ' exist. This behavior was discussed on IRC + if ( FileExists( sTargetPath ) ) then + printlog( CFN & "Re-using existing local copy of workfile" ) + 'warnlog( CFN & "Target file exists, it has not been deleted by prior test" ) + endif + + FileCopy( sSourcePath, sTargetPath ) + + ' Verify that the file has been created. return an empty string and warn + if ( not FileExists( sTargetPath ) ) then + warnlog( CFN & "File was not copied: " & sTargetFile ) + hFileOpenLocally() = false + gLastWorkFile = "" + exit function + endif + + ' This is a hook that allows to access the filename under which the file + ' has been saved. Due to restrictive coding guidelines we cannot return + ' the new filename. + gLastWorkFile = sTargetPath + + ' Finally open the file from the local work directory. It should open + ' ready for editing + hFileOpenLocally() = hFileOpen( gLastWorkFile ) + +end function +' +'------------------------------------------------------------------------------- +' function hFileCloseAll() as integer dim iDocumentCount as integer : iDocumentCount = 0 diff --git a/testautomation/global/tools/includes/required/t_filters.inc b/testautomation/global/tools/includes/required/t_filters.inc index 243483be9e7d..c0a23d56d092 100755..100644 --- a/testautomation/global/tools/includes/required/t_filters.inc +++ b/testautomation/global/tools/includes/required/t_filters.inc @@ -25,7 +25,7 @@ ' '/****************************************************************************** '* -'* owner : joerg.skottke@oracle.com +'* owner : gregor.hartmann@oracle.com '* '* short description : Retrieve and set filternames and suffixes '* diff --git a/testautomation/global/tools/includes/required/t_lists.inc b/testautomation/global/tools/includes/required/t_lists.inc index 9fa2172fbccf..9fa2172fbccf 100755..100644 --- a/testautomation/global/tools/includes/required/t_lists.inc +++ b/testautomation/global/tools/includes/required/t_lists.inc diff --git a/testautomation/global/tools/includes/required/t_menu.inc b/testautomation/global/tools/includes/required/t_menu.inc index 830012cc7dae..b03062b39471 100755..100644 --- a/testautomation/global/tools/includes/required/t_menu.inc +++ b/testautomation/global/tools/includes/required/t_menu.inc @@ -270,6 +270,12 @@ function hMenuFindSelect(MenuID as variant, SelectSlot as Boolean, ExpectedNr as warnlog "The real Position (Separators included) was: " + i endif i = RealEnd + else + if ( i = ExpectedNr ) then + if nID = "" then + warnlog "#i115132#Missing .uno Slots in context menus" + endif + endif endif next i else diff --git a/testautomation/global/tools/includes/required/t_option.inc b/testautomation/global/tools/includes/required/t_option.inc index 4f4467263072..4f4467263072 100755..100644 --- a/testautomation/global/tools/includes/required/t_option.inc +++ b/testautomation/global/tools/includes/required/t_option.inc diff --git a/testautomation/global/tools/includes/required/t_tools1.inc b/testautomation/global/tools/includes/required/t_tools1.inc index 051afec0ad24..837a989678be 100755..100644 --- a/testautomation/global/tools/includes/required/t_tools1.inc +++ b/testautomation/global/tools/includes/required/t_tools1.inc @@ -25,7 +25,7 @@ ' '/****************************************************************************** '* -'* owner : joerg.skottke@oracle.com +'* owner : gregor.hartmann@oracle.com '* '* short description : Tools (1) '* diff --git a/testautomation/global/tools/includes/required/t_tools2.inc b/testautomation/global/tools/includes/required/t_tools2.inc index e4f3bd9842e9..b82b93edba1f 100644 --- a/testautomation/global/tools/includes/required/t_tools2.inc +++ b/testautomation/global/tools/includes/required/t_tools2.inc @@ -226,32 +226,6 @@ end function '------------------------------------------------------------------------- -function GetBuildNumHidLst as String -'/// Get the "BuildId" out of the <i>hid.lst</i>. - Dim FileNum as Integer - Dim xmlZeile as String - dim iIndex as integer - dim sTemp as string - - if Dir (gtHidLstPath + "hid.lst") <> "" then - FileNum = FreeFile - Open (gtHidLstPath + "hid.lst") For Input As #FileNum - do until EOF(#FileNum) = True - line input #FileNum, xmlZeile - iIndex = inStr (1, xmlZeile, "010101010101010", 1) - sTemp = Left (xmlZeile, abs(iIndex - 1)) - ' usually only the first line is read - if (sTemp <> "") then exit do - loop - Close #FileNum - GetBuildNumHidLst = sTemp - else - GetBuildNumHidLst = "" - end if -end function - -'------------------------------------------------------------------------- - function hGetUNOService(optional bSilent as boolean, optional byRef sUnoPortExternal as string) as object '/// Function enables the UNO communication inside the '///+ TestTool to the office application. diff --git a/testautomation/global/tools/includes/required/t_tools3.inc b/testautomation/global/tools/includes/required/t_tools3.inc index 4b29928a1b93..4b29928a1b93 100755..100644 --- a/testautomation/global/tools/includes/required/t_tools3.inc +++ b/testautomation/global/tools/includes/required/t_tools3.inc |