1 <?xml version="1.0" encoding="UTF-8"?>
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
20 <script:module xmlns:script="http://openoffice.org/2000/script" script:name="Test_Ext" script:language="StarBasic">REM ***** BASIC *****
22 const cMessageExtensionService = "Extension Service"
23 const cMessageExtensionInstall = "Install Extension"
24 const cMessageExtensionUninstall = "Uninstall Extension"
27 Dim oTestExtension as Object, obj_null as Object
28 Dim sCurrentMessage as String
29 Dim bResult as Boolean
30 Dim sImplementationNameString as String
31 sImplementationNameString = cUnoSmoketestTestExtension + "$_TestExtension"
33 On Local Error GoTo EXTERROR
35 gCurrentTestCase = cLogfileFailed
36 LocalTestLog% = OpenLogDat (GetLogFileName(gCurrentDocTest))
38 sCurrentMessage = "SmokeTestCommandEnvironment (implemented in Java)"
39 gCurrentTestCase = cEXTService
41 'Create an implementation of com.sun.star.ucb.XCommandEnvironment which is needed for
42 'adding the extension. The implementation is in
43 'smoketest/org/libreoffice/smoketest/SmoketestCommandEnvironment.java and the code is in smoketest.jar
44 cmdEnv = createUnoService(cUnoSmoketestCommandEnvironment)
46 'Create the component context and then get the singleton ExtensionManager
47 'A singleton cannot be created with createUnoService
48 sCurrentMessage = cMessageExtensionService
49 ctx = getDefaultContext
50 ext_mgr = ctx.getValueByName("/singletons/" + cExtensionManager)
52 LogTestResult( "Extension "+ cMessageExtensionService, not IsNull (ext_mgr) )
53 if (IsNull(ext_mgr)) then
59 sCurrentMessage = cMessageExtensionInstall
60 gCurrentTestCase = cEXTInstall
62 'Add the extension. We must provide a file URL here.
63 'By passing "user" we determine that the actions we perform on
64 'XExtensionManager only affect the user installation. To modify the share installation one would pass "share".
67 ext_mgr.addExtension(sExtensionURL, props, "user", obj_null, cmdEnv)
69 'Check if the extension has been added by creating a service which is contained in the extension.
70 oTestExtension = createUnoService(cUnoSmoketestTestExtension)
71 bResult = (oTestExtension.getImplementationName = sImplementationNameString)
72 LogTestResult( "Extension "+ cMessageExtensionInstall, bResult )
79 sCurrentMessage = cMessageExtensionUninstall
80 gCurrentTestCase = cEXTUninstall
82 'Remove the package
83 ext_mgr.removeExtension("org.libreoffice.smoketest.TestExtension", cExtensionFileName, "user",obj_null, cmdEnv)
85 'Try to create the service which is contained in the now removed extension.
86 oTestExtension = createUnoService(cUnoSmoketestTestExtension)
88 'The service must not be available anymore. Therefore isNull must return true.
89 LogTestResult( "Extension "+ cMessageExtensionUninstall, IsNull (oTestExtension) )
91 Print #LocalTestLog, "---"
94 Exit Sub ' Without error
97 If ( gCurrentTestCase = cLogfileFailed ) then
98 LogTestResult( " ", False )
101 LogTestResult( "Extension "+ sCurrentMessage, False )
105 Exit Sub ' With error