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