xref: /aoo41x/main/smoketestdoc/data/Test_Ext.xml (revision cdf0e10c)
1<?xml version="1.0" encoding="UTF-8"?>
2<!--**********************************************************************
3*
4* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5*
6* Copyright 2000, 2010 Oracle and/or its affiliates.
7*
8* OpenOffice.org - a multi-platform office productivity suite
9*
10* This file is part of OpenOffice.org.
11*
12* OpenOffice.org is free software: you can redistribute it and/or modify
13* it under the terms of the GNU Lesser General Public License version 3
14* only, as published by the Free Software Foundation.
15*
16* OpenOffice.org is distributed in the hope that it will be useful,
17* but WITHOUT ANY WARRANTY; without even the implied warranty of
18* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19* GNU Lesser General Public License version 3 for more details
20* (a copy is included in the LICENSE file that accompanied this code).
21*
22* You should have received a copy of the GNU Lesser General Public License
23* version 3 along with OpenOffice.org.  If not, see
24* <http://www.openoffice.org/license.html>
25* for a copy of the LGPLv3 License.
26*
27**********************************************************************-->
28<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
29<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Test_Ext" script:language="StarBasic">REM  *****  BASIC  *****
30
31const cMessageExtensionService = &quot;Extension Service&quot;
32const cMessageExtensionInstall = &quot;Install Extension&quot;
33const cMessageExtensionUninstall = &quot;Uninstall Extension&quot;
34
35Sub TestExtensions
36	Dim oTestExtension as Object, obj_null as Object
37	Dim sCurrentMessage as String
38	Dim bResult as Boolean
39	Dim sImplementationNameString as String
40	sImplementationNameString = cUnoSmoketestTestExtension + &quot;$_TestExtension&quot;
41
42	On Local Error GoTo EXTERROR
43
44	gCurrentTestCase = cLogfileFailed
45	LocalTestLog% = OpenLogDat (GetLogFileName(gCurrentDocTest))
46
47	sCurrentMessage = cMessageExtensionService
48	gCurrentTestCase = cEXTService
49
50	&apos;Create an implementation of com.sun.star.ucb.XCommandEnvironment which is needed for
51	&apos;adding the extension. The implementation is in
52	&apos;javaunohelper/com/sun/star/comp/juhtest/SmoketestCommandEnvironment.java and the code is in juh.jar
53	cmdEnv = createUnoService(cUnoSmoketestCommandEnvironment)
54
55	&apos;Create the component context and then get the singleton ExtensionManager
56	&apos;A singleton cannot be created with createUnoService
57	ctx = getDefaultContext
58	ext_mgr = ctx.getValueByName(&quot;/singletons/&quot; + cExtensionManager)
59
60	LogTestResult( &quot;Extension &quot;+ cMessageExtensionService, not IsNull (ext_mgr) )
61	if (IsNull(ext_mgr)) then
62		Close #LocalTestLog%
63		LocalTestLog = 0
64		Exit Sub
65	End If
66
67	sCurrentMessage = cMessageExtensionInstall
68	gCurrentTestCase = cEXTInstall
69
70	&apos;Add the extension. We must provide a file URL here.
71	&apos;By passing &quot;user&quot; we determine that the actions we perform on
72	&apos;XExtensionManager only affect the user installation. To modify the share installation one would pass &quot;share&quot;.
73
74	Dim props() as Object
75	ext_mgr.addExtension(sExtensionURL + cExtensionFileName, props, &quot;user&quot;, obj_null, cmdEnv)
76
77	&apos;Check if the extension has been added by creating a service which is contained in the extension.
78	oTestExtension = createUnoService(cUnoSmoketestTestExtension)
79	bResult = (oTestExtension.getImplementationName = sImplementationNameString)
80	LogTestResult( &quot;Extension &quot;+ cMessageExtensionInstall, bResult )
81	if (not bResult) then
82		Close #LocalTestLog%
83		LocalTestLog = 0
84		Exit Sub
85	End If
86
87	sCurrentMessage = cMessageExtensionUninstall
88	gCurrentTestCase = cEXTUninstall
89
90	&apos;Remove the package
91	ext_mgr.removeExtension(&quot;org.openoffice.legacy.&quot; + cExtensionFileName, cExtensionFileName, &quot;user&quot;,obj_null, cmdEnv)
92
93	&apos;Try to create the service which is contained in the now removed extension.
94	oTestExtension = createUnoService(cUnoSmoketestTestExtension)
95
96	&apos;The service must not be available anymore. Therefor isNull must return true.
97	LogTestResult( &quot;Extension &quot;+ cMessageExtensionUninstall, IsNull (oTestExtension) )
98
99	Print #LocalTestLog, &quot;---&quot;
100	Close #LocalTestLog%
101	LocalTestLog = 0
102	Exit Sub &apos; Without error
103
104	EXTERROR:
105	If ( gCurrentTestCase = cLogfileFailed ) then
106		LogTestResult( &quot; &quot;, False )
107		Exit Sub
108	else
109		LogTestResult( &quot;Extension &quot;+ sCurrentMessage, False )
110		Close #LocalTestLog%
111		LocalTestLog = 0
112	End If
113	Exit Sub &apos; With error
114
115End Sub
116</script:module>
117