1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--**********************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 **********************************************************************-->
28 <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
29 <script:module xmlns:script="http://openoffice.org/2000/script" script:name="Test_Ext" script:language="StarBasic">REM ***** BASIC *****
31 const cMessageExtensionService = "Extension Service"
32 const cMessageExtensionInstall = "Install Extension"
33 const cMessageExtensionUninstall = "Uninstall Extension"
35 Sub TestExtensions (FilterType as Integer)
36 Dim oTestExtension as Object, obj_null as Object
37 Dim sCurrentMessage as String
38 Dim nCurrentAction as Integer
39 Dim bResult as Boolean
40 Dim sImplementationNameString as String
41 sImplementationNameString = cUnoSmoketestTestExtension + "$_TestExtension"
43 On Local Error GoTo EXTERROR
45 nCurrentAction = cLogfileFailed
46 FileChannel% = OpenLogDat (GetLogFileName(FilterType))
48 sCurrentMessage = cMessageExtensionService
49 nCurrentAction = cEXTService
51 'Create an implementation of com.sun.star.ucb.XCommandEnvironment which is needed for
52 'adding the extension. The implementation is in
53 'javaunohelper/com/sun/star/comp/juhtest/SmoketestCommandEnvironment.java and the code is in juh.jar
54 cmdEnv = createUnoService(cUnoSmoketestCommandEnvironment)
56 'Create the component context and then get the singleton ExtensionManager
57 'A singleton cannot be created with createUnoService
58 ctx = getDefaultContext
59 ext_mgr = ctx.getValueByName("/singletons/" + cExtensionManager)
61 LogState (not IsNull (ext_mgr), "Extension "+ cMessageExtensionService, FileChannel)
62 LogState (not IsNull (ext_mgr), "Extension "+ cMessageExtensionService, MainFileChannel)
63 SetStatus (FilterType, cEXTService, not IsNull (ext_mgr))
64 if (IsNull(ext_mgr)) then
69 sCurrentMessage = cMessageExtensionInstall
70 nCurrentAction = cEXTInstall
72 'Add the extension. We must provide a file URL here.
73 'By passing "user" we determine that the actions we perform on
74 'XExtensionManager only affect the user installation. To modify the share installation one would pass "share".
77 ext_mgr.addExtension(sExtensionURL + cExtensionFileName, props, "user", obj_null, cmdEnv)
79 'Check if the extension has been added by creating a service which is contained in the extension.
80 oTestExtension = createUnoService(cUnoSmoketestTestExtension)
81 bResult = (oTestExtension.getImplementationName = sImplementationNameString)
82 LogState (bResult, "Extension "+ cMessageExtensionInstall, FileChannel)
83 LogState (bResult, "Extension "+ cMessageExtensionInstall, MainFileChannel)
84 SetStatus (FilterType, cEXTInstall, bResult)
90 sCurrentMessage = cMessageExtensionUninstall
91 nCurrentAction = cEXTUninstall
93 'Remove the package
94 ext_mgr.removeExtension("org.openoffice.legacy." + cExtensionFileName, cExtensionFileName, "user",obj_null, cmdEnv)
96 'Try to create the service which is contained in the now removed extension.
97 oTestExtension = createUnoService(cUnoSmoketestTestExtension)
99 'The service must not be available anymore. Therefor isNull must return true.
100 LogState (IsNull (oTestExtension), "Extension "+ cMessageExtensionUninstall, FileChannel)
101 LogState (IsNull (oTestExtension), "Extension "+ cMessageExtensionUninstall, MainFileChannel)
102 SetStatus (FilterType, cEXTUninstall, IsNull (oTestExtension))
104 Print #FileChannel, "---"
106 Exit Sub ' Without error
109 If (nCurrentAction = cLogfileFailed) then
110 SetStatus (FilterType, cEXTService, False)
113 LogState (False, "Extension "+ sCurrentMessage, FileChannel)
114 LogState (False, "Extension "+ sCurrentMessage, MainFileChannel)
115 SetStatus (FilterType, nCurrentAction, False)
118 Exit Sub ' With error