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 2008 by Sun Microsystems, Inc.
7 '* OpenOffice.org - a multi-platform office productivity suite
9 '* $RCSfile: filedlg_autocomplete.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 12:18:14 $
15 '* This file is part of OpenOffice.org.
17 '* OpenOffice.org is free software: you can redistribute it and/or modify
18 '* it under the terms of the GNU Lesser General Public License version 3
19 '* only, as published by the Free Software Foundation.
21 '* OpenOffice.org is distributed in the hope that it will be useful,
22 '* but WITHOUT ANY WARRANTY; without even the implied warranty of
23 '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 '* GNU Lesser General Public License version 3 for more details
25 '* (a copy is included in the LICENSE file that accompanied this code).
27 '* You should have received a copy of the GNU Lesser General Public License
28 '* version 3 along with OpenOffice.org. If not, see
29 '* <http://www.openoffice.org/license.html>
30 '* for a copy of the LGPLv3 License.
32 '/******************************************************************************
34 '* owner : joerg.skottke@sun.com
36 '* short description : Autocompletion feature
38 '\******************************************************************************
40 testcase tAutocomplete
42 '///<h1>Autocompletion feature</h1>
44 '///<u><pre>Synopsis</pre></u>Test the autocompletion feature, filename completion<br>
45 '///<u><pre>Specification document</pre></u>No specification document available<br>
46 '///<u><pre>Files used</pre></u>
47 '///+ (User-Layer)/user/work/autocomplete<br>
48 '///+ (User-Layer)/user/work/autocomplete/autocomplete_a.odt</br>
49 '///+ (User-Layer)/user/work/autocomplete/autocomplete_b.odt</br>
50 '///+ (User-Layer)/user/work/autocomplete/autocomplete_bb.odt</br>
52 ' IMPORTANT NOTE: Autocompletion is asynchronous. This means that no rule
53 ' exists when exactly it is going to strike. If you are
54 ' using a networked environment you have to make sure that
55 ' all network ressources deliver a decent performance as
56 ' this seriously influences the speed of the autocompletion.
58 dim cBasePath as string
60 const WORKDIR = "autocomplete"
62 ' These are the files we create in the users homedirectory
63 dim aWorkFile( 3 ) as string
64 aWorkFile( 1 ) = "autocomplete_a.odt"
65 aWorkFile( 2 ) = "autocomplete_b.odt"
66 aWorkFile( 3 ) = "autocomplete_bb.odt"
68 ' These are the full paths to the files
69 dim aFullPath( 3 ) as string
71 ' These are the wildcarded filter strings
73 aWildCard( 1 ) = "autocomplete_?.odt"
74 aWildCard( 2 ) = "autocomplete_b?.odt"
75 aWildCard( 3 ) = "autocomplete_*.odt"
78 dim cCurrentPath as string
79 dim cAutocomplete as string
81 dim iCurrentDocument as integer
87 dim cEFString as string
91 '///<u><pre>Test case specification</pre></u>
93 '///+<li>Init: Make sure we only have no open documents</li>
94 do while( getDocumentCount > 0 )
98 '///+<li>Init: Get the current workpath</li>
99 cBasePath = hGetWorkPath()
100 aFullPath( 1 ) = cBasePath & WORKDIR & gPathSigne & aWorkFile( 1 )
101 aFullPath( 2 ) = cBasePath & WORKDIR & gPathSigne & aWorkFile( 2 )
102 aFullPath( 3 ) = cBasePath & WORKDIR & gPathSigne & aWorkFile( 3 )
103 hDeleteFile( aFullPath( 1 ) )
104 hDeleteFile( aFullPath( 2 ) )
105 hDeleteFile( aFullPath( 3 ) )
106 if ( dir( cBasePath & WORKDIR ) <> "" ) then
107 rmdir( cBasePath & WORKDIR )
110 '///+<li>Init: Create a directory called "autocomplete" in the user directory</li>
111 mkdir( cBasePath & WORKDIR )
112 if ( dir( cBasePath & WORKDIR ) = "" ) then
113 warnlog( "Failed to create work directory, aborting" )
117 '///+<li>Init: Create three documents within the workdir - autocomplete_a.odt/_b.odt/_bb.odt</li>
118 gApplication = "WRITER"
119 for iCurrentDocument = 1 to 3
121 kontext "DocumentWriter"
122 DocumentWriter.typeKeys( aWorkFile( iCurrentDocument ) )
123 hFileSaveAs( aFullPath( iCurrentDocument ) )
125 next iCurrentDocument
129 '///+<li>Open the File Open dialog</li>
130 printlog( "open the File Open dialog" )
133 '///+<li>Test case 1: Workdirectory and folder autocompletion</li>
135 '///+<li>Go to the work directory using the "Home" button</li>
139 '///+<li>Enter the first 4 characters of the testdirectory</li>
140 cLeft = left( WORKDIR, iLeft )
141 cEFString = convertpath( WORKDIR & "/" )
142 printlog( "Type """ & cLeft & """ into the filename entryfield" )
143 DateiName.typeKeys( cLeft )
145 '///+<li>Press the "END" key</li>
146 printlog( "Press the <END> key and wait for two seconds" )
147 DateiName.typeKeys( "<END>" )
148 sleep( 1 ) ' Required, do not remove
150 '///+<li>Verify that the "autocomplete" dir has been autocompleted</li>
151 cAutocomplete = DateiName.getSelText()
152 if ( cEFString = cAutocomplete ) then
153 printlog( "Autocompletion succeeded for workdirectory" )
155 warnlog( "Autocompletion failed" )
156 printlog( "Expected: " & cRight )
157 printlog( "Found...: " & cAutocomplete )
160 '///+<li>Press return on the FileOpen dialog</li>
161 printlog( "Press <RETURN> on the file open dialog -> Open"
163 OeffnenDlg.typeKeys( "<RETURN>" )
166 '///+<li>Test case 2: Filename autocompletion/selection</li>
168 '///+<li>Enter the string "auto" into the entryfield</li>
169 printlog( "Type "" auto "" into the entryfield" )
170 cLeft = left( aWorkFile( 1 ), 4 )
171 DateiName.typeKeys( cLeft )
174 '///+<li>Verify that the filename is expanded to autocomplete_a.odt</li>
175 cAutocomplete = DateiName.getSelText()
176 if ( aWorkFile( 1 ) = cAutocomplete ) then
177 printlog( "Autocompletion succeeded for first file" )
179 warnlog( "Autocompletion failed" )
180 printlog( "Expected: " & cRight )
181 printlog( "Found...: " & cAutocomplete )
184 '///+<li>Press the down-key in the entry field</li>
185 printlog( "Press down key in entry field" )
186 DateiName.typeKeys( "<DOWN>" )
189 '///+<li>Verify that the filename is expanded to autocomplete_b.odt</li>
190 cAutocomplete = DateiName.getSelText()
191 if ( aWorkFile( 2 ) = cAutocomplete ) then
192 printlog( "Autocompletion succeeded for second file" )
194 warnlog( "Autocompletion failed" )
195 printlog( "Expected: " & cRight )
196 printlog( "Found...: " & cAutocomplete )
200 '///+<li>Test case 3: Wildcards ? and * (click "Open" to apply)</li>
202 '///+<li>Enter autocomplete_?.odt -> 2 matches expected</li>
203 printlog( "Enter autocomplete_?.odt -> 2 matches expected" )
204 Dateiname.setText( aWildCard( 1 ) )
206 if ( DateiAuswahl.getItemCount() <> 2 ) then
207 warnlog( "Incorrect number of files displayed, 2 expected" )
209 printlog( "Correct number of files listed in files-list" )
212 '///+<li>Enter autocomplete_b?.odt -> 1 match expected</li>
213 printlog( "Enter autocomplete_b?.odt -> 1 match expected" )
214 Dateiname.setText( aWildCard( 2 ) )
216 if ( DateiAuswahl.getItemCount() <> 1 ) then
217 warnlog( "Incorrect number of files displayed, 1 expected" )
219 printlog( "Correct number of files listed in files-list" )
222 '///+<li>Enter autocomplete_*.odt -> 3 matches expected</li>
223 printlog( "Enter autocomplete_*.odt -> 3 matches expected" )
224 Dateiname.setText( aWildCard( 3 ) )
226 if ( DateiAuswahl.getItemCount() <> 3 ) then
227 warnlog( "Incorrect number of files displayed, 3 expected" )
229 printlog( "Correct number of files listed in files-list" )
234 '///+<li>Close File Open dialog</li>
235 printlog( "Close File Open dialog" )
239 '///+<li>Cleanup: Remove files, directories</li>
240 hDeleteFile( aFullPath( 1 ) )
241 hDeleteFile( aFullPath( 2 ) )
242 hDeleteFile( aFullPath( 3 ) )
243 rmdir( cBasePath & WORKDIR )