summaryrefslogtreecommitdiff
path: root/smoketestoo_native/data/scripts/Test_Ext.xba
blob: 00fc93ff86ebedd16e681a43ed78026acf4eef3d (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
<?xml version="1.0" encoding="UTF-8"?>
<!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 (FilterType as Integer)
Dim oTestExtension as Object, obj_null as Object
Dim sCurrentMessage as String
Dim nCurrentAction as Integer
Dim bResult as Boolean
Dim sImplementationNameString as String
sImplementationNameString = cUnoSmoketestTestExtension + &quot;$_TestExtension&quot;

	On Local Error GoTo EXTERROR
	
	nCurrentAction = cLogfileFailed
	FileChannel% = OpenLogDat (GetLogFileName(FilterType))
	
	sCurrentMessage = cMessageExtensionService
	nCurrentAction = cEXTService

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

	&apos;Create the component context and then get the singleton thePackageManagerFactory
	&apos;A singleton cannot be created with createUnoService
	ctx = getDefaultContext
	factory = ctx.getValueByName(&quot;/singletons/&quot; + cUnothePackageManagerFactory)

	&apos;Get the XPackageManager interface. By passing &quot;user&quot; we determine that the actions we perform on
	&apos;XPackageManager only affect the user installation. To modify the share installation one would pass &quot;share&quot;.
	ext_mgr = factory.getPackageManager(&quot;user&quot;)
	
	LogState (not IsNull (ext_mgr), &quot;Extension &quot;+ cMessageExtensionService, FileChannel)
	LogState (not IsNull (ext_mgr), &quot;Extension &quot;+ cMessageExtensionService, MainFileChannel)
	SetStatus (FilterType, cEXTService, not IsNull (ext_mgr))
	if (IsNull(ext_mgr)) then
  		Close #FileChannel%
		Exit Sub
	End If

	sCurrentMessage = cMessageExtensionInstall
	nCurrentAction = cEXTInstall
	
	&apos;Add the extension. We must provide a file URL here.
	ext_mgr.addPackage(sExtensionURL + cExtensionFileName, &quot;&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)
	LogState (bResult, &quot;Extension &quot;+ cMessageExtensionInstall, FileChannel)
	LogState (bResult, &quot;Extension &quot;+ cMessageExtensionInstall, MainFileChannel)
	SetStatus (FilterType, cEXTInstall, bResult)
	if (not bResult) then
   		Close #FileChannel%
		Exit Sub
	End If

	sCurrentMessage = cMessageExtensionUninstall
	nCurrentAction = cEXTUninstall
	
	&apos;Remove the package
	ext_mgr.removePackage(&quot;org.openoffice.legacy.&quot; + cExtensionFileName, cExtensionFileName, 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.
	LogState (IsNull (oTestExtension), &quot;Extension &quot;+ cMessageExtensionUninstall, FileChannel)
	LogState (IsNull (oTestExtension), &quot;Extension &quot;+ cMessageExtensionUninstall, MainFileChannel)
	SetStatus (FilterType, cEXTUninstall, IsNull (oTestExtension))
	
	Print #FileChannel, &quot;---&quot;
	Close #FileChannel%
	Exit Sub &apos; Without error

	EXTERROR:
	If 	(nCurrentAction = cLogfileFailed) then
		SetStatus (FilterType, cEXTService, False)
		Exit Sub
	else
		LogState (False, &quot;Extension &quot;+ sCurrentMessage, FileChannel)
		LogState (False, &quot;Extension &quot;+ sCurrentMessage, MainFileChannel)
		SetStatus (FilterType, nCurrentAction, False)
		Close #FileChannel%
	End If	
	Exit Sub &apos; With error

End Sub
</script:module>