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 : Autocompletion feature
32 '\******************************************************************************
34 testcase tAutocomplete
36 printlog( "Autocompletion in the OpenOffice.org file picker" )
38 ' IMPORTANT NOTE: Autocompletion is asynchronous. This means that no rule
39 ' exists when exactly it is going to strike. If you are
40 ' using a networked environment you have to make sure that
41 ' all network ressources deliver a decent performance as
42 ' this seriously influences the speed of the autocompletion.
44 ' Assemble a work directory path
45 const WORKDIR = "autocomplete"
46 dim cBasePath as string : cBasePath = hGetWorkPath()
47 dim cWorkDir as string : cWorkDir = cBasePath & WORKDIR
49 ' These are the files we create in the users homedirectory
50 dim aWorkFile( 3 ) as string
51 aWorkFile( 1 ) = "autocomplete_a.odt"
52 aWorkFile( 2 ) = "autocomplete_b.odt"
53 aWorkFile( 3 ) = "autocomplete_bb.odt"
55 ' These are the full paths to the files
56 dim aFullPath( 3 ) as string
58 ' These are the wildcarded filter strings
60 aWildCard( 1 ) = "autocomplete_?.odt"
61 aWildCard( 2 ) = "autocomplete_b?.odt"
62 aWildCard( 3 ) = "autocomplete_*.odt"
64 dim cCurrentPath as string
65 dim cAutocomplete as string
67 dim iCurrentDocument as integer
73 dim cEFString as string
77 printlog( "Close all open documents" )
80 printlog( "Assemble 3 filenames for workfiles" )
81 aFullPath( 1 ) = cWorkDir & gPathSigne & aWorkFile( 1 )
82 aFullPath( 2 ) = cWorkDir & gPathSigne & aWorkFile( 2 )
83 aFullPath( 3 ) = cWorkDir & gPathSigne & aWorkFile( 3 )
85 printlog( "Delete the 3 workfiles if they exist" )
86 hDeleteFile( aFullPath( 1 ) )
87 hDeleteFile( aFullPath( 2 ) )
88 hDeleteFile( aFullPath( 3 ) )
90 printlog( "Try to remove conflicting work directories" )
91 if ( dir( cBasePath & WORKDIR ) <> "" ) then
95 printlog( "Create workdirectory: " & cWorkDir )
97 if ( NOT FileExists( cWorkDir ) ) then
98 warnlog( "Failed to create work directory, aborting" )
102 gApplication = "WRITER"
103 printlog( "Create the workfiles - 3 writer files with minimum content" )
104 for iCurrentDocument = 1 to 3
105 call hCreateDocument()
106 kontext "DocumentWriter"
107 DocumentWriter.typeKeys( aWorkFile( iCurrentDocument ) )
108 hFileSaveAs( aFullPath( iCurrentDocument ) )
109 hUseAsyncSlot( "FileClose" )
110 next iCurrentDocument
112 printlog( "Open the File Open dialog" )
113 hUseAsyncSlot( "FileOpen" )
116 printlog( "Click the <Standard> button to get to the default work directory" )
119 cLeft = left( WORKDIR, iLeft )
120 cEFString = convertpath( WORKDIR & "/" )
121 printlog( "Type """ & cLeft & """ into the filename entryfield" )
122 DateiName.typeKeys( cLeft )
124 printlog( "Press the <END> key and wait for two seconds" )
125 DateiName.typeKeys( "<END>" )
126 sleep( 1 ) ' Required, do not remove
128 cAutocomplete = DateiName.getSelText()
129 if ( cEFString = cAutocomplete ) then
130 printlog( "Autocompletion succeeded for workdirectory" )
132 warnlog( "Autocompletion failed" )
133 printlog( "Expected: " & cEFString )
134 printlog( "Found...: " & cAutocomplete )
137 printlog( "Press <RETURN> on the file open dialog -> Open"
139 OeffnenDlg.typeKeys( "<RETURN>" )
141 printlog( "Type "" auto "" into the entryfield" )
142 cLeft = left( aWorkFile( 1 ), 4 )
143 DateiName.typeKeys( cLeft )
146 cAutocomplete = DateiName.getSelText()
147 if ( aWorkFile( 1 ) = cAutocomplete ) then
148 printlog( "Autocompletion succeeded for first file" )
150 warnlog( "Autocompletion failed" )
151 printlog( "Expected: " & cEFString )
152 printlog( "Found...: " & cAutocomplete )
155 printlog( "Press down key in entry field" )
156 DateiName.typeKeys( "<DOWN>" )
159 cAutocomplete = DateiName.getSelText()
160 if ( aWorkFile( 2 ) = cAutocomplete ) then
161 printlog( "Autocompletion succeeded for second file" )
163 warnlog( "Autocompletion failed" )
164 printlog( "Expected: " & cEFString )
165 printlog( "Found...: " & cAutocomplete )
168 printlog( "Enter autocomplete_?.odt -> 2 matches expected" )
169 Dateiname.setText( aWildCard( 1 ) )
171 if ( DateiAuswahl.getItemCount() <> 2 ) then
172 warnlog( "Incorrect number of files displayed, 2 expected" )
174 printlog( "Correct number of files listed in files-list" )
177 printlog( "Enter autocomplete_b?.odt -> 1 match expected" )
178 Dateiname.setText( aWildCard( 2 ) )
180 if ( DateiAuswahl.getItemCount() <> 1 ) then
181 warnlog( "Incorrect number of files displayed, 1 expected" )
183 printlog( "Correct number of files listed in files-list" )
186 printlog( "Enter autocomplete_*.odt -> 3 matches expected" )
187 Dateiname.setText( aWildCard( 3 ) )
189 if ( DateiAuswahl.getItemCount() <> 3 ) then
190 warnlog( "Incorrect number of files displayed, 3 expected" )
192 printlog( "Correct number of files listed in files-list" )
196 printlog( "Close File Open dialog" )
200 printlog( "Delete workfiles and -directory" )
201 hDeleteFile( aFullPath( 1 ) )
202 hDeleteFile( aFullPath( 2 ) )
203 hDeleteFile( aFullPath( 3 ) )
204 rmdir( cBasePath & WORKDIR )