diff options
Diffstat (limited to 'testautomation/global/tools/includes/required')
-rwxr-xr-x[-rw-r--r--] | testautomation/global/tools/includes/required/t_dir.inc | 88 | ||||
-rw-r--r-- | testautomation/global/tools/includes/required/t_dirloc.inc | 288 | ||||
-rw-r--r-- | testautomation/global/tools/includes/required/t_doc1.inc | 516 | ||||
-rwxr-xr-x | testautomation/global/tools/includes/required/t_doc2.inc | 161 | ||||
-rwxr-xr-x[-rw-r--r--] | testautomation/global/tools/includes/required/t_files.inc | 433 | ||||
-rwxr-xr-x[-rw-r--r--] | testautomation/global/tools/includes/required/t_filters.inc | 15 | ||||
-rwxr-xr-x[-rw-r--r--] | testautomation/global/tools/includes/required/t_lists.inc | 26 | ||||
-rwxr-xr-x | testautomation/global/tools/includes/required/t_menu.inc | 208 | ||||
-rw-r--r-- | testautomation/global/tools/includes/required/t_option2.inc | 22 | ||||
-rwxr-xr-x[-rw-r--r--] | testautomation/global/tools/includes/required/t_tools1.inc | 229 | ||||
-rwxr-xr-x[-rw-r--r--] | testautomation/global/tools/includes/required/t_tools2.inc | 311 | ||||
-rwxr-xr-x[-rw-r--r--] | testautomation/global/tools/includes/required/t_tools3.inc | 289 |
12 files changed, 907 insertions, 1679 deletions
diff --git a/testautomation/global/tools/includes/required/t_dir.inc b/testautomation/global/tools/includes/required/t_dir.inc index 0c7d887825f7..04c4bd8956f9 100644..100755 --- a/testautomation/global/tools/includes/required/t_dir.inc +++ b/testautomation/global/tools/includes/required/t_dir.inc @@ -31,55 +31,6 @@ '* '\************************************************************************ -function hFileExists ( Dat as String ) as Boolean - '/// Checks if a file exists - '/// <u>Input</u>: Filename with complete path - '/// <u>Return</u>: TRUE or FALSE if the file exists. - if app.Dir ( Dat ) = "" then - hFileExists = FALSE - else - hFileExists = TRUE - end if -end function -' -'------------------------------------------------------------------------------- -' -function hDirectoryExists ( Verz as String ) as Boolean - '/// Checks if a directory exists - '/// <u>Input</u>: Directory with complete path - '/// <u>Return</u>: TRUE or FALSE if the directory exists. - ' at the end of the string has to be teh path seperator, else the dir-command doesn't work - if right ( Verz, 1 ) <> gPathSigne then Verz = Verz + gPathsigne - if app.Dir ( Verz, 16 ) = "" then - hDirectoryExists = FALSE - else - hDirectoryExists = TRUE - end if -end function -' -'------------------------------------------------------------------------------- -' -function hKillFile ( Dat as String ) as Boolean - '/// Delete a file - '/// <u>Input</u>: File with complete path - '/// <u>Return</u>: TRUE or FALSE success on deleting? - if app.Dir ( Dat ) <> "" then - try - app.kill ( Dat ) - catch - endcatch - if app.Dir ( Dat ) <> "" then - hKillFile = FALSE - else - hKillFile = TRUE - end if - else - hKillFile = TRUE - end if -end function -' -'------------------------------------------------------------------------------- -' function DirNameList (ByVal sPfad$ , lsDirName() as String ) as Integer '/// seperate a path in its parts '/// <u>Input</u>: Path to seperate; Empty list, because it get's reset in this function!; @@ -293,45 +244,8 @@ end function ' '------------------------------------------------------------------------------- ' -function PfadExtract ( sFiledat$ ) as string - '/// Get the path from a file - '/// <u>Input</u>: file with path - '/// <u>Return</u>: path without the filename - Dim s$ : Dim i% : Dim k% - dim ls(25) as String - - s$ = "" - i% = DirNameList( sFileDat$, ls() ) - k% = 2 - do until K%>=i% - ls( 1 ) = ls( 1 ) + ls(k%) - k% = k% +1 - loop - PfadExtract = Left( ls(1), Len(ls( 1 ))-1) -end function -' -'------------------------------------------------------------------------------- -' -function hPfadname (Dateipfad$) as string - '/// Get the path from a file - '/// <u>Input</u>: file with path - '/// <u>Return</u>: path without the filename - dim wh as integer - - for wh = len(Dateipfad$) to 1 step -1 - if mid(Dateipfad$,wh,1) = gPathSigne then - hpfadname = left(Dateipfad$,wh) - exit for - else - hpfadname = Dateipfad$ - end if - next wh -end function -' -'------------------------------------------------------------------------------- -' function DateiExtract ( sFileDat$ ) - '/// Get the filename from a path + '/// Get the filename from a path '/// <u>Input</u>: path with file '/// <u>Return</u>: filename without the path Dim i% diff --git a/testautomation/global/tools/includes/required/t_dirloc.inc b/testautomation/global/tools/includes/required/t_dirloc.inc deleted file mode 100644 index d8bef397c74b..000000000000 --- a/testautomation/global/tools/includes/required/t_dirloc.inc +++ /dev/null @@ -1,288 +0,0 @@ -'************************************************************************** -' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -' -' Copyright 2000, 2010 Oracle and/or its affiliates. -' -' OpenOffice.org - a multi-platform office productivity suite -' -' This file is part of OpenOffice.org. -' -' OpenOffice.org is free software: you can redistribute it and/or modify -' it under the terms of the GNU Lesser General Public License version 3 -' only, as published by the Free Software Foundation. -' -' OpenOffice.org is distributed in the hope that it will be useful, -' but WITHOUT ANY WARRANTY; without even the implied warranty of -' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -' GNU Lesser General Public License version 3 for more details -' (a copy is included in the LICENSE file that accompanied this code). -' -' You should have received a copy of the GNU Lesser General Public License -' version 3 along with OpenOffice.org. If not, see -' <http://www.openoffice.org/license.html> -' for a copy of the LGPLv3 License. -' -'/************************************************************************ -'* -'* owner : thorsten.bosbach@sun.com -'* -'* short description : functions for directories and files; execution happens in the testtool -'* -'\************************************************************************ - -function hFileExistsLocal ( Dat as String ) as Boolean - '/// Checks if a file exists - '/// <u>Input</u>: Filename with complete path - '/// <u>Return</u>: TRUE or FALSE if the file exists. - if Dir ( Dat ) = "" then - hFileExistsLocal = FALSE - else - hFileExistsLocal = TRUE - end if -end function -' -'------------------------------------------------------------------------------- -' -function hDirectoryExistsLocal ( Verz as String ) as Boolean - '/// Checks if a directory exists - '/// <u>Input</u>: Directory with complete path - '/// <u>Return</u>: TRUE or FALSE if the directory exists. - ' at the end of the string has to be teh path seperator, else the dir-command doesn't work - if right ( Verz, 1 ) <> gPathSigne then Verz = Verz + gPathSigne - if Dir ( Verz, 16 ) = "" then - hDirectoryExistsLocal = FALSE - else - hDirectoryExistsLocal = TRUE - end if -end function -' -'------------------------------------------------------------------------------- -' -function hKillFileLocal ( Dat as String ) as Boolean - '/// Delete a file - '/// <u>Input</u>: File with complete path - '/// <u>Return</u>: TRUE or FALSE success on deleting? - if Dir ( Dat ) <> "" then - try - kill ( Dat ) - catch - endcatch - if Dir ( Dat ) <> "" then - hKillFileLocal = FALSE - else - hKillFileLocal = TRUE - end if - else - hKillFileLocal = TRUE - end if -end function -' -'------------------------------------------------------------------------------- -' -function DirNameListLocal (ByVal sPfad$ , lsDirName() as String ) as Integer - '/// seperate a path in its parts - '/// <u>Input</u>: Path to seperate; Empty list, because it get's reset in this function!; - '/// <u>Return</u>: Number on entries in the list; list with entries - Dim i% - Dim Pos% - - lsDirName(0) = 0 - do - Pos% = InStr(1, sPfad$, "\") ' got a path - i% = Val(lsDirName(0) ) + 1 - lsDirName(0) = i% - lsDirName( i% ) = Left( sPfad$, Pos% ) ' .. put in list - sPfad = Mid( sPfad$, Pos% + 1 ) ' ...cut off - loop while Pos%>0 - lsDirName( i% ) = sPfad$ - DirNameListLocal = i% ' count of -end function -' -'------------------------------------------------------------------------------- -' -function GetFileNameListLocal ( sPath$, sMatch$ ,lsFile() as String ) as integer - '/// Get files from a directory that match the pattern and append them to a list (without path) - '/// <u>Input</u>: Directory with complete path; Search Pattern, e.g *.*; List - '/// <u>Return</u>: count of appended entries; updated list - Dim Count% - Dim Datname as String - - Count% = 0 - - if right ( sPath$, 1 ) <> gPathSigne then sPath$ = sPath$ + gPathSigne - ' at the end of the string has to be teh path seperator, else the dir-command doesn't work - Datname = Dir( sPath$ + sMatch$ , 0) - - do until Len(Datname) = 0 - Count% = Count% + 1 - lsFile(Count%) = Datname ' append - lsFile(0) = Count% - Datname = Dir - loop - - GetFileNameListLocal = Count% ' all files -end function -' -'------------------------------------------------------------------------------- -' -function GetFileListLocal ( sPath$, sMatch$ ,lsFile() as String ) as integer - '/// Get files from a directory that match the pattern and append them to a list (<b>with</b> path) - '/// <u>Input</u>: Directory with complete path; Search Pattern, e.g *.*; List - '/// <u>Return</u>: count of appended entries; updated list - Dim Count% - Dim Datname as String - - Count% = 0 - - if right ( sPath$, 1 ) <> gPathSigne then sPath$ = sPath$ + gPathSigne - ' at the end of the string has to be teh path seperator, else the dir-command doesn't work - Datname = Dir( sPath$ + sMatch$ , 0) - - do until Len(Datname) = 0 - lsFile(0) = Val(lsFile(0)) + 1 - lsFile( lsFile(0) ) =sPath$ + Datname - Count% = Count% + 1 - Datname = Dir - loop - GetFileListLocal = Count% -end function -' -'------------------------------------------------------------------------------- -' -function GetDirListLocal ( sPath$, sMatch$ ,lsFile() as String ) as integer - '/// Get Subdirectories from a directory and append them to a list (<b>with</b> path) - '/// <u>Input</u>: Directory with complete path; Search Pattern, e.g *; List - '/// <u>Return</u>: count of appended entries; updated list - Dim Count% - Dim Verzeichnis as String - - if right ( sPath$, 1 ) <> gPathSigne then sPath$ = sPath$ + gPathSigne - ' at the end of the string has to be teh path seperator, else the dir-command doesn't work - Verzeichnis = Dir( sPath$ + sMatch$ , 16) - Count% = 0 - - do until Len(Verzeichnis) = 0 - if Verzeichnis <>"." AND Verzeichnis <> ".." then - lsFile(0) = Val(lsFile(0)) + 1 - lsFile( lsFile(0) ) = sPath$ + Verzeichnis + gPathSigne - Count% = Count% + 1 - end if - Verzeichnis = Dir - loop - - GetDirListLocal = Count% -end function -' -'------------------------------------------------------------------------------- -' -function GetAllDirListLocal ( byVal sPath$, byVal sMatch$ ,lsFile() as String ) as integer - '/// Get all directorys recursiv that match the pattern and append them to a list - '/// <u>Input</u>: Directory with complete path; Search Pattern, e.g *; Empty list, because it get's reset in this function!; - '/// <u>Return</u>: Count of appended entries (1. entry is the whole path); updated list - Dim Count% : Dim DirCount% - - DirCount% = 1 ' dummy - Count% = 1 - lsFile(0) = 1 'new list - lsFile(1) = sPath$ 'first path is the calling path - - do until Count%>Val(lsFile(0)) ' get first generation - DirCount% = GetDirListLocal ( lsFile(Count%) , sMatch$, lsFile() ) ' append all subdirectories - Count% = Count% +1 - loop - - GetAllDirListLocal = Count% - 1 ' count of listelements -end function -' -'------------------------------------------------------------------------------- -' -function GetAllFileListLocal ( byVal sPath$, byVal sMatch$ ,lsFile() as String ) as integer - '/// Get all Files recursiv (including in subdirectories) that match the pattern and append them to a list - '/// <u>Input</u>: Directory with complete path; Search Pattern, e.g *.*; Empty list, because it get's reset in this function!; - '/// <u>Return</u>: Count of appended entries (1. entry is the whole path); updated list - Dim DirCount% : Dim FileCount% : Dim Count% - Dim lsDir(1000) as String - - DirCount% = GetAllDirListLocal ( sPath$, "*", lsDir() ) ' just all directories - FileCount% = 0 - lsFile(0) = 1 - lsFile(1) = sPath$ - - For Count% = 1 to Val( lsDir(0) ) - FileCount% = FileCount% + GetFileListLocal ( lsDir( Count% ), sMatch$, lsFile() ) - next Count% - - GetAllFileListLocal = FileCount% ' count of files -end function -' -'------------------------------------------------------------------------------- -' -function KillFileListLocal ( lsList() as String ) as Boolean - '/// Delete all files in the list - '/// <u>Input</u>: List with files - '/// <u>Return</u>: TRUE or FALSE if files are killed; modified list with not deleted files. - Dim i as Integer - Dim FehlerListe ( 1000 ) as String - - FehlerListe ( 0 ) = 0 - for i=1 to ListCount ( lsList() ) - try - kill ( lsList(i) ) - catch - ListAppend ( FehlerListe (), lsList(i) ) - endcatch - next i - - lsList(0) = 0 ' delete old list - KillFileListLocal = TRUE - for i=1 to ListCount ( FehlerListe () ) - KillFileListLocal = FALSE - ListAppend ( lsList(), FehlerListe (i) ) - next i -end function -' -'------------------------------------------------------------------------------- -' -function KillDirListLocal ( lsList() as String ) as Boolean - '/// Delete all directories in the list - '/// <u>Input</u>: List with directories - '/// <u>Return</u>: TRUE or FALSE if directories are killed; modified list with not deleted directories. - Dim i as Integer - Dim FehlerListe ( 1000 ) as String - - FehlerListe ( 0 ) = 0 - for i=1 to ListCount ( lsList() ) - try - rmDir ( lsList(i) ) - catch - ListAppend ( FehlerListe (), lsList(i) ) - endcatch - next i - - lsList(0) = 0 ' delete old list - KillDirListLocal = TRUE - for i=1 to ListCount ( FehlerListe () ) - KillDirListLocal = FALSE - ListAppend ( lsList(), FehlerListe (i) ) - next i -end function -' -'------------------------------------------------------------------------------- -' -function GetFileSizesLocal ( lsList() as String ) as long - '/// Computes the total Filesize of the files in the list - '/// <u>Input</u>: List with files - '/// <u>Return</u>: Filesize in bytes - Dim iSum - Dim i as Integer - - iSum = 0 - for i=1 to ListCount ( lsList() ) - try - iSum = iSum + FileLen ( lsList(i) ) - catch - endcatch - next i - - GetFileSizesLocal = iSum -end function diff --git a/testautomation/global/tools/includes/required/t_doc1.inc b/testautomation/global/tools/includes/required/t_doc1.inc index ed74336dfc72..61c6afadab03 100644 --- a/testautomation/global/tools/includes/required/t_doc1.inc +++ b/testautomation/global/tools/includes/required/t_doc1.inc @@ -34,7 +34,6 @@ sub hNewDocument ( optional bANewDoc ) '/// hNewDocument : open a new document dependent on 'gApplication' ///' dim sTemp as string - gApplication = gApplication if IsMissing ( bANewDoc ) <> TRUE then if bANewDoc = TRUE then @@ -52,10 +51,10 @@ sub hNewDocument ( optional bANewDoc ) else FileOpen "FileName", "private:factory/swriter", "FrameName", "_default", "SynchronMode", TRUE end if - if ( DocumentWriter.IsMax() = false ) then - DocumentWriter.Maximize() - Wait( 2000 ) - end if + if ( DocumentWriter.IsMax() = false ) then + DocumentWriter.Maximize() + Wait( 2000 ) + end if case "CALC" Kontext "DocumentCalc" if gNoNewDoc = TRUE then @@ -63,10 +62,10 @@ sub hNewDocument ( optional bANewDoc ) else FileOpen "FileName", "private:factory/scalc", "FrameName", "_default", "SynchronMode", TRUE end if - if ( DocumentCalc.IsMax() = false ) then - DocumentCalc.Maximize() - Wait( 2000 ) - end if + if ( DocumentCalc.IsMax() = false ) then + DocumentCalc.Maximize() + Wait( 2000 ) + end if case "IMPRESS" Kontext "DocumentImpress" if gNoNewDoc = TRUE then @@ -84,10 +83,10 @@ sub hNewDocument ( optional bANewDoc ) end if Kontext "DocumentImpress" Sleep 2 - if ( DocumentImpress.IsMax() = false ) then - DocumentImpress.Maximize() - Wait( 2000 ) - end if + if ( DocumentImpress.IsMax() = false ) then + DocumentImpress.Maximize() + Wait( 2000 ) + end if end if case "DRAW" Kontext "DocumentDraw" @@ -96,10 +95,10 @@ sub hNewDocument ( optional bANewDoc ) else FileOpen "FileName", "private:factory/sdraw", "FrameName", "_default", "SynchronMode", TRUE end if - if ( DocumentDraw.IsMax() = false ) then - DocumentDraw.Maximize() - Wait( 2000 ) - end if + if ( DocumentDraw.IsMax() = false ) then + DocumentDraw.Maximize() + Wait( 2000 ) + end if case "MASTERDOCUMENT" Kontext "DocumentMasterDoc" if gNoNewDoc = TRUE then @@ -111,10 +110,10 @@ sub hNewDocument ( optional bANewDoc ) sleep (1) if Navigator.Exists(5) then Navigator.Close Kontext "DocumentMasterDoc" - if ( DocumentMasterDoc.IsMax() = false ) then - DocumentMasterDoc.Maximize() - Wait( 2000 ) - end if + if ( DocumentMasterDoc.IsMax() = false ) then + DocumentMasterDoc.Maximize() + Wait( 2000 ) + end if case "MATH" Kontext "DocumentMath" if gNoNewDoc = TRUE then @@ -123,10 +122,10 @@ sub hNewDocument ( optional bANewDoc ) FileOpen "FileName", "private:factory/smath", "FrameName", "_default", "SynchronMode", TRUE end if Kontext "DocumentMath" - if ( DocumentMath.IsMax() = false ) then - DocumentMath.Maximize() - Wait( 2000 ) - end if + if ( DocumentMath.IsMax() = false ) then + DocumentMath.Maximize() + Wait( 2000 ) + end if case "HTML" Kontext "DocumentWriterWeb" if gNoNewDoc = TRUE then @@ -135,10 +134,10 @@ sub hNewDocument ( optional bANewDoc ) FileOpen "FileName", "private:factory/swriter/web", "FrameName", "_default", "SynchronMode", TRUE end if Kontext "DocumentWriterWeb" - if ( DocumentWriterWeb.IsMax() = false ) then - DocumentWriterWeb.Maximize() - Wait( 2000 ) - end if + if ( DocumentWriterWeb.IsMax() = false ) then + DocumentWriterWeb.Maximize() + Wait( 2000 ) + end if case "DATABASE" FileOpen "FileName", "private:factory/sdatabase?Interactive", "FrameName", "_default", "SynchronMode", TRUE Kontext "DatabaseWizard" @@ -189,37 +188,55 @@ end sub '------------------------------------------------------------------------------- ' function hCreateLabels() as Boolean - '/// hCreateLabels : open the tab-dialog for making a new lable (file/new/lable) ///' - FileOpen "FileName", "private:factory/swriter?slot=21051", "FrameName", "_default", "SynchronMode", TRUE - Sleep (2) + + hCreateLabels() = false + + FileOpen( "FileName", "private:factory/swriter?slot=21051", "FrameName", "_default", "SynchronMode", TRUE ) + Kontext - Active.Setpage TabEtiketten - Kontext "TabEtiketten" - if Not TabEtiketten.Exists then - Warnlog "Dialog for Labels is not up!" - hCreateLabels = False + if ( Active.exists( 5 ) ) then + Active.setPage TabEtiketten + + if ( TabEtiketten.exists( 1 ) ) then + if ( Tabetiketten.isVisible() ) then + hCreateLabels() = true + else + warnlog( "<TabEtiketten> is not visible" ) + endif + else + warnlog( "<TabEtiketten> not open" ) + endif else - hCreateLabels = True + warnlog( "Failed to open <TabEtiketten>" ) endif - Sleep (2) + end function ' '------------------------------------------------------------------------------- ' function hCreateBusinessCards() as Boolean - '/// hCreateBusinessCards : open the tab-dialog for making a new business card (file/new/business cards) ///' - FileOpen "FileName", "private:factory/swriter?slot=21052", "FrameName", "_default", "SynchronMode", TRUE - Sleep (2) + + hCreateBusinessCards() = false + + FileOpen( "FileName", "private:factory/swriter?slot=21052", "FrameName", "_default", "SynchronMode", TRUE ) + Kontext - Active.Setpage TabEtikettenMedium - Kontext "TabEtikettenMedium" - if Not TabEtikettenMedium.Exists then - Warnlog "Dialog for BusinessCards is not up!" - hCreateBusinessCards = False + if ( Active.exists( 5 ) ) then + Active.setPage TabEtikettenMedium + + if ( TabEtikettenMedium.exists( 1 ) ) then + if ( TabetikettenMedium.isVisible() ) then + hCreateBusinessCards() = true + else + warnlog( "<TabEtikettenMedium> is not visible" ) + endif + else + warnlog( "<TabEtikettenMedium> not open" ) + endif else - hCreateBusinessCards = True + warnlog( "Failed to open <TabEtikettenMedium>" ) endif - Sleep (2) + end function ' '------------------------------------------------------------------------------- @@ -231,301 +248,206 @@ function hCloseDocument() '/// Accept to lose changes' Kontext "Active" - if Active.Exists(2) then + 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 ' '------------------------------------------------------------------------------- ' -sub gMouseClick ( X%, Y%, optional mb% ) - '/// gMouseClick ( x_Position, y-Position ) : make a mouseclick on the document (dependent on 'gApplication') ///' - '/// default left mousebutton will be used otherwise you can optionally give the mousebutton to press - '/// 1 = left mouse button - '/// 2 = left mouse button - '/// 3 = left mouse button +sub gMouseClick ( X%, Y%, optional _mousebutton ) - gApplication = gApplication + dim oDocument as object + dim mousebutton as integer - if IsMissing(mb%) then mb% = 1 + ' Handle infamous optional parameter + if ( IsMissing( _mousebutton ) ) then + mousebutton = 1 + else + mousebutton = _mousebutton + endif - select case gApplication - case "BACKGROUND" - Kontext "BACKGROUND" - autoexecute = false - Desktop.MouseDown ( X%, Y%, mb% ) - Desktop.MouseUp ( X%, Y%, mb% ) - autoexecute = true - case "CALC" - Kontext "DocumentCalc" - autoexecute = false - DocumentCalc.MouseDown ( X%, Y%, mb% ) - DocumentCalc.MouseUp ( X%, Y%, mb% ) - autoexecute = true - case "DRAW" - Kontext "DocumentDraw" - autoexecute=false - DocumentDraw.MouseDown ( X%, Y%, mb% ) - DocumentDraw.MouseUp ( X%, Y%, mb% ) - autoexecute=true - case "WRITER" - Kontext "DocumentWriter" - autoexecute=false - DocumentWriter.MouseDown ( X%, Y%, mb% ) - DocumentWriter.MouseUp ( X%, Y%, mb% ) - autoexecute=true - case "HTML" - Kontext "DocumentWriterWeb" - autoexecute=false - DocumentWriterWeb.MouseDown ( X%, Y%, mb% ) - DocumentWriterWeb.MouseUp ( X%, Y%, mb% ) - autoexecute=true - case "MASTERDOCUMENT" - Kontext "DocumentMasterDoc" - autoexecute=false - DocumentMasterDoc.MouseDown ( X%, Y%, mb% ) - DocumentMasterDoc.MouseUp ( X%, Y%, mb% ) - autoexecute=true - case "IMPRESS" - Kontext "DocumentImpress" - autoexecute=false - DocumentImpress.MouseDown ( X%, Y%, mb% ) - DocumentImpress.MouseUp ( X%, Y%, mb% ) - autoexecute=true - case "MATH" - Kontext "DocumentMath" - autoexecute=false - DocumentMath.MouseDown ( X%, Y%, mb% ) - DocumentMath.MouseDown ( X%, Y%, mb% ) - autoexecute=true - case "CHART" - Kontext "DocumentChart" - autoexecute=false - DocumentChart.MouseDown ( X%, Y%, mb% ) - DocumentChart.MouseUp ( X%, Y%, mb% ) - autoexecute=true - end select - sleep (2) + hSetDocumentContext() ' set kontext to current document type + oDocument = hSetDocumentObject() ' get the current document object + + autoexecute = false + oDocument.MouseDown ( X%, Y%, mousebutton ) + oDocument.MouseUp ( X%, Y%, mousebutton ) + autoexecute = true + wait( 1000 ) + end sub ' '------------------------------------------------------------------------------- ' sub gMouseDoubleClick ( X%, Y% ) - '/// gMouseDoubleClick ( x_Position, y-Position ) : make a mouse-doubleclick on the document ( dependent on 'gApplication' ) ///' - gApplication = gApplication - select case gApplication - case "CALC" - Kontext "DocumentCalc" - DocumentCalc.MouseDoubleClick ( X%, Y% ) - case "DRAW" - Kontext "DocumentDraw" - DocumentDraw.MouseDoubleClick ( X%, Y% ) - case "BACKGROUND" - Kontext "BACKGROUND" - Desktop.MouseDoubleClick ( X%, Y% ) - case "WRITER" - Kontext "DocumentWriter" - DocumentWriter.MouseDoubleClick ( X%, Y% ) - case "HTML" - Kontext "DocumentWriterWeb" - DocumentWriterWeb.MouseDoubleClick ( X%, Y% ) - case "MASTERDOCUMENT" - Kontext "DocumentMasterDoc" - DocumentMasterDoc.MouseDoubleClick ( X%, Y% ) - case "IMPRESS" - Kontext "DocumentImpress" - DocumentImpress.MouseDoubleClick ( X%, Y% ) - case "MATH" - Kontext "DocumentMath" - DocumentMath.MouseDoubleClick ( X%, Y% ) - end select - Sleep (2) + dim oDocument as object + + hSetDocumentContext() ' set kontext to current document type + oDocument = hSetDocumentObject() ' get the current document object + oDocument.MouseDoubleClick ( X%, Y% ) + wait( 1000 ) + end sub ' '------------------------------------------------------------------------------- ' sub gMouseMove ( BeginX%, BeginY%, EndX%, EndY% ) - '/// gMouseMove ( BeginX, BeginY, EndX, EndY ) : make a mousemove trom Bx,By to Ex,Ey on the document ( dependent on 'gApplication' ) ///' - gApplication = gApplication - select case gApplication - case "CALC" - Kontext "DocumentCalc" - DocumentCalc.MouseDown ( BeginX%, BeginY% ) - DocumentCalc.MouseMove ( EndX%, EndY%) - DocumentCalc.MouseUp ( EndX%, EndY% ) - case "DRAW" - Kontext "DocumentDraw" - DocumentDraw.MouseDown ( BeginX%, BeginY% ) - DocumentDraw.MouseMove ( EndX%, EndY% ) - DocumentDraw.MouseUp ( EndX%, EndY% ) - case "WRITER" - Kontext "DocumentWriter" - DocumentWriter.MouseDown ( BeginX%, BeginY% ) - DocumentWriter.MouseMove ( EndX%, EndY%) - DocumentWriter.MouseUp ( EndX%, EndY% ) - case "HTML" - Kontext "DocumentWriterWeb" - DocumentWriterWeb.MouseDown ( BeginX%, BeginY% ) - DocumentWriterWeb.MouseMove ( EndX%, EndY%) - DocumentWriterWeb.MouseUp ( EndX%, EndY% ) - case "MASTERDOCUMENT" - Kontext "DocumentMasterDoc" - DocumentMasterDoc.MouseDown ( BeginX%, BeginY% ) - DocumentMasterDoc.MouseMove ( EndX%, EndY%) - DocumentMasterDoc.MouseUp ( EndX%, EndY% ) - case "IMPRESS" - Kontext "DocumentImpress" - DocumentImpress.MouseDown ( BeginX%, BeginY% ) - DocumentImpress.MouseMove ( EndX%, EndY%) - DocumentImpress.MouseUp ( EndX%, EndY% ) - case "MATH" - Kontext "DocumentMath" - DocumentMath.MouseDown ( BeginX%, BeginY% ) - DocumentMath.MouseMove ( EndX%, EndY%) - DocumentMath.MouseDown ( EndX%, EndY% ) - end select - Sleep (2) + dim oDocument as object + + hSetDocumentContext() ' set kontext to current document type + oDocument = hSetDocumentObject() ' get the current document object + oDocument.MouseDown ( BeginX%, BeginY% ) + oDocument.MouseMove ( EndX%, EndY%) + oDocument.MouseUp ( EndX%, EndY% ) + wait( 1000 ) + end sub ' '------------------------------------------------------------------------------- ' sub gMouseDown ( BeginX%, BeginY% ) - '/// gMouseDown ( x_Position, y-Position ) : make a mousedown on the document (dependent on 'gApplication') ///' - '///+ DON'T FORGETT to call gMouseUp ! ///' - gApplication = gApplication - select case gApplication - case "CALC" - Kontext "DocumentCalc" - DocumentCalc.MouseDown ( BeginX%, BeginY% ) - case "DRAW" - Kontext "DocumentDraw" - DocumentDraw.MouseDown ( BeginX%, BeginY% ) - case "WRITER" - Kontext "DocumentWriter" - DocumentWriter.MouseDown ( BeginX%, BeginY% ) - case "HTML" - Kontext "DocumentWriterWeb" - DocumentWriterWeb.MouseDown ( BeginX%, BeginY% ) - case "MASTERDOCUMENT" - Kontext "DocumentMasterDoc" - DocumentMasterDoc.MouseDown ( BeginX%, BeginY% ) - case "IMPRESS" - Kontext "DocumentImpress" - DocumentImpress.MouseDown ( BeginX%, BeginY% ) - case "MATH" - Kontext "DocumentMath" - DocumentMath.MouseDown ( BeginX%, BeginY% ) - end select - Sleep (2) + dim oDocument as object + + hSetDocumentContext() ' set kontext to current document type + oDocument = hSetDocumentObject() ' get the current document object + oDocument.MouseDown ( BeginX%, BeginY% ) + wait( 300 ) + end sub ' '------------------------------------------------------------------------------- ' sub gMouseMove2 ( EndX%, EndY% ) - '/// gMouseMove2 ( x_Position, y-Position ) : move the pointer to position on the document (dependent on 'gApplication') ///' - gApplication = gApplication - select case gApplication - case "CALC" - Kontext "DocumentCalc" - DocumentCalc.MouseMove ( EndX%, EndY%) - case "DRAW" - Kontext "DocumentDraw" - DocumentDraw.MouseMove ( EndX%, EndY% ) - case "WRITER" - Kontext "DocumentWriter" - DocumentWriter.MouseMove ( EndX%, EndY%) - case "HTML" - Kontext "DocumentWriterWeb" - DocumentWriterWeb.MouseMove ( EndX%, EndY%) - case "MASTERDOCUMENT" - Kontext "DocumentMasterDoc" - DocumentMasterDoc.MouseMove ( EndX%, EndY%) - case "IMPRESS" - Kontext "DocumentImpress" - DocumentImpress.MouseMove ( EndX%, EndY%) - case "MATH" - Kontext "DocumentMath" - DocumentMath.MouseMove ( EndX%, EndY%) - end select - Sleep (2) + dim oDocument as object + + hSetDocumentContext() ' set kontext to current document type + oDocument = hSetDocumentObject() ' get the current document object + oDocument.MouseMove ( EndX%, EndY%) + wait( 300 ) + end sub ' '------------------------------------------------------------------------------- ' sub gMouseUp ( EndX%, EndY% ) - '/// gMouseUp ( x_Position, y-Position ) : make a release button on the document (dependent on 'gApplication') ///' - gApplication = gApplication - select case gApplication - case "CALC" - Kontext "DocumentCalc" - DocumentCalc.MouseUp ( EndX%, EndY% ) - case "DRAW" - Kontext "DocumentDraw" - DocumentDraw.MouseUp ( EndX%, EndY% ) - case "WRITER" - Kontext "DocumentWriter" - DocumentWriter.MouseUp ( EndX%, EndY% ) - case "HTML" - Kontext "DocumentWriterWeb" - DocumentWriterWeb.MouseUp ( EndX%, EndY% ) - case "MASTERDOCUMENT" - Kontext "DocumentMasterDoc" - DocumentMasterDoc.MouseUp ( EndX%, EndY% ) - case "IMPRESS" - Kontext "DocumentImpress" - DocumentImpress.MouseUp ( EndX%, EndY% ) - case "MATH" - Kontext "DocumentMath" - DocumentMath.MouseUp ( EndX%, EndY% ) - end select - Sleep (2) + dim oDocument as object + + hSetDocumentContext() ' set kontext to current document type + oDocument = hSetDocumentObject() ' get the current document object + oDocument.MouseUp ( EndX%, EndY% ) + wait( 300 ) + end sub ' '------------------------------------------------------------------------------- ' -sub hTypeKeys ( OutputText , optional iLoop as Integer ) - '/// hTypeKeys ( OutputText , optional iLoop as Integer ): type the keys in 'outputtext' 'iLoop' times ///' - Dim i as integer - - If IsMissing(iLoop) = True then iLoop = 1 - For i = 1 to iLoop - Select Case Ucase(gApplication) - Case "WRITER" - Kontext "DocumentWriter" - DocumentWriter.TypeKeys OutputText - Case "MASTERDOCUMENT" - Kontext "DocumentMasterDoc" - DocumentMasterDoc.TypeKeys OutputText - Case "HTML" - Kontext "DocumentWriterWeb" - DocumentWriterWeb.TypeKeys OutputText - case "CALC" - Kontext "DocumentCalc" - DocumentCalc.TypeKeys OutputText - case "DRAW" - Kontext "DocumentDraw" - DocumentDraw.TypeKeys OutputText - case "IMPRESS" - Kontext "DocumentImpress" - DocumentImpress.TypeKeys OutputText - case "MATH" - Kontext "DocumentMath" - DocumentMath.TypeKeys OutputText - end select - wait 500 - next i +sub hTypeKeys ( OutputText , optional _iLoop as Integer ) + + dim iRepeat as integer + dim iLoop as integer + dim oDocument as object + + ' Handle infamous optional parameter + If ( IsMissing( _iLoop ) ) then + iLoop = 1 + else + iLoop = _iLoop + endif + + 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 + end sub +'******************************************************************************* + +function hSetDocumentContext() as string + + ' link gApplication to its document kontext + + dim cDocumentContext as string + + select case( gApplication ) + case "DRAW" : cDocumentContext = "DocumentDraw" + case "IMPRESS" : cDocumentContext = "DocumentImpress" + case "WRITER" : cDocumentContext = "DocumentWriter" + case "CALC" : cDocumentContext = "DocumentCalc" + case "MATH" : cDocumentContext = "DocumentMath" + case "HTML" : cDocumentContext = "DocumentWriterWeb" + case "MASTERDOCUMENT" : cDocumentContext = "DocumentMasterDoc" + case "CHART" : cDocumentContext = "DocumentChart" + case "BACKGROUND" : cDocumentContext = "Background" + case else : warnlog( "Unknown gApplication: " & gApplication ) + end select + + kontext cDocumentContext : hSetDocumentContext() = cDocumentContext + +end function + +'******************************************************************************* + +function hSetDocumentObject() as object + + ' link gApplication to its document object + + dim oDocumentObject as object + + select case( gApplication ) + Case "WRITER" : oDocumentObject = DocumentWriter + Case "MASTERDOCUMENT" : oDocumentObject = DocumentMasterDoc + Case "HTML" : oDocumentObject = DocumentWriterWeb + case "CALC" : oDocumentObject = DocumentCalc + case "DRAW" : oDocumentObject = DocumentDraw + case "IMPRESS" : oDocumentObject = DocumentImpress + case "MATH" : oDocumentObject = DocumentMath + case "CHART" : oDocumentObject = DocumentChart + case "BACKGROUND" : oDocumentObject = Desktop + case else : warnlog( "Unknown gApplication: " & gApplication ) + end select + + hSetDocumentObject() = oDocumentObject + +end function + +'******************************************************************************* + +function hSetDocumentFactory() as string + + ' link gApplication to its factory as used by FileOpen slot + + dim cDocumentFactory as string + + select case( gApplication ) + case "DRAW" : cDocumentFactory = "private:factory/sdraw" + case "IMPRESS" : cDocumentFactory = "private:factory/simpress" + case "WRITER" : cDocumentFactory = "private:factory/swriter" + case "CALC" : cDocumentFactory = "private:factory/scalc" + case "MATH" : cDocumentFactory = "private:factory/smath" + case "HTML" : cDocumentFactory = "private:factory/swriter/web" + case "MASTERDOCUMENT" : cDocumentFactory = "private:factory/swriter/GlobalDocument" + case "DATABASE" : cDocumentFactory = "private:factory/sdatabase?Interactive" + case else : warnlog( "Unknown gApplication: " & gApplication ) + end select + + hSetDocumentFactory() = cDocumentFactory + +end function
\ No newline at end of file diff --git a/testautomation/global/tools/includes/required/t_doc2.inc b/testautomation/global/tools/includes/required/t_doc2.inc index efd2d2799a0e..4941d0fcf7ad 100755 --- a/testautomation/global/tools/includes/required/t_doc2.inc +++ b/testautomation/global/tools/includes/required/t_doc2.inc @@ -31,35 +31,34 @@ '* '\*********************************************************************** -private const VERBOSE = TRUE - sub hTabelleEinfuegen '/// <b>WRITER only </b>///' '/// hTabelleEinfuegen hInsertTable ///' '/// insert a dummy table in writer/writerweb/masterdocument ///' TableInsertTable - sleep(2) + Kontext "TabelleEinfuegenWriter" - wait 500 - TabelleEinfuegenWriter.OK - sleep(1) - - Kontext "TableObjectbar" - sleep(1) - if TableObjectbar.NotExists then - Kontext "TextObjectbar" - TextObjectbar.SetNextToolBox - end if + if ( TabelleEinfuegenWriter.exists( 2 ) ) then + + hCloseDialog( TabelleEinfuegenWriter, "ok" ) + + Kontext "TableObjectbar" + if ( TableObjectbar.exists( 1 ) ) then + ' We are happy then, do nothing + else + Kontext "TextObjectbar" + TextObjectbar.SetNextToolBox + end if + + select case ( gApplication ) + Case "WRITER" : Kontext "DocumentWriter" + Case "MASTERDOCUMENT" : Kontext "DocumentMasterDoc" + Case "HTML" : Kontext "DocumentWriterWeb" + end select + else + warnlog( "hTabelleEinfuegen: Failed to open <TabelleEinfuegenWriter> dialog" ) + endif - select case uCASE(gApplication) - Case "WRITER" - Kontext "DocumentWriter" - Case "MASTERDOCUMENT" - Kontext "DocumentMasterDoc" - Case "HTML" - Kontext "DocumentWriterWeb" - end select - sleep(1) end sub ' '------------------------------------------------------------------------------- @@ -109,14 +108,48 @@ sub SchreibenInMathdok ( Eingabe as String ) warnlog "--No Clipboard available :-(--" printlog "---ClipTest--- should: "+Eingabe +", is: "+GetClipboard endif - EditPaste - sleep(3) + hUseAsyncSlot( "EditPaste" ) 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) @@ -124,22 +157,22 @@ function sMakeReadOnlyDocumentEditable() as boolean dim iWait as integer dim rc as integer const CFN = "sMakeReadOnlyDocumentEditable::" - - if ( VERBOSE ) then printlog( CFN & "Making document editable (create a copy) if it is readonly" ) - + + 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 + ' 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 ( VERBOSE ) then printlog( "Handling create copy message" ) + if ( GVERBOSE ) then printlog( "Handling create copy message" ) Active.yes() wait( 1000 ) endif @@ -153,12 +186,12 @@ function sMakeReadOnlyDocumentEditable() as boolean exit do endif catch - if ( VERBOSE ) then printlog "Attempt " & iWait & " to make document readable failed" + if ( GVERBOSE ) then printlog "Attempt " & iWait & " to make document readable failed" iWait = iWait + 1 wait ( 1000 ) endcatch else - if ( VERBOSE ) then printlog "Attempt " & iWait & " to make document readable failed" + if ( GVERBOSE ) then printlog "Attempt " & iWait & " to make document readable failed" iWait = iWait + 1 wait ( 1000 ) end if @@ -166,26 +199,26 @@ function sMakeReadOnlyDocumentEditable() as boolean 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 ( VERBOSE ) then printlog( CFN & "Document was read-only. A copy will be used." ) + if ( GVERBOSE ) then printlog( CFN & "Document was read-only. A copy will be used." ) Active.Yes() - if ( VERBOSE ) then printlog( CFN & "Closed 'use copy' message" ) + if ( GVERBOSE ) then printlog( CFN & "Closed 'use copy' message" ) catch - if ( VERBOSE ) then printlog( CFN & "Probing for unexpected messagebox..." ) + if ( GVERBOSE ) then printlog( CFN & "Probing for unexpected messagebox..." ) active.ok() qaerrorlog( "#i100701 - Object not found message" ) endcatch @@ -198,13 +231,13 @@ function sMakeReadOnlyDocumentEditable() as boolean printlog( CFN & "Document appears to be editable" ) endif else - if ( VERBOSE ) then printlog( CFN & "Button <Bearbeiten> is pressed, document is editable" ) + if ( GVERBOSE ) then printlog( CFN & "Button <Bearbeiten> is pressed, document is editable" ) sMakeReadOnlyDocumentEditable() = FALSE endif else - if ( VERBOSE ) then printlog( CFN & "Control <Bearbeiten> is not enabled" ) + if ( GVERBOSE ) then printlog( CFN & "Control <Bearbeiten> is not enabled" ) endif - + end function ' '------------------------------------------------------------------------------- @@ -215,16 +248,20 @@ function fSelectFirstOLE() as integer '+ 0 := Sucess '- 1 := unknown application - dim bNavigatorWasVisible as boolean - bNavigatorWasVisible = FALSE - dim iIndex + const RETVAL_SUCCESS = 0 + const RETVAL_UNKNOWN_APPLICATION = -1 + + const MAX_WAIT_FOR_NAVIGATOR = 10 + + dim bNavigatorWasVisible as boolean : bNavigatorWasVisible = FALSE + dim iIndex as integer - fSelectFirstOLE = -1 + fSelectFirstOLE() = RETVAL_UNKNOWN_APPLICATION - select case uCASE(gApplication) + select case ( gApplication ) case "CALC" : Kontext "NavigatorCalc" 'First check if Navigator is visible and remember result - if NavigatorCalc.exists (10) then + if NavigatorCalc.exists ( MAX_WAIT_FOR_NAVIGATOR ) then bNavigatorWasVisible = TRUE else try @@ -240,7 +277,7 @@ function fSelectFirstOLE() as integer endcatch end if Kontext "NavigatorCalc" - if NavigatorCalc.exists (10) then + if NavigatorCalc.exists ( MAX_WAIT_FOR_NAVIGATOR ) then 'Select first OLE in list Liste.TypeKeys "<HOME>" for iIndex = 1 to 8 @@ -252,12 +289,12 @@ function fSelectFirstOLE() as integer Liste.select(6) Liste.TypeKeys "+" Liste.TypeKeys "<DOWN><RETURN>" - fSelectFirstOLE = 0 + fSelectFirstOLE() = RETVAL_SUCCESS else QAErrorLog "Navigator couldn't be opened!" end if case "DRAW" , "IMPRESS" : Kontext "NavigatorDraw" - if NavigatorDraw.Exists(10) then + if NavigatorDraw.Exists( MAX_WAIT_FOR_NAVIGATOR ) then bNavigatorWasVisible = TRUE else try @@ -272,21 +309,21 @@ function fSelectFirstOLE() as integer ViewNavigator endcatch Kontext "NavigatorDraw" - if NavigatorDraw.exists(10) then + if NavigatorDraw.exists( MAX_WAIT_FOR_NAVIGATOR ) then 'Select first OLE in list Liste.TypeKeys "<HOME>" Liste.select(1) Liste.TypeKeys "+<DOWN><RETURN>" - fSelectFirstOLE = 0 + fSelectFirstOLE() = RETVAL_SUCCESS else - QAErrorLog "Navigator did not occoured!" + QAErrorLog "Navigator did not open!" end if end if case "WRITER" , "HTML" , "MASTERDOCUMENT" : - select case uCASE(gApplication) + select case ( gApplication ) case "MASTERDOCUMENT" : Kontext "NavigatorGlobalDoc" - if NavigatorGlobalDoc.Exists(10) then + if NavigatorGlobalDoc.Exists( MAX_WAIT_FOR_NAVIGATOR ) then bNavigatorWasVisible = TRUE else ViewNavigator @@ -299,7 +336,7 @@ function fSelectFirstOLE() as integer endif case else : Kontext "NavigatorWriter" 'First check if Navigator is visible and remember result - if NavigatorWriter.Exists (10) then + if NavigatorWriter.Exists ( MAX_WAIT_FOR_NAVIGATOR ) then bNavigatorWasVisible = TRUE else try @@ -317,7 +354,7 @@ function fSelectFirstOLE() as integer end if end select Kontext "NavigatorWriter" - if NavigatorWriter.Exists(10) then + if NavigatorWriter.Exists( MAX_WAIT_FOR_NAVIGATOR ) then ' Check if all content is visible if Auswahlliste.GetItemCount < 2 then Inhaltsansicht.Click @@ -329,7 +366,7 @@ function fSelectFirstOLE() as integer next iIndex Auswahlliste.select(5) Auswahlliste.TypeKeys "+<DOWN><RETURN>" - fSelectFirstOLE = 0 + fSelectFirstOLE() = RETVAL_SUCCESS else QAErrorLog "Navigator did not occoured!" end if @@ -340,7 +377,7 @@ function fSelectFirstOLE() as integer if bNavigatorWasVisible = TRUE then printlog "Leaving navigator open as initially found" else - if fSelectFirstOLE = 0 then + if ( fSelectFirstOLE = RETVAL_SUCCESS ) then ViewNavigator printlog "Closing navigator as initially found" else diff --git a/testautomation/global/tools/includes/required/t_files.inc b/testautomation/global/tools/includes/required/t_files.inc index 0736de15debf..42b575c1187a 100644..100755 --- a/testautomation/global/tools/includes/required/t_files.inc +++ b/testautomation/global/tools/includes/required/t_files.inc @@ -31,328 +31,125 @@ '* '\****************************************************************************** -private const VERBOSE = FALSE ' set to TRUE for debugging +function hGrafikEinfuegen( cFile as string ) as Boolean -function hGrafikEinfuegen ( Grafik$ ) as Boolean - '/// hGrafikEinfuegen hGraphicInsert - '/// A graphic will be inserted (not linked). - '/// <u>Input</u>: Filename with complete path - '/// <u>Return</u>: TRUE or FALSE if the graphic could be inserted or not. + hGrafikEinfuegen() = hInsertGraphic( cFile, "Static" ) + exit function + +end function - Dim DieDatei as String - Dim IsActive as Boolean +'******************************************************************************* - DieDatei = ConvertPath ( Grafik$ ) +function hGrafikVerknuepftEinfuegen( cFile as string ) as Boolean - InsertGraphicsFromFile - WaitSlot() + hGrafikVerknuepftEinfuegen() = hInsertGraphic( cFile, "Linked" ) + exit function - Kontext - If Active.Exists(1) then - warnlog " Hinweis: " & Active.GetText - Active.Ok - End If +end function +'******************************************************************************* - Kontext "GrafikEinfuegenDlg" - if ( GrafikEinfuegenDlg.exists( 2 ) ) then +function hInsertGraphic( byval cFile as string, byval cMode as string ) as boolean - Vorschau.Uncheck - if gApplication <> "HTML" then - Verknuepfen.UnCheck - end if + ' Insert a graphic file to the current document either linked or static + ' cFile: Fully qualified path to the file to be inserted + ' cMode: Supply "Linked" to link, empty string or anything else is static - Dateiname.SetText DieDatei - DateiTyp.Select 1 ' set the filter to 'all formats' - Oeffnen.Click + ' In difference to the older functions (GrafikEinfuegen etc.) this function + ' does provide a working returnvalue and does not secretly hide warnings and + ' errors. It does not set the file type. - Kontext "Active" - if Active.Exists(2) then - Warnlog " Hinweis: " & Active.GetText - try - Active.OK - catch - try - Active.Yes - catch - Active.Cancel - endcatch - endcatch - Kontext "GrafikEinfuegenDlg" - if GrafikEinfuegenDlg.Exists then - GrafikEinfuegenDlg.Cancel - GarfikEinfuegenDlg.notExists( 4 ) - endif - else - hGrafikEinfuegen = IsImageLoaded - end if - else - warnlog( "Insert graphics dialog not open" ) - endif - -end function -' -'------------------------------------------------------------------------------- -' -function hGrafikVerknuepftEinfuegen ( Grafik$ ) as Boolean - '/// hGrafikEinfuegenEinfuegen hGraphicInsertLinked - '/// A graphic will be inserted <b>LINKED</b> - '/// <u>Input</u>: Filename with complete path - '/// <u>Return</u>: TRUE or FALSE if the graphic could be inserted or not. - Dim DieDatei as String - Dim IsActive as Boolean - - DieDatei = ConvertPath ( Grafik$ ) - - InsertGraphicsFromFile - WaitSlot() - - Kontext - If Active.Exists(1) then - warnlog " Hinweis: " & Active.GetText - Active.Ok - End If - Kontext "GrafikEinfuegenDlg" - if ( GrafikEinfuegenDlg.exists( 1 ) ) then - - Vorschau.UnCheck - if gApplication <> "HTML" AND gApplication <> "HTML" then - Verknuepfen.Check - end if + ' Make hFileWait() complain about any messageboxes + const SHOW_WARNINGS = true - Dateiname.SetText DieDatei - DateiTyp.Select 1 ' set the filter to 'all formats' - Oeffnen.Click + ' Find out whether we link the file or not + dim bLinked as boolean : bLinked = false + if ( lcase( cMode ) = "linked" ) then bLinked = true - Kontext "Active" - if Active.Exists(2) then - Warnlog " Hinweis: " + Active.GetText - try - Active.OK - catch - Active.Yes - endcatch - Kontext "GrafikEinfuegenDlg" - if GrafikEinfuegenDlg.Exists then - GrafikEinfuegenDlg.Cancel + hInsertGraphic() = false + cFile = convertpath( cFile ) + + if ( FileExists( cFile ) ) then + InsertGraphicsFromFile + + kontext "GrafikEinfuegenDlg" + if ( GrafikEinfuegenDlg.exists( 3 ) ) then + + Vorschau.unCheck() + if ( Verknuepfen.isEnabled() ) then + if ( bLinked ) then + Verknuepfen.check() + else + Verknuepfen.unCheck() + endif endif + + DateiName.setText( cFile ) + Oeffnen.click() + + if ( hFileWait( SHOW_WARNINGS ) >= 0 ) then hInsertGraphic() = true + else - hGrafikVerknuepftEinfuegen = IsImageLoaded - end if + warnlog( "hInsertGraphic(): Failed to open <Insert Graphics> dialog" ) + endif else - 'GrafikEinfuegenDlg not open + warnlog( "hInsertGraphic(): File does not exist: " & cFile ) endif + end function -' -'------------------------------------------------------------------------------- -' -function IsItSaved as boolean - '/// IsItSaved - '/// Wait until document is saved. - Dim iLoop as integer - IsItSaved = FALSE - sleep(3) - for iLoop =1 to 20 - try - 'Calling slot 'IsDocSaving' - IsItSaved = IsDocSaving - catch - IsItSaved = FALSE - endcatch +'******************************************************************************* - if IsItSaved = TRUE then - exit for - end if - sleep(1) - next iLoop - sleep(2) -end function -' -'------------------------------------------------------------------------------- -' -function IsItLoaded as boolean - '/// IsItLoaded - '/// Wait until document is loaded - Dim iLoop as integer +function hIsNamedDocLoaded( cFileName as string ) as boolean - IsItLoaded = FALSE - sleep(3) - for iLoop =1 to 20 - try - 'Calling slot 'IsDocLoading' - IsItLoaded = IsDocLoading - catch - IsItLoaded = FALSE - endcatch + ' Retrieve the current filename from the document properties - which in + ' comparision to the old approach to retrive 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 + ' error, though. - if IsItLoaded = TRUE then - exit for - end if - sleep(1) - next iLoop - sleep(2) -end function -' -'------------------------------------------------------------------------------- -' -function hIsNamedDocLoaded (ShouldFile as String, optional bSilent as boolean) as Boolean - dim sTemp as string - '/// hIsNamedDocLoaded ///' - '/// !fails always if a template is loaded, because you have to set a new filename in the save-dialog -> not usable in this case ! ///' - '/// Input: name of loaded file; Output: True/False ///' - '///+' if a doc got loaded, the filename in a 'SaveAs' Dlg is different from "" /// - '///+' usually the file name of the loaded document with an changed extension chosen from SO /// - - if (isMissing(bSilent)) then - bSilent = False - endif + const CFN = "global::tools::includes::required::hIsNamedDocumentLoaded(): " + const RC_FAILURE = -1 - hIsNamedDocLoaded = FALSE ' Let's start WorstCase :-( - FileSaveAs - Kontext "SpeichernDlg" - If DateiOhneExt(DateiExtract(Dateiname.GetSelText)) = DateiOhneExt(DateiExtract(ShouldFile)) Then - hIsNamedDocLoaded = True - Else - sTemp = left(right(ShouldFile,2),1) ' get the 2nd last character ' vor;dot;sti;pot;std;xlt - if (((sTemp="o") or (sTemp="t") or (sTemp="l")) and ((left(right(ShouldFile,4),1)=".") or (left(right(ShouldFile,5),1)="."))) then - hIsNamedDocLoaded = TRUE ' exception! for linux! and MS-Office Templates - else - if ((Dateiname.GetSeltext = "") and not bSilent) then - Warnlog "Default filename is empty!"+left(right(ShouldFile,3),1) + dim cDocumentName as string + dim iDocumentNameLength as integer + + hIsNamedDocLoaded() = false + + if ( hUseAsyncSlot( "FileProperties" ) <> RC_FAILURE ) then + + kontext "TabDokument" + if ( TabDokument.exists( 2 ) ) then + + cDocumentName = DokumentName.getText() + iDocumentNameLength = len( cDocumentName ) + + if ( GVERBOSE ) then + printlog( CFN & "Expected file: " & cFileName ) + printlog( CFN & "Current file.: " & cDocumentName ) + printlog( CFN & "Comparing last " & iDocumentNameLength & " characters" ) endif - endif - End If - SpeichernDlg.Cancel -end function -' -'------------------------------------------------------------------------------- -' -function IsImageLoaded - '/// IsImageLoaded - '/// Wait until images in document are loaded - Dim i% : Dim Herbert as Boolean - Sleep 3 - for i%=1 to 20 - try - Herbert = IsDocImageLoading - catch - Herbert = FALSE - endcatch - if Herbert = TRUE then - i%=100 + if ( right( cFileName, iDocumentNameLength ) = cDocumentName ) then + if ( GVERBOSE ) then printlog( CFN & "This is the expected file" ) + hIsNamedDocLoaded() = true + else + if ( GVERBOSE ) then printlog( CFN & "This is *not* the expected file" ) + endif + + hCloseDialog( TabDokument, "cancel" ) + else + warnlog( CFN & "Unable to open dialog <Document Properties>" ) endif - Sleep (1) - next i% - if i<100 then - IsImageLoaded = FALSE - else - IsImageLoaded = TRUE - end if -end function -' -'------------------------------------------------------------------------------- -' -sub hIsWebPageLoaded as boolean - 'Author: Joerg Sievers - '/// If a document in StarOffice Writer is loaded all 9 items in the - '///+ statusbar are visible otherwise not. - '///+ This sub checks the state of these items. - Dim i as integer - Dim iGibtdenStatusraus as integer - printlog "- global::tools::inc::tfiles.inc::hIsWebPageLoaded" - hIsWebPageLoaded = FALSE - for i = 1 to 20 - Kontext "DocumentWriter" - if DocumentWriter.Exists(3) then - 'Count the items on the status bar. - iGibtdenStatusraus = DocumentWriter.StatusGetItemCount - 'There are nine items on the status bar if the web page has been loaded. - if iGibtdenStatusraus = 9 then - hIsWebPageLoaded = TRUE - exit for - end If - end if - WaitSlot( 3000 ) - next i -end sub -' -'------------------------------------------------------------------------------- -' -sub hSys2IntDlg - '/// Change from system to StarOffice-internal file-dialog (only for Win32) - if gPlatgroup <> "unx" then - Call hhSysToInt ( TRUE ) - endif - gUseSysDlg = FALSE -end sub -' -'------------------------------------------------------------------------------- -' -sub hInt2SysDlg - '/// Change from StarOffice-internal to system file-dialog (only for Win32) - if gPlatgroup <> "unx" then - Call hhSysToInt ( FALSE ) - endif - gUseSysDlg = TRUE -end sub -' -'------------------------------------------------------------------------------- -' -sub hhSysToInt ( bwhats as Boolean ) - '/// subroutine for <i>hSys2IntDlg</i> and </i>hInt2SysDlg</i> - ToolsOptions - hToolsOptions ( "StarOffice", "General" ) - if bwhats = TRUE then - StarOfficeDialogeBenutzen.Check else - StarOfficeDialogeBenutzen.Uncheck - end if - Sleep 1 - Kontext "OptionenDlg" - OptionenDlg.OK - WaitSlot( 3000 ) -end sub -' -'------------------------------------------------------------------------------- -' -function hGetUsedFilter () as string - '/// Get used filter for loaded file. - try - FileSaveAs - Kontext "SpeichernDlg" - hGetUsedFilter = dateityp.getseltext - SpeichernDlg.Cancel - catch - hGetUsedFilter = "Not possible; try/catch fail in function" - endcatch -end function -' -'------------------------------------------------------------------------------- -' -function hFileExport (sName as string, sFilter as string) as boolean - '/// Wrapper function to simplify the use of the export functions, just give a filename and export format. - '///+ INPUT:<ul><li>sName: filename</li><li>sFilter: "PDF": call export for PDF</li></ul> - '///+ RETURN: execution success? - select case sFilter - case "PDF" : '/// use the function 'hExportAsPDF' with RECOMMENDED values /// ' - hFileExport = hExportAsPDFmulti (3, TRUE, sName, FALSE, TRUE, 1, 1) - end select - kontext - if active.exists(5) then - try - printlog active.getText - active.ok - warnLog "i26820 - errormessage about saving" - catch - printlog "pdf unexpected error in hFileExport()" - endcatch + warnlog( CFN & "Unable to execute slot <FileProperties>" ) endif + end function -' -'------------------------------------------------------------------------------- -' + +'******************************************************************************* + function hExportAsPDFmulti (iTypeOfCall as integer, bExecute as boolean, sFileName as string, bAutoExtension as boolean, bOverwriteFile as boolean, iRange as integer, iConpression as integer, optional sRange as string) as boolean '/// Export a document to PDF with various options. '///+ INPUT @@ -633,6 +430,12 @@ end function ' '------------------------------------------------------------------------------- ' +function hFileDelete( cFileOrig as string ) as boolean + hFileDelete() = hDeleteFile( cFileOrig ) +end function +' +'------------------------------------------------------------------------------- +' function hDeleteFile( cFileOrig as string ) as boolean const CFN = "global::tools::includes::required::t_files.inc::hDeleteFile():" @@ -665,7 +468,7 @@ function hDeleteFile( cFileOrig as string ) as boolean warnlog( CFN & "File was not deleted: " & cFile ) hDeleteFile() = false else - if ( VERBOSE ) then printlog( CFN & "File successfully deleted: " & cFile ) + if ( GVERBOSE ) then printlog( CFN & "File successfully deleted: " & cFile ) hDeleteFile() = true endif catch @@ -698,8 +501,8 @@ function hFileOpen( cFile as string ) as boolean dim sFile as string : sFile = convertToURL( convertpath( cFile ) ) hFileOpen() = FALSE - const CFN = "global::tools::inc::t_files.inc::hFileOpen():" - if ( VERBOSE ) then printlog( CFN & "Load: " & sFile ) + const CFN = "global::tools::inc::t_files.inc::hFileOpen(): " + if ( GVERBOSE ) then printlog( CFN & "Load: " & sFile ) FileOpen( "URL", sFile, "FrameName", "_default" ) if ( hFileWait( FALSE ) >= 0 ) then hFileOpen() = TRUE @@ -715,9 +518,9 @@ function hFileOpenSpecial( cFile as string, cFlag as string ) as boolean ' cFlag = <Any other string> treats string as password dim sFile as string : sFile = convertToURL( convertpath( cFile ) ) - const CFN = "global::tools::inc::t_files.inc::hFileOpenSpecial():" + const CFN = "global::tools::inc::t_files.inc::hFileOpenSpecial(): " hFileOpenSpecial() = FALSE - if ( VERBOSE ) then printlog( "Load (Flag): " & sFile & " (" & cFlag & ")" ) + if ( GVERBOSE ) then printlog( "Load (Flag): " & sFile & " (" & cFlag & ")" ) select case( lcase( cFlag ) ) case "readonly" @@ -740,9 +543,9 @@ end function function hFileOpenWithFilter( cFile as string, cFilter as string ) dim sFile as string : sFile = convertToURL( convertpath( cFile ) ) - const CFN = "global::tools::inc::t_files.inc::hFileOpenWithFilter():" + const CFN = "global::tools::inc::t_files.inc::hFileOpenWithFilter(): " hFileOpenWithFilter() = FALSE - if ( VERBOSE ) then printlog( CFN & "Load (Filter): " & sFile & " (" & cFilter & ")" ) + if ( GVERBOSE ) then printlog( CFN & "Load (Filter): " & sFile & " (" & cFilter & ")" ) FileOpen( "URL", sFile, "FrameName", "_default", "FilterName", cFilter ) if ( hFileWait( FALSE ) >= 0 ) then hFileOpenWithFilter() = TRUE @@ -752,9 +555,9 @@ end function ' function hFileSave() as boolean - const CFN = "global::tools::inc::t_files.inc::hFileSave():" + const CFN = "global::tools::inc::t_files.inc::hFileSave(): " hFileSave() = FALSE - if ( VERBOSE ) then printlog( CFN & "Save file." ) + if ( GVERBOSE ) then printlog( CFN & "Save file." ) FileSave( "SynchronMode", TRUE ) if ( hFileWait( TRUE ) >= 0 ) then hFileSave() = TRUE @@ -765,9 +568,9 @@ end function function hFileSaveAs( cFile as string ) as boolean dim sFile as string : sFile = convertToURL( convertpath( cFile ) ) - const CFN = "global::tools::inc::t_files.inc::hFileSaveAs():" + const CFN = "global::tools::inc::t_files.inc::hFileSaveAs(): " hFileSaveAs() = FALSE - if ( VERBOSE ) then printlog( CFN & "Save: " & sFile ) + if ( GVERBOSE ) then printlog( CFN & "Save: " & sFile ) FileSaveAs( "URL", sFile, "Overwrite", FALSE ) if ( hFileWait( TRUE ) >= 0 ) then hFileSaveAs() = TRUE @@ -778,9 +581,9 @@ end function function hFileSaveAsKill( cFile as string ) as boolean dim sFile as string : sFile = convertToURL( convertpath( cFile ) ) - const CFN = "global::tools::inc::t_files.inc::hFileSaveAsKill():" + const CFN = "global::tools::inc::t_files.inc::hFileSaveAsKill(): " hFileSaveAsKill() = FALSE - if ( VERBOSE ) then printlog( CFN & "Save, replacing: " & sFile ) + if ( GVERBOSE ) then printlog( CFN & "Save, replacing: " & sFile ) FileSaveAs( "URL", sFile, "Overwrite", TRUE ) if ( hFileWait( TRUE ) >= 0 ) then hFileSaveAsKill() = TRUE @@ -791,9 +594,9 @@ end function function hFileSaveAsKillWithPassword( cFile as string, cPassword as string ) as boolean dim sFile as string : sFile = convertToURL( convertpath( cFile ) ) - const CFN = "global::tools::inc::t_files.inc::hFileSaveAsKillWithPassword():" + const CFN = "global::tools::inc::t_files.inc::hFileSaveAsKillWithPassword(): " hFileSaveAsKillWithPassword() = FALSE - if ( VERBOSE ) then printlog( CFN & "Save with password, replacing: " & sFile & "::" & cPassword ) + if ( GVERBOSE ) then printlog( CFN & "Save with password, replacing: " & sFile & "::" & cPassword ) FileSaveAs( "URL", sFile, "Overwrite", TRUE, "Password", cPassword ) if ( hFileWait( TRUE ) >= 0 ) then hFileSaveAsKillWithPassword() = TRUE @@ -804,9 +607,9 @@ end function function hFileSaveAsWithFilter( cFile as string, cFilter as string ) as boolean dim sFile as string : sFile = convertToURL( convertpath( cFile ) ) - const CFN = "global::tools::inc::t_files.inc::hFileSaveAsWithFilter():" + const CFN = "global::tools::inc::t_files.inc::hFileSaveAsWithFilter(): " hFileSaveAsWithFilter() = FALSE - if ( VERBOSE ) then printlog( CFN & "Save with filter: " & sFile & "::" & cFilter ) + if ( GVERBOSE ) then printlog( CFN & "Save with filter: " & sFile & "::" & cFilter ) FileSaveAs( "URL", sFile, "FilterName", cFilter, "Overwrite", FALSE ) if ( hFileWait( TRUE ) >= 0 ) then hFileSaveAsWithFilter() = TRUE @@ -817,9 +620,9 @@ end function function hFileSaveAsWithFilterKill( cFile as string, cFilter as string ) as boolean dim sFile as string : sFile = convertToURL( convertpath( cFile ) ) - const CFN = "global::tools::inc::t_files.inc::hFileSaveAsWithFilterKill():" + const CFN = "global::tools::inc::t_files.inc::hFileSaveAsWithFilterKill(): " hFileSaveAsWithFilterKill() = FALSE - if ( VERBOSE ) then printlog( CFN & "Save with filter, replacing: " & sFile & "::" & cFilter ) + if ( GVERBOSE ) then printlog( CFN & "Save with filter, replacing: " & sFile & "::" & cFilter ) FileSaveAs( "URL", sFile, "FilterName", cFilter, "Overwrite", TRUE ) if ( hFileWait( TRUE ) >= 0 ) then hFileSaveAsWithFilterKill() = TRUE @@ -833,7 +636,7 @@ function hFileWait( optional bWarn as boolean ) as integer ' Returns the time it took the slot to finish ' Negative returnvalues are given on timeout or any blocking dialog - const CFN = "global::tools::inc::t_files.inc::hFileWait():" + const CFN = "global::tools::inc::t_files.inc::hFileWait(): " const MAX_WAIT = 10 dim iWait as integer : iWait = 0 dim bWarnlog as boolean @@ -924,7 +727,7 @@ function hFileWait( optional bWarn as boolean ) as integer loop - if ( VERBOSE ) then + if ( GVERBOSE ) then select case iWait case -1 : printlog( CFN & "Timeout reached, rc = " & iWait ) case -2 : printlog( CFN & "Macro security warning displayed, rc = " & iWait ) diff --git a/testautomation/global/tools/includes/required/t_filters.inc b/testautomation/global/tools/includes/required/t_filters.inc index 21ba12af5363..f6a2beca6eb0 100644..100755 --- a/testautomation/global/tools/includes/required/t_filters.inc +++ b/testautomation/global/tools/includes/required/t_filters.inc @@ -516,4 +516,19 @@ function hGetSection( lsList() as string , iSectionBegin as integer , iSectionEn end function +'******************************************************************************* + +function hGetUsedFilter () as string + + ' used in math and graphics modules + '/// Get used filter for loaded file. + try + FileSaveAs + Kontext "SpeichernDlg" + hGetUsedFilter = dateityp.getseltext + SpeichernDlg.Cancel + catch + hGetUsedFilter = "Not possible; try/catch fail in function" + endcatch +end function diff --git a/testautomation/global/tools/includes/required/t_lists.inc b/testautomation/global/tools/includes/required/t_lists.inc index 3819a21097b0..f32db2f29277 100644..100755 --- a/testautomation/global/tools/includes/required/t_lists.inc +++ b/testautomation/global/tools/includes/required/t_lists.inc @@ -595,31 +595,5 @@ function hListClearBlank( lsList() as string ) as integer end function -'******************************************************************************* - -function hListIntegrityTest( sList() as string ) as boolean - - const CFN = "global::tools::inc::t_list.inc::hListIntegrityTest:" - - '///<h3>Verify that listcount( array ) < ubound( array )</h3> - ' NOTE: some listfunctions fail if ubound = listcount - - dim iListCount as integer - dim iUbound as integer - - iListCount = listcount( sList() ) - iUbound = ubound( sList() ) - - if ( iListCount >= iUbound ) then - warnlog( CFN & "ListCount points beyond array boundary" ) - warnlog( CFN & "ListCount: " & iListCount ) - warnlog( CFN & "UBOUND...: " & iUbound ) - hListIntegrityTest() = false - exit function - end if - - hListIntegrityTest() = true - -end function diff --git a/testautomation/global/tools/includes/required/t_menu.inc b/testautomation/global/tools/includes/required/t_menu.inc index d8b1288c3e04..a7c64b37865d 100755 --- a/testautomation/global/tools/includes/required/t_menu.inc +++ b/testautomation/global/tools/includes/required/t_menu.inc @@ -585,37 +585,57 @@ function hUseMenu () '///<b> function hUseMenu () </b>///' '///+ very global function: depends on 'gApplication' just activates the menu-bar ///' - Select Case Ucase(gApplication) - Case "WRITER" - Kontext "DocumentWriter" - DocumentWriter.UseMenu - Case "MASTERDOCUMENT" - Kontext "DocumentMasterDoc" - DocumentMasterDoc.UseMenu - Case "HTML" - Kontext "DocumentWriterWeb" - DocumentWriterWeb.UseMenu - case "CALC" ' there are 2 entries over :-( usually only one, html 0 :-(((( - Kontext "DocumentCalc" - DocumentCalc.UseMenu - case "DRAW" - Kontext "DocumentDraw" - DocumentDraw.UseMenu - case "IMPRESS" - Kontext "DocumentImpress" - DocumentImpress.UseMenu - case "MATH" : - Kontext "DocumentMath" - DocumentMath.UseMenu - case "DATABASE" : - Kontext "DATABASE" - Database.UseMenu - case "BASIC" : - Kontext "BasicIde" - BasicIde.UseMenu - case "NONE" : - Kontext "DocumentBackground" - DocumentBackground.UseMenu + Select Case ( gApplication ) + Case "WRITER" + + Kontext "DocumentWriter" + DocumentWriter.UseMenu + + Case "MASTERDOCUMENT" + + Kontext "DocumentMasterDoc" + DocumentMasterDoc.UseMenu + + Case "HTML" + + Kontext "DocumentWriterWeb" + DocumentWriterWeb.UseMenu + + case "CALC" ' there are 2 entries over :-( usually only one, html 0 :-(((( + + Kontext "DocumentCalc" + DocumentCalc.UseMenu + + case "DRAW" + + Kontext "DocumentDraw" + DocumentDraw.UseMenu + + case "IMPRESS" + + Kontext "DocumentImpress" + DocumentImpress.UseMenu + + case "MATH" : + + Kontext "DocumentMath" + DocumentMath.UseMenu + + case "DATABASE" : + + Kontext "DATABASE" + Database.UseMenu + + case "BASIC" : + + Kontext "BasicIde" + BasicIde.UseMenu + + case "NONE" : + + Kontext "DocumentBackground" + DocumentBackground.UseMenu + end select end function @@ -625,47 +645,64 @@ end function function hOpenContextMenu() '/// very global function: depends on 'gApplication' just opens the Context Menu ///' - Select Case Ucase(gApplication) - Case "WRITER" - Kontext "DocumentWriter" - DocumentWriter.openContextMenu - Case "MASTERDOCUMENT" - Kontext "DocumentMasterDoc" - DocumentMasterDoc.openContextMenu - Case "HTML" - Kontext "DocumentWriterWeb" - DocumentWriterWeb.openContextMenu - case "CALC" - Kontext "DocumentCalc" - DocumentCalc.openContextMenu - case "DRAW" - Kontext "DocumentDraw" - DocumentDraw.openContextMenu - case "IMPRESS" - Kontext "DocumentImpress" - DocumentImpress.openContextMenu - case "MATH" : - Kontext "DocumentMath" - DocumentMath.openContextMenu + Select Case ( gApplication ) + Case "WRITER" + + Kontext "DocumentWriter" + DocumentWriter.openContextMenu + + Case "MASTERDOCUMENT" + + Kontext "DocumentMasterDoc" + DocumentMasterDoc.openContextMenu + + Case "HTML" + + Kontext "DocumentWriterWeb" + DocumentWriterWeb.openContextMenu + + case "CALC" + + Kontext "DocumentCalc" + DocumentCalc.openContextMenu + + case "DRAW" + + Kontext "DocumentDraw" + DocumentDraw.openContextMenu + + case "IMPRESS" + + Kontext "DocumentImpress" + DocumentImpress.openContextMenu + + case "MATH" : + + Kontext "DocumentMath" + DocumentMath.openContextMenu + end select end function '******************************************************************************* -function hGetWindowCaption(sApplication as string, optional bAll as boolean) +function hGetWindowCaption( sApplication as string, optional bAll as boolean ) '///<b> function hGetWindowCaption () </b>///' '///+ just returns the string from the application main window ///' '///+ If optional parameter = true, thenn go throught all applications and get caption; return array ///' + ' BEWARE: THIS FUNCTION MODIFIES ITS FUNCTION PARAMETER UNDER CERTAIN + ' CONDITIONS! + dim sTemp as string dim aApplication() as string dim aTemp(10) as string dim iTimes as integer dim i as integer - aApplication = array("SWRITER","SGLOBAL","SWEB","SCALC","SDRAW","SIMPRESS","SMATH","BASIC","BACK") + aApplication = array("SWRITER","SGLOBAL","SWEB","SCALC","SDRAW","SIMPRESS","SMATH","BASIC","DATABASE","SOFFICE") if (isMissing(bAll) OR (NOT bAll)) then iTimes = 0 else @@ -722,7 +759,13 @@ function hGetWindowCaption(sApplication as string, optional bAll as boolean) sTemp = BasicIDE.caption catch endcatch - Case "BACK" + Case "DATABASE" + Kontext "DATABASE" + try + sTemp = DataBase.caption + catch + endcatch + Case "SOFFICE" Kontext "DocumentBackground" try sTemp = DocumentBackground.caption @@ -748,7 +791,7 @@ end function '******************************************************************************* -function fSplitWindowTitle(sInString as string) +function fSplitWindowTitle( sInString as string ) dim a, b, x, i, iProductname as integer dim sTemp() as string @@ -811,35 +854,33 @@ function fSplitWindowTitle(sInString as string) ' sanity checks, to warn if assumptions are not met! select case x - case 1: - if ((bTestToolCommunication) OR (bDebugVersion)) then - qaErrorLog "t_menu.inc::fSplitWindowTitle: Unknown count of Window Title Strings! 1" - bError = TRUE - endif - case 2: - if ((bTestToolCommunication) OR (NOT bDebugVersion)) then - qaErrorLog "t_menu.inc::fSplitWindowTitle: Unknown count of Window Title Strings! 2" - bError = TRUE - endif - case 3: - if ((NOT bTestToolCommunication) OR (bDebugVersion)) then - qaErrorLog "t_menu.inc::fSplitWindowTitle: Unknown count of Window Title Strings! 3" - bError = TRUE - endif - case 4: - if ((NOT bTestToolCommunication) OR (NOT bDebugVersion)) then - qaErrorLog "t_menu.inc::fSplitWindowTitle: Unknown count of Window Title Strings! 4" - bError = TRUE - endif - case else: - qaErrorLog "t_menu.inc::fSplitWindowTitle: Unknown count of Window Title Strings! 0" + case 1: + if ((bTestToolCommunication) OR (bDebugVersion)) then + qaErrorLog "t_menu.inc::fSplitWindowTitle: Unknown count of Window Title Strings! 1" + bError = TRUE + endif + case 2: + if ((bTestToolCommunication) OR (NOT bDebugVersion)) then + qaErrorLog "t_menu.inc::fSplitWindowTitle: Unknown count of Window Title Strings! 2" + bError = TRUE + endif + case 3: + if ((NOT bTestToolCommunication) OR (bDebugVersion)) then + qaErrorLog "t_menu.inc::fSplitWindowTitle: Unknown count of Window Title Strings! 3" bError = TRUE + endif + case 4: + if ((NOT bTestToolCommunication) OR (NOT bDebugVersion)) then + qaErrorLog "t_menu.inc::fSplitWindowTitle: Unknown count of Window Title Strings! 4" + bError = TRUE + endif + case else: + qaErrorLog "t_menu.inc::fSplitWindowTitle: Unknown count of Window Title Strings! 0" + bError = TRUE end select - if bError then - printlog sInString - endif - + if bError then printlog sInString + if (x > 1) then ' there is more to evaluate ' save the current computed values for i=0 to 2 @@ -849,7 +890,6 @@ function fSplitWindowTitle(sInString as string) redim sTempReturn(4) as string ' copy data back for i=0 to 2 - '***** Warning: Indention error ***** sTempReturn(i) = sTempReturn2(i) next i ' set remaining values, if exist diff --git a/testautomation/global/tools/includes/required/t_option2.inc b/testautomation/global/tools/includes/required/t_option2.inc index 174048985c59..2b10f50ce00a 100644 --- a/testautomation/global/tools/includes/required/t_option2.inc +++ b/testautomation/global/tools/includes/required/t_option2.inc @@ -196,6 +196,9 @@ function hSetMacroSecurity( iLevel as integer ) as integer '///Switch between macro security levels in Tools/Options '///<ul> const CFN = "hSetMacroSecurity::" + const RETVAL_FAILURE = -1 + const DEFAULT_WAIT_TIME = 2 + dim iOldSecurityLevel as integer dim caLevel( 3 ) as string @@ -206,7 +209,7 @@ function hSetMacroSecurity( iLevel as integer ) as integer if ( ( iLevel < GC_MACRO_SECURITY_LEVEL_LOW ) or ( iLevel > GC_MACRO_SECURITY_LEVEL_VERYHIGH ) ) then warnlog( CFN & "Invalid index (0...3) passed to function: " & ilevel ) - hSetMacroSecurity() = -1 + hSetMacroSecurity() = RETVAL_FAILURE exit function end if @@ -216,12 +219,12 @@ function hSetMacroSecurity( iLevel as integer ) as integer '///+<li>Click on the macro security button</li> Kontext "TabSecurity" - if ( MacroSecurity.exists( 2 ) ) then + if ( MacroSecurity.exists( DEFAULT_WAIT_TIME ) ) then MacroSecurity.click() '///+<li>Ensure we are on the Security Level page</li> kontext "Active" - if ( Active.exists( 2 ) ) then + if ( Active.exists( DEFAULT_WAIT_TIME ) ) then Kontext active.setpage TabSecurityLevel @@ -241,12 +244,12 @@ function hSetMacroSecurity( iLevel as integer ) as integer else printlog( CFN & "Security Tabpage not available. Aborting." ) kontext "OptionenDlg" - if ( OptionenDlg.exists( 2 ) ) then + if ( OptionenDlg.exists( DEFAULT_WAIT_TIME ) ) then OptionenDlg.cancel() else warnlog( CFN & "Unrecoverable error, status unknown." ) endif - hSetMacroSecurity() = -1 + hSetMacroSecurity() = RETVAL_FAILURE exit function endif @@ -263,12 +266,12 @@ function hSetMacroSecurity( iLevel as integer ) as integer else printlog( CFN & "Macro Security Dialog did not open. Aborting." ) kontext "OptionenDlg" - if ( OptionenDlg.exists( 2 ) ) then + if ( OptionenDlg.exists( DEFAULT_WAIT_TIME ) ) then OptionenDlg.cancel() else warnlog( CFN & "Unrecoverable error, status unknown." ) endif - hSetMacroSecurity() = -1 + hSetMacroSecurity() = RETVAL_FAILURE exit function endif @@ -276,7 +279,7 @@ function hSetMacroSecurity( iLevel as integer ) as integer TabSecurityLevel.ok() else warnlog( CFN & "The Macro Security Button is not available" ) - iOldSecurityLevel = -1 + iOldSecurityLevel = RETVAL_FAILURE end if Kontext "OptionenDLG" OptionenDLG.OK() @@ -312,6 +315,7 @@ function hGetMacroSecurityAPI() as integer '///</ol> const CFN = "hGetMacroSecurityAPI::" + const RETVAL_FAILURE = -1 dim oUnoOfficeConnection as object dim oUnoConfigurationAccess as object @@ -336,7 +340,7 @@ function hGetMacroSecurityAPI() as integer catch warnlog( CFN & "Failed to retrieve macro security Level via API" ) - iLevel = -1 + iLevel = RETVAL_FAILURE endcatch diff --git a/testautomation/global/tools/includes/required/t_tools1.inc b/testautomation/global/tools/includes/required/t_tools1.inc index a908af39e5af..7242d1c3653d 100644..100755 --- a/testautomation/global/tools/includes/required/t_tools1.inc +++ b/testautomation/global/tools/includes/required/t_tools1.inc @@ -35,8 +35,6 @@ private SLEEP_TIME_REQUESTED as integer private SLEEP_CALLS_SUM as integer private SLEEP_TIME_USED as integer -private const VERBOSE = FALSE - function GetClipboardText as string '/// Returns the correct clipboard text (also if there is a 'RETURN' at it's end. @@ -318,7 +316,7 @@ function Sleep( optional _iSeconds as integer ) as integer printlog( CFN & "Zero time. Please consider removing Sleep() statement" ) endif - if ( VERBOSE ) then + if ( GVERBOSE ) then SLEEP_CALLS_SUM = SLEEP_CALLS_SUM + 1 SLEEP_TIME_USED = SLEEP_TIME_USED + iTimeDiff / 1000 ' good enough SLEEP_TIME_REQUESTED = SLEEP_TIME_REQUESTED + iSeconds @@ -412,10 +410,10 @@ sub DialogTest( Window, optional iNumber as integer) 'save with respect to application and language sCapturePath = ConvertPath (gOfficePath + "user\work\screenshots"+iSprache+"\") sPicName = sCapturePath + lCase(gApplication) + 'create directory if it doesn't exist - if hDirectoryExists(sPicName) <> TRUE then - mkdir (sPicName) - end if + if ( not FileExists(sPicName) ) then mkdir sPicName + sPicName = sPicName + sName try sleep 1 @@ -697,28 +695,6 @@ end function '******************************************************************************* -sub ErgebnisSchreiben ( Window, Name$ ) - - '/// ErgebnisSchreiben - '///+ Used in context with making screenshots. - - Dim FileNum% : Dim i% - Dim Datei$ - Dim Text$ : Dim Text2$ - - Datei$ = sCapturePath + "Ergebis.txt" - Text2$ = Window.Name - Text$ = Text2$ + " => " + Name$ - - FileNum% = FreeFile - Open Datei$ for Append as #FileNum% - Print #FileNum%, Text$ - Close #FileNum% - -end sub - -'******************************************************************************* - sub TextInDatei ( TextText$, Datei$ ) '/// TextInDatei @@ -860,16 +836,14 @@ function ActiveDeactivateAsianSupport ( WhatState as Boolean ) as Boolean gAsianSup = WhatState ' Set the global variable Kontext "ExtrasOptionenDlg" - ExtrasOptionenDlg.OK - Sleep (3) + hCloseDialog( ExtrasOptionenDlg, "ok" ) else ActiveDeactivateAsianSupport = TRUE If WhatState = FALSE then warnlog "Deactivating of asian language support is not possible, because it is disabled in cjk versions" end if Kontext "ExtrasOptionenDlg" - ExtrasOptionenDlg.OK - Sleep (3) + hCloseDialog( ExtrasOptionenDlg, "ok" ) end if end function @@ -899,16 +873,14 @@ function ActiveDeactivateCTLSupport ( WhatState as Boolean ) as Boolean gCTLSup = WhatState ' Set the global variable Kontext "ExtrasOptionenDlg" - ExtrasOptionenDlg.OK - Sleep (3) + hCloseDialog( ExtrasOptionenDlg, "ok" ) else ActiveDeactivateCTLSupport = TRUE If WhatState = FALSE then warnlog "Deactivating of CTL language support is not possible, because it is disabled in ctl versions" end if Kontext "ExtrasOptionenDlg" - ExtrasOptionenDlg.OK - Sleep (3) + hCloseDialog( ExtrasOptionenDlg, "ok" ) end if end function @@ -1147,183 +1119,30 @@ end sub sub raiseApplication ' Try to solve focus problem on MacOS X; After calling this function, OOo should be most front; - Dim i as integer - Dim a as integer - Dim b as integer - Dim tBundle as string - Dim aPath + dim iCurrentDir as integer + dim iNumberOfHits as integer : iNumberOfHits = 0 + dim iDirPosition as integer + dim tBundle as string + dim aPath ' string array with dynamic itemcount, intended. ' Calling just the .app with open on MacOS X via shell command if ( lcase( gPlatform ) = "osx" ) then - + + ' Split the path into its components aPath = split(gNetzOfficePath, gPathSigne) - a=0 + ' make sure 'Contents' is just one time in path - for i=0 to uBound(aPath) - - if "Contents" = aPath(i) then - a=a+1 - endif - - next i + for iCurrentDir = 0 to uBound(aPath) + if "Contents" = aPath( iCurrentDir ) then iNumberOfHits = iNumberOfHits + 1 + next iCurrentDir ' exit if not - if a<>1 then - exit sub - end if + if ( iNumberOfHits <> 1 ) then exit sub - i=inStr(gNetzOfficePath, "Contents") - tBundle=left(gNetzOfficePath, i-2) - shell("open",1 ,tBundle, true) + iDirPosition = inStr( gNetzOfficePath, "Contents" ) + tBundle = left( gNetzOfficePath, iDirPosition - 2 ) + + shell( "open", 1, tBundle, true ) end if end sub - -'******************************************************************************* - -function hUseAsyncSlot( cSlot as string ) as integer - - dim iWait as integer - dim iTime as integer : iTime = 0 - const MAX_WAIT = 100 - const DELAY = 100 - const CFN = "global::tools::includes::required::hUseAsyncSlot():" - - if ( VERBOSE ) then printlog( CFN & "Using slot: " & cSlot ) - WaitSlot() - for iWait = 1 to MAX_WAIT - try - select case ( lcase( cSlot ) ) - case "fileclose" : FileClose - case "filesaveas" : FileSaveAs( "SynchronMode", TRUE ) - case "filesaveall" : FileSaveAll( "SynchronMode", TRUE ) - case "fileexport" : FileExport - case "filereload" : FileReload( "SynchronMode", TRUE ) - case "fileopen" : FileOpen - - case "editdoc" : EditDoc - case "editcopy" : EditCopy - case "editchangesrecord" : EditChangesRecord - case "editchangesshow" : EditChangesShow - case "editchangesprotecttrace" : EditChangesProtectTrace - case "editchangescomment" : EditChangesComment - - case "editpaste" : EditPaste - case "editcopy" : EditCopy - 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 "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 "formatparagraph" : FormatParagraph - 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 "insertindexesbibliographyentry" : InsertIndexesBibliographyEntry - case "insertobjectchart" : InsertObjectChart - case "inserttablewriter" : InsertTableWriter - case "insertobjectformulawriter" : InsertObjectFormulaWriter - case "insertfloatingframe" : InsertFloatingFrame - - case "contextpositionandsize" : ContextPositionAndSize - - case "toolslanguagehyphenate" : ToolsLanguageHyphenate - case "toolsupdateallindexes" : ToolsUpdateAllIndexes - case "toolsupdatefields" : ToolsUpdateFields - case "toolsupdatelinks" : ToolsUpdateLinks - case "toolslanguagehangulhanjaconversion" : ToolsLanguageHangulHanjaConversion - - ' This is the property browser in the BASIC IDE - case "contextproperties" : ContextProperties - - case else : warnlog( "Unknown slot called: " & cSlot ) - end select - - exit for - catch - wait( DELAY ) - iTime = iWait * DELAY - endcatch - next iWait - - ' Timeout is -1 - if ( iTime = MAX_WAIT * DELAY ) then - iTime = -1 - endif - if ( VERBOSE ) then printlog( CFN & "Exit with rc=" & iTime ) - hUseAsyncSlot() = iTime - - -end function - -'******************************************************************************* - -function hClickButton( oButton as object ) as integer - - dim iWait as integer - dim iTime as integer : iTime = 0 - const MAX_WAIT = 50 - const CFN = "global::tools::includes::required::hClickButton():" - - if ( VERBOSE ) then printlog( CFN & "Click button: " & oButton.name() ) - WaitSlot() - for iWait = 1 to MAX_WAIT - try - if ( oButton.exists() ) then - if ( VERBOSE ) then printlog( CFN & "Button exists" ) - if ( oButton.isEnabled() ) then - if ( VERBOSE ) then printlog( "Button is enabled" ) - oButton.click() - endif - endif - exit for - catch - wait( 100 ) - iTime = iWait * 100 - endcatch - next iWait - if ( iTime = 5000 ) then - iTime = -1 - endif - if ( VERBOSE ) then printlog( CFN & "Exit with rc=" & iTime ) - hClickButton() = iTime - -end function - - diff --git a/testautomation/global/tools/includes/required/t_tools2.inc b/testautomation/global/tools/includes/required/t_tools2.inc index 2301c2e5648f..449977d9329d 100644..100755 --- a/testautomation/global/tools/includes/required/t_tools2.inc +++ b/testautomation/global/tools/includes/required/t_tools2.inc @@ -96,69 +96,6 @@ function hSetLocaleStrings (fLocale as String, TBOstringLocale() as String ) as hSetLocaleStrings = bFoundLanguage end function -'------------------------------------------------------------------------- - -sub GetHTMLCharSet as String -'///function to get the Character Set for HTML export -'///+(tools/options/load&save/HTML compatibility -> Character Set) - ToolsOptions - hToolsOptions ( "LoadSave", "HTMLCompatibility" ) - GetHTMLCharSet = Zeichensatz.GetSelText - Kontext "ExtrasOptionenDlg" - ExtrasOptionenDlg.OK -end sub - -'------------------------------------------------------------------------- - -sub SetHTMLCharSet ( CharSet as String ) -'///routine to set the Character Set for HTML export -'///+( tools/options/load&save/HTML compatibility -> Character Set ) - ToolsOptions - hToolsOptions ( "LoadSave", "HTMLCompatibility" ) - Zeichensatz.Select CharSet - Kontext "ExtrasOptionenDlg" - ExtrasOptionenDlg.OK -end sub - -'------------------------------------------------------------------------- - -sub SetHTMLCharSetToUTF8 as Boolean -'///function to set the Character Set for HTML export to 'Unicode UTF8' -'///+( tools/options/load&save/HTML compatibility -> Character Set ) - Dim i as Integer - Dim sDum as String - - ToolsOptions - hToolsOptions ( "LoadSave", "HTMLCompatibility" ) - - for i=1 to Zeichensatz.GetItemCount - sDum = Zeichensatz.GetItemText (i) - if Instr ( lcase (sDum), "utf-8" ) <> 0 then - Zeichensatz.Select (i) - i=1000 - else - if Instr ( lcase (sDum), "utf8" ) <> 0 then - Zeichensatz.Select (i) - i=1000 - else - if Instr ( lcase (sDum), "utf 8" ) <> 0 then - Zeichensatz.Select (i) - i=1000 - end if - end if - end if - next i - if i<1000 then - SetHTMLCharSetToUTF8 = FALSE - else - SetHTMLCharSetToUTF8 = TRUE - end if - Kontext "ExtrasOptionenDlg" - ExtrasOptionenDlg.OK -end sub - -'------------------------------------------------------------------------- - function dec(Ref as integer) '/// decrement variable, call it like 'dec variable' ///' ' reference or value .-) an excursion :-)) @@ -177,235 +114,11 @@ end function '------------------------------------------------------------------------- -function ActivateAutoPilot ( sWhichOne as String ) as Boolean -'Author: TZ -'///Routine to activate (WebPage Autopilot, Form Autopilot, Documentconverter and Euroconveter) -'///Open via menu items (not via SlotID or Macro URL) -'///<u>input</u>: Which Autopilot (<i>webpage</i>, <i>form</i>, <i>documentconverter</i>, <i>euroconverter</i>,<i>addressdatasource</i>) -'///<u>output</u>:<ul><li>TRUE: Autopilot is open</li><li>FALSE: Autopilot can not be opened</li></ul> - Dim bIsLoaded as boolean, LoadTime as integer, PrintTime as Integer - - bIsLoaded = FALSE - LoadTime = 0 - - select case gApplication - case "WRITER" - Kontext "DocumentWriter" - DocumentWriter.UseMenu - case "HTML" - Kontext "DocumentWriterWeb" - DocumentWriterWeb.UseMenu - case "MASTERDOCUMENT" - Kontext "DocumentMasterDoc" - DocumentMasterDoc.UseMenu - case "CALC" - Kontext "DocumentCalc" - DocumentCalc.UseMenu - case "IMPRESS" - Kontext "DocumentImpress" - DocumentImpress.UseMenu - case "DRAW" - Kontext "DocumentDraw" - DocumentDraw.UseMenu - case "MATH" - Kontext "DocumentMath" - DocumentMath.UseMenu - case else - Kontext "DocumentWriter" - DocumentWriter.UseMenu - end select - sleep(2) - hMenuSelectNr(1) - sleep(2) - hMenuSelectNr(4) - sleep(2) - - select case lcase (sWhichOne) - case "webpage" : hMenuSelectNr(5) - case "documentconverter" : hMenuSelectNr(6) - case "euroconverter" : hMenuSelectNr(7) - case "addressdatasource" : hMenuSelectNr(8) - end select - sleep(5) - - while bIsLoaded = False - while LoadTime < 20 - PrintTime = LoadTime * 3 - select case lcase ( sWhichOne ) - case "webpage" : Kontext "AutopilotWebPage" - if AutopilotWebPage.Exists(1) then - bIsLoaded = true - printlog "Autopilot is loaded in " + PrintTime + " seconds!" - LoadTime = 20 - ActivateAutoPilot = TRUE - end if - case "report" : Kontext "AutoPilotReport" - if AutoPilotReport.Exists(1) then - bIsLoaded = true - printlog "Autopilot is loaded in " + PrintTime + " seconds!" - LoadTime = 20 - ActivateAutoPilot = TRUE - end if - case "form" : Kontext "ChooseDatabase" - if ChooseDatabase.Exists(1) then - bIsLoaded = true - printlog "Autopilot is loaded in " + PrintTime + " seconds!" - LoadTime = 20 - ActivateAutoPilot = TRUE - end if - case "documentconverter" : Kontext "DocumentConverter" - if DocumentConverter.Exists(1) then - bIsLoaded = true - printlog "Autopilot is loaded in " + PrintTime + " seconds!" - LoadTime = 20 - ActivateAutoPilot = TRUE - end if - case "euroconverter" : Kontext "AutoPilotEuroKonverter" - if AutoPilotEuroKonverter.Exists(1) then - bIsLoaded = true - printlog "Autopilot is loaded in " + PrintTime + " seconds!" - LoadTime = 20 - ActivateAutoPilot = TRUE - end if - case "addressdatasource" : Kontext "AddressSourceAutopilot" - if AddressSourceAutopilot.Exists(1) then - bIsLoaded = true - printlog "Autopilot is loaded in " + PrintTime + " seconds!" - LoadTime = 20 - ActivateAutoPilot = TRUE - end if - - end select - 'NOTE: Maybe a messagebox occurs. - Kontext "Active" - if Active.Exists (1) then - warnlog Active.GetText - try - Active.OK - catch - Active.Cancel - endcatch - ActivateAutoPilot = FALSE - end if - sleep(1) - LoadTime = LoadTime + 1 - if LoadTime = 20 and bIsLoaded = False then - warnlog "Autopilot has not been loaded!" - ActivateAutoPilot = FALSE - bIsLoaded = TRUE - end if - wend - wend -end function - -'------------------------------------------------------------------------- - -function SetURL ( sURL as String ) -'Author: TZ -'/// Routine to open a special URL with <i>file open</i>-dialog -'/// <u>input</u>: The URL as string - FileOpen - Kontext "OeffnenDlg" - Dateiname.SetText sURL - Oeffnen.Click - wait 500 -end function - -'------------------------------------------------------------------------- - -function fGetFileText (sFilename as string, iCount as long) as string -'/// This function is for getting the first or last n characters of a file -'///+<u>Input</u>:<ul><li>filename</li><li>number</li></ul>If the number greater 0 then get n characters from start. -'///+A number smaller 0 get from end of file. -'///+<u>Output</u>:<ul><li>string with <b><i>n</i></b> characters</li></ul> - - dim iFile as integer ' filehandle - dim iTem as integer ' get 2 bytes of the file - dim iTemByte(2) as integer ' move 1 byte from iTem in each item - dim sTemp as string ' string of file - dim iSize as long ' size in bytes of file - dim i as long ' runner :-) - - iFile = FreeFile -' Printlog "FreeFile: " + iFile - if (dir (sFilename) <> "") then -' Printlog "FileLen: " + FileLen(sFile) - Open sFilename For binary access read shared As #iFile -' Printlog "Loc: " + Loc(#iFile) ' LONG! where am i in the file? - - iSize = Lof(#iFile) ' get size in bytes of file - if (iSize > 65530) then '65536 = 64kB - 'Warnlog "fGetFileText: file '" + sFilename + "' might get problems on reading it? size is > 65530 Byte: '" + iSize + "'" - else -' printlog "iSize: " + iSize - endif - - sTemp = "" - if (iCount >= 0) then ' get bytes from file start - get iFile,1,sTemp ' get max 64kByte; but not the 1st 2 bytes :-( - get iFile,1,iTem ' get the first 2 bytes of the file - iTemByte(2) = (iTem AND &H0000FF00) \ &H100 ' and seperate the bytes - iTemByte(1) = (iTem AND &H000000FF) - sTemp = chr(iTemByte(1)) + chr(iTemByte(2)) + sTemp ' put them together - else ' get bytes from file end - if ((iSize+iCount) > 0) then - select case (iSize+iCount) - case 1: get iFile,1,sTemp ' take bytes from the end of the file - get iFile,1,iTem ' get the first 2 bytes of the file - sTemp = chr(iTemByte(2)) + sTemp ' put them together - case else: get iFile,(iSize+iCount)-1,sTemp ' take bytes from the end of the file - end select - else - get iFile,1,sTemp ' take bytes from the end of the file - get iFile,1,iTem ' get the first 2 bytes of the file - iTemByte(2) = (iTem AND &H0000FF00) \ &H100 ' and seperate the bytes - iTemByte(1) = (iTem AND &H000000FF) - sTemp = chr(iTemByte(1)) + chr(iTemByte(2)) + sTemp ' put them together - endif - endif -' printlog "'"+left(sTemp,iSize)+"'" ' gotcha! - - if (iSize-(Abs(iCount)) >= 0) then - fGetFileText = left(sTemp,Abs(iCount)) - else - 'Warnlog "fGetFileText: file '" + sFilename + "' isn't as big as expected; will only return '" + iSize+ "' bytes fom: " + iCount - fGetFileText = left(sTemp,iSize) - endif - - ' debugging routine -------------------------------------- - ' iSize = Lof(#iFile) - ' printlog "iSize: " + iSize - ' sTemp = "" - ' if iSize > 0 then - ' printlog "iSize \ 2: " + (iSize \ 2) - ' for i = 0 to ((iSize \ 2)-1) - ' get iFile,(i*2)+1,iTem - ' Printlog "i: " + i + ": 0x" + hex(iTem) - ' iTemByte(2) = (iTem AND &H0000FF00) \ &H100 - ' iTemByte(1) = (iTem AND &H000000FF) - ' sTemp = sTemp + chr(iTemByte(1)) + chr(iTemByte(2)) - ' next i - ' if (iSize MOD 2) = 1 then - ' get iFile,iSize,iTem - ' Printlog "i: " + iSize + ": 0x" + hex(iTem) - ' iTemByte(1) = (iTem AND &H000000FF) - ' sTemp = sTemp + chr(iTemByte(1)) - ' endif - ' endif - ' printlog "'"+sTemp+"'" - ' debugging routine -------------------------------------- - Close #iFile - else ' does file exist - Warnlog "fGetFileText: file '" + sFilename + "' doesn't exist" - fGetFileText = "" - endif -end function -' -'------------------------------------------------------------------------- -' function fSetMeasurementToCM() as string '/// Sets the measurement unit to centimeter (cm) and returns the unit. Dim i as integer + + const LANGUAGE_CODE_JAPANESE = 81 Call hNewDocument ToolsOptions @@ -413,7 +126,7 @@ function fSetMeasurementToCM() as string case "WRITER" Call hToolsOptions("WRITER","GENERAL") Masseinheit.Select(2) - if iSprache = 81 then + if iSprache = LANGUAGE_CODE_JAPANESE then fSetMeasurementToCM = Right$( Tabulatorenabstand.Gettext, 3 ) else fSetMeasurementToCM = Right$( Tabulatorenabstand.Gettext, 2 ) @@ -421,7 +134,7 @@ function fSetMeasurementToCM() as string case "CALC" Call hToolsOptions("CALC","GENERAL") Masseinheit.Select(2) - if iSprache = 81 then + if iSprache = LANGUAGE_CODE_JAPANESE then fSetMeasurementToCM = Right$( Tabulator.Gettext , 3 ) else fSetMeasurementToCM = Right$( Tabulator.Gettext , 2 ) @@ -429,7 +142,7 @@ function fSetMeasurementToCM() as string case "IMPRESS" Call hToolsOptions("IMPRESS","GENERAL") Masseinheit.Select(2) - if iSprache = 81 then + if iSprache = LANGUAGE_CODE_JAPANESE then fSetMeasurementToCM = Right$( Tabulatorabstand.Gettext, 3 ) else fSetMeasurementToCM = Right$( Tabulatorabstand.Gettext, 2 ) @@ -437,7 +150,7 @@ function fSetMeasurementToCM() as string case "DRAW" Call hToolsOptions("DRAW","GENERAL") Masseinheit.Select(2) - if iSprache = 81 then + if iSprache = LANGUAGE_CODE_JAPANESE then fSetMeasurementToCM = Right$( Tabulatorabstand.Gettext, 3 ) else fSetMeasurementToCM = Right$( Tabulatorabstand.Gettext, 2 ) @@ -445,7 +158,7 @@ function fSetMeasurementToCM() as string case "MASTERDOCUMENT" Call hToolsOptions("WRITER","GENERAL") Masseinheit.Select(2) - if iSprache = 81 then + if iSprache = LANGUAGE_CODE_JAPANESE then fSetMeasurementToCM = Right$( Tabulatorenabstand.Gettext, 3 ) else fSetMeasurementToCM = Right$( Tabulatorenabstand.Gettext, 2 ) @@ -457,7 +170,7 @@ function fSetMeasurementToCM() as string 'because .sdw, .sxw etc. export to HTML depends on it. Call hToolsOptions("WRITER","GENERAL") Masseinheit.Select(2) - if iSprache = 81 then + if iSprache = LANGUAGE_CODE_JAPANESE then fSetMeasurementToCM = Right$( Tabulatorenabstand.Gettext, 3 ) else fSetMeasurementToCM = Right$( Tabulatorenabstand.Gettext, 2 ) @@ -498,12 +211,6 @@ End Function '------------------------------------------------------------------------- -function fRemoveDoubleSpace(stringToChange as string) As String - fRemoveDoubleSpace = fRemoveDoubleCharacter(stringToChange, " ") -End Function - -'------------------------------------------------------------------------- - function writeCrashRepFile() '/// Creates a file <i>(gOfficePath)</i>/user/work/crashrep.txt with two lines: '///+ <ol><li>name of .bas file</li> @@ -559,7 +266,7 @@ function hGetUNOService(optional bSilent as boolean, optional byRef sUnoPortExte ' To not to change the old behaviour, set variable if parameter is not given if (isMissing(bSilent)) then - bSilent = FALSE + bSilent = TRUE end if ' master.inc::sStartUpOffice needs just the Port Numberr from UNO, to pass it to first start up 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 |