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 : check the internal file dialog ( 1. part )
32 '\***************************************************************************
34 sub CheckDirectoryName( dirname as string )
36 ' Try to create a folder twice and make sure a warning comes up that the
37 ' folder already exists
40 dim FULLPATH as string
41 FULLPATH = gOfficePath + "user\work\" + dirname + "\"
43 printlog( " - Create the folder and verify it's existence" )
49 printlog( " - creating folder for the " + i + ". time" )
52 printlog( " - press 'new folder' button" )
56 if ( NeuerOrdner.exists( 2 ) ) then
57 printlog( " - name the folder" )
58 OrdnerName.SetText( dirname )
59 printlog( " - press OK")
62 warnlog( "New Folder dialog not displayed" )
65 ' Take care of the File Exists Dialog
66 printlog( " - check for 'File Exists'-Dialog" )
68 If Active.Exists() then
71 'if the file exists during first run of the test: just go on
73 warnlog( "File exists. Did you clean the output-dir?" )
76 'if the active exists, we will return to the 'new folder' dialog
77 'it must be closed as well
81 'this should only be displayed on second run
83 warnlog( "No message that the folder '" + dirname + "' exists!" )
89 printlog( " - verify the existence of the new directory" )
90 if App.Dir ( ConvertPath ( FULLPATH ), 16 ) = "" then
91 Warnlog( "The directory'" + dirname + "' wasn't created!" )
93 printlog( " - delete it")
94 App.RmDir ( ConvertPath ( FULLPATH ) )
100 warnlog( "Could not create the directory. Bugid: #108256# or #106510# ?" )
106 '*******************************************************************************
108 sub CreateInvalidDirectory( dirname as string )
110 'Try to create a directory with a name that is invalid by using characters
111 'that are not allowed for a filesystems. An errormessage is expected.
114 dim FULLPATH as string
115 FULLPATH = gOfficePath + "user\work\" + dirname + "\" 'experimental
117 printlog( " - Trying to create directory <" + FULLPATH + ">" )
122 if ( OeffnenDlg.exists( 2 ) ) then
126 Kontext "NeuerOrdner"
127 if ( NeuerOrdner.exists( 2 ) ) then
129 OrdnerName.SetText( dirname )
132 warnlog( "New Folder dialog did not open" )
136 if gPlatgroup() = "unx" then
138 'unx allows weird filenames
139 if App.Dir ( ConvertPath ( FULLPATH ), 16 ) = "" then
140 Warnlog " the '" + dirname + "'-dir wasn't created!"
142 App.RmDir ( ConvertPath ( FULLPATH ) )
149 if Active.Exists( 2 ) then
151 printlog( " - handle the 'Active' dialog" )
155 if Active.Exists( 2 ) then
156 warnlog( "Double errormessage displayed, one expected." )
160 Kontext "NeuerOrdner"
165 warnlog( "No warning that the folder can't be created!" )
169 if App.Dir( ConvertPath ( FULLPATH ), 16 ) <> "" then
170 Warnlog "The directory '"+ dirname + "' contains invalid chars"
171 App.RmDir( ConvertPath ( FULLPATH ) )
180 warnlog( "Could not create the directory. Bugid: #108256# or #106510# ?" )
186 '*******************************************************************************
188 sub CreateValidDirectory( dirname as string )
190 'Create a directory that has a valid name at a valid location
191 'The directory should not exist.
192 'It will be created in the user's directory
194 dim FULLPATH as string
195 FULLPATH = gOfficePath() + "user\work\" + dirname + "\" 'experimental
198 printlog( " - Trying to create directory: <" + FULLPATH + ">" )
202 printlog( " - Open the file-open dialog" )
206 printlog( " - name the folder" )
207 Kontext "NeuerOrdner"
208 OrdnerName.SetText( dirname )
211 printlog( " - check if the directory has been created" )
212 if App.Dir ( ConvertPath ( FULLPATH ) , 16 ) = "" then
213 warnlog( "The '" + dirname + "' has not been created!" )
215 App.RmDir( ConvertPath ( FULLPATH ) )
216 printlog( " - existing file was successfully deleted" )
221 warnlog( "Could not create the directory. Bugid: #108256# or #106510# ?" )
227 '*******************************************************************************
229 sub CreateValidDirectoryCrop( dirname as string , cropname as string)
231 'Create a directory that has a name with leading or trailing spaces.
232 'Those names are valid but must be cropped.
233 'The directory should not exist.
234 'It will be created in the user's directory.
236 dim FULLPATH as string
237 FULLPATH = gOfficePath + "user\work\" + dirname + "\" 'experimental
238 dim CROPPATH as string
239 CROPPATH = gOfficePath + "user\work\" + cropname + "\" 'experimental
241 printlog( " - Trying to create directory: <" + FULLPATH + ">" )
245 printlog( " - open the file-open dialog" )
249 printlog( " - name the folder" )
250 Kontext "NeuerOrdner"
251 OrdnerName.SetText( dirname )
255 printlog( " - check if the directory has been created" )
256 if App.Dir( ConvertPath ( CROPPATH ), 16 ) = "" then
258 warnlog( "The leading or trailing spaces have not been deleted!" )
263 App.RmDir( ConvertPath ( CROPPATH ) )
264 printlog( " - existing directory was successfully deleted." )
270 warnlog( "Could not create the directory. Bugid: #108256# or #106510# ?" )
276 '*******************************************************************************
278 function LoadDocumentReadOnly ( sDatei as String, TypeOfDocument as Integer, ReadOnlyFlag as Boolean ) as Boolean
280 LoadDocumentReadOnly = TRUE
285 Dateiname.SetText sDatei
287 if ReadOnlyFlag = TRUE then
295 if Active.Exists( 2 ) then
296 LoadDocumentReadOnly = FALSE
297 Warnlog Active.GetText
300 if Active.Exists( 1 ) then
301 Warnlog "A second messagebox is active!"
305 Kontext "Filterauswahl"
306 If FilterAuswahl.Exists( 2 ) then
307 Warnlog "Filterbox is also active!"
312 'printlog( " - check for (unexpected) filter-dialog" )
313 Kontext "Filterauswahl"
315 If ( FilterAuswahl.Exists( 2 ) ) then
316 Warnlog( "Filterbox is active, this is not expected" )
317 FilterAuswahl.Cancel()
319 qaerrorlog( "TODO: There is no way that this function can handle " & _
320 "the filterdialog correctly, rewrite it!" )
321 warnlog( "The test will most likely fail!" )
323 LoadDocumentReadOnly() = false
332 if ( OeffnenDlg.exists( 2 ) ) then
333 warnlog( "File-Open dialog is open, this is not expected at this point" )
334 printlog( "Exiting routine to recover" )
338 LoadDocumentReadOnly() = false
345 select case TypeOfDocument
347 case 1 : InsertSection ' Writer
349 Active.Setpage TabBereiche
350 Kontext "TabBereiche"
352 case 2 : FormatCells ' Calc
354 Active.SetPage TabZahlen
357 case 3 : SlideShowPresentationSettings ' Impress
358 Kontext "Bildschirmpraesentation"
359 Bildschirmpraesentation.Cancel
360 case 4 : InsertLayer ' Draw
361 Kontext "EbeneEinfuegenDlg"
362 EbeneEinfuegenDlg.Cancel
363 case 5 : FormatLegend ' Chart
364 Kontext "TabUmrandungChart" :
365 TabUmrandungChart.Cancel
366 case 6 : FormatFonts ' Math
367 Kontext "Schriftarten"
371 if LoadDocumentReadOnly = TRUE then
372 Warnlog "The document wasn't loaded read only"
381 '*******************************************************************************
383 sub hSetUNIXAttributes()
385 ' NOTE: Requested by TBO
386 ' This sub tries to set the file-attributes on the qatesttool-snapshot on
388 ' Since all BASIC commands are platform independent, it cannot be checked
390 ' If you are not the owner of the testtool snapshot, this is *not* going to
394 dim cFullPath as string
395 dim cParameter as string
396 dim cCommand as string
399 if ( gPLatGroup = "unx" ) then
401 cCommand = "chmod" ' Fallback, if no following definition matches
402 if ( gPlatform = "sol" ) then
403 cCommand = "/usr/bin/chmod"
405 if ( gPlatform = "x86" ) then
406 cCommand = "/usr/bin/chmod"
408 if ( gPlatform = "lin" ) then
409 cCommand = "/bin/chmod"
412 cFullPath = convertpath( gTesttoolPath + "framework/filedlg/input/noentry" )
413 printlog( "Trying to set attributes for " + cFullPath )
414 cParameter = "-R 000 " + cFullPath
415 rc = shell( cCommand , 0 , cParameter , false )
417 ' the readentry-directory must be readonly, the files as well
418 cFullPath = convertpath( gTesttoolPath + "framework/filedlg/input/readentry" )
419 printlog( "Trying to set attributes for " + cFullPath )
420 cParameter = "-R 444 " + cFullPath
421 rc = shell( cCommand , 0 , cParameter , false )
422 'need to remove the "S" attribute
423 cParameter = "-R -s " + cFullPath
424 rc = shell( cCommand , 0 , cParameter , false )
426 ' the readonly-directory: Only the directory is read-only, the files are rw
427 cFullPath = convertpath( gTesttoolPath + "framework/filedlg/input/readonly/*.*" )
428 printlog( "Trying to set attributes for " + cFullPath )
429 cParameter = "444 " + cFullPath
430 rc = shell( cCommand , 0 , cParameter , false )
434 printlog( "No file-attribute setting for non-UNIX platforms" )
441 '*******************************************************************************
443 function hGetFirstNameFromFileList() as string
450 const CFN = "hGetFirstNameFromFileList()::"
451 dim brc as boolean 'a multi purpose boolean returnvalue
452 dim cFileName as string
456 Dateiauswahl.typeKeys( "<HOME>" )
457 Dateiauswahl.typeKeys( "<SPACE>" )
459 cFileName =lcase( Dateiauswahl.GetSelText() )
460 printlog( CFN & "File: " & cFileName )
462 if ( cFileName = "" ) then
463 warnlog( CFN & "Filename is empty, probably a timing issue" )
466 if ( cFileName = "cvs" ) then
467 printlog( CFN & "Skipping CVS directory" )
468 Dateiauswahl.TypeKeys( "<Down>" )
470 cFileName = lcase ( Dateiauswahl.GetSelText() )
471 printlog( CFN & "File: " & cFileName )
474 hGetFirstNameFromFileList() = cFileName