1 'encoding UTF-8 Do not remove or change this line!
2 '**************************************************************************
3 ' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 ' Copyright 2000, 2010 Oracle and/or its affiliates.
7 ' OpenOffice.org - a multi-platform office productivity suite
9 ' This file is part of OpenOffice.org.
11 ' OpenOffice.org is free software: you can redistribute it and/or modify
12 ' it under the terms of the GNU Lesser General Public License version 3
13 ' only, as published by the Free Software Foundation.
15 ' OpenOffice.org is distributed in the hope that it will be useful,
16 ' but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ' GNU Lesser General Public License version 3 for more details
19 ' (a copy is included in the LICENSE file that accompanied this code).
21 ' You should have received a copy of the GNU Lesser General Public License
22 ' version 3 along with OpenOffice.org. If not, see
23 ' <http://www.openoffice.org/license.html>
24 ' for a copy of the LGPLv3 License.
26 '/************************************************************************
28 '* owner : gregor.hartmann@oracle.com
30 '* short description : Perform standard operations on all samples/templates etc.
32 '\***********************************************************************
34 private const MAX_FILE_COUNT = 3000 ' the max number of templates or samples
36 ' NOTE: Usually we have only about a 100 templates but in multi-language
37 ' installations there are more than 2100. You should not run these
38 ' tests on multi language installations. Really.
40 testcase tOpenObjectsWithFileDialog( cCategory as string )
42 printlog( "Open templates and samples using the file open dialog" )
44 const CFN = "tOpenObjectsWithFileDialog::"
47 dim lsFile ( MAX_FILE_COUNT ) as String ' list of all files below samples or templates
48 dim sRootPath as String ' rootpath, depends on cCategory
49 dim sRootPathFallback as string
53 dim sFileIn as String ' file to open
54 dim sFileOut as string ' file to save, reload, delete
55 dim sPathOut as string
56 sPathOut = hGetWorkPath()
57 dim sExtension as String ' filter: determines whether to test the file
59 dim iCurrentTemplate as Integer ' increment: current template from lsFile()
60 dim iTemplateCount as integer
62 dim bSkipFile as boolean ' turns true if file is to be skipped
63 dim brc as boolean ' some multi purpose boolan returncode
64 dim cOfficePath as string
66 ' the path where the samples/templates are located, verify function params
67 ' note that for some time the suffixes for the different filetypes are changed,
68 ' so we have separate names for samples and templates.
70 if ( FileExists( gOfficeBasisPath ) ) then
71 cOfficePath = gOfficeBasisPath
73 cOfficePath = mid( gOfficeBasisPath, len( gNetzOfficePath ) + 1 )
74 if ( FileExists( cOfficePath ) ) then
75 printlog( "Using: " & cOfficePath )
77 warnlog( "Test script error: Invalid Office path: " & cOfficePath )
82 printlog( "Build path to templates/samples directory" )
84 case "SAMPLES" : sRootPath = cOfficePath & "share\samples\" & gISOLang
85 sRootPathFallback = "/opt/openoffice.org/basis3.0/share/samples/" & gISOLang
87 case "TEMPLATES" : sRootPath = cOfficePath & "share\template\" & gISOLang
88 sRootPathFallback = "/opt/openoffice.org/basis3.0/share/template/" & gISOLang
91 warnlog( CFN & "Invalid category passed to function" )
95 sRootPath = convertpath( sRootPath )
97 if ( NOT FileExists( sRootPath ) ) then
98 qaerrorlog( "Root Path does not exist: " & sRootPath )
99 sRootPath = sRootPathFallback
100 if ( NOT FileExists( sRootPathFallback ) ) then
101 warnlog( "No usable office root path found. Aborting test" )
103 printlog( "Using hard coded fallback" )
107 printlog( "Using path..: " & sRootPath )
108 printlog( "Using filter: " & sFilter )
110 printlog( "Retrieve filelist from directory" )
111 GetAllFileList ( sRootPath, sFilter, lsFile() )
112 hListDelete( lsFile(), 1 )
114 printlog( "Remove posible .lock-files from list" )
115 iTemplateCount = listCount( lsFile() )
117 while( iCurrentTemplate <= iTemplateCount )
118 if ( instr( lsFile( iCurrentTemplate ), "~lock." ) > 0 ) then
119 hListDelete( lsFile(), iCurrentTemplate )
120 iTemplateCount = iTemplateCount - 1
122 iCurrentTemplate = iCurrentTemplate + 1
126 printlog( "Remove Wizard related files from list" )
127 iTemplateCount = listCount( lsFile() )
129 while( iCurrentTemplate <= iTemplateCount )
130 if ( instr( lsFile( iCurrentTemplate ), "wizard" ) > 0 ) then
131 hListDelete( lsFile(), iCurrentTemplate )
132 iTemplateCount = iTemplateCount - 1
134 iCurrentTemplate = iCurrentTemplate + 1
138 printlog( "Files to be loaded:" )
139 hListPrint ( lsFile() , "" , "" )
140 if ( listcount( lsfile() ) = 1 ) then
141 if ( gProductName = "OpenOffice.org" ) then
142 printlog( gProductName & " comes with no samples, skipping" )
145 warnlog( "Filelist seems to be incomplete. GetAllFileList() failed!" )
149 printlog( "List of samples/templates appears to be valid" )
152 iTemplateCount = listCount( lsFile() )
153 for iCurrentTemplate = 1 to iTemplateCount
156 printlog( "Loading file " & iCurrentTemplate & " of " & iTemplateCount )
158 ' sFileIn holds the file we currently work with
159 sFileIn = lsFile( iCurrentTemplate )
161 printlog( "Load: " & sFileIn )
164 printlog( "Handle known dialogs" )
165 hHandleActivesOnLoad( 0 , 2 )
167 printlog( "Check for Filter Selection dialog" )
168 Kontext "FilterAuswahl"
169 if ( FilterAuswahl.exists( 1 ) ) then
170 warnlog( "Loading failed, ASCII filter dialog present" )
171 FilterAuswahl.cancel()
175 printlog( "Close navigator, if open" )
177 hCloseDialog( Navigator, "close,optional" )
179 sFileOut = cCategory & "_" & iCurrentTemplate
180 sFileOut = convertpath( sPathOut & sFileOut )
182 printlog( "Saving file to: " & sFileOut )
183 hFileSaveAsKill( sFileOut )
185 ' note: this is delayed, because the dialogs take time to pop up
186 ' even while the dialog is visible, we can work with the doc.
187 printlog( "Handle known dialogs" )
188 hHandleInitialDialogs()
190 printlog( "Close document" )
193 printlog( "Load document again" )
194 hFileOpen( sFileOut )
196 printlog( "Handle known dialogs" )
197 hHandleActivesOnLoad( 0 , 2 )
199 printlog( "Close navigator, if open" )
201 hCloseDialog( Navigator, "close,optional" )
203 printlog( "Close document" )
208 printlog( "Delete file" )
209 hDeleteFile( sFileOut )
211 next iCurrentTemplate