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: scripting_organizers.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 12:18:15 $
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 : Test scripting-organizers / document-attached scripts
38 '\******************************************************************************
40 testcase tScriptingOrganizers( iDialog as integer )
42 if ( instr( gtSysName , "Solaris" ) > 0 ) then
43 qaerrorlog( "#i93502# JavaScript organizer broken" )
47 '///<H1>Test scripting-organizers</H1>
48 ' 1 = BeanShell (.bsh)
49 ' 2 = JavaScript (.js)
53 dim cFileName as string
54 cFileName = "sftest" & hGetSuffix( "current" )
55 dim cCompare as string
57 dim cFilePath as string
58 cFilePath= hGetWorkPath() & cFileName
59 cFilePath= convertpath( cFilePath )
61 dim iPos as integer ' position of the workdocument in treelist
62 dim brc as boolean ' boolean return code used to determine the status
64 dim cLibName as string
66 dim cModName as string
68 dim cScriptName as string
70 dim iItemCount as integer
73 '///+<li>Set macro security level to low</li>
75 printlog( "Test init: set macro security level to low" )
76 hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_LOW )
78 '///+<li>For both script organizers (javascript/beanshell) do</li>
80 '///+<li>Create a script name of type TTMod.(.bsh|js)</li>
82 case 1 : cScriptName = cModName & ".bsh"
83 case 2 : cScriptName = cModName & ".js"
86 '///+<li>Delete the workfile in case it has been left over by prior run</li>
87 brc = hDeleteFile( cFilePath )
89 '///+<li>Open a new document</li>
90 printlog( "Test init: Create and prepare document" )
91 brc = hCreateDocument()
93 '///+<li>Modify the document</li>
96 '///+<li>Save the document (Menu File->Save As...)</li>
97 brc = hFileSaveAsKill( cFilePath )
99 '///+<li>Open the ScriptOrganizer</li>
101 printlog( "Test 1: ScriptOrganizer/Documents" )
102 brc = hOpenScriptOrganizer( iDialog )
104 warnlog( "Could not open the script Organizer, aborting" )
105 brc = hDestroyDocument()
109 '///+<li>Count the objects in the collapsed treelist</li>
110 kontext "ScriptOrganizer"
111 iItemCount = hGetNodeCount( ScriptTreeList )
113 '///+<li>Verify that there are exactly three items in the treelist</li>
114 if ( ScriptTreeList.getItemCount() <> IDOCPOS ) then
115 warnlog( "Incorrect number of documents listed in treelist, aborting" )
116 kontext "ScriptOrganizer"
117 ScriptOrganizer.cancel()
118 brc = hDestroyDocument()
122 '///+<li>Select the document at pos. 3</li>
123 kontext "ScriptOrganizer"
124 ScriptTreeList.select( IDOCPOS )
126 '///+<li>Test status of Buttons</li>
128 '///+<li>"Create" should be enabled</li>
129 if ( not PBCreate.isEnabled() ) then
130 warnlog( "Create button should be enabled" )
133 '///+<li>"Edit" should be disabled</li>
134 if ( PBEdit.isEnabled() ) then
135 warnlog( "Edit button should be disabled" )
138 '///+<li>"Rename" should be disabled</li>
139 if ( PBRename.isEnabled() ) then
140 warnlog( "Rename button should be disabled" )
143 '///+<li>"Delete" should be disabled</li>
144 if ( PBDelete.isEnabled() ) then
145 qaerrorlog( "#i50527# - Delete button should be disabled" )
151 printlog( "Test 2: Libraries/Scripts create/rename" )
153 '///+<li>Create a new library</li>
154 brc = hCreateScriptingObject( "initial_lib" )
156 '///+<li>Rename the library</li>
157 brc = hRenameScriptingObject( cLibName )
159 '///+<li>Verify that renaming worked</li>
160 brc = hVerifyNodeName( ScriptTreeList , cLibName )
162 qaerrorlog( "#i50526# Renaming failed: " & cLibName )
165 '///+<li>Remember name of the library, it is deleted later</li>
166 cLibName = ScriptTreeList.getSelText()
168 '///+<li>Test status of Buttons</li>
170 '///+<li>"Create" should be enabled</li>
171 if ( not PBCreate.isEnabled() ) then
172 warnlog( "Create button should be enabled" )
175 '///+<li>"Edit" should be disabled</li>
176 if ( PBEdit.isEnabled() ) then
177 warnlog( "Edit button should be disabled" )
180 '///+<li>"Rename" should be enabled</li>
181 if ( not PBRename.isEnabled() ) then
182 warnlog( "Rename button should be enabled" )
185 '///+<li>"Delete" should be enabled</li>
186 if ( not PBDelete.isEnabled() ) then
187 warnlog( "Delete button should be enabled" )
191 '///+<li>Create a new script</li>
192 brc = hCreateScriptingObject( "initial_mod" )
194 '///+<li>Rename the script</li>
195 brc = hRenameScriptingObject( cModName )
197 '///+<li>Verify that renaming worked</li>
198 brc = hVerifyNodeName( ScriptTreeList , cScriptName )
200 qaerrorlog( "#i50526# Renaming failed: " & cScriptName )
203 '///+<li>Remember the module name, it is deleted later</li>
204 cModName = ScriptTreeList.getSelText()
206 '///+<li>Test status of Buttons</li>
208 '///+<li>"Create" should be disabled</li>
209 if ( PBCreate.isEnabled() ) then
210 warnlog( "Create button should not be enabled" )
213 '///+<li>"Edit" should be enabled</li>
214 if ( not PBEdit.isEnabled() ) then
215 warnlog( "Edit button should be enabled" )
218 '///+<li>"Rename" should be enabled</li>
219 if ( not PBRename.isEnabled() ) then
220 warnlog( "Rename button should be enabled" )
223 '///+<li>"Delete" should be enabled</li>
224 if ( not PBDelete.isEnabled() ) then
225 warnlog( "Delte button should be enabled" )
229 '///+<li>Exit the scriptorganizer (cancel)</li>
230 kontext "ScriptOrganizer"
231 brc = hCloseScriptOrganizer()
233 '///+<li>Save the file</li>
235 printlog( "Test 3: Script storage in documents (save/load)" )
239 warnlog( "Document Changed status not set" )
244 '///+<li>Close the document</li>
245 brc = hDestroyDocument()
247 '///+<li>Reload the document.</li>
248 brc = hFileOpen( cFilePath )
250 '///+<li>Open the ScriptOrganizer</li>
251 brc = hOpenScriptOrganizer( iDialog )
253 '///+<li>Select the document</li>
254 ScriptTreeList.select( 3 )
256 '///+<li>Expand the node</li>
257 iPos = hExpandNode( ScriptTreeList , 0 )
259 '///+<li>Select the module</li>
260 ScriptTreeList.select( 4 )
262 '///+<li>Select the script</li>
263 iPos = hExpandNode( ScriptTreeList , 0 )
264 ScriptTreeList.select( 5 )
269 '///+<li>Delete the script (should work)</li>
270 printlog( "Test 4: Script removal / Document changed" )
271 brc = hDeleteScript( cModName , true )
273 warnlog( "Bad rc: hDelteScript()" )
276 '///+<li>Delete the module (should work)</li>
277 brc = hDeleteScript( cLibName , true )
279 warnlog( "Bad rc: hDelteScript()" )
282 '///+<li>Delete the document (which should not work)</li>
283 brc = hDeleteScript( cFileName , false )
285 qaerrorlog( "#i50527# Delete enabled for document object" )
288 '///+<li>Exit all dialogs (close the script organizer)</li>
289 kontext "ScriptOrganizer"
290 brc = hCloseScriptOrganizer()
292 '///+<li>Save the file via File Save button on standardbar</li>
296 warnlog( "Document Changed status expected after script deletion" )
301 '///+<li>Close the document</li>
302 brc = hDestroyDocument()
304 '///+<li>Reload the document.</li>
305 printlog( "Reload the document." )
306 brc = hFileOpen( cFilePath )
308 qaerrorlog( "#i50530# Macros not completely removed from doc when deleted" )
311 '///+<li>Open the ScriptOrganizer, look for the library</li>
313 printlog( "Test 5: Verification of script removal" )
314 brc = hOpenScriptOrganizer( iDialog )
315 kontext "ScriptOrganizer"
316 iItemCount = hGetNodeCount( ScriptTreeList )
317 if ( iItemCount <> IDOCPOS ) then
318 warnlog( "Treelist not populated, the test cannot continue" )
319 brc = hCloseScriptOrganizer()
320 brc = hDestroyDocument()
324 '///+<li>Verify that all libraries/scripts have been removed</li>
325 iPos = hExpandNode( ScriptTreeList , IDOCPOS )
326 if ( iPos <> 3 ) then
327 warnlog( "Not all libraries/scripts have been deleted" )
330 '///+<li>Test Exit: Cleanup - close all dialogs</li>
331 brc = hCloseScriptOrganizer()
333 '///+<li>Close the navigator if it is open</li>
334 brc = hCloseNavigator()
336 '///+<li>Close the document</li>
337 brc = hDestroyDocument()
339 '///+<li>Delete the workfile</li>
340 brc = hDeleteFile( cFilePath )
342 warnlog( "Could not delete: " & cFilePath & " - do so manually!" )
347 '///+<li>Set macro security level to default</li>
348 hSetmacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_DEFAULT )