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 : Test scripting-organizers / document-attached scripts
32 '\******************************************************************************
34 testcase tScriptingOrganizers( iDialog as integer )
36 if ( instr( gtSysName , "Solaris" ) > 0 ) then
37 qaerrorlog( "#i93502# JavaScript organizer broken" )
41 ' 1 = BeanShell (.bsh)
42 ' 2 = JavaScript (.js)
46 dim cFileName as string
47 cFileName = "sftest" & hGetSuffix( "current" )
48 dim cCompare as string
50 dim cFilePath as string
51 cFilePath= hGetWorkPath() & cFileName
52 cFilePath= convertpath( cFilePath )
54 dim iPos as integer ' position of the workdocument in treelist
55 dim brc as boolean ' boolean return code used to determine the status
57 dim cLibName as string
59 dim cModName as string
61 dim cScriptName as string
63 dim iItemCount as integer
66 printlog( "Test init: set macro security level to low" )
67 hSetMacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_LOW )
70 case 1 : cScriptName = cModName & ".bsh"
71 case 2 : cScriptName = cModName & ".js"
74 brc = hDeleteFile( cFilePath )
76 printlog( "Test init: Create and prepare document" )
77 brc = hCreateDocument()
81 brc = hFileSaveAsKill( cFilePath )
84 printlog( "Test 1: ScriptOrganizer/Documents" )
85 brc = hOpenScriptOrganizer( iDialog )
87 warnlog( "Could not open the script Organizer, aborting" )
88 brc = hDestroyDocument()
92 kontext "ScriptOrganizer"
93 iItemCount = hGetNodeCount( ScriptTreeList )
95 if ( ScriptTreeList.getItemCount() <> IDOCPOS ) then
96 warnlog( "Incorrect number of documents listed in treelist, aborting" )
97 kontext "ScriptOrganizer"
98 ScriptOrganizer.cancel()
99 brc = hDestroyDocument()
103 kontext "ScriptOrganizer"
104 ScriptTreeList.select( IDOCPOS )
106 if ( not PBCreate.isEnabled() ) then
107 warnlog( "Create button should be enabled" )
110 if ( PBEdit.isEnabled() ) then
111 warnlog( "Edit button should be disabled" )
114 if ( PBRename.isEnabled() ) then
115 warnlog( "Rename button should be disabled" )
118 if ( PBDelete.isEnabled() ) then
119 qaerrorlog( "#i50527# - Delete button should be disabled" )
124 printlog( "Test 2: Libraries/Scripts create/rename" )
126 brc = hCreateScriptingObject( "initial_lib" )
128 brc = hRenameScriptingObject( cLibName )
130 brc = hVerifyNodeName( ScriptTreeList , cLibName )
132 qaerrorlog( "#i50526# Renaming failed: " & cLibName )
135 cLibName = ScriptTreeList.getSelText()
137 if ( not PBCreate.isEnabled() ) then
138 warnlog( "Create button should be enabled" )
141 if ( PBEdit.isEnabled() ) then
142 warnlog( "Edit button should be disabled" )
145 if ( not PBRename.isEnabled() ) then
146 warnlog( "Rename button should be enabled" )
149 if ( not PBDelete.isEnabled() ) then
150 warnlog( "Delete button should be enabled" )
153 brc = hCreateScriptingObject( "initial_mod" )
155 brc = hRenameScriptingObject( cModName )
157 brc = hVerifyNodeName( ScriptTreeList , cScriptName )
159 qaerrorlog( "#i50526# Renaming failed: " & cScriptName )
162 cModName = ScriptTreeList.getSelText()
164 if ( PBCreate.isEnabled() ) then
165 warnlog( "Create button should not be enabled" )
168 if ( not PBEdit.isEnabled() ) then
169 warnlog( "Edit button should be enabled" )
172 if ( not PBRename.isEnabled() ) then
173 warnlog( "Rename button should be enabled" )
176 if ( not PBDelete.isEnabled() ) then
177 warnlog( "Delte button should be enabled" )
180 kontext "ScriptOrganizer"
181 hCloseDialog( ScriptOrganizer, "close" )
184 printlog( "Test 3: Script storage in documents (save/load)" )
188 warnlog( "Document Changed status not set" )
193 brc = hDestroyDocument()
195 brc = hFileOpen( cFilePath )
197 brc = hOpenScriptOrganizer( iDialog )
199 ScriptTreeList.select( 3 )
201 iPos = hExpandNode( ScriptTreeList , 0 )
203 ScriptTreeList.select( 4 )
205 iPos = hExpandNode( ScriptTreeList , 0 )
206 ScriptTreeList.select( 5 )
211 printlog( "Test 4: Script removal / Document changed" )
212 brc = hDeleteScript( cModName , true )
214 warnlog( "Bad rc: hDelteScript()" )
217 brc = hDeleteScript( cLibName , true )
219 warnlog( "Bad rc: hDelteScript()" )
222 brc = hDeleteScript( cFileName , false )
224 qaerrorlog( "#i50527# Delete enabled for document object" )
227 kontext "ScriptOrganizer"
228 hCloseDialog( ScriptOrganizer, "close" )
233 warnlog( "Document Changed status expected after script deletion" )
238 brc = hDestroyDocument()
240 printlog( "Reload the document." )
241 brc = hFileOpen( cFilePath )
243 qaerrorlog( "#i50530# Macros not completely removed from doc when deleted" )
247 printlog( "Test 5: Verification of script removal" )
248 brc = hOpenScriptOrganizer( iDialog )
249 kontext "ScriptOrganizer"
250 iItemCount = hGetNodeCount( ScriptTreeList )
251 if ( iItemCount <> IDOCPOS ) then
252 warnlog( "Treelist not populated, the test cannot continue" )
253 kontext "ScriptOrganizer"
254 hCloseDialog( ScriptOrganizer, "close" )
255 brc = hDestroyDocument()
259 iPos = hExpandNode( ScriptTreeList , IDOCPOS )
260 if ( iPos <> 3 ) then
261 warnlog( "Not all libraries/scripts have been deleted" )
264 kontext "ScriptOrganizer"
265 hCloseDialog( ScriptOrganizer, "close" )
268 hCloseDialog( Navigator, "close,optional" )
270 brc = hDestroyDocument()
272 brc = hDeleteFile( cFilePath )
274 warnlog( "Could not delete: " & cFilePath & " - do so manually!" )
278 hSetmacroSecurityAPI( GC_MACRO_SECURITY_LEVEL_DEFAULT )