1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_cppuhelper.hxx"
26
27 #include <cppuhelper/stdidlclass.hxx>
28
29 #include <com/sun/star/reflection/XIdlClassProvider.hpp>
30 #include <com/sun/star/lang/XServiceInfo.hpp>
31
32 #include "testhelper.hxx"
33
34 using namespace ::com::sun::star::uno;
35 using namespace ::com::sun::star::lang;
36 using namespace ::com::sun::star::reflection;
37 using namespace ::rtl;
38
39
40
41
testidlclass(const Reference<XMultiServiceFactory> & rSMgr)42 void testidlclass( const Reference < XMultiServiceFactory > &rSMgr)
43 {
44 const OUString sImplName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.cpputest") ) );
45
46 // this reference is static to test behaviour during exiting application
47 Reference < XIdlClass > r =
48 ::cppu::createStandardClass(
49 rSMgr ,
50 sImplName,
51 Reference < XIdlClass > () ,
52 (XMultiServiceFactory * ) 0 ,
53 (XServiceInfo * ) 0
54 );
55
56 OSL_ASSERT( r.is() );
57
58
59 { // test the xidlclassprovider interface !
60 Reference< XIdlClassProvider > rProv( r , UNO_QUERY );
61 OSL_ASSERT( rProv.is() );
62
63 {
64 Sequence < Reference < XIdlClass > > seq = rProv->getIdlClasses();
65
66 // is always one
67 OSL_ASSERT( seq.getLength() == 1 );
68
69 // test the weak reference
70 rProv->getIdlClasses();
71
72 }
73
74 rProv->getIdlClasses();
75
76
77 }
78
79
80 OSL_ASSERT( r->getName() == sImplName );
81
82 // test equals
83 Reference < XIdlClass > r2 =
84 ::cppu::createStandardClass(
85 rSMgr ,
86 sImplName,
87 Reference < XIdlClass > () ,
88 (XMultiServiceFactory * ) 0 ,
89 (XServiceInfo * ) 0
90 );
91 // test for implementation name
92 OSL_ASSERT( r2->equals( r ) );
93
94 Sequence < Reference < XIdlClass > > seqIdlClass = r->getInterfaces();
95
96 //TODO !
97 // one idl class for one interface
98 // this test fails, if core reflection fails !
99 // OSL_ASSERT( 1 == seqIdlClass.getLength() );
100 // Reference < XIdlClass > rIdlInterface = seqIdlClass.getArray()[0];
101
102 // check for IdlClass interface returned by Core Reflection
103 // OSL_ASSERT( rIdlInterface.is() );
104
105
106
107 // Test all ten templates
108 Reference< XIdlClass > x = ::cppu::createStandardClass(
109 rSMgr ,
110 sImplName,
111 Reference < XIdlClass > () ,
112 (XMultiServiceFactory * ) 0 ,
113 (XServiceInfo * ) 0 ,
114 (XServiceInfo * ) 0
115 );
116
117 // Test all ten templates
118 x = ::cppu::createStandardClass(
119 rSMgr ,
120 sImplName,
121 Reference < XIdlClass > () ,
122 (XMultiServiceFactory * ) 0 ,
123 (XServiceInfo * ) 0 ,
124 (XServiceInfo * ) 0 ,
125 (XServiceInfo * ) 0
126 );
127
128
129 // Test all ten templates
130 x = ::cppu::createStandardClass(
131 rSMgr ,
132 sImplName,
133 Reference < XIdlClass > () ,
134 (XMultiServiceFactory * ) 0 ,
135 (XServiceInfo * ) 0 ,
136 (XServiceInfo * ) 0 ,
137 (XServiceInfo * ) 0 ,
138 (XServiceInfo * ) 0
139 );
140
141
142
143 // Test all ten templates
144 x = ::cppu::createStandardClass(
145 rSMgr ,
146 sImplName,
147 Reference < XIdlClass > () ,
148 (XMultiServiceFactory * ) 0 ,
149 (XServiceInfo * ) 0 ,
150 (XServiceInfo * ) 0 ,
151 (XServiceInfo * ) 0 ,
152 (XServiceInfo * ) 0 ,
153 (XServiceInfo * ) 0
154 );
155
156
157
158 // Test all ten templates
159 x = ::cppu::createStandardClass(
160 rSMgr ,
161 sImplName,
162 Reference < XIdlClass > () ,
163 (XMultiServiceFactory * ) 0 ,
164 (XServiceInfo * ) 0 ,
165 (XServiceInfo * ) 0 ,
166 (XServiceInfo * ) 0 ,
167 (XServiceInfo * ) 0 ,
168 (XServiceInfo * ) 0 ,
169 (XServiceInfo * ) 0
170 );
171
172
173 // Test all ten templates
174 x = ::cppu::createStandardClass(
175 rSMgr ,
176 sImplName,
177 Reference < XIdlClass > () ,
178 (XMultiServiceFactory * ) 0 ,
179 (XServiceInfo * ) 0 ,
180 (XServiceInfo * ) 0 ,
181 (XServiceInfo * ) 0 ,
182 (XServiceInfo * ) 0 ,
183 (XServiceInfo * ) 0 ,
184 (XServiceInfo * ) 0 ,
185 (XServiceInfo * ) 0
186 );
187
188
189
190
191 // Test all ten templates
192 x = ::cppu::createStandardClass(
193 rSMgr ,
194 sImplName,
195 Reference < XIdlClass > () ,
196 (XMultiServiceFactory * ) 0 ,
197 (XServiceInfo * ) 0 ,
198 (XServiceInfo * ) 0 ,
199 (XServiceInfo * ) 0 ,
200 (XServiceInfo * ) 0 ,
201 (XServiceInfo * ) 0 ,
202 (XServiceInfo * ) 0 ,
203 (XServiceInfo * ) 0 ,
204 (XServiceInfo * ) 0
205 );
206
207 // Test all ten templates
208 x = ::cppu::createStandardClass(
209 rSMgr ,
210 sImplName,
211 Reference < XIdlClass > () ,
212 (XMultiServiceFactory * ) 0 ,
213 (XServiceInfo * ) 0 ,
214 (XServiceInfo * ) 0 ,
215 (XServiceInfo * ) 0 ,
216 (XServiceInfo * ) 0 ,
217 (XServiceInfo * ) 0 ,
218 (XServiceInfo * ) 0 ,
219 (XServiceInfo * ) 0 ,
220 (XServiceInfo * ) 0 ,
221 (XServiceInfo * ) 0
222 );
223 }
224