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 tModifyObjects( iMode as integer, cCategory as string, sVer as string )
42 ' This test loads/saves and reloads every template or sample shipped with
43 ' the product. One of the special challenges of the test is to find out
44 ' which document type a sample/template belongs to as well as to handle
45 ' any possible dialogs the samples/documents may trigger.
47 ' iMode = 1 means to open the document (0 = just get its name)
48 ' cCategory may be "SAMPLES" or "TEMPLATES"
49 ' sVER is the fileformat for saving files, typically this is "current"
51 const CFN = "tModifyObjects::"
53 const TEMPLATE_COUNT = 237 ' For en-US/Oracle Open Office, numbers may differ for Languages/Brands
54 const SAMPLE_COUNT = 56 ' For en-US/Oracle Open Office, numbers may differ for Languages/Brands
56 ' Varaibles needed to navigate on the Templates And Samples dialog
57 dim iObjectFolder as integer
58 dim iObjectFolders as integer
60 ' Iterators and number of documents, test values
61 dim iObject as integer ' Iterator
62 dim iObjectCount( 20 ) as integer
63 dim iObjectSum as integer : iObjectSum = 0
64 dim iObjectCountExpected as integer
66 ' Where to store the files
68 dim sPath as string : sPath = hGetWorkPath()
70 ' Reset counter, if the office becomes unstable you might want to use it.
71 ' See further below on how to enable this feature
72 dim iReset as integer : iReset = 0
76 ' Find out if we are testing samples or templates, fix the number of items
77 ' allowed for each category
78 select case( lcase( cCategory ) )
79 case "templates" : iObjectCountExpected = TEMPLATE_COUNT
80 case "samples" : iObjectCountExpected = SAMPLE_COUNT
83 printlog( "Open Templates and Samples dialog" )
87 ' This is the icon on the left pane
88 hSelectCategory( cCategory )
90 ' The number of folders for the category on the middle pane
91 iObjectFolders = FileList.getItemCount()
93 printlog( "Count the items in the templates and samples dialog" )
94 for iObject = 1 to iObjectFolders
95 hSelectFileFolder( iObject , true )
96 iObjectCount( iObject ) = FileList.getItemCount()
97 iObjectSum = iObjectSum + iObjectCount( iObject )
101 printlog( "Verify object count (en_US only)" )
102 if ( gProductName = "Oracle Open Office" and gISOLang = "en-US" ) then
103 if ( iObjectSum <> iObjectCountExpected ) then
104 warnlog( "Number of objects has changed. OLD: " & iObjectCountExpected &_
105 " NEW: " & iObjectSum )
107 printlog( "Object count is ok for en-US / Oracle Open Office" )
110 printlog( "Template count testing skipped for non-en_US/StarOffice" )
113 Kontext "TemplateAndDocuments"
114 printlog( "Switch from preview to document info, required to limit load-times" )
115 ' Another good test case would be to enable the preview.
117 hCloseDialog( TemplateAndDocuments, "cancel" )
120 printlog( "Starting to load/save/close/reload/close all Objects" )
123 ' Iterate over the folders in the middle pane of the templates and samples
124 ' dialog, open the folders and load the containing files
125 ' If you want to debug the office using this test, get the Object indices
126 ' from the logfiles and change the loops to only load the file in question
128 ' These are the folders
129 for iObjectFolder = 1 to iObjectFolders
130 ' for iObjectFolder = MyFailedFolder to MyFailedFolder
132 ' These are the individual files
133 for iObject = 1 to iObjectCount( iObjectFolder )
134 ' for iObject = MyFailedFile to MyFailedFile
136 ' Preset gApplication to "Writer", this is the basis
137 gApplication = "WRITER"
140 printlog( "Folder index = " & iObjectFolder & ", Object index = " & iObject )
142 printlog( "Close all files" )
145 ' every now and then the office becomes a little unstable.
146 ' Enable the if()-block then, otherwise you might miss some broken
147 ' documents (because the test aborts too early)
148 'if ( iReset = 10 ) then
149 ' call exitRestartTheOffice()
153 printlog( "Open <FileNewFromTemplate>" )
157 printlog( "Select category: " & cCategory )
158 hSelectCategory( cCategory )
160 printlog( "Select a folder, do not print debug info" )
161 hSelectFileFolder( iObjectFolder , false )
163 printlog( "Select a document by index, iMode = 1 -> Open it" )
164 hSelectDocumentObject( iObject , iMode )
166 ' In few cases we accidentially work on a folder. So we test for the
167 ' Templates and Samples dialog again, if it is closed we have a
168 ' regular document, otherwise we have a folder which we then skip.
169 kontext "TemplateAndDocuments"
170 if ( TemplateAndDocuments.exists() ) then
171 if ( not edit.isEnabled() ) then
172 printlog( CFN & "Object is folder or #edit# is disabled, skipping" )
174 TemplateAndDocuments.cancel()
177 printlog( "Loading file..." )
178 printlog( "Check for Filter Options dialog" )
180 ' Yes, hFileWait() knows which dialog is in the way so we can ask it
181 ' directly. The ASCII filter dialog has the number -6
182 if ( hFileWait( false ) = -6 ) then
183 warnlog( "Load failure: ASCII filter dialog displayed, recovering" )
184 kontext "FilterAuswahl"
185 hCloseDialog( FilterAuswahl, "cancel" )
188 printlog( "Build filename; save, reload and delete" )
189 sFile = sPath & cCategory & iObjectFolder & "_" & iObject
190 printlog( "File is: " & sFile )
193 printlog( "Close Navigator (if present)" )
194 hCloseDialog( Navigator, "close,optional" )
196 printlog( "Save file" )
197 hFileSaveAsKill( sFile )
199 printlog( "Close file" )
202 printlog( "Open file" )
205 printlog( "Handle possible dialogs" )
206 hHandleActivesOnLoad( 1 , 2 )
209 printlog( "Close Navigator (if present)" )
210 hCloseDialog( Navigator, "close,optional" )
212 printlog( "Close document" )
215 printlog( "Delete work document" )
226 printlog( "Close last remaining document(s) and exit test" )