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