1cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?> 2*5111cb72SAndrew Rist<!--*********************************************************** 3*5111cb72SAndrew Rist * 4*5111cb72SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 5*5111cb72SAndrew Rist * or more contributor license agreements. See the NOTICE file 6*5111cb72SAndrew Rist * distributed with this work for additional information 7*5111cb72SAndrew Rist * regarding copyright ownership. The ASF licenses this file 8*5111cb72SAndrew Rist * to you under the Apache License, Version 2.0 (the 9*5111cb72SAndrew Rist * "License"); you may not use this file except in compliance 10*5111cb72SAndrew Rist * with the License. You may obtain a copy of the License at 11*5111cb72SAndrew Rist * 12*5111cb72SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 13*5111cb72SAndrew Rist * 14*5111cb72SAndrew Rist * Unless required by applicable law or agreed to in writing, 15*5111cb72SAndrew Rist * software distributed under the License is distributed on an 16*5111cb72SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17*5111cb72SAndrew Rist * KIND, either express or implied. See the License for the 18*5111cb72SAndrew Rist * specific language governing permissions and limitations 19*5111cb72SAndrew Rist * under the License. 20*5111cb72SAndrew Rist * 21*5111cb72SAndrew Rist ***********************************************************--> 22*5111cb72SAndrew Rist 23*5111cb72SAndrew Rist 24cdf0e10cSrcweir<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 25cdf0e10cSrcweir<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Test_Ext" script:language="StarBasic">REM ***** BASIC ***** 26cdf0e10cSrcweir 27cdf0e10cSrcweirconst cMessageExtensionService = "Extension Service" 28cdf0e10cSrcweirconst cMessageExtensionInstall = "Install Extension" 29cdf0e10cSrcweirconst cMessageExtensionUninstall = "Uninstall Extension" 30cdf0e10cSrcweir 31cdf0e10cSrcweirSub TestExtensions 32cdf0e10cSrcweir Dim oTestExtension as Object, obj_null as Object 33cdf0e10cSrcweir Dim sCurrentMessage as String 34cdf0e10cSrcweir Dim bResult as Boolean 35cdf0e10cSrcweir Dim sImplementationNameString as String 36cdf0e10cSrcweir sImplementationNameString = cUnoSmoketestTestExtension + "$_TestExtension" 37cdf0e10cSrcweir 38cdf0e10cSrcweir On Local Error GoTo EXTERROR 39cdf0e10cSrcweir 40cdf0e10cSrcweir gCurrentTestCase = cLogfileFailed 41cdf0e10cSrcweir LocalTestLog% = OpenLogDat (GetLogFileName(gCurrentDocTest)) 42cdf0e10cSrcweir 43cdf0e10cSrcweir sCurrentMessage = cMessageExtensionService 44cdf0e10cSrcweir gCurrentTestCase = cEXTService 45cdf0e10cSrcweir 46cdf0e10cSrcweir 'Create an implementation of com.sun.star.ucb.XCommandEnvironment which is needed for 47cdf0e10cSrcweir 'adding the extension. The implementation is in 48cdf0e10cSrcweir 'javaunohelper/com/sun/star/comp/juhtest/SmoketestCommandEnvironment.java and the code is in juh.jar 49cdf0e10cSrcweir cmdEnv = createUnoService(cUnoSmoketestCommandEnvironment) 50cdf0e10cSrcweir 51cdf0e10cSrcweir 'Create the component context and then get the singleton ExtensionManager 52cdf0e10cSrcweir 'A singleton cannot be created with createUnoService 53cdf0e10cSrcweir ctx = getDefaultContext 54cdf0e10cSrcweir ext_mgr = ctx.getValueByName("/singletons/" + cExtensionManager) 55cdf0e10cSrcweir 56cdf0e10cSrcweir LogTestResult( "Extension "+ cMessageExtensionService, not IsNull (ext_mgr) ) 57cdf0e10cSrcweir if (IsNull(ext_mgr)) then 58cdf0e10cSrcweir Close #LocalTestLog% 59cdf0e10cSrcweir LocalTestLog = 0 60cdf0e10cSrcweir Exit Sub 61cdf0e10cSrcweir End If 62cdf0e10cSrcweir 63cdf0e10cSrcweir sCurrentMessage = cMessageExtensionInstall 64cdf0e10cSrcweir gCurrentTestCase = cEXTInstall 65cdf0e10cSrcweir 66cdf0e10cSrcweir 'Add the extension. We must provide a file URL here. 67cdf0e10cSrcweir 'By passing "user" we determine that the actions we perform on 68cdf0e10cSrcweir 'XExtensionManager only affect the user installation. To modify the share installation one would pass "share". 69cdf0e10cSrcweir 70cdf0e10cSrcweir Dim props() as Object 71cdf0e10cSrcweir ext_mgr.addExtension(sExtensionURL + cExtensionFileName, props, "user", obj_null, cmdEnv) 72cdf0e10cSrcweir 73cdf0e10cSrcweir 'Check if the extension has been added by creating a service which is contained in the extension. 74cdf0e10cSrcweir oTestExtension = createUnoService(cUnoSmoketestTestExtension) 75cdf0e10cSrcweir bResult = (oTestExtension.getImplementationName = sImplementationNameString) 76cdf0e10cSrcweir LogTestResult( "Extension "+ cMessageExtensionInstall, bResult ) 77cdf0e10cSrcweir if (not bResult) then 78cdf0e10cSrcweir Close #LocalTestLog% 79cdf0e10cSrcweir LocalTestLog = 0 80cdf0e10cSrcweir Exit Sub 81cdf0e10cSrcweir End If 82cdf0e10cSrcweir 83cdf0e10cSrcweir sCurrentMessage = cMessageExtensionUninstall 84cdf0e10cSrcweir gCurrentTestCase = cEXTUninstall 85cdf0e10cSrcweir 86cdf0e10cSrcweir 'Remove the package 87cdf0e10cSrcweir ext_mgr.removeExtension("org.openoffice.legacy." + cExtensionFileName, cExtensionFileName, "user",obj_null, cmdEnv) 88cdf0e10cSrcweir 89cdf0e10cSrcweir 'Try to create the service which is contained in the now removed extension. 90cdf0e10cSrcweir oTestExtension = createUnoService(cUnoSmoketestTestExtension) 91cdf0e10cSrcweir 92cdf0e10cSrcweir 'The service must not be available anymore. Therefor isNull must return true. 93cdf0e10cSrcweir LogTestResult( "Extension "+ cMessageExtensionUninstall, IsNull (oTestExtension) ) 94cdf0e10cSrcweir 95cdf0e10cSrcweir Print #LocalTestLog, "---" 96cdf0e10cSrcweir Close #LocalTestLog% 97cdf0e10cSrcweir LocalTestLog = 0 98cdf0e10cSrcweir Exit Sub ' Without error 99cdf0e10cSrcweir 100cdf0e10cSrcweir EXTERROR: 101cdf0e10cSrcweir If ( gCurrentTestCase = cLogfileFailed ) then 102cdf0e10cSrcweir LogTestResult( " ", False ) 103cdf0e10cSrcweir Exit Sub 104cdf0e10cSrcweir else 105cdf0e10cSrcweir LogTestResult( "Extension "+ sCurrentMessage, False ) 106cdf0e10cSrcweir Close #LocalTestLog% 107cdf0e10cSrcweir LocalTestLog = 0 108cdf0e10cSrcweir End If 109cdf0e10cSrcweir Exit Sub ' With error 110cdf0e10cSrcweir 111cdf0e10cSrcweirEnd Sub 112cdf0e10cSrcweir</script:module> 113