1<?xml version="1.0" encoding="UTF-8"?> 2<!--********************************************************************** 3* 4* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5* 6* Copyright 2000, 2010 Oracle and/or its affiliates. 7* 8* OpenOffice.org - a multi-platform office productivity suite 9* 10* This file is part of OpenOffice.org. 11* 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. 15* 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). 21* 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. 26* 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 ***** 30 31const cMessageExtensionService = "Extension Service" 32const cMessageExtensionInstall = "Install Extension" 33const cMessageExtensionUninstall = "Uninstall Extension" 34 35Sub TestExtensions 36 Dim oTestExtension as Object, obj_null as Object 37 Dim sCurrentMessage as String 38 Dim bResult as Boolean 39 Dim sImplementationNameString as String 40 sImplementationNameString = cUnoSmoketestTestExtension + "$_TestExtension" 41 42 On Local Error GoTo EXTERROR 43 44 gCurrentTestCase = cLogfileFailed 45 LocalTestLog% = OpenLogDat (GetLogFileName(gCurrentDocTest)) 46 47 sCurrentMessage = cMessageExtensionService 48 gCurrentTestCase = cEXTService 49 50 'Create an implementation of com.sun.star.ucb.XCommandEnvironment which is needed for 51 'adding the extension. The implementation is in 52 'javaunohelper/com/sun/star/comp/juhtest/SmoketestCommandEnvironment.java and the code is in juh.jar 53 cmdEnv = createUnoService(cUnoSmoketestCommandEnvironment) 54 55 'Create the component context and then get the singleton ExtensionManager 56 'A singleton cannot be created with createUnoService 57 ctx = getDefaultContext 58 ext_mgr = ctx.getValueByName("/singletons/" + cExtensionManager) 59 60 LogTestResult( "Extension "+ cMessageExtensionService, not IsNull (ext_mgr) ) 61 if (IsNull(ext_mgr)) then 62 Close #LocalTestLog% 63 LocalTestLog = 0 64 Exit Sub 65 End If 66 67 sCurrentMessage = cMessageExtensionInstall 68 gCurrentTestCase = cEXTInstall 69 70 'Add the extension. We must provide a file URL here. 71 'By passing "user" we determine that the actions we perform on 72 'XExtensionManager only affect the user installation. To modify the share installation one would pass "share". 73 74 Dim props() as Object 75 ext_mgr.addExtension(sExtensionURL + cExtensionFileName, props, "user", obj_null, cmdEnv) 76 77 'Check if the extension has been added by creating a service which is contained in the extension. 78 oTestExtension = createUnoService(cUnoSmoketestTestExtension) 79 bResult = (oTestExtension.getImplementationName = sImplementationNameString) 80 LogTestResult( "Extension "+ cMessageExtensionInstall, bResult ) 81 if (not bResult) then 82 Close #LocalTestLog% 83 LocalTestLog = 0 84 Exit Sub 85 End If 86 87 sCurrentMessage = cMessageExtensionUninstall 88 gCurrentTestCase = cEXTUninstall 89 90 'Remove the package 91 ext_mgr.removeExtension("org.openoffice.legacy." + cExtensionFileName, cExtensionFileName, "user",obj_null, cmdEnv) 92 93 'Try to create the service which is contained in the now removed extension. 94 oTestExtension = createUnoService(cUnoSmoketestTestExtension) 95 96 'The service must not be available anymore. Therefor isNull must return true. 97 LogTestResult( "Extension "+ cMessageExtensionUninstall, IsNull (oTestExtension) ) 98 99 Print #LocalTestLog, "---" 100 Close #LocalTestLog% 101 LocalTestLog = 0 102 Exit Sub ' Without error 103 104 EXTERROR: 105 If ( gCurrentTestCase = cLogfileFailed ) then 106 LogTestResult( " ", False ) 107 Exit Sub 108 else 109 LogTestResult( "Extension "+ sCurrentMessage, False ) 110 Close #LocalTestLog% 111 LocalTestLog = 0 112 End If 113 Exit Sub ' With error 114 115End Sub 116</script:module> 117