update dev300-m58
[ooovba.git] / cppuhelper / test / testidlclass.cxx
blob4c96c011eb18b9f88f4f28cf6dc90827691268ff
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: testidlclass.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_cppuhelper.hxx"
33 #if OSL_DEBUG_LEVEL == 0
34 #undef NDEBUG
35 #define NDEBUG
36 #endif
37 #include <assert.h>
39 #include <cppuhelper/stdidlclass.hxx>
41 #include <com/sun/star/reflection/XIdlClassProvider.hpp>
42 #include <com/sun/star/lang/XServiceInfo.hpp>
44 #include "testhelper.hxx"
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::lang;
48 using namespace ::com::sun::star::reflection;
49 using namespace ::rtl;
54 void testidlclass( const Reference < XMultiServiceFactory > &rSMgr)
56 const OUString sImplName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.cpputest") ) );
58 // this reference is static to test behaviour during exiting application
59 Reference < XIdlClass > r =
60 ::cppu::createStandardClass(
61 rSMgr ,
62 sImplName,
63 Reference < XIdlClass > () ,
64 (XMultiServiceFactory * ) 0 ,
65 (XServiceInfo * ) 0
68 assert( r.is() );
71 { // test the xidlclassprovider interface !
72 Reference< XIdlClassProvider > rProv( r , UNO_QUERY );
73 assert( rProv.is() );
76 Sequence < Reference < XIdlClass > > seq = rProv->getIdlClasses();
78 // is always one
79 assert( seq.getLength() == 1 );
81 // test the weak reference
82 rProv->getIdlClasses();
86 rProv->getIdlClasses();
92 assert( r->getName() == sImplName );
94 // test equals
95 Reference < XIdlClass > r2 =
96 ::cppu::createStandardClass(
97 rSMgr ,
98 sImplName,
99 Reference < XIdlClass > () ,
100 (XMultiServiceFactory * ) 0 ,
101 (XServiceInfo * ) 0
103 // test for implementation name
104 assert( r2->equals( r ) );
106 Sequence < Reference < XIdlClass > > seqIdlClass = r->getInterfaces();
108 //TODO !
109 // one idl class for one interface
110 // this test fails, if core reflection fails !
111 // assert( 1 == seqIdlClass.getLength() );
112 // Reference < XIdlClass > rIdlInterface = seqIdlClass.getArray()[0];
114 // check for IdlClass interface returned by Core Reflection
115 // assert( rIdlInterface.is() );
119 // Test all ten templates
120 Reference< XIdlClass > x = ::cppu::createStandardClass(
121 rSMgr ,
122 sImplName,
123 Reference < XIdlClass > () ,
124 (XMultiServiceFactory * ) 0 ,
125 (XServiceInfo * ) 0 ,
126 (XServiceInfo * ) 0
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
141 // Test all ten templates
142 x = ::cppu::createStandardClass(
143 rSMgr ,
144 sImplName,
145 Reference < XIdlClass > () ,
146 (XMultiServiceFactory * ) 0 ,
147 (XServiceInfo * ) 0 ,
148 (XServiceInfo * ) 0 ,
149 (XServiceInfo * ) 0 ,
150 (XServiceInfo * ) 0
155 // Test all ten templates
156 x = ::cppu::createStandardClass(
157 rSMgr ,
158 sImplName,
159 Reference < XIdlClass > () ,
160 (XMultiServiceFactory * ) 0 ,
161 (XServiceInfo * ) 0 ,
162 (XServiceInfo * ) 0 ,
163 (XServiceInfo * ) 0 ,
164 (XServiceInfo * ) 0 ,
165 (XServiceInfo * ) 0
170 // Test all ten templates
171 x = ::cppu::createStandardClass(
172 rSMgr ,
173 sImplName,
174 Reference < XIdlClass > () ,
175 (XMultiServiceFactory * ) 0 ,
176 (XServiceInfo * ) 0 ,
177 (XServiceInfo * ) 0 ,
178 (XServiceInfo * ) 0 ,
179 (XServiceInfo * ) 0 ,
180 (XServiceInfo * ) 0 ,
181 (XServiceInfo * ) 0
185 // Test all ten templates
186 x = ::cppu::createStandardClass(
187 rSMgr ,
188 sImplName,
189 Reference < XIdlClass > () ,
190 (XMultiServiceFactory * ) 0 ,
191 (XServiceInfo * ) 0 ,
192 (XServiceInfo * ) 0 ,
193 (XServiceInfo * ) 0 ,
194 (XServiceInfo * ) 0 ,
195 (XServiceInfo * ) 0 ,
196 (XServiceInfo * ) 0 ,
197 (XServiceInfo * ) 0
203 // Test all ten templates
204 x = ::cppu::createStandardClass(
205 rSMgr ,
206 sImplName,
207 Reference < XIdlClass > () ,
208 (XMultiServiceFactory * ) 0 ,
209 (XServiceInfo * ) 0 ,
210 (XServiceInfo * ) 0 ,
211 (XServiceInfo * ) 0 ,
212 (XServiceInfo * ) 0 ,
213 (XServiceInfo * ) 0 ,
214 (XServiceInfo * ) 0 ,
215 (XServiceInfo * ) 0 ,
216 (XServiceInfo * ) 0
219 // Test all ten templates
220 x = ::cppu::createStandardClass(
221 rSMgr ,
222 sImplName,
223 Reference < XIdlClass > () ,
224 (XMultiServiceFactory * ) 0 ,
225 (XServiceInfo * ) 0 ,
226 (XServiceInfo * ) 0 ,
227 (XServiceInfo * ) 0 ,
228 (XServiceInfo * ) 0 ,
229 (XServiceInfo * ) 0 ,
230 (XServiceInfo * ) 0 ,
231 (XServiceInfo * ) 0 ,
232 (XServiceInfo * ) 0 ,
233 (XServiceInfo * ) 0