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