summaryrefslogtreecommitdiff
path: root/smoketest/data/Basic/Standard/Test_Ext.xml
blob: 364a6a68402a942fd3fe78604f9309042d599470 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?xml version="1.0" encoding="UTF-8"?>
<!--
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 -->
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Test_Ext" script:language="StarBasic">REM  *****  BASIC  *****

const cMessageExtensionService = &quot;Extension Service&quot;
const cMessageExtensionInstall = &quot;Install Extension&quot;
const cMessageExtensionUninstall = &quot;Uninstall Extension&quot;

Sub TestExtensions
    Dim oTestExtension as Object, obj_null as Object
    Dim sCurrentMessage as String
    Dim bResult as Boolean
    Dim sImplementationNameString as String
    sImplementationNameString = cUnoSmoketestTestExtension + &quot;$_TestExtension&quot;

    On Local Error GoTo EXTERROR

    gCurrentTestCase = cLogfileFailed
    LocalTestLog% = OpenLogDat (GetLogFileName(gCurrentDocTest))

    sCurrentMessage = &quot;SmokeTestCommandEnvironment (implemented in Java)&quot;
    gCurrentTestCase = cEXTService

    &apos;Create an implementation of com.sun.star.ucb.XCommandEnvironment which is needed for
    &apos;adding the extension. The implementation is in
    &apos;smoketest/org/libreoffice/smoketest/SmoketestCommandEnvironment.java and the code is in smoketest.jar
    cmdEnv = createUnoService(cUnoSmoketestCommandEnvironment)

    &apos;Create the component context and then get the singleton ExtensionManager
    &apos;A singleton cannot be created with createUnoService
    sCurrentMessage = cMessageExtensionService
    ctx = getDefaultContext
    ext_mgr = ctx.getValueByName(&quot;/singletons/&quot; + cExtensionManager)

    LogTestResult( &quot;Extension &quot;+ cMessageExtensionService, not IsNull (ext_mgr) )
    if (IsNull(ext_mgr)) then
        Close #LocalTestLog%
        LocalTestLog = 0
        Exit Sub
    End If

    sCurrentMessage = cMessageExtensionInstall
    gCurrentTestCase = cEXTInstall

    &apos;Add the extension. We must provide a file URL here.
    &apos;By passing &quot;user&quot; we determine that the actions we perform on
    &apos;XExtensionManager only affect the user installation. To modify the share installation one would pass &quot;share&quot;.

    Dim props() as Object
    ext_mgr.addExtension(sExtensionURL + cExtensionFileName, props, &quot;user&quot;, obj_null, cmdEnv)

    &apos;Check if the extension has been added by creating a service which is contained in the extension.
    oTestExtension = createUnoService(cUnoSmoketestTestExtension)
    bResult = (oTestExtension.getImplementationName = sImplementationNameString)
    LogTestResult( &quot;Extension &quot;+ cMessageExtensionInstall, bResult )
    if (not bResult) then
        Close #LocalTestLog%
        LocalTestLog = 0
        Exit Sub
    End If

    sCurrentMessage = cMessageExtensionUninstall
    gCurrentTestCase = cEXTUninstall

    &apos;Remove the package
    ext_mgr.removeExtension(&quot;org.libreoffice.smoketest.TestExtension&quot;, cExtensionFileName, &quot;user&quot;,obj_null, cmdEnv)

    &apos;Try to create the service which is contained in the now removed extension.
    oTestExtension = createUnoService(cUnoSmoketestTestExtension)

    &apos;The service must not be available anymore. Therefor isNull must return true.
    LogTestResult( &quot;Extension &quot;+ cMessageExtensionUninstall, IsNull (oTestExtension) )

    Print #LocalTestLog, &quot;---&quot;
    Close #LocalTestLog%
    LocalTestLog = 0
    Exit Sub &apos; Without error

    EXTERROR:
    If ( gCurrentTestCase = cLogfileFailed ) then
        LogTestResult( &quot; &quot;, False )
        Exit Sub
    else
        LogTestResult( &quot;Extension &quot;+ sCurrentMessage, False )
        Close #LocalTestLog%
        LocalTestLog = 0
    End If
    Exit Sub &apos; With error

End Sub
</script:module>