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