summaryrefslogtreecommitdiff
path: root/framework/test/test_componentenumeration.bas
blob: c837bea2fb73fd3f662a5f8e7fcf6667146794da (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
rem *************************************************************
rem  
rem  Licensed to the Apache Software Foundation (ASF) under one
rem  or more contributor license agreements.  See the NOTICE file
rem  distributed with this work for additional information
rem  regarding copyright ownership.  The ASF licenses this file
rem  to you under the Apache License, Version 2.0 (the
rem  "License"); you may not use this file except in compliance
rem  with the License.  You may obtain a copy of the License at
rem  
rem    http://www.apache.org/licenses/LICENSE-2.0
rem  
rem  Unless required by applicable law or agreed to in writing,
rem  software distributed under the License is distributed on an
rem  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
rem  KIND, either express or implied.  See the License for the
rem  specific language governing permissions and limitations
rem  under the License.
rem  
rem *************************************************************
rem	_______________________________________________________________________________________________________________________________________
rem	Test script for helper class "framework/helper/OComponentAccess and OComponentEnumeration.
rem	These two classes are used for "framework/baeh_services/Desktop::getComponents()" only.
rem	_______________________________________________________________________________________________________________________________________


Sub Main

	rem	___________________________________________________________________________________________________________________________________
	rem	Get all current components of the frame tree as an enumeration access object.
	rem	The return value must be a valid reference!
	xComponentAccess = StarDesktop.Components
	if( isNull(xComponentAccess) = TRUE ) then
		msgbox "Error: Desktop return null reference as enumeration access to all tree components!"
		exit Sub
	endif

	rem	___________________________________________________________________________________________________________________________________
	rem	Control service specification of helper class "framework/helper/OComponentAccess".
	rem	The follow output must occure:	com.sun.star.lang.XTypeProvider
	rem									com.sun.star.container.XEnumerationAccess -> com.sun.star.container.XElementAccess
	msgbox xComponentAccess.dbg_supportedInterfaces

	rem	___________________________________________________________________________________________________________________________________
	rem	Test interface XElementAccess of helper OComponentAcces.

	rem	Method hasElements() must return TRUE, because if you call this from the basic IDE at least one task must exist ...
	rem	the IDE by himself. Normaly two tasks exist - an empty writer document and a basic frame.
	rem Attention: Not all tasks or frames must support a full implemented component!
	if( xComponentAccess.hasElements <> TRUE ) then
		msgbox "Error: xComponentAccess has no elements - but I can't believe it!"
		exit Sub
	endif		

	rem	Method getElementType() must return the cppu type of XComponent.
	rem	Otherwise something is wrong or implementation has changed.
	if( xComponentAccess.getElementType.Name <> "com.sun.star.lang.XComponent" ) then
		msgbox "Error: xComponentAccess return wrong type as element type! - Has implementation changed?"
		exit Sub
	endif
	
	rem	___________________________________________________________________________________________________________________________________
	rem	Test interface XEnumerationAccess of helper OComponentAcces.
	rem	The return value must be a valid reference!
	xComponentEnumeration = xComponentAccess.createEnumeration
	if( isNull(xComponentEnumeration) = TRUE ) then
		msgbox "Error: Could not create a component enumeration!"
		exit Sub
	endif
	
	rem ___________________________________________________________________________________________________________________________________
	rem	Control service specification of helper class "framework/helper/OComponentEnumeration".
	rem	The follow output must occure:	com.sun.star.lang.XTypeProvider
	rem									com.sun.star.lang.XEventListener
	rem									com.sun.star.container.XEnumeration
	msgbox xComponentEnumeration.dbg_supportedInterfaces
	
	rem ___________________________________________________________________________________________________________________________________
	rem	Test interface XEnumeration of helper OComponentEnumeration.
	nElementCounter = 0
	while( xComponentEnumeration.hasMoreElements = TRUE )
		xElement = xComponentEnumeration.nextElement
		if( isNull(xElement) = TRUE ) then
			msgbox "Error: An empty component in enumeration detected! Whats wrong?"
			exit Sub
		endif
		nElementCounter = nElementCounter + 1
	wend
	if( nElementCounter < 1 ) then
		msgbox "Warning: The enumeration was empty. I think it's wrong ... please check it again."
	endif
	msgbox "Info: An enumeration with " + nElementCounter + " element(s) was detected."
	
	rem ___________________________________________________________________________________________________________________________________
	rem If this point arrived our test was successful.
	msgbox "Test of framework/helper/OComponentAccess & OComponentEnumeration was successful!"
	
End Sub