xref: /aoo41x/main/smoketestdoc/data/Test_Ext.xml (revision 5111cb72)
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 = &quot;Extension Service&quot;
28cdf0e10cSrcweirconst cMessageExtensionInstall = &quot;Install Extension&quot;
29cdf0e10cSrcweirconst cMessageExtensionUninstall = &quot;Uninstall Extension&quot;
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 + &quot;$_TestExtension&quot;
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	&apos;Create an implementation of com.sun.star.ucb.XCommandEnvironment which is needed for
47cdf0e10cSrcweir	&apos;adding the extension. The implementation is in
48cdf0e10cSrcweir	&apos;javaunohelper/com/sun/star/comp/juhtest/SmoketestCommandEnvironment.java and the code is in juh.jar
49cdf0e10cSrcweir	cmdEnv = createUnoService(cUnoSmoketestCommandEnvironment)
50cdf0e10cSrcweir
51cdf0e10cSrcweir	&apos;Create the component context and then get the singleton ExtensionManager
52cdf0e10cSrcweir	&apos;A singleton cannot be created with createUnoService
53cdf0e10cSrcweir	ctx = getDefaultContext
54cdf0e10cSrcweir	ext_mgr = ctx.getValueByName(&quot;/singletons/&quot; + cExtensionManager)
55cdf0e10cSrcweir
56cdf0e10cSrcweir	LogTestResult( &quot;Extension &quot;+ 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	&apos;Add the extension. We must provide a file URL here.
67cdf0e10cSrcweir	&apos;By passing &quot;user&quot; we determine that the actions we perform on
68cdf0e10cSrcweir	&apos;XExtensionManager only affect the user installation. To modify the share installation one would pass &quot;share&quot;.
69cdf0e10cSrcweir
70cdf0e10cSrcweir	Dim props() as Object
71cdf0e10cSrcweir	ext_mgr.addExtension(sExtensionURL + cExtensionFileName, props, &quot;user&quot;, obj_null, cmdEnv)
72cdf0e10cSrcweir
73cdf0e10cSrcweir	&apos;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( &quot;Extension &quot;+ 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	&apos;Remove the package
87cdf0e10cSrcweir	ext_mgr.removeExtension(&quot;org.openoffice.legacy.&quot; + cExtensionFileName, cExtensionFileName, &quot;user&quot;,obj_null, cmdEnv)
88cdf0e10cSrcweir
89cdf0e10cSrcweir	&apos;Try to create the service which is contained in the now removed extension.
90cdf0e10cSrcweir	oTestExtension = createUnoService(cUnoSmoketestTestExtension)
91cdf0e10cSrcweir
92cdf0e10cSrcweir	&apos;The service must not be available anymore. Therefor isNull must return true.
93cdf0e10cSrcweir	LogTestResult( &quot;Extension &quot;+ cMessageExtensionUninstall, IsNull (oTestExtension) )
94cdf0e10cSrcweir
95cdf0e10cSrcweir	Print #LocalTestLog, &quot;---&quot;
96cdf0e10cSrcweir	Close #LocalTestLog%
97cdf0e10cSrcweir	LocalTestLog = 0
98cdf0e10cSrcweir	Exit Sub &apos; Without error
99cdf0e10cSrcweir
100cdf0e10cSrcweir	EXTERROR:
101cdf0e10cSrcweir	If ( gCurrentTestCase = cLogfileFailed ) then
102cdf0e10cSrcweir		LogTestResult( &quot; &quot;, False )
103cdf0e10cSrcweir		Exit Sub
104cdf0e10cSrcweir	else
105cdf0e10cSrcweir		LogTestResult( &quot;Extension &quot;+ sCurrentMessage, False )
106cdf0e10cSrcweir		Close #LocalTestLog%
107cdf0e10cSrcweir		LocalTestLog = 0
108cdf0e10cSrcweir	End If
109cdf0e10cSrcweir	Exit Sub &apos; With error
110cdf0e10cSrcweir
111cdf0e10cSrcweirEnd Sub
112cdf0e10cSrcweir</script:module>
113