xref: /trunk/main/cppuhelper/test/testidlclass.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_cppuhelper.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <cppuhelper/stdidlclass.hxx>
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <com/sun/star/reflection/XIdlClassProvider.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #include "testhelper.hxx"
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
39*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
40*cdf0e10cSrcweir using namespace ::com::sun::star::reflection;
41*cdf0e10cSrcweir using namespace ::rtl;
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir void testidlclass( const Reference < XMultiServiceFactory > &rSMgr)
47*cdf0e10cSrcweir {
48*cdf0e10cSrcweir 	const OUString sImplName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.cpputest") ) );
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir 	// this reference is static to test behaviour during exiting application
51*cdf0e10cSrcweir 	Reference < XIdlClass > r =
52*cdf0e10cSrcweir 				::cppu::createStandardClass(
53*cdf0e10cSrcweir 								rSMgr ,
54*cdf0e10cSrcweir 								sImplName,
55*cdf0e10cSrcweir 								Reference < XIdlClass > () ,
56*cdf0e10cSrcweir 								(XMultiServiceFactory * ) 0 ,
57*cdf0e10cSrcweir 								(XServiceInfo * ) 0
58*cdf0e10cSrcweir 											);
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir 	OSL_ASSERT( r.is() );
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir 	{  // test the xidlclassprovider interface !
64*cdf0e10cSrcweir 		Reference< XIdlClassProvider > rProv( r , UNO_QUERY );
65*cdf0e10cSrcweir 		OSL_ASSERT( rProv.is() );
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir 		{
68*cdf0e10cSrcweir 			Sequence < Reference < XIdlClass > > seq = rProv->getIdlClasses();
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir 			// is always one
71*cdf0e10cSrcweir 			OSL_ASSERT( seq.getLength() == 1 );
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir 			// test the weak reference
74*cdf0e10cSrcweir 			rProv->getIdlClasses();
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 		}
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir 		rProv->getIdlClasses();
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir 	}
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir 	OSL_ASSERT( r->getName() == sImplName );
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir 	// test equals
87*cdf0e10cSrcweir 	Reference < XIdlClass > r2 =
88*cdf0e10cSrcweir 				::cppu::createStandardClass(
89*cdf0e10cSrcweir 								rSMgr ,
90*cdf0e10cSrcweir 								sImplName,
91*cdf0e10cSrcweir 								Reference < XIdlClass > () ,
92*cdf0e10cSrcweir 								(XMultiServiceFactory * ) 0 ,
93*cdf0e10cSrcweir 								(XServiceInfo * ) 0
94*cdf0e10cSrcweir 											);
95*cdf0e10cSrcweir 	// test for implementation name
96*cdf0e10cSrcweir 	OSL_ASSERT( r2->equals( r ) );
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir 	Sequence < Reference < XIdlClass > > seqIdlClass = r->getInterfaces();
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 	//TODO !
101*cdf0e10cSrcweir 	// one idl class for one interface
102*cdf0e10cSrcweir 	// this test fails, if core reflection fails !
103*cdf0e10cSrcweir //	OSL_ASSERT( 1 == seqIdlClass.getLength() );
104*cdf0e10cSrcweir //	Reference < XIdlClass > rIdlInterface = seqIdlClass.getArray()[0];
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 	// check for IdlClass interface returned by Core Reflection
107*cdf0e10cSrcweir //	OSL_ASSERT( rIdlInterface.is() );
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 	// Test all ten templates
112*cdf0e10cSrcweir 	Reference< XIdlClass > x = ::cppu::createStandardClass(
113*cdf0e10cSrcweir 								rSMgr ,
114*cdf0e10cSrcweir 								sImplName,
115*cdf0e10cSrcweir 								Reference < XIdlClass > () ,
116*cdf0e10cSrcweir 								(XMultiServiceFactory * ) 0 ,
117*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
118*cdf0e10cSrcweir 								(XServiceInfo * ) 0
119*cdf0e10cSrcweir 											);
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir 	// Test all ten templates
122*cdf0e10cSrcweir 	x = ::cppu::createStandardClass(
123*cdf0e10cSrcweir 								rSMgr ,
124*cdf0e10cSrcweir 								sImplName,
125*cdf0e10cSrcweir 								Reference < XIdlClass > () ,
126*cdf0e10cSrcweir 								(XMultiServiceFactory * ) 0 ,
127*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
128*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
129*cdf0e10cSrcweir 								(XServiceInfo * ) 0
130*cdf0e10cSrcweir 											);
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 	// Test all ten templates
134*cdf0e10cSrcweir 	x = ::cppu::createStandardClass(
135*cdf0e10cSrcweir 								rSMgr ,
136*cdf0e10cSrcweir 								sImplName,
137*cdf0e10cSrcweir 								Reference < XIdlClass > () ,
138*cdf0e10cSrcweir 								(XMultiServiceFactory * ) 0 ,
139*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
140*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
141*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
142*cdf0e10cSrcweir 								(XServiceInfo * ) 0
143*cdf0e10cSrcweir 											);
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 	// Test all ten templates
148*cdf0e10cSrcweir 	x = ::cppu::createStandardClass(
149*cdf0e10cSrcweir 								rSMgr ,
150*cdf0e10cSrcweir 								sImplName,
151*cdf0e10cSrcweir 								Reference < XIdlClass > () ,
152*cdf0e10cSrcweir 								(XMultiServiceFactory * ) 0 ,
153*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
154*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
155*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
156*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
157*cdf0e10cSrcweir 								(XServiceInfo * ) 0
158*cdf0e10cSrcweir 											);
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir 	// Test all ten templates
163*cdf0e10cSrcweir 	x = ::cppu::createStandardClass(
164*cdf0e10cSrcweir 								rSMgr ,
165*cdf0e10cSrcweir 								sImplName,
166*cdf0e10cSrcweir 								Reference < XIdlClass > () ,
167*cdf0e10cSrcweir 								(XMultiServiceFactory * ) 0 ,
168*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
169*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
170*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
171*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
172*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
173*cdf0e10cSrcweir 								(XServiceInfo * ) 0
174*cdf0e10cSrcweir 											);
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir 	// Test all ten templates
178*cdf0e10cSrcweir 	x = ::cppu::createStandardClass(
179*cdf0e10cSrcweir 								rSMgr ,
180*cdf0e10cSrcweir 								sImplName,
181*cdf0e10cSrcweir 								Reference < XIdlClass > () ,
182*cdf0e10cSrcweir 								(XMultiServiceFactory * ) 0 ,
183*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
184*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
185*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
186*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
187*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
188*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
189*cdf0e10cSrcweir 								(XServiceInfo * ) 0
190*cdf0e10cSrcweir 											);
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir 	// Test all ten templates
196*cdf0e10cSrcweir 	x = ::cppu::createStandardClass(
197*cdf0e10cSrcweir 								rSMgr ,
198*cdf0e10cSrcweir 								sImplName,
199*cdf0e10cSrcweir 								Reference < XIdlClass > () ,
200*cdf0e10cSrcweir 								(XMultiServiceFactory * ) 0 ,
201*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
202*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
203*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
204*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
205*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
206*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
207*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
208*cdf0e10cSrcweir 								(XServiceInfo * ) 0
209*cdf0e10cSrcweir 											);
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir 	// Test all ten templates
212*cdf0e10cSrcweir 	x = ::cppu::createStandardClass(
213*cdf0e10cSrcweir 								rSMgr ,
214*cdf0e10cSrcweir 								sImplName,
215*cdf0e10cSrcweir 								Reference < XIdlClass > () ,
216*cdf0e10cSrcweir 								(XMultiServiceFactory * ) 0 ,
217*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
218*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
219*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
220*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
221*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
222*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
223*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
224*cdf0e10cSrcweir 								(XServiceInfo * ) 0  ,
225*cdf0e10cSrcweir 								(XServiceInfo * ) 0
226*cdf0e10cSrcweir 											);
227*cdf0e10cSrcweir }
228