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