'encoding UTF-8 Do not remove or change this line!
'*************************************************************************
'
' Licensed to the Apache Software Foundation (ASF) under one
' or more contributor license agreements. See the NOTICE file
' distributed with this work for additional information
' regarding copyright ownership. The ASF licenses this file
' to you under the Apache License, Version 2.0 (the
' "License"); you may not use this file except in compliance
' with the License. You may obtain a copy of the License at
'
' http://www.apache.org/licenses/LICENSE-2.0
'
' Unless required by applicable law or agreed to in writing,
' software distributed under the License is distributed on an
' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
' KIND, either express or implied. See the License for the
' specific language governing permissions and limitations
' under the License.
'
'*************************************************************************
'*
'* short description : very important routines to start a testscript
'*
'************************************************************************
'*
' Global:
' #1 GetUseFiles ' First routine which will be called automatically by starting a testscript
' #1 LoadDeclaration ' Includes the whole declaration (.sid- and .win-files)
' #1 LoadGlobalIncludeFiles ' Includes global .inc-files
'
' Recover routines:
' #1 TestEnter ' Internal subroutine called at testcase-start -> start recovering
' #1 TestExit ' Internal subroutine called at testcase-end
' If an error in a testscript occurs the test jumps directly into this routine
' #1 PleaseRecover ' Recover routine used by TestExit- and TestEnter
'
' Office Startroutines:
' #1 hStartTheOffice ' Routine to start the Office
' #1 ExitRestartTheOffice ' Exit and restart the office - after 30 seconds
' #1 FirstOfficeStart ' First office start with ResetApplication function
' #1 sStartUpOffice ' sub routine which is being called from hStartTheOffice and ExitRestartTheOffice
' #1 hExitTheOffice ' sub routine to just exit the office
'
' Special Information:
' #1 hFirstOutPut ' Creates a general information header in result files for all tests
' #1 mMakeGeneralOptionsAPI ' Sets general options in the office via API, without UI
' #1 hIsResultWriteable ' Is TT able to write the resultfile in the directory?
' #0 hDetectStatusDatabase ' Detecting the status database server
' #1 hDisableQuickstarter ' Disable the Quickstart feature on win32 systems
'*
'\***********************************************************************
sub GetUseFiles
'///GetUseFiles: The first routine which will be called automatically by starting a testscript.
'/// Include all important libraries (.inc) for the startup.
Dim bQuickstarterStatus as boolean
Dim sTemp as string
Dim sPrivateEnvironmentLocation as string
Dim sEnvironmentVersion as string
Dim sEnvironmentDisplayVersion as string
Dim sEnvironmentVersionMinor as string
gTestcaseStart = Now() ' get start time of test preparation phase
GVERBOSE = FALSE ' global switch to make some functions more talkative for profiling purposes
use "global\system\includes\sysinfo.inc" '///+ sysinfo.inc : routines to get all system informations
use "global\system\includes\inivalue.inc" '///+ inivalue.inc : routines to work with ini-files
use "global\system\includes\iniinfo.inc" '///+ iniinfo.inc : routines to get all informations about OpenOffice.org
use "global\system\includes\status.inc" '///+ status.inc : all routines to put the status-info into database
'/// Call important system- and start-routines.
Call LoadGlobalIncludeFiles '///+
LoadGlobalIncludeFiles: Include file with global routines (master.inc)
Call GetToolPlatform '///+GetToolPlatform: Detect operating environment for the Testtool (sysinfo.inc)
Call GetOfficePlatform '///+GetOfficePlatform: Detect operating environment for the office (sysinfo.inc)
Call GetIniInformation '///+GetIniInformation: Get all information out of the testtool.ini/.testtoolrc and set it on global variables (iniinfo.inc)
Call GetOfficeInformation '///+GetOfficeInformation: Set sAppExe for startup (iniinfo.inc)
gVersionsnummer = FindBuildID
' split versionstring into its parts
call hSetBuildVersionInformation(False)
Call LoadDeclaration '///+- LoadDeclaration: Load all declaration files (master.inc)
Call FirstOfficeStart '///+- FirstOfficeStart: Try to start the office for first time (master.inc)
Call GetLanguageInformation '///+- GetLanguageInformation: Detect the language of office (iniinfo.inc)
Call hFirstOutput '///+- hFirstOutput: Make last adjustments and creat information output (master.inc)
'/// make some default setting
Call mMakeGeneralOptionsAPI '///+- mMakeGeneralOptionsAPI
: Set general options - system-file-dialogs off on Win32
- work-dir to internal ../user/work-dir
(master.inc)
'///+- Disabling the Quickstarter.
'This can't be done via API right now.
bQuickstarterStatus = hDisableQuickstarter
printlog "** Quickstarter disabled : " & bQuickstarterStatus
printlog "----------------------------------------------------------------------------------------------------"
printlog ""
if (NOT gSamePC) then
gTestToolPath = gRemotePath
end if
' Check if environment works with this OOo version
'/// Control the behaviour of the environment via the file qa/qatesttool/global/version.txt:
'/// [EnvironmentVersion]
'/// Current=OOH680
'/// DisplayName=2.4.x
'/// If 'Current' doesn't match the OOo version major string, the environment refuses to work, by exiting the test with a messagebox and a warning.
'/// The checking can be disabled, by using Current=HEAD, or removing the file version.txt
sPrivateEnvironmentLocation = ConvertPath (gTestToolPath + "global\version.txt")
if fileExists(sPrivateEnvironmentLocation) then
sEnvironmentVersion = getIniValue(sPrivateEnvironmentLocation, "EnvironmentVersion", "Current")
sEnvironmentDisplayVersion = getIniValue(sPrivateEnvironmentLocation, "EnvironmentVersion", "DisplayName")
sEnvironmentVersionMinor = getIniValue(sPrivateEnvironmentLocation, "EnvironmentVersion", "Minor")
else
sEnvironmentVersion = "HEAD"
sEnvironmentDisplayVersion = "Developer"
end if
if sEnvironmentVersion <> "HEAD" then
if (len(gMajor) > 5) then
if lCase(left(gMajor,6)) <> lCase(left(sEnvironmentVersion,6)) OR (lCase(gMinor) <> lCase(sEnvironmentVersionMinor)) then
warnlog "This environment '" + sEnvironmentVersion + sEnvironmentVersionMinor + "' is not suitable for this OOo version '" + left(gMajor,6) + gMinor + "'!"+chr(13)+"Please get the environment suitable for this OOo version!"+chr(13)+"This Environment only works with OOo " + sEnvironmentDisplayVersion + "!"
if MsgBox ("This environment '" + sEnvironmentVersion + sEnvironmentVersionMinor +"' is not suitable for this OOo version '" + left(gMajor,6) + gMinor + "'! Please get the environment suitable for this OOo version! This Environment only works with OOo " + sEnvironmentDisplayVersion + "!", 16, "Error at startup") = 1 then
end
end if
end if
end if
end if
end sub
'-------------------------------------------------------------------------
sub LoadDeclaration
'/// Include all .sid-declarations (all menu-items as SlotIDs)
'///+<German names> (DEPRECATED, only fixes allowed!)
use "global\sid\all.sid" '///+
- all.sid: All menuitems (German)
use "global\sid\bars.sid" '///+- leisten.sid: All toolbars and toolboxes (German)
use "global\sid\context.sid" '///+- kontext.sid: All context menus
use "global\sid\others.sid" '///+- allgem.sid: other slots (German)
'///<English names>
use "global\sid\e_all.sid" '///+- e_all.sid : all menuitems
'/// Include all .win-declarations (all dialogs as HelpIDs)
'///+<German names> (OBSOLETE, only fixes allowed!)
use "global\win\tab_a_d.win" '///+- All tabpages A...Z
use "global\win\tab_e_g.win"
use "global\win\tab_h_o.win"
use "global\win\tab_p_s.win"
use "global\win\tab_t_z.win"
use "global\win\dial_a_c.win" '///+- All dialogs A...Z
use "global\win\dial_d_h.win"
use "global\win\dial_i_o.win"
use "global\win\dial_p_s.win"
use "global\win\dial_t_z.win"
use "global\win\sys_dial.win" '///+- sys_dial.win: Systemdialogs
use "global\win\dokument.win" '///+- dokument.win: All document-types
use "global\win\mathop.win" '///+- mathop.win: Windows with all math operators
use "global\win\piloten.win" '///+- piloten.win: Database-, Impress-, Microsoft(R) import-autopilots
use "global\win\w_autop.win" '///+- w_autop.win: All Writer autopilots
'///<English names>
use "global\win\edia_a_c.win" '///+- All dialogs A...Z
use "global\win\edia_d_h.win"
use "global\win\edia_i_o.win"
use "global\win\edia_p_s.win"
use "global\win\edia_t_z.win"
use "global\win\etab_a_d.win" '///+- All tabpages A...Z
use "global\win\etab_e_g.win"
use "global\win\etab_h_o.win"
use "global\win\etab_p_s.win"
use "global\win\etab_t_z.win"
use "global\win\e_mathop.win" '///+- e_mathop.win: Mathoperators
use "global\win\bars.win" '///+- bars.win: All bars as windows
use "global\win\etoolbox.win" '///+- etoolsbox.win: Toolboxes
use "global\win\spadmin.win" '///+- spadmin.win: SPAdmin
use "global\win\reportdesigner.win" '///+- reportdesigner.win: ReportDesigner
end sub
'-------------------------------------------------------------------------
sub LoadGlobalIncludeFiles
'///Load all important global files.
use "global\tools\includes\required\t_dir.inc" '///+- t_dir: Routines to parse directories (methods execute on the office side)
use "global\tools\includes\required\t_doc1.inc" '///+- t_doc1: Global routines to work on office documents (I)
use "global\tools\includes\required\t_doc2.inc" '///+- t_doc2: Global routines to work on office documents (II)
use "global\tools\includes\required\t_files.inc" '///+- t_files: Routines to open/save/print files
use "global\tools\includes\required\t_filters.inc" '///+- t_filters: Get information about filters
use "global\tools\includes\required\t_lists.inc" '///+- t_lists: Work with array/lists in basic scripts
use "global\tools\includes\required\t_menu.inc" '///+- t_menu: Routines to work with menus in the office
use "global\tools\includes\required\t_option.inc" '///+- t_option: Routine to navigate in the options-dialoge of office (I)
use "global\tools\includes\required\t_option2.inc" '///+- t_option2: Routine to navigate in the options-dialoge of office (II)
use "global\tools\includes\required\t_tools1.inc" '///+- t_tools1 : Global routines (I)
use "global\tools\includes\required\t_tools2.inc" '///+- t_tools2: Global routines (II)
use "global\tools\includes\required\t_tools3.inc" '///+- t_tools3: Global routines (III)
end sub
'-------------------------------------------------------------------------
sub FirstOfficeStart
'/// First start-routine.
Dim i as integer
' To nail down a possible culprint on test runs, the availability of existing user settings is checked.
' In some environments the deleting of the settings might fail before the test is started - this will log it:
if (fileExists(gOfficePath)) then
qaErrorLog ("QA_DEBUG: User settings directory was not deleted before test start!: '" + gOfficePath + "'")
else
printlog ("QA_DEBUG: User settings directory is unavailable before soffice is started - this is good. '" + gOfficePath + "'")
endif
caselog "" '///+- Stop the first default-output into the resultfile
Call hStartTheOffice '///+- Start the office
ResetApplication '///+- Make the first recovering without an error output.
'Disabling crash handling by TestTool. The crash reporter is used instead.
'Needs to get executed everytime after a 'ResetApplication' command
catchGPF false
' Recover to backingwindow, until resetApplication can handle this
hFileCloseAll()
end sub
'-------------------------------------------------------------------------
sub hStartTheOffice (optional sProfPath as String, optional sProfParameter as String)
Dim tVersionsnummer as string
Dim tLastVersion as string
Dim tlVersion() as string
Dim tilVersion as integer
Dim tiPosA as integer
Dim tiPosB as integer
Dim sErrorInformation as string
Dim sTemp as string
Dim sPlatformProgramPath as string
sErrorInformation = "global::systen::inc::master.inc:hStartTheOffice: "
if lcase( gPlatform ) = "osx" then
sPlatformProgramPath = "MacOS"
else
sPlatformProgramPath = "program"
end if
'/// input: optional sProfPath as String [path for profiling data]
'/// input: optional sProfParameter as String [filename for profiling data]
'///+- Be sure the path to the result file exists and is writeable
'///+
- If it doesn't exist, try to create it
'///+- If it isn't writeable a messagebox will be thrown
'///+- The test will be stopped because without this path the testtool cannot write the resultfile to disk
if (hIsResultWriteable() <> TRUE) then
if MsgBox (sErrorInformation + "The test won't start! Please correct the error of the not createable RESULT file!", 16, "Error at startup") = 1 then
end
end if
end if
if gSamePC = TRUE then
tVersionsnummer = FindBuildID
' split versionstring into its parts
tlVersion() = Split(tVersionsnummer, ",")
tilVersion = uBound(tlVersion()) ' array counts from 0 on!
tLastVersion = tlVersion(tilVersion)
' major is from start to 'm'
tiPosA = instr(tLastVersion, ":") + 1
tiPosB = instr(tLastVersion, ")")
gBuild = cInt(Mid(tLastVersion, tiPosA, tiPosB-tiPosA))
end if
'Startroutine for soffice.exe
if sGetCrashreporterValues() <> TRUE then
sTemp = "Please correct the entries in your testtool.ini/.testtoolrc." & Chr(13) & _
"Here are the current entries:" & Chr(13) & Chr(13) & _
"[Crashreporter]" & Chr(13) & _
"UseProxy=" & gUseProxy & " (Has to be set to (true/false)" & Chr(13) & _
"ProxyServer=" & gProxyServer & Chr(13) & _
"ProxyPort=" & gProxyPort & Chr(13) & _
"AllowContact=" & gAllowContact & " (Has to be set to (true/false)" & Chr(13) & _
"ReturnAddress=" & gReturnAddress
printlog (sTemp)
if MsgBox (sTemp, 16, "Error in TestTool control file!") = 1 then
'TODO: Function to write the missing information to TT control file.
'The test execution will be stopped here.
end
end if
end if
'///+- The normal start routine.
'///+
- If you want to create a logfile for timestamps, the parameter -env:RTL_LOGFILE=[Path] is appended. (Note: On Win32 the path must have two backslashes)
'///+- To ignore the crash- and recover- process for OpenOffice.org-documents the parameter -norestore -nocrashreport is also appended
'///+- To disable the configuration lock dialog -nolockcheck is also appended
'///+- To enable the automated testing -enableautomation has been added
'///+- If you make a remote-test, the office process can't be started by the testtool; you would get an error message
try
if IsMissing (sProfPath) then
sStartUpOffice
else
if IsMissing (sProfParameter) then
QAErrorLog sErrorInformation & " Parameter 'sProfParameter' is NOT OPTIONAL if sProfPath has been set!"
'The test execution will be stopped here.
end
else
sStartUpOffice (sProfPath, sProfParameter)
end if
end if
catch
if gSamePC = FALSE then
Exceptlog
if MsgBox (sErrorInformation + "It is not possible to start the office application on a remote system." _
& Chr(10) & "Please start the office application.", 1, "Starting the office application") = 2 then
end
else
warnlog sErrorInformation + "The test has a problem to start the office application. It needs a second chance!"
'///+- Sometimes the first start instruction does not work correctly, so here it gets a second chance to start.
if IsMissing (sProfPath) then
sStartUpOffice
else
if IsMissing (sProfParameter) then
QAErrorLog sErrorInformation & " Parameter 'sProfParameter' is NOT OPTIONAL if sProfPath has been set!"
'The test execution will be stopped here.
end
else
sStartUpOffice (sProfPath, sProfParameter)
end if
end if
end if
end if
endcatch
'///+ - Set the debug output in an non-product version to the Testtool
try
'Only in a debug version of the office: Setting the assertion output to TestTool.
CaptureAssertions TRUE
catch
endcatch
Kontext "WelcomeDialog"
if WelcomeDialog.Exists(2) then
'///+
- Clicking on Next button
NextBtn.Click
Kontext "TabFirstStartLicense"
if TabFirstStartLicense.Exists(1) then
'///+- If the next tabpage will be visible pressing to get the 'Next'-button available.
LicenseText.TypeKeys "" , TRUE
Kontext "WelcomeDialog"
'///+- Clicking on Next button
try
NextBtn.Click
catch
qaErrorLog "#i86137# STRG-A failed on license text, using workaround."
Kontext "TabFirstStartLicense"
while scrolldown.isEnabled
try
scrolldown.click
catch
endcatch
wend
' Now trying again to go on...
Kontext "WelcomeDialog"
NextBtn.Click
endcatch
else
if NOT gooo then
warnlog sErrorInformation & "The second page (license) of the 'Welcome to $PRODUCTNAME'-wizard is not visible!"
end if
end if
Kontext "TabPersonalDataMigration"
'///+- If an OpenOffice 1.1.x exists the migration page will be visible.
if TabPersonalDataMigration.Exists(1) then
'///+- Uncheck the checkbox for tranferring personal data to get a clean configuration.
TransferPersonalData.uncheck
Kontext "WelcomeDialog"
'///+- Clicking on Next button
NextBtn.Click
'TODO: Add exception handling.
end if
Kontext "TabFirstStartUser"
if TabFirstStartUser.Exists(1) then
Kontext "WelcomeDialog"
'///+- If the next tabpage will be visible clicking on 'Next'-button.
NextBtn.Click
'TODO: Add exception handling.
end if
Kontext "TabFirstStartOnlineUpdate"
if TabFirstStartOnlineUpdate.Exists(1) then
try
checkForUpdates.uncheck
catch
endcatch
Kontext "WelcomeDialog"
'///+- If the next tabpage will be visible clicking on 'Next'-button.
NextBtn.Click
'TODO: Add exception handling.
end if
Kontext "TabFirstStartRegistration"
if TabFirstStartRegistration.Exists(1) then
'///+- If the next tabpage will be visible checking 'do not want to register'-radio button.
doNotWantRegister.Check
Kontext "WelcomeDialog"
'///+- Clicking on 'Next'-button.
WelcomeDialog.OK
else
warnlog sErrorInformation & "The fourth page (register) of the 'Welcome to $PRODUCTNAME'-wizard is not visible!"
end if
end if
'///+
'Disable Quickstarter internaly
hDisableQuickstarterAPI
end sub
'-------------------------------------------------------------------------
sub ExitRestartTheOffice (optional sProfPath as String, optional sProfParameter as String)
'/// input: optional sProfPath as String [path for profiling data]
'/// input: optional sProfParameter as String [filename for profiling data]
'/// If a messagebox comes up (yes, no) it will be closed (only one messagbox)
Dim i as integer
Dim sErrorInformation as string
sErrorInformation = "global::systen::inc::master.inc:ExitRestartTheOffice: "
hExitTheOffice()
if IsMissing (sProfPath) then
sStartUpOffice
else
if IsMissing (sProfParameter) then
QAErrorLog sErrorInformation & " Parameter 'sProfParameter' is NOT OPTIONAL if sProfPath has been set!"
'The test execution will be stopped here.
end
else
sStartUpOffice (sProfPath, sProfParameter)
end if
end if
'Disabling crash handling by TestTool. The crash reporter is used instead.
try
catchGPF false
catch
endcatch
'Disable Quickstarter internaly
hDisableQuickstarterAPI
' Recover to backingwindow, until resetApplication can handle this
hFileCloseAll()
end sub
'-------------------------------------------------------------------------
sub hExitTheOffice()
'/// Just shut down OOo
'/// If a messagebox comes up (yes, no) it will be closed (only one messagbox)
'Disable Quickstarter internaly, last chance to join processes - important if testtool restarted OOo after a crash!
hDisableQuickstarterAPI
try
FileExit "SynchronMode", TRUE
catch
endcatch
try
Kontext "Active"
if Active.Exists(2) then
Active.No
end if
catch
endcatch
' This is only >0 if defined in TestTool configuration file
' It is needed for a gcov enabled OOo build (Code coverage)
' and for valgrind (Memory leaks) tests
' valgrind: 90;1,5min, gcov 290;4,5min
sleep(30+gOOoShutdownTimeOut)
end sub
'-------------------------------------------------------------------------
sub TestEnter
'/// Automatically called, when a testcase-routine starts
Call PleaseRecover ("TestEnter")
'Needed for status.inc
gTestcaseStart = Now()
Call writeCrashRepFile()
end sub
'-------------------------------------------------------------------------
sub TestExit
'/// Automatically called at the end of a testcase or directly called when an error occured
'///+ - Write the data for status page in a list in status.inc
Call PleaseRecover ("TestExit")
if ((gTestName <> "") AND isStatusEnabled()) then
'gTestName set in hStatusIn
call hStatusAddTestcase()
end if
end sub
'-------------------------------------------------------------------------
sub PleaseRecover (sWhat as String)
Dim sError as String
Dim sInterrupt as Boolean
Dim sOtherError as Boolean
Dim i as Integer
Dim a as Integer
sInterrupt = FALSE
sOtherError = FALSE
'/// Close the translation window.
try
if gDasNicht = 0 then
Kontext "TranslationWindow"
if TranslationWindow.Exists then
TranslationWindow.Close
end if
end if
catch
endcatch
'/// Use ResetApplication method
try
call hCloseAllToolbars
'All error-strings are in sError
gStartTheOffice = FALSE
'This is the trigger for a restart after application crashed:
sError = ResetApplication
'If sError = empty then no error occured.
if sError <> "" then
printlog " ** Error in " + sWhat + " -Routine **"
warnlog sError
end if
catch
if NOT gStartTheOffice then
printlog "global::system::inc::PleaseRecover: No office running while trying to recover: " + sError + " " + sWhat
sInterrupt = TRUE
else
resetApplication
endif
endcatch
try
'Kill all commands after the reset
AppAbort
catch
endcatch
'/// If the office crashes interrupt = TRUE and the office should be started again.
if sInterrupt = TRUE then
try
Call hStartTheOffice
SetClipboard ""
catch
try
QAErrorLog "killapp: "+gTestName+"--"+getTestcaseName
killapp
catch
ExceptLog
endcatch
endcatch
try
'kill all commands after the reset
AppAbort
catch
endcatch
end if
try
'Only in a debug version of the office: Setting the assertion output to TestTool
CaptureAssertions TRUE
catch
endcatch
'Disabling crash handling by TestTool. The crash reporter is used instead.
try
catchGPF false
catch
endcatch
Kontext
' Recover to backingwindow, until resetApplication can handle this
hFileCloseAll()
end sub
'-------------------------------------------------------------------------
sub hFirstOutput
'/// Create a general header in result files for all tests.
Dim sDir as String
Dim sDir1 as String
Dim sMajor as String
if gSamePC = TRUE then
if (len(gMajor)>3) then
sMajor = left(gMajor,3)
end if
'Detecting child workspaces (CWS) and status database server
if InStr(gVersionsnummer , "[CWS:") <> 0 then
gCWS = TRUE
else
gCWS = FALSE
end if
if hDetectStatusDatabase = TRUE then
gStatusDatabase = TRUE
else
gStatusDatabase = FALSE
end if
else
gVersionsnummer = "REMOTE"
end if
iSystemSprache = hGetSystemLanguage
bDebugVersion = NOT isProduct
printlog "----------------------------------------------------------------------------------------------------"
printlog " I n f o r m a t i o n A b o u t T h e T e s t E n v i r o n m e n t"
printlog "----------------------------------------------------------------------------------------------------"
printlog "** Application build ID : " & sMajor & gVersionsnummer
if bDebugVersion = TRUE then
printlog "** DEBUG version : " & bDebugVersion
end if
if gCWS = FALSE then
printlog "** Build type : MASTER"
else
printlog "** Build type : CWS"
end if
if isStatusEnabled() then
'http://wiki.services.openoffice.org/wiki/QUASTe
printlog "** Status feature (QUASTe) : Enabled " + gLocalStatusDatabase
end if
printlog "----------------------------------------------------------------------------------------------------"
printlog "** Application installation path : " + gNetzOfficePath
printlog "** User configuration path : " + gOfficePath
printlog "** Started application : " + sAppExe
printlog "----------------------------------------------------------------------------------------------------"
printlog "** Application language : " + iSprache + " (" + gLanguage + " / " + gISOLang + ")"
printlog "** System language : " + iSystemSprache + " (" + GetLanguageText (iSystemSprache) + ")"
if gSamePC = FALSE then
printlog "** Platform VCL TestTool : " + gtSYSName
printlog "** Platform application : " + gSYSName + " (" + gHost + ") "
printlog "** Path to remote base path : " + gRemotePath
else
printlog "** Testing platform : " + gtSYSName
end if
printlog "----------------------------------------------------------------------------------------------------"
sDir1 = ConvertPath (gOfficePath + "user\work\"
sDir = App.Dir (sDir1, 16)
if sDir = "" then
App.MKDir (sDir1)
printlog "** Work path has been created : " + sDir1
end if
'Disabling embedded translation tooling
gDasNicht = 1
'Disabling embedded screenshot tooling depending on value in .testtoolrc/ini
gbSnapShot = sGetScreenshotValue
end sub
'-------------------------------------------------------------------------
sub mMakeGeneralOptionsAPI
'/// At the beginning of each testrun set some defaults with the API
'///+ and write them down into the result file (.res).
'///+
Dim bHelpTip as Boolean
Dim sTempPath as string
Dim sWorkPath as string
Dim oUnoOfficeConnection as object
Dim oUnoConfigurationAccess as object
Dim aPropertyValue(1) As new com.sun.star.beans.PropertyValue ' Array of pairs: Property with Value
Dim xViewRoot
Dim sTempList
Dim bError as boolean
const sFileFunction = "global::system::inc::master.inc::hMakeGeneralOptionsAPI:: "
' Open OOo UNO-Port for communication
oUnoOfficeConnection=hGetUnoService(TRUE)
if (isNull(oUnoOfficeConnection)) then
warnlog (sFileFunction+"Couldn't create Uno access")
exit sub
end if
try
' Open Configuration access
oUnoConfigurationAccess=oUnoOfficeConnection.createInstance("com.sun.star.configuration.ConfigurationProvider")
if (isNull(oUnoConfigurationAccess)) then
warnlog (sFileFunction+"Couldn't create Configuration access")
exit sub
end if
' These Value pairs don't change inside this function, so they are only set once here.
' Specifies the location of the view root in the configuration:
' The value is the Path name of teh configuration item to change.
aPropertyValue(0).Name="nodepath"
' Controls how updates are handled in the cache: If false , the cache
' must operate in write-through mode, where updates are written to
' persistent storage at once - that is before ::commitChanges() returns.
aPropertyValue(1).Name="lazywrite"
aPropertyValue(1).Value=False
'///+- Tools / Language Settings / Languages
'///+ Check if Asian language support is enabled and set gAsianSup variable TRUE or FALSE.
aPropertyValue(0).Value="/org.openoffice.Office.Common/I18N/CJK"
xViewRoot=oUnoConfigurationAccess.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess",aPropertyValue())
gAsianSup = xViewRoot.getByName("AsianTypography")
' I don't use something more on the path: "/org.openoffice.Office.Common/I18N/CJK"
' Destroy, discard, dump, get rid of, put away, throw away, trash, the object:
xViewRoot.dispose()
'///+ Check if CTL (=complex text layout) is enabled amd set gCTLSup variable TRUE or FALSE.
aPropertyValue(0).Value="/org.openoffice.Office.Common/I18N/CTL"
xViewRoot=oUnoConfigurationAccess.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess",aPropertyValue())
gCTLSup = xViewRoot.getByName("CTLFont")
xViewRoot.dispose()
if gAsianSup = TRUE then
printlog "** Asian language support : " & gAsianSup
end if
if gCTLSup = TRUE then
printlog "** Complex text layout support : " & gCTLSup
end if
'///+
- Set gAccessibility from Options API
aPropertyValue(0).Value="/org.openoffice.VCL/Settings/ConfigurableSettings['Accessibility']"
xViewRoot=oUnoConfigurationAccess.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess",aPropertyValue())
gAccessibility = xViewRoot.getByName("EnableATToolSupport")
xViewRoot.dispose()
if gAccessibility then
printlog "** Accessibility support : " & gAccessibility
end if
'///+ - Switch the system file dialogs to "internal" file dialogs.
aPropertyValue(0).Value="/org.openoffice.Office.Common/Misc"
xViewRoot=oUnoConfigurationAccess.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess",aPropertyValue())
xViewRoot.setPropertyValue("UseSystemFileDialog", false)
xViewRoot.commitChanges()
' Since we use lazywrite=false, the call to '.commitChanges()' returns if all data is written.
' This call to ask for pending changes is just to convince me;
if xViewRoot.hasPendingChanges() then
qaErrorLog(sFileFunction+"Changes still pending...: UseSystemFileDialog")
' At this point there is no needed to think about what to do, if it doesn't work.
end if
xViewRoot.dispose()
gUseSysDlg = FALSE
'printlog "** Using system file dialogs : " & gUseSysDlg
if (lcase(gPlatform) = "osx") then
'///+
- Switch the system print dialogs to "internal" print dialogs.
aPropertyValue(0).Value="/org.openoffice.Office.Common/Misc"
xViewRoot=oUnoConfigurationAccess.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess",aPropertyValue())
try
xViewRoot.setPropertyValue("UseSystemPrintDialog", false)
xViewRoot.commitChanges()
xViewRoot.dispose()
catch
endcatch
end if
'///+
- Disabling the bubble help.
aPropertyValue(0).Value="/org.openoffice.Office.Common/Help"
xViewRoot=oUnoConfigurationAccess.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess",aPropertyValue())
bHelpTip = xViewRoot.getByName("Tip")
if (bHelpTip) then
xViewRoot.setPropertyValue("Tip", false)
xViewRoot.commitChanges()
bHelpTip = FALSE
if xViewRoot.hasPendingChanges() then
qaErrorLog(sFileFunction+"Changes still pending...: HelpTip")
end if
'printlog "** Help/Tips : " & bHelpTip
end if
xViewRoot.dispose()
'///+
- Disable automatic check for updates
' Encapsulating this in a try...catch block because external (non-Sun) builds
' do usually not support online update so the API is not available and we get an
' exception. In case of failure we print a QAErrorLog.
try
aPropertyValue(0).Value="/org.openoffice.Office.Jobs/Jobs/Job['UpdateCheck']/Arguments"
xViewRoot=oUnoConfigurationAccess.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess",aPropertyValue())
xViewRoot.replaceByName("AutoCheckEnabled", false)
xViewRoot.commitChanges()
' Since we use lazywrite=false, the call to '.commitChanges()' returns if all data is written.
' This call to ask for pending changes is just to convince me;
if xViewRoot.hasPendingChanges() then
qaErrorLog(sFileFunction+"Changes still pending...: AutoCheckEnabled")
' At this point there is no needed to think about what to do, if it doesn't work.
end if
xViewRoot.dispose()
gAutoUpdate = TRUE
catch
qaErrorLog( sFileFunction & "This build does not support online update." )
gAutoUpdate = FALSE
endcatch
'///+ OOo Improvement - only if BUILD_SPECIAL is set we have this file created.
sTempPath = gOfficeBasisPath & "share/registry/oooimprovement.xcd"
sTempPath = ConvertPath( sTempPath )
if ( FileExists( sTempPath ) ) then
gOOoImprovementIsEnabled = TRUE
else
gOOoImprovementIsEnabled = FALSE
endif
'///+
- Setting the work directory in Tools / Options,
sTempPath = ConvertPath (gOfficePath + "user\work")
'///+
- If the temp-path does not exist it will be created.
if (app.dir(sTempPath, 16) <> "work") then
try
app.mkdir (sTempPath)
bError = FALSE
catch
QAErrorLog sFileFunction + "Couldn't create temp-directory: '" + sTempPath + "'"
bError = TRUE
endcatch
else
bError = FALSE
end if
if (NOT bError) then
oUnoConfigurationAccess=oUnoOfficeConnection.createInstance("com.sun.star.util.PathSettings")
oUnoConfigurationAccess.Work = convertToURL(ConvertPath (gOfficePath + "user\work"))
sWorkPath = convertFromURL(oUnoConfigurationAccess.Work)
printlog "** 'My Documents'-path is now : " & sWorkPath
end if
'///+
- Setting the directory for temporary files (=temp-path).
sTempPath = ConvertPath (gOfficePath + "user\temp")
'///+
- If the temp-path does not exist it will be created.
if (app.dir(sTempPath, 16) <> "temp") then
try
app.mkdir (sTempPath)
bError = FALSE
catch
QAErrorLog sFileFunction + "Couldn't create temp-directory: '" + sTempPath + "'"
bError = TRUE
endcatch
else
bError = FALSE
end if
if (NOT bError) then
' recycle from above: oUnoConfigurationAccess=oUnoOfficeConnection.createInstance("com.sun.star.util.PathSettings")
oUnoConfigurationAccess.Temp = convertToURL(ConvertPath (gOfficePath + "user\temp"))
sTempPath = convertFromURL(oUnoConfigurationAccess.Temp)
printlog "** 'Temporary files'-path : " & sTempPath
end if
'///Check which 'Macro Security Level' is set and put it into gMacroSecurityLevel variable.
gMacroSecurityLevel = hSetMacroSecurityAPI( 2 )
catch
ExceptLog
MsgBox (sFileFunction + "The test did not start correctly or the application crashed." & Chr(13) & _
"Please correct the problem to make the general settings otherwise the test won't start!", 16, "Error at startup")
'The test stops here if mMakeGeneralOptionsAPI has been run into problems (GPF, failure, ..)
end
endcatch
'///+
end sub
'-------------------------------------------------------------------------
function hIsResultWriteable() as boolean
'///Running a test without being able to write the RESULT file to disk is worthless.
'///+This functions checks if the directory exists, tries to create it and checks if it is writeable.
'///+If this fails, the test won't start and presents a messagebox.
Dim sResultFilePath as string
Dim sTestDir as string
'Get the path to the RESULT directory
sResultFilePath = GetIniValue (gTesttoolIni, gTTProfileName , "LogBaseDir")
if (dir(sResultFilePath, 16) = "") then ' doesn't exist
try
MkDir (ConvertPath(sResultFilePath, gtPlatform))
' WorkAround for bug in dir() #104037#
MkDir (ConvertPath(sResultFilePath+ gPathSigne+"ID104037", gtPlatform))
if (dir(sResultFilePath, 16) <> "") then
' does exist
hIsResultWriteable = TRUE
printlog "global::system::inc::master.inc::hIsResultWriteable: created RESULT directory: '" + sResultFilePath + "'"
' WorkAround for bug in dir()
RmDir (ConvertPath(sResultFilePath + gPathsigne + "ID104037", gtPlatform))
else
warnlog "global::system::inc::master.inc::hIsResultWriteable: Make the directory '" + sResultFilePath + "' writeable; RESULT file can not be saved;"
hIsResultWriteable = FALSE
end if
catch
warnlog "global::system::inc::master.inc::hIsResultWriteable: Create the directory '" + sResultFilePath + "'; RESULT file can not be saved; (no right to create the directory)"
hIsResultWriteable = FALSE
endcatch
else
' Check if it is writeable
try
sTestDir = "tbotest" ' nasty bug, if the path is with a path sign at the end; usually on on windows root dirs :-(
if (right(ConvertPath(sResultFilePath, gtPlatform), 1) <> hGetPathSigne(gtPlatform)) then
sTestDir = hgetPathSigne(gtPlatform) + sTestDir
end if
MkDir (ConvertPath(sResultFilePath + sTestDir, gtPlatform))
RmDir (ConvertPath(sResultFilePath + sTestDir, gtPlatform))
hIsResultWriteable = TRUE
catch
warnlog "global::system::inc::master.inc::hIsResultWriteable: Make the directory '" + convertPath(sResultFilePath, gtPlatform) + "' writeable; RESULT file can not be saved;"
hIsResultWriteable = FALSE
endcatch
end if
end function
'-------------------------------------------------------------------------
sub hDetectStatusDatabase as Boolean
'/// Detecting the status database server.
dim sOOoLocalStatusDatabase as string
dim sPrivateEnvironmentLocation as string
dim sTemp as string
sTemp = GetIniValue ( gTesttoolIni, "StatusFeatureLevel" , "Current" )
if sTemp = "" then
sPrivateEnvironmentLocation = ConvertPath (gTestToolPath + "errorlog\privateenvironment.txt")
if fileExists(sPrivateEnvironmentLocation) then
gStatusFeatureLevel = getIniValue(sPrivateEnvironmentLocation, "StatusFeatureLevel", "Current")
else
' manual submitting status from errorlog directory
gStatusFeatureLevel = 2
end if
else
gStatusFeatureLevel = sTemp
end if
if gStatusFeatureLevel = 0 then
' automatical submitting status; filespace location defined in privateenvironment.inc
hDetectStatusDatabase = TRUE
gLocalStatusDatabase = ""
else
if gStatusFeatureLevel = 1 then
' automatical submitting status; filespace location defined in testtoolrc
hDetectStatusDatabase = TRUE
sOOoLocalStatusDatabase = GetIniValue ( gTesttoolIni, "OOoLocalStatusDatabase" , "Current" )
if sOOoLocalStatusDatabase <> "" then
if dir(sOOoLocalStatusDatabase,16) <> "" then
gLocalStatusDatabase = sOOoLocalStatusDatabase
'printlog "** OOo Local Status Database Path: '" + sOOoLocalStatusDatabase + "'"
else
qaErrorLog "** OOo Local Status Database Path: '" + sOOoLocalStatusDatabase + "' doesn't exist or is not a directory."
gLocalStatusDatabase = ""
end if
else
qaErrorLog "You are using status mode 1; you have to define the public filespace location in your testtoolrc:"+chr(13)+"[OOoLocalStatusDatabase]"+chr(13)+"Type=Path"+chr(13)+"Current=."
gLocalStatusDatabase = ""
end if
sTemp = GetIniValue ( gTesttoolIni, "StatusDatabaseServerIP" , "Current" )
if sTemp = "" then
qaErrorLog "You are using status mode 1; you have to define the database server adress in your testtoolrc:"+chr(13)+"[StatusDatabaseServerIP]"+chr(13)+"Type=Path"+chr(13)+"Current=."
else
privateDatabaseServerIP = sTemp
end if
sTemp = GetIniValue ( gTesttoolIni, "StatusDatabaseServerPath" , "Current" )
if sTemp = "" then
qaErrorLog "You are using status mode 1; you have to define the database server path in your testtoolrc:"+chr(13)+"[StatusDatabaseServerPath]"+chr(13)+"Type=Path"+chr(13)+"Current=."
else
privateDatabaseServerPath = sTemp
end if
else
if gStatusFeatureLevel = 2 then
hDetectStatusDatabase = TRUE
gLocalStatusDatabase = "errorlog directory"
else
hDetectStatusDatabase = FALSE
gLocalStatusDatabase = ""
end if
end if
end if
end sub
'-------------------------------------------------------------------------
function hDisableQuickstarter as boolean
'/// On all systems, disable the Quickstart feature which is enabled by default.
'///+ Returns: Answer to the question 'Was action taken, to disable it?'
Dim bTemp as boolean
Dim bResult as boolean
Dim bVeto as boolean
bTemp = FALSE
bResult = TRUE
bVeto = FALSE ' True if Tools-Options-Memory needs to get triggert
'This needs/can not be done on the following platforms:
'- MacOS X
'- Linux/Unix builds of StarOffice/Suite
'- Win32 if already disabled, or not available.
if gPlatGroup <> "unx" then
' if quickstart.exe exists, it might run, else no need to open options UI
bVeto = fileExists(gNetzOfficePath + "program\quickstart.exe")
else
if (lcase(gPlatform) = "osx") then
bVeto = FALSE
else
' Not needed if StarOffice/Suite
bVeto = gOOo
end if
end if
if bVeto then
'First, disabling the Quickstarter via UI
ToolsOptions
call hToolsOptions ("STAROFFICE", "MEMORY")
try
bTemp = LoadQuickstarter.isChecked
if bTemp then
LoadQuickstarter.uncheck
end if
catch
bResult = FALSE
endcatch
Kontext "ExtrasOptionenDlg"
ExtrasOptionenDlg.OK
else
bResult = FALSE
end if
'Second, closing the Quickstarter process that a restart of the office
hDisableQuickstarterAPI()
hDisableQuickstarter = bResult
end function
'-------------------------------------------------------------------------
sub sStartUpOffice (optional sProfPath as String, optional sProfParameter as String)
Dim sParameter as String
Dim sErrorInformation as string
Dim sUnoPort as string
Dim sPlatformProgramPath as string
Dim sPlatformBinExt as string
sErrorInformation = "global::systen::inc::master.inc:sStartUpOffice: "
'/// The environment for the non-GUI Crashreporter function will be set.
setChildEnv("ERRORREPORT_HTTPPROXYSERVER",gProxyServer)
setChildEnv("ERRORREPORT_HTTPPROXYPORT",gProxyPort)
setChildEnv("ERRORREPORT_HTTPCONNECTIONTYPE",gConnectionType)
setChildEnv("ERRORREPORT_RETURNADDRESS",gReturnAddress)
setChildEnv("ERRORREPORT_SUBJECT","Error_Report_from_TestTool")
setChildEnv("ERRORREPORT_BODYFILE",ConvertPath (gOfficePath & "user\work\crashrep.txt"))
' Set a valid URE_BOOTSTRAP path for soffice, else the invalid one from this testtool instance
' will get used i86718 - would result in a message about vcl stuff and a not starting soffice
if lcase( gPlatform ) = "osx" then
sPlatformProgramPath = "MacOS"
sPlatformBinExt = "rc"
else
sPlatformProgramPath = "program"
if gPlatGroup <> "unx" then
sPlatformBinExt = ".ini"
else
sPlatformBinExt = "rc"
end if
end if
setChildEnv("URE_BOOTSTRAP",convertToURL(convertPath(gNetzOfficePath + sPlatformProgramPath + "/fundamental" + sPlatformBinExt)))
' Getting UNO-port
hGetUNOService(true, sUnoPort)
if sUnoPort <> "" then
sUnoPort = "-accept=socket,host=localhost,port=" + sUnoPort + ";urp "
else
sUnoPort = ""
warnlog "UNO port is not defined: Set it in the TestTool application: Extra -> Settings -> Misc -> Remote UNO Port"
end if
'/// To start the application some parameter need to be set:
'///+ - -enableautomation to enable the TCP/IP connection between office application and TestTool
'///+ - -norestore to eliminate the the document recovery functionylity after a crash
'///+ - -nolockcheck to elimante the 'parallel running instances'-check and always start the application
'///+ - -autocrashreport to enable the non-GUI crash report functionality
'///+ - -accept=socket,host=localhost,port=12345;urp to enable UNO connection
'///+ - OPTIONAL application parameters for profiling tests
sParameter = "-enableautomation -norestore -nolockcheck -autocrashreport -nofirststartwizard " & sUnoPort & sAppParameter & " "
if IsMissing (sProfPath) then
'///+ - Factory-parameter which depends on the value of gApplication (WRITER, CALC, ...)
sParameter = sParameter & sFactory
' try/catch is needed for special tasks, to workaround time outs
try
Start sAppExe, sParameter
catch
endcatch
try
' This is only >0 if defined in TestTool configuration file
' It is needed for valgrind (Memory leaks) tests
' Valgrind: 420;8min
sleep(gOOoStartupTimeOut)
catch
endcatch
else
if IsMissing (sProfParameter) then
'/// If OPTIONAL profiling path parameters have been set the profiling filename will be checked
'///+ because then this parameter is not optional.
QAErrorLog sErrorInformation & " Parameter 'sProfParameter' is NOT OPTIONAL if sProfPath has been set!"
'The test execution will be stopped here.
end
else
'/// If both OPTIONAL parameters (path, filename) have been set, the office application
'///+ will be started with an additional parameter:
'///+ - -env:RTL_LOGFILE=pathname/filename to write the profiling log.
sParameter = sParameter & "-env:RTL_LOGFILE=" & sProfPath & sProfParameter
end if
'///+ - Factory-parameter which depends on the value of gApplication (WRITER, CALC, ...)
Start sAppExe, sParameter & " " & sFactory
end if
end sub
sub StartTheOffice
'/// this routine is not intended to be called from within a testscript.
'/// this routine will get called by the VCL TestTool application, in case it recognizes there is no soffice.bin running anymore or not responding anymore
'/// this happens usually after OpenOffice.org crashed
'keep it as short as possible!
warnlog "OpenOffice.org application crashed or can not be started. Double click the above error message if exists for the culprint."
sStartUpOffice()
try
catchGPF false
catch
endcatch
hDisableQuickstarterAPI()
' set global variable for backwards compatibility
gStartTheOffice = TRUE
end sub